About Monkey 2 › Forums › Monkey 2 Projects › VSynth effects
This topic contains 2 replies, has 2 voices, and was last updated by
Simon Armstrong 1 year, 6 months ago.
-
AuthorPosts
-
September 21, 2017 at 9:36 pm #10678
Early days but the new effects section in my VSynth arpeggiator project are turning out to be a lot of fun.
Save to wav is now working (24 bit only) , uploaded sample output here.
The reverb implementation is too slow for Debug so not quite ready for prime time.
Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889Class Distortion Implements EffectConst DistortionControls:=New String[]("Overdrive","Gain")Method ControlNames:String[]()Return DistortionControlsEndMethod EffectAudio(samples:V Ptr,sampleCount:Int,control:V[][])Local overdrive:=control[0]Local gain:=control[1]For Local s:=0 Until sampleCount*2Local i:=s/2Local v:=samples[s]v*=overdrive[i]If v>0v=1-Exp(-v)Elsev=-1+Exp(v)Endifv*=gain[i]samples[s]=vNextEndEndClass Reverb Implements EffectConst Controls:=New String[]("Wet","Dry","Effect")Struct PoleField distance:MField dampen:VMethod New(meters:M,gain:V)distance=metersdampen=gainEndEndField poles:=New List<Pole>Field future:V[]Field removeSource:=TrueMethod New()poles.Add(New Pole(510,0.5))EndMethod ControlNames:String[]()Return ControlsEndMethod EffectAudio(samples:V Ptr,sampleCount:Int,control:V[][])Local wetness:=control[0]Local dryness:=control[1]Local falloff:=control[2]Local n1:=math.Min(future.Length,sampleCount*2)For Local i:=0 Until n1samples[i]+=future[i]*falloff[i/2]NextFor Local pole:=Eachin polesLocal seconds:=pole.distance/SpeedOfSoundLocal offset:=Int(AudioFrequency*seconds)Local maxOffset:Int=(sampleCount+offset)*2If future.Length<maxOffset future=future.Resize(maxOffset)Local dampen:=pole.dampenFor Local i:=0 Until sampleCountLocal l:=samples[i*2+0]Local r:=samples[i*2+1]future[(offset+i)*2+0]+=l*dampenfuture[(offset+i)*2+1]+=r*dampenNextNextLocal n2:=math.Min(future.Length,sampleCount*2)For Local i:=0 Until n2Local wet:=wetness[i/2]Local dry:=dryness[i/2]samples[i]=wet*future[i]+dry*(samples[i]-future[i])Nextfuture=future.Slice(sampleCount*2)EndEndSeptember 22, 2017 at 10:32 am #10698You might want to think about effects busses.
in essence. you have a buss – which is a buffer the same size as the output.
for each ‘sound’ you have a float from 0 to 1 for each bus.
at 0 the ‘sound’ will not go to the buss, at 1 it will be full volume to the bus. so you have a volume that sets the amount gong to the bus.
For each buffer loop. (once filled) you will have some audio in the bus buffer. You then just do your effect on this buffer.
The result is the output buffer plus the effect bus buffer
September 24, 2017 at 1:02 am #10764Thanks Adam, I can see the reason for bussing when multiple instruments are involved but not too clear on any benefit to what I suppose I would classify as a standalone synth project.
-
AuthorPosts
You must be logged in to reply to this topic.