Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
MIDI Buffer Repeat Notes Command
A MIDI Changes script can use the Buffer Repeat Notes (BR) command to modify an existing sequence of up to 16 notes in an input buffer by repeating each note according to a preset Repeat Map. For example, CFG used with a Repeat Map of "222" would become CCFFGG.
The format for Buffer Repeat Notes is BRvb.i0=count, where v is Voice number 1-8, and b is buffer number 1-4. i0 is the index (position) where the repeats should start, and count is the number of notes to be operated upon in the original sequence.
i0 and count may be unsigned integers or valid expressions, including current MIDI control values, random values, current computer keyboard states or mouse position, input or buffered notes, oscillators, and User Variables.
i0 will be limited to the 0-255 buffer range. The count value will be limited to 0-16; a value of 0 means no action is taken.
Typically, you would initialize the buffer from the live input stream using the Buffer Copy command, then use Buffer Repeat Notes to duplicate notes in all or any portion of the original note sequence. The duplicated sequence replaces the original, and since it is longer it pushes any subsequent notes farther along in the sequence, increasing the overall buffer sequence length.
The duplication process does not change the play start and end buffer positions, so you may want to use Set Pointers to change these to reflect your application for the new sequence. For example, suppose the original start-end sequence held 8 notes and you duplicated the first 4 of these, pushing the second 4 beyond the end of the sequence. If you leave the pointers as they were, the new play sequence will be the 8 notes that result from the duplication, and the other 4 will be ignored.
Each of the selected notes may be repeated an arbitrary number of times, from 0 to 16. This is controlled by the Repeat Map, which is a string of numerals that specifies the total number of notes that should replace each original note. The Repeat Map holds up to 16 numerals, one for each of the possible notes in the original sequence.
At each position in the map, the value is the number of final notes to replace each original note; in the above CFG example, the map was "222". If it had been "333" the result would have been CCCFFFGGG, and if it had been "321" the result would have been CCCFFG.
If the Repeat Map holds a 0 at any position, the corresponding note is removed instead of being repeated; other notes move down to fill in the gap.
A '.' in the Repeat Map will cause the corresponding note to be replaced with silence; no copies will be made of that note.
In addition to simple duplication, the Buffer Repeat Notes command can use an optional Note Adjust Map that can add a different amount to each copy of an original. For example, suppose the Note Adjust Map is "012", the original note sequence is CFG, and the Repeat Map is "321".
The first numeral in the Repeat Map would indicate that the C will result in 3 notes; the first will be the original plus the first Note Adjust Map entry of 0, so it will be unchanged. The second will have 1 added to the original to become C#, and the third will have 2 added to the original to become D. There will be only 2 copies of the F, one unchanged and one incremented to F#. The G will be unchanged.
Note that while the Repeat Map positions correspond to the positions of the original note sequence, the Note Adjust Map positions correspond to copy number. The first entry is always added to the first copy of each original note, the second is added to the second copy, and so on. The same map is used for each original note.
A '.' in the Note Adjust Map will cause the corresponding copy note to be replaced with silence. One application for this is expanding a note sequence into multiple measures. For example, to convert CFG into C...F...C... you would use a Repeat Map of "444" so that each original note will be expanded into 4 final notes. The Note Adjust Map would be "0...", where the iniital 0 indicates to copy the original note directly, with no adjustment. The 3 periods indicate that the next 3 positions will hold silence instead of copies.
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
Over 30 Years of Innovative Instrumentation
© Copyright 2007 - 2017 by Interstellar Research
All rights reserved