Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
MIDI Buffer File Load
Changes: BLbvb.i0="MyFile", BLmN.i0="MyFile"
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.
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
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:
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:
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.
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:
For up to 128 signed 16-bit values (-32768 to +32767) use an uppercase 'W':
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'.)
Use an uppercase 'D' for signed 32-bit values (from -2147483648 to +2147483647):
You can also store raw text (or in fact anything) as up to 256 bytes, using:
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:
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:
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.
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.
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:
(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'):
For the count of 32-bit (double-word) values, use 'd' or 'D':
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
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
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.
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.
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
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.
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
Over 35 Years of Innovative Instrumentation
© Copyright 2007 - 2023 by Interstellar Research
All rights reserved