Daqarta
Data AcQuisition And Real-Time Analysis
Scope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
The following is from the Daqarta Help system:

Features:

Oscilloscope

Spectrum Analyzer

8-Channel
Signal Generator

(Absolutely FREE!)

Spectrogram

Pitch Tracker

Pitch-to-MIDI

DaqMusiq Generator
(Free Music... Forever!)

Engine Simulator

LCR Meter

Remote Operation

DC Measurements

True RMS Voltmeter

Sound Level Meter

Frequency Counter
    Period
    Event
    Spectral Event

    Temperature
    Pressure
    MHz Frequencies

Data Logger

Waveform Averager

Histogram

Post-Stimulus Time
Histogram (PSTH)

THD Meter

IMD Meter

Precision Phase Meter

Pulse Meter

Macro System

Multi-Trace Arrays

Trigger Controls

Auto-Calibration

Spectral Peak Track

Spectrum Limit Testing

Direct-to-Disk Recording

Accessibility

Applications:

Frequency response

Distortion measurement

Speech and music

Microphone calibration

Loudspeaker test

Auditory phenomena

Musical instrument tuning

Animal sound

Evoked potentials

Rotating machinery

Automotive

Product test

Contact us about
your application!

MIDI Buffer File Load


Changes: BLbvb.i0="MyFile", BLmN.i0="MyFile"

Introduction:

A MIDI Changes script can load MIDI buffers or macro buffers (Buf0-Buf7) with lists of values from simple text files, which you can then access directly for any desired purpose.

For example, you can store lists of selected General MIDI instrument numbers, perhaps sorted by note sustain from short (like Pizzicato Strings, number 45) to continuous (like Organs). Then you can use direct access to randomly choose instruments, while controlling the sustain property by controlling the selection range.

The load operation would normally be done once at the beginning of a script, and the remainder of the script enclosed in an infinite loop.


Command Summary:

In the summary below, v is voice number 1-8, b is MIDI buffer number 1-4, and N is Macro Array buffer Buf0-Buf7:

    BLbvb="MyFile" Load text file as unsigned 8-bit bytes
    BLBvb="MyFile" Load text file as signed 8-bit bytes
    BLwvb="MyFile" Load text file as unsigned 16-bit words
    BLWvb="MyFile" Load text file as signed 16-bit words
    BLdvb="MyFile" Load text file as unsigned 32-bit double words
    BLDvb="MyFile" Load text file as signed 32-bit double words
    BLtvb="MyFile" Load text file as raw text
    BLTvb="MyFile" Load text file as valid keyboard characters only
    BLmN="MyFile" Load text file to macro array BufN, 64-bit fixed-point
    BLmN="<Notes" Load Notes text to macro array BufN, 64-bit fixed-point
    BLmN="<NoteS" Load Notes string to macro array BufN, 8-bit characters

Loading MIDI Buffers From Text Files:

MIDI buffers accept only integer values, but you can use signed or unsigned integers of 8-, 16-, or 32-bit sizes. They can then be read as such via the corresponding direct access option. The file load command has the same upper- and lowercase 'b', 'w', and 'd' options for loading that you will later use for reading.

To load a file of up to 256 unsigned 8-bit (byte) values like Instrument numbers to MIDI voice v, buffer b from a file named MyFile.TXT, you can use:

BLbvb="MyFile"

Note that the .TXT file extension is appended automatically.

By default, files loaded by these commands are assumed to be in Daqarta's User_DataMIDI_Setup folder. If "MyFile.TXT" is instead in the User_Data folder, use:

BLbvb="..MyFile"

If the specified file does not exist, the Changes script will not run. It will report a 'File access error' at the offending file name in the script.

The values loaded to the buffer will be limited to the unsigned byte range of 0-255; values outside this range will be "clamped" to the nearest limit.

To load up to 256 signed 8-bit values like +/-Note or Pan position, use an uppercase 'B'. Saved values will be limited to the range from -128 to +127:

BLBvb="MyFile"

For up to 128 unsigned 16-bit (word) values like Scales (actually only 12 bits, but too big for a byte), use a lowercase 'w'. Values will be limited to 0-65535:

BLwvb="MyFile"

For up to 128 signed 16-bit values (-32768 to +32767) use an uppercase 'W':

BLWvb="MyFile"

For up to 64 unsigned 32-bit (double-word) values like random seeds, use a lowercase 'd'. Values will be limited to 0 to 2^32-1 = 4294967295. (You must use this mode for values entered in hexadecimal, beginning with 'h'.)

BLdvb="MyFile"

Use an uppercase 'D' for signed 32-bit values (-2147483646 and +2147483647):

BLDvb="MyFile"

You can also store raw text (or in fact anything) as up to 256 bytes, using:

BLtvb="MyFile"

This will simply copy the first 256 bytes from the file to the buffer, without any checking at all.

Alternatively, you can limit the copy so that it accepts only valid keyboard characters, excluding ASCII control characters 0-31 and extended ASCII characters above 127:

BLTvb="MyFile"


Loading Macro Buffers From Text Files:

Macro Array buffers Buf0 to Buf7 hold up to 1024 high-precision values each, with 32 integer bits and 32 fraction bits (approximately 9 digits plus 9 decimal places).

There are extensive macro commands for loading, manipulating, and displaying these buffers, but MIDI commands can load them with simple text files just as for MIDI buffers, and access the resulting arrays using direct access.

To load macro BufN with values from MyFile.TXT, use:

BLmN="MyFile"

These larger buffers offer the ability to hold the full AllScales.TXT file that comes with Daqarta, which holds over 500 standard scales and can be extended to add your own custom scales. (MIDI buffers can only hold up to 128 words... the size needed for 12-bit Scale values.)

Also, while MIDI buffers only hold integers, macro buffers allow you to hold lists of LFO frequencies or other fractional data.


Loading Macro Buffers From Notes Text:

Instead of loading Macro Array buffers Buf0 - Buf7 from a file, you can load directly from text entered into the Daqarta Notes area. This is done by replacing the file name in the BLmN command with either "<Notes" (to load numerical values) or "<NoteS" (to load text strings).

BLmN="<Notes" is essentially identical to the macro command BufN="<Notes", which is discussed in the Copy List From Notes subtopic under Array Copy/Swap Operations. However, the MIDI version only loads values to a single BufN, as for a single-channel macro where the BufN="<Notes" command is preceded by BufN#N=1.

BLmN="<NoteS" is identical to the macro command BufN="<NoteS", which is discussed in the Copy String From Notes subtopic under the same Array Copy/Swap Operations topic.

Note that unlike the corresponding macro copy commands, there is no command here to copy from the File Notes of a loaded .DQA file. If the file has been opened normally, the above commands can copy from the ordinary visible Notes area. You can not copy from the hidden File Notes area of a file that have been loaded into the Generator as an Arb or Play file.


Number of Buffer Values Loaded:

After you load a file, you can read how many values were actually loaded. For example, to set variable UA with the count of 8-bit (byte) values loaded to MIDI voice v, buffer b, use:

UA=BLbvb

(Note that UA=BLBvb will return the same value. You may wish to use this form as a reminder if you loaded signed 8-bit values.)

For the count of 16-bit (word) values, replace the 'b' with 'w' (or 'W'):

UA=BLwvb

For the count of 32-bit (double-word) values, use 'd' or 'D':

UA=BLdvb

Note that these commands don't retain information about the actual data size (byte, word, or double-word) you used when loading the file. Only the total bytes loaded are saved, and they are just interpreted according to the 'b', 'w', or 'd' size specified in the command. So, for example, if the file was loaded as 100 double-words, using UA=BLbvb would set UA to 400.

For the count of values loaded to macro buffer BufN, use

UA=BLmN

Note that for macro buffers the count is not size-specific as for MIDI buffers, since the elements are of fixed size (32 integer bits and 32 fraction bits).

The count value is actually one more than the final index that was loaded. For both MIDI and macro buffer file loads, it is only a true count if you loaded the file to the beginning of the buffer. (See Buffer Load Start Position, below.) If you append another file in the same buffer, the count obtained after that is thus the total number of values loaded up to the end of the second file.

One important use for the number of values loaded is as a limit for a random selection. For example, if you have loaded a list of Instrument numbers to Voice 2, Buffer 3 and you want to select one of these at random to set the Voice 1 Instrument, you first set UA to the number of values. Since buffer index numbers start at zero, the maximum index would be one less than UA:

UA=BLb23           ;Count of values loaded
I1=Bb23.?(0,UA-1)  ;Random selection

Buffer Load Start Position;

The preceding discussion assumes that the MIDI or macro buffer should be loaded starting at the beginning (index 0). But you can start at any other index i0 by appending to the left side of the command, after a period:

BLbvb.i0="MyFile" (MIDI buffer load)

BLmN.i0="MyFile" (Macro buffer load)

The i0 start index assumes the data size indicated in the command; in the above example byte values are loaded starting at index i0.

If the MIDI buffer load command uses a 'w' or 'W' to specify loading word-sized values, i0 is the starting word. Likewise, if 'd' or 'D' is used to specify double-word loading, i0 is the starting double-word.

If you have just loaded a file and want to append another one, you can use the initial number of values loaded (see above) as the i0 starting index for the second load. The new number of values loaded will then be the total of both,

In all cases, whether i0 is used or not, a load command saves as many values as it finds in the file, or until the buffer is full (256 bytes, 128 words, or 64 dwouble-words for MIDI buffers, or 1024 values for macro buffers). There is no way to stop short, but a subsequent load can set i0 to overwrite the unwanted values.


Text File Format:

For loading lists of values, the most readable and maintainable format is a single column of values.

Since MIDI buffers only hold integers, any decimal places will be rounded off during the load. The values will also be limited according to the specified data width (byte, word, or double-word) and signed or unsigned format.

Macro buffers hold fixed-point values with 32-bit signed integers and 32-bit fraction portions, with no data width or sign constraints.

Comments may be included in the file by preceding them with a semicolon; the remainder of that line will be ignored. For example, here is the beginning of the AllScales.TXT file included with Daqarta:


4095   ;CdDeEFgGaAbB   Chromatic
2773   ;C D EF G A B   Major
2906   ;C De F Ga b    Natural Minor

When loaded with (say) BLw34="Scales", the 0th word of Voice 3, Buffer 4 will hold 4095, the next word will hold 2773, and the following will hold 2906.

(Since a MIDI buffer only holds 128 words, a better choice would be a 1024-point macro buffer that can easily accommodate the whole 500+ entries of AllScales.TXT)

If you want to restrict usage to certain scales, you can make a copy of AllScales.TXT and call it MyScales.TXT. Then delete all the entries you don't want to use. Alternatively, you can just precede unwanted lines with a semicolon, making it easy to re-enable them in the future.


Included Text Files:

AllScales.TXT contains all scales in the Musical Scales List. You can add your own Custom Scales as desired, using the above format.

GlossyScales.TXT contains 42 scales selected from the above list which sound best with the GlossyTracks.DQM setup.

AllInst.TXT contains all 128 General MIDI Instruments. The format is:

  
;General MIDI Instrument Sounds

;Piano:
0    ;Acoustic Grand Piano
1    ;Bright Acoustic Piano
2    ;Electric Grand Piano
. . .
127  ;Gunshot

GlossyInst.TXT is a copy of the above with certain instruments (like Gunshot and the rest of the Sound Effects group) commented out, as used by GlossyTracks.

AllPerc.TXT contains all standard and extended General MIDI Percussion Sounds that are available on the Windows default Microsoft GS Wavetable Software Synthesizer. The format is:

  
;General MIDI Percussion Sounds

; 0-26  (Unknown)
27   ;High Q
28   ;Slap
29   ;Record Scratch 1
. . .
87   ;Open Sudro
; 88-127   (Unknown)

GlossyPerc.TXT is a copy of the above, with Click 1 (32) and Long Whistle (72) commented out for use by GlossyTracks.


See also Buffer Direct Access, Changes Script Buffer Operations, Changes Script Overview, Changes Script Editor, MIDI Voice Setup Dialogs, Pitch-to-MIDI dialog, Pitch Track Toolbox - Overview


GO:

Questions? Comments? Contact us!

We respond to ALL inquiries, typically within 24 hrs.
INTERSTELLAR RESEARCH:
Over 30 Years of Innovative Instrumentation
© Copyright 2007 - 2017 by Interstellar Research
All rights reserved