Velocity measures how forcefully a musical note is played. In MIDI, it accompanies note-on and note-off messages and ranges from 0 to 127; higher values indicate louder or more forceful performance. section 14.1.1
Velocity differs from pitch: pitch identifies the note, while velocity captures its performance dynamics. During tokenization, original values are reduced to 32 bins, producing velocity events with values from 0 to 31. section 14.1.1 section 14.2.2
Use velocity in a performance-based music representation to:
- Preserve expressive differences between forceful and gentle notes. section 14.1.1
- Represent changing dynamics as separate velocity events alongside note-on, note-off, and time-shift events. section 14.1.1
- Control vocabulary size by mapping each original velocity to a 32-bin token value. section 14.1.1 section 14.2.2
A velocity event in practice
A note-on event for pitch 74 with velocity 86 records a D5 played forcefully. After tokenization, velocity 86 becomes velocity value 21, followed by a note-on event with value 74.
Listing 14.1 Example notes in a performance-based music representation
<[SNote] time: 1.0325520833333333 type: note_on, value: 74, velocity: 86> <[SNote] time: 1.0442708333333333 type: note_on, value: 38, velocity: 77> <[SNote] time: 1.2265625 type: note_off, value: 74, velocity: None> <[SNote] time: 1.2395833333333333 type: note_on, value: 73, velocity: 69> <[SNote] time: 1.2408854166666665 type: note_on, value: 37, velocity: 64>
Inspect the first five performance events to see velocity attached to note-on events and absent from the note-off event. section 14.1.1
