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

# MIDI Buffer Velocity and Chord Maps

Changes: Bv="string", Bv=sN.i0, Bc="string", Bc=sN.i0

## Basic Operation:

The Buffer Velocity Map (Bv) and Chord Map (Bc) commands allow a MIDI Changes script to use random, oscillator, or live or Buffer note values to set Velocity Patterns or Chord Patterns using Buffer Fill commands.

The map allows you to create a random or semi-random pattern, yet still have a certain amount of control over the values used. The map is a string of up to 32 characters from which the actual pattern characters will be chosen, based upon the input data values.

The Velocity Map command format is Bv="string", and the Chord Map is Bc="string". The quotes around the string are mandatory.

Alternatively, you can copy these strings from macro string arrays Str0 to Str7 via Bv=sN.i0 for Velocity or Bc=sN.i0 for Chords, where N is the string array number 0-7 and i0 is the starting index in the array to copy from.

The velocity map can contain any valid velocity characters, including '0' (off) to '8' (full loudness) and '_' (sustain prior note). Similarly, the chord map can contain any valid chord characters.

If you select characters randomly from the full map, the probability of any particular character is based on the number of times it appears in the map.

For example, JukeBox.DQM sets the velocity map with Bv="0_8_8_8_8_8_8888", which gives a 9/16 probability of '8', a 6/16 probability of '_', and a 1/16 probability of '0' when it uses Bf1V.1=(?(0,15),UA-1) to select UA-1 characters at random over the 0,15 range of the map.

You can select over a smaller range of the same map to get different probabilities. The 0th item is the first one in the string, starting from the left.

You can also use non-uniform random values to weight the selection toward the center or either end. For example, Bf1V.1=(?2H(0,15),UA-1) would use a triangular distribution that would favor the high-index end of the map, with the probability of low-index selections falling linearly toward index 0.

If you attempt to use a selector index that is beyond the limits of the specified map, the given index is divided by the map length and the remainder is used as the actual index. (This is known as a "modulus" or MOD operation.) In the 16-character JukeBox map example above, suppose you set the random limits to ?(0,25) instead of ?(0,15): Bf1V.1=(?(0,25),UA-1). If a random index of (say) 23 is chosen then the actual index will be 23 MOD 16, which is 7.

Note that a script must include an appropriate Map command before a Buffer Fill (BF or Bf) or Buffer Copy (BC) to a Velocity or Chord Pattern. Otherwise, the map will be empty and the pattern will receive only nulls.

Map commands are global; all scripts use the current Velocity and Chord Maps. The maps can be changed as often as desired. You can also have a large fixed map and change which part is used.

The same Velocity Map is used for both tonal Voice Velocity Patterns and Percussion Velocity Patterns.

You can create a large Velocity Map and use different parts of it for tonal and percussion instruments, or maybe one part for continuous tonal instruments like wind or brass and another for percussive tonal instruments like piano or guitar.

Likewise, you can use a large Chord Map and use different sets of chords for different instrument types, or for different parts of a performance.

## Percussion Rolls (Drum Rolls):

For Percussion voices, the Velocity Map supports additional characters K through Z that cause percussion rolls. See Percussion Velocity Pattern and Rolls for details. These characters are ignored for tonal voices, and no note sounds.

However, there is an additional way to get rolls, with wider velocity and roll rate ranges, using direct manipulation of the velocity stream when using MIDI Changes Scripts with Velocity Maps. The Music_from_Anything macro mini-app uses this method, with macro commands that prepare values for a special MIDI script.

An ordinary buffer fill would typically use values in the 0-31 range (if using the whole Velocity Map for percussion), and they would be translated as usual, including the K through Z characters for rolls, if present.

However, if the buffer includes a value of 128 or above, that value does not use Velocity Map. Instead, it is used directly to specify a roll, based on the value's bitmap.

The low 2 bits (0 and 1) select velocities, shown below along with the equivalent Velocity Map character:

```      Bits     Velocity  Equivalent
1xxxxx00      80        "5"
1xxxxx01      96        "6"
1xxxxx10      112       "7"
1xxxxx11      127       "8"
```

Bits 2-6 select one of 32 values of roll period. Taking these 5 bits as a binary value between 0 and 31, add 2 to get the number of Trace Update intervals per hit, from 2 to 33.

For example, consider a binary value of b10000011. The high bit is set to indicate that this is a direct roll. The low 2 bits are both set, indicating a velocity of 127. Bits 2-6 are zeros, giving a roll period of 0 + 2 = 2 Trace Update intervals. At the default of 10 msec per Trace Update this would be 20 msec per roll hit, or 50 hits per second... a very fast roll.

If bits 2-6 were all set for a binary value of 31, the roll period would be (31 + 2) * 10 msec or 330 msec per roll hit, or about 3 hits per second. This is pretty slow to be called a "roll", but it's still musically useful.

As discussed in Percussion Velocity Pattern and Rolls, a roll series lasts as long as the normal percussion beat interval, including any following sustain characters ("_") and the effect of any Percussion Hold setting for that voice.

GO: