Eyyyyy
So coding in C++ was a bit overwhelming for me but I did get a decent version going in Super Collider.
Code is here if anyone's interested. Am new to text based coding so any general practice/logic/tidyness tips
are appreciated.
I ended up using a wrapper for PartConv for convenience.
(
s = Server.default;
// Set up options for the Bela
s.options.numAnalogInChannels = 2;
s.options.numAnalogOutChannels = 2;
s.options.numDigitalChannels = 0;
s.options.maxLogins = 4;
s.options.blockSize = 16;
s.options.numInputBusChannels = 2;
s.options.numOutputBusChannels = 2;
~newpreset;
~impulse = "./cello.wav";
~ezConv = EZConv(~impulse, fftSize: 512);
s.waitForBoot {
//drysignal
{
var dry;
dry = AnalogIn.ar(1) * 0.77;
SoundIn.ar(0) * dry;
}.play;
//synthdef for convolution
SynthDef(\wet, { |out|
Out.ar(out, SynthDef.wrap({
~ezConv = EZConv(~impulse);
~input = SoundIn.ar(0);
~blend = AnalogIn.ar(1) * -0.55 + 0.55 * ~input ; // input * blend pot
~ezConv.ar(~blend, mul: 0.5);
}))
}).add;
~wet = Synth(\wet);
//re-run this task when changing impulses
~task = Task({
1.do({arg i;
~wet.free;
~ezConv.free;
~ezConv = EZConv(~impulse, fftSize: 512);
~wet = Synth(\wet);
0.25.rrand(0.75).wait;
})
});
//reading analog in from server and sending to client
~ctrl = {
var a0 = AnalogIn.kr(0);
SendReply.kr(Impulse.kr(10), '/ctrl', [a0]);
}.play;
~preset = 1.0;
~currentpre = 0;
OSCdef('listen', {arg msg;
~preset = msg[3].linlin(0.0, 1.0, 0.0, 1.0).trunc(0.07);
// [~preset].postln; // used for testing
// this is the case loop that evaluates the analog in and changes the impulse depending on value
p = ~preset;
x = case
{ (p <= 1) && (p >= 0.97) && (p != ~newpreset)} { y = 1; ~newpreset = p; y.postln; ~impulse = "./cello.wav"; ~impulse.postln; ~task.reset; ~task.resume;}
{ (p <= 0.90) && (p >= 0.81) && (p != ~newpreset)} { y = 2; ~newpreset = p; y.postln; ~impulse = "./cymbal.wav"; ~impulse.postln; ~task.reset; ~task.resume;}
{ (p <= 0.77) && (p >= 0.70) && (p != ~newpreset)} { y = 3; ~newpreset = p; y.postln; ~impulse = "./opera.wav"; ~impulse.postln; ~task.reset; ~task.resume;}
{ (p <= 0.66) && (p >= 0.55) && (p != ~newpreset)} { y = 4; ~newpreset = p; y.postln;}
{ (p <= 0.50) && (p >= 0.40) && (p != ~newpreset)} { y = 5; ~newpreset = p; y.postln;}
{ (p <= 0.37) && (p >= 0.25) && (p != ~newpreset)} { y = 6; ~newpreset = p; y.postln;}
{ (p <= 0.20) && (p >= 0.12) && (p != ~newpreset)} { y = 7; ~newpreset = p; y.postln;}
{ (p <= 0.09) && (p >= 0) && (p != ~newpreset)} { y = 8; ~newpreset = p; y.postln;}
}, '/ctrl');
}
)