uvi-script
Musical event scripting with Lua
Loading...
Searching...
No Matches
Voice Manipulation

Functions

function sendScriptModulation (id, targetValue, rampTime, voiceId)
 send a script modulation event to control a Script Modulation source.
 
function sendScriptModulation2 (id, startValue, targetValue, rampTime, voiceId)
 send a script modulation event to control a Script Modulation source.
 
function changeTune (voiceId, shift, relative, immediate)
 change the tuning of specific voice in (fractionnal) semitones.
 
function changePan (voiceId, pan, relative, immediate)
 changes the pan position of a specific note event.
 
function changeVolume (voiceId, gain, relative, immediate)
 changes a voice's volume.
 
function changeVolumedB (voiceId, dBGain, relative, immediate)
 change the volume of specific voice in decibels.
 
function setSampleOffset (voiceId, value)
 changes a sample starting point in milliseconds.
 
function fadeout (voiceId, duration, killVoice, reset, layer)
 starts a volume fade-out.
 
function fadein (voiceId, duration, reset, layer)
 starts a volume fade-in for a specific voice.
 
function fade (voiceId, targetValue, duration, layer)
 starts a volume fade.
 
function fade2 (voiceId, startValue, targetValue, duration, layer)
 starts a volume fade.
 

Detailed Description

Per-voice control functions for manipulating individual playing notes.

Each triggered note creates a voice with a unique ID. These functions allow you to modify voice parameters (tuning, volume, panning) and control voice lifecycle (fading, releasing).

Voice Parameters:

Voice Fading:

Voice Control:

Voice Creation:

Note
Always store voice IDs if you plan to manipulate voices later. Voice IDs are returned by playNote() and postEvent().
See also
Voice Manipulation, Events, Time and Threading

Function Documentation

◆ changePan()

function changePan ( voiceId ,
pan ,
relative ,
immediate  )

changes the pan position of a specific note event.

Parameters
voiceIdid of the voice to be transposed
panpanoramic position between -1 and 1
relative(optional) specify if the transposition is relative to the last changePan, default to false
immediate(optional) apply transpostion without smoothing, default to false

Panning note from left to right Example:

function onNote(e)
local id = postEvent(e)
local pan = 2*(e.note/127) - 1
changePan(id, pan)
end
void onNote(table e)
event callback that will receive all incoming note-on events if defined.
function postEvent(e, delta)
send a script event back to the script engine event queue.
Definition api.lua:842
function changePan(voiceId, pan, relative, immediate)
changes the pan position of a specific note event.
Definition api.lua:504
See also
changeTune, changeVolume, changeVolumedB

◆ changeTune()

function changeTune ( voiceId ,
shift ,
relative ,
immediate  )

change the tuning of specific voice in (fractionnal) semitones.

Parameters
voiceIdid of the voice to be transposed
shifttransposition in semitones to be applied
relative(optional) specify if the transposition is relative to the last changeTune transposition, default to false
immediate(optional) apply transpostion without smoothing, default to false

Example:

--change tune by +/- 0.5 semitone
function onNote(e)
local id = postEvent(e)
local tune = math.random(-0.5, 0.5)
changeTune(id, tune)
end
function changeTune(voiceId, shift, relative, immediate)
change the tuning of specific voice in (fractionnal) semitones.
Definition api.lua:477
See also
changePan, changeVolume, changeVolumedB

◆ changeVolume()

function changeVolume ( voiceId ,
gain ,
relative ,
immediate  )

changes a voice's volume.

N.B.: the changeVolume() gain will be applied on top of other changes made using fade()

Parameters
voiceIdid of the voice to be transposed
gainlinear gain to be applied between 0 and 1
relative(optional) specify if the transposition is relative to the last changeVolume, default to false
immediate(optional) apply transpostion without smoothing, default to false
See also
changeTune, changePan, changeVolumedB

◆ changeVolumedB()

function changeVolumedB ( voiceId ,
dBGain ,
relative ,
immediate  )

change the volume of specific voice in decibels.

N.B.: the changeVolume() gain will be applied on top of other changes made using fade()

Parameters
voiceIdid of the voice to be transposed
dBgaingain to be applied in decibels
relative(optional) specify if the transposition is relative to the last changeVolumedB, default to false
immediate(optional) apply transpostion without smoothing, default to false

Example:

-- dynamic expander: loud velocities are boosted by +6dB
-- while small velocities are attenuated by 6dB
function onNote(e)
local id = postEvent(e)
local gain = ((e.velocity-1)/126) * 12 - 6
changeVolumedB(id, gain)
end
function changeVolumedB(voiceId, dBGain, relative, immediate)
change the volume of specific voice in decibels.
Definition api.lua:546
See also
changeTune, changePan, changeVolume

◆ fade()

function fade ( voiceId ,
targetValue ,
duration ,
layer  )

starts a volume fade.

N.B.: the fade volume will be applied on top of other changes made using changeVolume()

Parameters
voiceIdthe voice id to fade
targetValuethe volume target to reach
durationthe fade duration in ms
layer(optional) target layer in [1;Program.layers], 0 for all layers (broadcast), default is 0
See also
fadein, fadeout, fade2, changeVolume

◆ fade2()

function fade2 ( voiceId ,
startValue ,
targetValue ,
duration ,
layer  )

starts a volume fade.

N.B.: the fade volume will be applied on top of other changes made using changeVolume()

Parameters
voiceIdthe voice id to fade
startValuethe initial ramp volume
targetValuethe volume target to reach
durationthe fade duration in ms
layer(optional) target layer in [1;Program.layers], 0 for all layers (broadcast), default is 0
See also
fadein, fadeout, fade, changeVolume

◆ fadein()

function fadein ( voiceId ,
duration ,
reset ,
layer  )

starts a volume fade-in for a specific voice.

N.B.: the fade volume will be applied on top of other changes made using changeVolume()

Parameters
voiceIdthe voice id to fade-in
durationthe fade-in duration in ms
resetmake the fade start at 0 instead of the current fade value (if a fade is ongoing)
layer(optional) target layer in [1;Program.layers], 0 for all layers (broadcast), default is 0

Example:

function onNote(e)
postEvent(e) -- play root
local id1 = playNote(e.note+12, e.velocity) -- 2nd harmonic
local id2 = playNote(e.note+19, e.velocity) -- 3rd harmonic
fadein(id1, 1000, true)
fadein(id2, 5000, true)
end
function playNote(note, vel, duration, layer, channel, input, vol, pan, tune, slice, oscIndex)
helper function to generate a note event.
Definition api.lua:931
function fadein(voiceId, duration, reset, layer)
starts a volume fade-in for a specific voice.
Definition api.lua:632
See also
fadeout, fade, fade2, changeVolume

◆ fadeout()

function fadeout ( voiceId ,
duration ,
killVoice ,
reset ,
layer  )

starts a volume fade-out.

N.B.: the fade volume will be applied on top of other changes made using changeVolume()

Parameters
voiceIdthe voice id to fade-out
durationthe fade-out duration in ms
killVoicekill the voice at the end of the fade-out if true
resetmake the fade start at 1 instead of the current fade value (if a fade is ongoing)
layer(optional) target layer in [1;Program.layers], 0 for all layers (broadcast), default is 0
See also
fadein, fade, fade2, changeVolume

◆ sendScriptModulation()

function sendScriptModulation ( id ,
targetValue ,
rampTime ,
voiceId  )

send a script modulation event to control a Script Modulation source.

enables per voice script-driven piece-wise linear modulation source control.

Parameters
idthe modulation source id (can be changed on each modulation source)
targetValuethe modulation value in [0;1] if the source is unipolar or [-1;1] if the source is bipolar
rampTimethe rampTime in milliseconds (defaults to 20ms)
voiceIdthe optional voice id of the voice to be controlled. If it is not specified then the value is the same for all voices (broadcast mode).
local id = playNote(note, vel)
local sourceIndex = 0
local targetValue = 0.5
local rampTime = 100 -- ramp to modValue over 100 ms
sendScriptModulation(sourceIndex, targetValue, rampTime, id)
function sendScriptModulation(id, targetValue, rampTime, voiceId)
send a script modulation event to control a Script Modulation source.
Definition api.lua:417

◆ sendScriptModulation2()

function sendScriptModulation2 ( id ,
startValue ,
targetValue ,
rampTime ,
voiceId  )

send a script modulation event to control a Script Modulation source.

enables per voice script-driven piece-wise linear modulation source control.

Parameters
idthe modulation source id (can be changed on each modulation source)
startValuethe start modulation value in [0;1] if the source is unipolar or [-1;1] if the source is bipolar
targetValuethe target modulation value in [0;1] if the source is unipolar or [-1;1] if the source is bipolar
rampTimethe rampTime in milliseconds (defaults to 20ms)
voiceIdthe optional voice id of the voice to be controlled. If it is not specified then the value is the same for all voices (broadcast mode).
local id = playNote(note, vel)
local sourceIndex = 0
local startValue = 0.1
local targetValue = 0.5
local rampTime = 100 -- ramp to modValue over 100 ms
sendScriptModulation2(sourceIndex, startValue, targetValue, rampTime, id)
function sendScriptModulation2(id, startValue, targetValue, rampTime, voiceId)
send a script modulation event to control a Script Modulation source.
Definition api.lua:447

◆ setSampleOffset()

function setSampleOffset ( voiceId ,
value  )

changes a sample starting point in milliseconds.

if the oscillator is in streaming mode then the offset will be clipped according to streaming preload preferences

Parameters
voiceIdid of the voice to apply the samplestart
valueoffset in milliseconds in the sample