Skip to content

Commit

Permalink
Merge pull request #5 from schollz/pitch_bend
Browse files Browse the repository at this point in the history
Pitch bend implementation
  • Loading branch information
schollz authored Dec 27, 2021
2 parents e978d4a + a93ab16 commit 3d6c9ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
4 changes: 4 additions & 0 deletions icarus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ function setup_midi()
skeys:on(d.note)
elseif d.type=="note_off" then
skeys:off(d.note)
elseif d.type=="pitchbend" then
local bend_st = (util.round(d.val / 2)) / 8192 * 2 -1 -- Convert to -1 to 1
engine.bend(bend_st * params:get("bend_range"))
end
end
end
Expand All @@ -87,6 +90,7 @@ function setup_midi()
mididevice[mididevice_list[v]].active=true
end)
params:add{type="option",id="midichannel",name="midi ch",options=midi_channels,default=1}
params:add_number("bend_range", "bend range", 0, 48, 2)

if #mididevice_list>1 then
params:set("midi",2)
Expand Down
21 changes: 11 additions & 10 deletions lib/Engine_Icarus.sc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ Engine_Icarus : CroneEngine {
(0..5).do({arg i;
SynthDef("icarussynth"++i,{
arg amp=0.5, hz=220, pan=0, envgate=0,
pulse=0,saw=0,
pulse=0,saw=0,bend=0,
attack=0.015,decay=1,release=2,sustain=0.9,
lpf=20000,resonance=0,portamento=0.1,tremelo=0,destruction=0,
pwmcenter=0.5,pwmwidth=0.05,pwmfreq=10,detuning=0.1,
feedback=0.5,delaytime=0.25, delaytimelag=0.1, sublevel=0;

// vars
var ender,snd,local,in,ampcheck;
var ender,snd,local,in,ampcheck,hz_dream,hz_sub;

// envelope stuff
ender = EnvGen.ar(
Expand All @@ -38,19 +38,15 @@ Engine_Icarus : CroneEngine {
);

// dreamcrusher++
in = VarSaw.ar(Lag.kr(hz+(
SinOsc.kr(LFNoise0.kr(1))*
(((hz).cpsmidi+1).midicps-(hz))*detuning
),portamento),
hz_dream=(Lag.kr(hz+(SinOsc.kr(LFNoise0.kr(1))*(((hz).cpsmidi+1).midicps-(hz))*detuning),portamento).cpsmidi + bend).midicps;
in = VarSaw.ar(hz_dream,
width:
LFTri.kr(pwmfreq+rrand(0.1,0.3),mul:pwmwidth/2,add:pwmcenter),
mul:0.5
);
// add suboscillator
in = in + Pulse.ar(Lag.kr(hz/2+(
SinOsc.kr(LFNoise0.kr(1))*
(((hz/2).cpsmidi+1).midicps-(hz/2))*detuning
),portamento),
hz_sub=(Lag.kr(hz/2+(SinOsc.kr(LFNoise0.kr(1))*(((hz/2).cpsmidi+1).midicps-(hz/2))*detuning),portamento).cpsmidi + bend).midicps;
in = in + Pulse.ar(hz_sub,
width:
LFTri.kr(pwmfreq+rrand(0.1,0.3),mul:pwmwidth/2,add:pwmcenter),
mul:0.5*sublevel
Expand Down Expand Up @@ -254,6 +250,11 @@ Engine_Icarus : CroneEngine {
icarusPlayer[i].set(\pwmfreq,msg[1]);
});
});
this.addCommand("bend","f", { arg msg;
(0..5).do({arg i;
icarusPlayer[i].set(\bend,msg[1]);
});
});

}

Expand Down

0 comments on commit 3d6c9ed

Please sign in to comment.