Module xVoiceManager
This class keeps track of active, playing voices as they are triggered.
.
In more detail
This class understands some of the more advanced aspects of triggering and releasing voices in Renoise. This includes the ability to trigger and release specific instruments in specific tracks, while preserving the ability to freely move around in Renoise while doing so.
Without voice-management it would be too easy to create hanging notes. Everything from switching track, instrument or octave while playing, to having multiple MIDI sources could cause trouble. A good voice-manager will understand this and be able to determine the originating 'place' where the voice got triggered.
Also the class is able to assist with automatic note-column allocation while recording. It's a basic approach, but close enough to how Renoise usually works to feel familiar.
- Recordings start from the currently selected note column
- New note columns (voices) are allocated as new notes arrive
- Voices stay with their column as other voices are released/removed
Observable events
Attach notifiers to detect when messages are triggered or released:
triggered_observable
-> fired right after a voice starts playing
released_observable
-> fired right before a voice is released
After you have attached a notifier, you will receive a 'bang', but no argument. Instead, you should look for the triggered/released_index
properties - they will contain the value you need.
Example
How to instantiate a copy of this class, and feed xMidiMessages into it:
local voicemgr = xVoiceManager{
follow_track = false,
}
voicemgr.triggered_observable:add_notifier(function()
print(voicemgr.triggered_index)
end)
voicemgr.released_observable:add_notifier(function()
print(voicemgr.released_index)
end)
local xmsg = some_note_on_message -- provide your own message
voicemgr:input_message(xmsg) -- should trigger our notifier
Functions
get_active_notes () | |
register (xmsg) | register/add a voice |
release_all () | Release all active voices |
release_all_instrument (instr_idx) | Release all voices associated with a specific instrument |
release_all_track (track_idx) | Release all voices associated with a specific track |
release (voice_idx) | release specific voice |
check_expired () | check if any voices have expired (when duration is set) |
get_voice_index (xmsg) | locate among active voices, taking the pitch + track + instrument into consideration (if all match, the voice is considered active...) |
get_available_columns (track_idx) | |
attach_to_song () | Monitor changes to tracks and instruments |
Tables
self.voices | table |
Fields
self.voice_limit | the maximum number of voices (0 = 'unlimited') TODO not yet implemented |
self.duration | number, note duration in seconds (0 = infinite) |
self.column_allocation | bool, whether to use automatic column allocation or not |
self.released_index | voice about to be released (0 = none) |
self.triggered_index | newly triggered voice (0 = none) |
Functions
- get_active_notes ()
-
Returns:
-
table
containing all active MIDI-pitches [[ - register (xmsg)
-
register/add a voice
Parameters:
- xmsg
- release_all ()
- Release all active voices
- release_all_instrument (instr_idx)
-
Release all voices associated with a specific instrument
Parameters:
- instr_idx
- release_all_track (track_idx)
-
Release all voices associated with a specific track
Parameters:
- track_idx
- release (voice_idx)
-
release specific voice
Parameters:
- voice_idx
- check_expired ()
- check if any voices have expired (when duration is set)
- get_voice_index (xmsg)
-
locate among active voices, taking the pitch + track + instrument into
consideration (if all match, the voice is considered active...)
Parameters:
- xmsg (xMidiMessage) should be a MIDI note-message
Returns:
- number or nil
- table
- get_available_columns (track_idx)
-
Parameters:
- track_idx
Returns:
-
table
- attach_to_song ()
- Monitor changes to tracks and instruments
Tables
Fields
- self.voice_limit
- the maximum number of voices (0 = 'unlimited') TODO not yet implemented
- self.duration
- number, note duration in seconds (0 = infinite)
- self.column_allocation
- bool, whether to use automatic column allocation or not
- self.released_index
- voice about to be released (0 = none)
- self.triggered_index
- newly triggered voice (0 = none)