| User-Defined Opcode Database |
|---|
signal splicer
Download UDO FileThis UDO performs realtime re-triggering and reversing of samples in a style similar to that found on most audio trackers. The main difference here is that the samples are being created on the fly during run-time.
ares trackerSplice asig, ksegLength, kmode
asig - input signal
ksegLength - length of re-triggered sample in seconds, for now max=1, if you need longer just change the size of your function table
kmode - either 0, 1, 2 depending on what you want. 0 does no processing, 1 will re-trigger and 2 will reverse
opcode trackerSplice, a, akk asig, kseglength, kmode xin setksmps 1 kindx init 0 ksamp init 1 aout init 0 itbl ftgenonce 0, 0, 2^16, 7, 0, 2^16, 0 ;create table to hold samples kseglength = kseglength*sr ;convert length to samples andx phasor sr/ftlen(itbl) ;ensure phasor is set to correct freq tabw asig, andx*ftlen(itbl), itbl ;write signal to table andx1 delay andx, 1 ;insert a 1 sample delay so that the read point ;always stays one sample behind the write pointer apos samphold andx1*ftlen(itbl), ksamp ;hold sample position whem ksamp=0 if(kmode>=1 && kmode <2) then ;do retrigger when kmode==1 kpos downsamp apos kindx = (kindx>kseglength ? 0 : kindx+1) if(kindx+kpos> ftlen(itbl)) then kindx = -kseglength endif aout table apos+kindx, itbl, 0, 1 ksamp = 0 elseif(kmode>=2 && kmode<3) then ;do reverse when kmode==2 kpos downsamp apos kindx = ((kindx+kpos)<=0 ? ftlen(itbl)-kpos : kindx-1) aout table apos+kindx, itbl, 0, 1 ksamp = 0 else ;when kmode==0 simple pass signal through ksamp = 1 aout = asig endif xout aout endop
<CsoundSynthesizer> <CsOptions> -odac </CsOptions> <CsInstruments> sr = 44100 ksmps = 32 nchnls = 2 ;================================= ; spliceTracker UDO ;================================= opcode trackerSplice, a, akk asig, kseglength, kmode xin setksmps 1 kindx init 0 ksamp init 1 aout init 0 itbl ftgenonce 0, 0, 2^16, 7, 0, 2^16, 0 ;create table to hold samples kseglength = kseglength*sr ;convert length to samples andx phasor sr/ftlen(itbl) ;ensure phasor is set to correct freq tabw asig, andx*ftlen(itbl), itbl ;write signal to table andx1 delay andx, 1 ;insert a 1 sample delay so that the read point ;always stays one sample behind the write pointer apos samphold andx1*ftlen(itbl), ksamp ;hold sample position whem ksamp=0 if(kmode>=1 && kmode <2) then ;do retrigger when kmode==1 kpos downsamp apos kindx = (kindx>kseglength ? 0 : kindx+1) if(kindx+kpos> ftlen(itbl)) then kindx = -kseglength endif aout table apos+kindx, itbl, 0, 1 ksamp = 0 elseif(kmode>=2 && kmode<3) then ;do reverse when kmode==2 kpos downsamp apos kindx = ((kindx+kpos)<=0 ? ftlen(itbl)-kpos : kindx-1) aout table apos+kindx, itbl, 0, 1 ksamp = 0 else ;when kmode==0 simple pass signal through ksamp = 1 aout = asig endif xout aout endop ;============================================ ; trackerSplice example ; ; you will need to change 'house.wav' ; so that it points to your own sample ;============================================ instr 1 ksegLength = .15 ;length of retriggered audio in second, max=1 kmode randi 3, 1 ;randomise mode for demo purposes asig diskin2 "house.wav", 1, 0, 1 ;works best on sound files with beats aout trackerSplice asig, ksegLength, int(kmode) outs aout, aout endin </CsInstruments> <CsScore> i1 0 1000 </CsScore> </CsoundSynthesizer>
Rory Walsh. Mar 2011
| Previous | Home | Next |
| tieStatus | TransGen |