Commit e83c886e authored by jhammen's avatar jhammen
Browse files

update mixer controls

parent c40617b5
......@@ -22,46 +22,46 @@ Guitarix TS9 simulation, connect Nekobi to the input:
local distortion = Lv2.Plugin("http://guitarix.sourceforge.net/plugins/gxts9#ts9sim")
distortion.control("fslider1_", 1000)
distortion.control("fslider2_", 1.0)
distortion.connect(nekobi)
nekobi => distortion
/**
Mixer for things that need reverb, just 3 inputs (drums sampler is stereo, distortion is mono)
*/
local reverbMixer = Audio.Mixer(3,2)
reverbMixer.connect(drums808, 0.3)
reverbMixer.connect(distortion)
local gains = [[0.3, 0], [0, 0.3], [1, 1]]
local reverbMixer = Audio.Mixer(3, 2, gains);
[drums808, distortion] => reverbMixer
/**
Reverb is GxZita_rev1, mix all the way wet:
*/
local reverb = Lv2.Plugin("http://guitarix.sourceforge.net/plugins/gx_zita_rev1_stereo#_zita_rev1_stereo")
reverb.control("DRY_WET_MIX", 1.0)
reverb.connect(reverbMixer)
reverbMixer => reverb
/**
Main mixer: 7 input channels with various gain settings, then mixer into main stereo output
*/
local mainMixer = Audio.Mixer(7, 2)
mainMixer.connect(drums808, 0.2) // input 1 + 2
mainMixer.connect(drumsHard, 0.5) // input 3 + 4
mainMixer.connect(distortion, 0.7) // input 5
mainMixer.connect(reverb) // input 6 + 7
local gains = [[0.2, 0], [0, 0.2], [0.5, 0], [0, 0.5], 0.7, [1, 0], [0, 1]]
local mainMixer = Audio.Mixer(7, 2, gains);
[drums808, drumsHard, distortion, reverb] => mainMixer
local mainOutput = Audio.StereoOutput("main", "system:playback_1", "system:playback_2")
mainOutput.connect(mainMixer)
mainMixer => Audio.StereoOutput("main", true)
/**
## Midi Controller
Create a system MIDI input, connect to a control surface via e.g. QJackCtl:
Create a system MIDI input, connect to a control surface via e.g. QJackCtl,
and control nekobi parameters with knobs that send MIDI CC 15 and 16:
*/
local midiInput = Midi.Input("controller")
/**
Control nekobi parameters with knobs that send MIDI CC 15 and 16:
*/
nekobi.addController(midiInput, 15, "cutoff")
nekobi.addController(midiInput, 16, "env_mod")
Midi.Input("controller").onControl(function(cc, m) {
if(cc.controller == 16) {
print("cut " + cc.value / 1.27 + "\n")
nekobi.control("cutoff", cc.value / 1.27)
} else if(cc.controller == 17) {
print("env " + cc.value / 1.27 + "\n")
nekobi.control("env_mod", cc.value / 1.27)
}
})
/**
## Midi Patterns
......@@ -162,7 +162,7 @@ To run:
don't forget to connect a control surface
Script source is [here](http://bipscript.org/examples/jinglebee/jinglebee.bip)
Script source is [here](http://www.bipscript.org/en/examples/jinglebee/jinglebee.html)
Feel free to hack it!
*/
......
......@@ -8,7 +8,6 @@ two or more instruments into a single stereo output.
First we create plugins to represent drums and bass respectively, note we
do not take the typical step of connecting them to the main audio outputs:
*/
local sampler = Lv2.Plugin("http://www.openavproductions.com/fabla", "fabla808")
......@@ -25,43 +24,49 @@ output channels:
local mixer = Audio.Mixer(4, 2)
/**
At this point we connect the mixer output to the main audio outputs:
We can also specify an array of initial gain values when creating the mixer. If we omit that as above the
initial gains will be set according to the following logic:
- the first input channel connects to the first output channel with a gain of 1.0, all other outputs are not connected
- each subsequent input connects to the following output channel, or back to the first output channel if they run out
- continue until all input channels are each connected to one output channel (output channels may not all be connected)
So in the case of a 4x2 mixer, the initial gains will be set up for unity gain on two stereo inputs which is
exactly what we want here.
At this point we connect the mixer output to the main audio outputs using the multiplex connection operator:
*/
local mainOutput = Audio.StereoOutput("main", "system:playback_1", "system:playback_2")
mainOutput.connect(mixer)
mixer => Audio.StereoOutput("main", true);
/**
Next we connect our inputs using the connect method which assigns the
instruments to the next available input channel(s). How many inputs are
assigned depends on what we plug in, most audio sources are either
mono or stereo meaning 1 or 2 channels respectively.
At this point all the input channels are unused and available and we are
dealing with stereo instruments with two channels each. So the first
call to connect will assign the drum sampler to mixer input channels 1
and 2, and the following call will assign the bass synth to channels 3 and 4:
We can also use the multiplex connection operator to connect the sound sources to the inputs of the mixer
using array notation. The elements of the array are connected sequentially to the inputs on the right side of
the operator.
In this case we have two stereo plugins in the array so the
net result is the sampler stereo output connected to the first two channels of the mixer and the
synth on the following two channels.
*/
mixer.connect(sampler)
mixer.connect(synth)
[sampler, synth] => mixer
/**
*/
/**
## MIDI Control
We can also connect a hardware controller to the mixer, in this case we have a
simple control surface and we want the faders to control the input gains.
We create a Midi.Input that will connect to the control surface:
*/
local mixerControl = Midi.Input("mixerControl")
We create a Midi.Input that will appear in the system with the name "control", the control
surface should connect to this input.
/**
Now we can use the onControl callback to update the mixer gains when control messages are received, note we
normalize the amount from 0-127 (MIDI control range) to a float amount 0-1.0 as expected by the gain method:
normalize the amount from 0-127 (MIDI control range) to a float amount 0.0 - 1.0 as expected by the gain method:
*/
mixerControl.onControl(function(cc, m) {
Midi.Input("control").onControl(function(cc, m) {
local amount = cc.value / 127.0
switch(cc.controller) {
/**
......@@ -120,21 +125,27 @@ Here we fade the bass out over the course of the 3rd measure by
sending control messages on every 16th note to successively
knock down the gain for channels 3 and 4:
*/
local changeL = Audio.MixerGain(2, 0, 0.0)
local changeR = Audio.MixerGain(3, 1, 0.0)
for(local i = 0; i < 16; i++) {
local gain = 1 - i / 16.0
mixer.scheduleGain(3, 1, gain, 3 + i / 16.0)
mixer.scheduleGain(4, 2, gain, 3 + i / 16.0)
local gain = 1 - (i + 1)/ 16.0
changeL.amount = gain
changeR.amount = gain
mixer.schedule(changeL, 3 + i / 16.0)
mixer.schedule(changeR, 3 + i / 16.0)
}
/**
And fade it back in again on the 4th measure:
And fade it back in again on the 5th measure:
*/
for(local i = 0; i < 16; i++) {
local gain = i / 16.0
mixer.scheduleGain(3, 1, gain, 4 + i / 16.0)
mixer.scheduleGain(4, 2, gain, 4 + i / 16.0)
local gain = (i + 1) / 16.0
changeL.amount = gain
changeR.amount = gain
mixer.schedule(changeL, 5 + i / 16.0)
mixer.schedule(changeR, 5 + i / 16.0)
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment