[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] instrument repository?



andy baxter wrote:

I managed to make a half-decent organ sound by filtering pink noise through a bandpass filter and then adding different harmonics. The code I wrote is pasted below (though could do with some more work).

It's more of a synthdef generator than a simple synthdef - the harmonic parameters can only be altered during the creation of the synthdef at the moment, not live.

( // additive filtered noise synth generator.
var numHarm = 10, harmMult = 2, harmOffset = 1, harmDecayPower=2;
SynthDef.new("miditest", { arg freq = 440, amp = 0.4, out = 0, fwidth = 0.0005, attackTime = 0.01, decayTime= 0.2, sustainLevel= 0.7, releaseTime= 1, peakLevel= 1, curve= 'sine', gate = 1 ;
   Out.ar(out, Pan2.ar(
       Mix.fill(numHarm,{
           arg index;
           index.postln;
           EnvGen.kr(Env.adsr(
                   attackTime, decayTime, sustainLevel,
                   releaseTime, peakLevel, curve),
               gate, doneAction:2 ) *
           BBandPass.ar(PinkNoise.ar(amp),
               freq*(index*harmMult+harmOffset),
fwidth,1/(fwidth*((index*harmMult+harmOffset)**harmDecayPower) )
           )
       } ),
       0.5 ) );
   }
   ).store;

)



P.S. the harmonic parameters work as follows:

numHarm: Number of harmonics. 1=just fundamental.
harmDecayPower: make the harmonics decay in amplitude with this inverse power. I.e. 1= 1/n, 2=1/n^2, 1.5=1/n^1.5. Affects the brightness of the sound.
harmMult, harmOffset: which harmonics to include. E.g.:
   hM=1, hO=1 - all harmonics.
   hM=2, hO=1 - odd numbered harmonics (I.e. f*1, f*3, f*5...)
hM=2, hO=2 - even numbered harmonics (and doubled fundamental. I.e. f*2, f*4, f*6)

andy

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/