// title: Additive Synthesis Demo with QuNEO - Patch 1 // author: Bruno Ruviaro // description: // QuNeo controller additive synthesis demo. // code: // ************************************ // Additive Synthesis Demo with QuNEO // Patch 1 - Harmonic Series // Bruno Ruviaro, 2013-07-22 // ************************************ /* Use QuNEO SCLOrk Preset #1 for piano-like play Use QuNEO SCLOrk Preset #2 for toggle-like play Pads play 16 first partials of the harmonic series: 13 14 15 16 09 10 11 12 05 06 07 08 01 02 03 04 Long Slider controls fundamental frequency Vertical Sliders control ADSR envelope */ s.waitForBoot({ // Some variables var notes = Array.newClear(128); ~att = 0.01; ~dec = 0.3; ~sus = 0.5; ~rel = 1.0; ~fundamental = 110; ~quNeoChannel = 11; MIDIIn.connectAll; MIDIdef.freeAll; MIDIdef.noteOn( key: \noteOn, func: {arg vel, note; var partial = note - 35; // start from 1 notes[note] = Synth("addsynth", [ \freq, ~fundamental * partial, \amp, vel.linlin(0, 127, 0, 0.5), \att, ~att, \dec, ~dec, \sus, ~sus, \rel, ~rel; ])}, noteNum: (30..127), // Ignore notes lower than 24 (= 46Hz) chan: ~quNeoChannel); MIDIdef.noteOff( key: \noteOff, func: {arg vel, note; notes[note].release}, chan: ~quNeoChannel); MIDIdef.cc( key: \adsr, func: {arg val, ccnum; case {ccnum==6} {~att = val.linlin(0, 127, 0.01, 4)} {ccnum==7} {~dec = val.linlin(0, 127, 0.05, 2)} {ccnum==8} {~sus = val.linlin(0, 127, 0.10, 1)} {ccnum==9} {~rel = val.linlin(0, 127, 0.05, 4)}; [~att, ~dec, ~sus, ~rel].round(0.01).postln}, ccNum: (6..9)); // Vertical Sliders MIDIdef.cc( key: \fundamental, func: {arg val, ccnum; ~fundamental = val.linexp(0, 127, 55, 220); ("Fundamental is "++~fundamental.round(0.1)++" Hz").postln}, ccNum: 10); // Long Slider // A synth SynthDef("addsynth", { arg freq = 440, amp = 0.1, gate = 1, att = 0.01, dec = 0.3, sus = 0.5, rel = 1; var snd, env; env = EnvGen.ar(Env.adsr(att, dec, sus, rel), gate, doneAction: 2); snd = SinOsc.ar(freq, 0, amp) * env; Out.ar(0, snd!2); }).add; });