[Csnd] panner with a twist
Date | 2012-08-04 12:46 |
From | peiman khosravi |
Subject | [Csnd] panner with a twist |
Hello, I'm working on making a multichannel granular texture instrument with partikkel (or even just an impulse generator like gausstrig) with a twist: each time the panning 'position' is changed the sound leaves a small traces behind, with a user-defined decay rate (e.g. 10 seconds with an exponential decay). Any idea how this could be realised in an efficient way? I suppose the design would need to be similar to the attack/decay duration of a compressor but I've no idea how that's done. Many Thanks Peiman |
Date | 2012-08-04 13:58 |
From | Justin Smith |
Subject | Re: [Csnd] panner with a twist |
Just brainstorming here: maybe getting the absolute value of the change in panning position, and sending that through portk, and adding it to your dispersion? Something like: kprev init 0 kdelta = abs(kposition - kprev) kprev = kposition kexpand portk kdelta, khtime kspread = kbasespread+(kexpand * kresiduewidth) this is a little simplistic, but may be enough? On Sat, Aug 4, 2012 at 4:46 AM, peiman khosravi |
Date | 2012-08-04 14:40 |
From | peiman khosravi |
Subject | Re: [Csnd] panner with a twist |
Hi Justin, Thanks for the idea. Yes something like that would work, but I was hoping for a little bit more control over the morphology of the dispersion. Exponential seems works better. I came up with this test csd. Not there yet but it wort of works in principle I think. Best, Peiman <CsoundSynthesizer> <CsOptions> -W -odevaudio -d </CsOptions> <CsInstruments> sr = 44100 ksmps = 1 nchnls = 2 instr 1 ;Simple sine at 440Hz aout oscil 1000, 2000, 1 kpan oscil .5, .5, 1 kpan = kpan +.5 if (kpan==1) then ktest=0 reinit decay elseif (kpan==0) then ktest=1 endif if (ktest==1) then kexpon = kpan goto play endif decay: kexpon expon 1, 3, 0.000001 rireturn play: kexpon port kexpon, .01 aexpon upsamp kexpon outs aout*aexpon, aout*aexpon ;printk2 ktest endin </CsInstruments> <CsScore> f1 0 4096 10 1 i1 0 10 </CsScore> </CsoundSynthesizer> On 4 August 2012 13:58, Justin Smith <noisesmith@gmail.com> wrote: Just brainstorming here: maybe getting the absolute value of the |
Date | 2012-08-04 16:14 |
From | peiman khosravi |
Subject | Re: [Csnd] panner with a twist |
This seems to work I think. Now let's see if it works in context. P <CsoundSynthesizer> <CsOptions> -W -otest.wav -d </CsOptions> <CsInstruments> sr = 44100 ksmps = 1 nchnls = 2 gitrace init 3 instr panning gkpan linseg p4, p3, p5 ;gkpan = kpan +.5 endin ;;;;;;;;;; instr traceL ;Simple sine at 440Hz kpan = 1-gkpan ktest init 1 if (kpan==1) then ktest=0 reinit decay elseif (kpan==0) then ktest=1 endif if (ktest==1) then kexpon = kpan goto play endif decay: kexpon expseg 1, gitrace, 0.0001 rireturn play: kexpon port kexpon, .01, i(kpan) gaexponL upsamp kexpon endin ;;;;;;;;;;;;;;; ;;;;;;;;;; instr traceR ;Simple sine at 440Hz kpan = gkpan ktest init 1 if (kpan==1) then ktest=0 reinit decay elseif (kpan==0) then ktest=1 endif if (ktest==1) then kexpon = kpan goto play endif decay: kexpon expseg 1, gitrace, 0.000001 rireturn play: kexpon port kexpon, .01, i(kpan) gaexponR upsamp kexpon endin ;;;;;;;;;;;;;;; instr signal aout gausstrig 3000, 100, .02, 1 atraceL = aout*gaexponL atraceR = aout*gaexponR aoutL, aoutR pan2 aout, gkpan, 0 outs atraceL+aoutL, atraceR+aoutR endin </CsInstruments> <CsScore> f1 0 4096 10 1 i"traceL" 0 10 i"traceR" 0 10 i"panning" 0 1 0 1 i"panning" + 1 1 0 i"panning" + 1 0 1 i"signal" 0 10 </CsScore> </CsoundSynthesizer> On 4 August 2012 14:40, peiman khosravi <peimankhosravi@gmail.com> wrote: Hi Justin, |
Date | 2012-08-04 20:55 |
From | peiman khosravi |
Subject | Re: [Csnd] panner with a twist |
OK I'm taking another look at your idea. What I was doing was way too convoluted. Can you walk me through this formula please? Is kbasespread for vbap? Thanks again Peiman
On 4 August 2012 13:58, Justin Smith <noisesmith@gmail.com> wrote: Just brainstorming here: maybe getting the absolute value of the |
Date | 2012-08-04 21:02 |
From | peiman khosravi |
Subject | Re: [Csnd] panner with a twist |
Another issue is that the instrument parameters (e.g. periodicity or grain density) will be changing as the sound 'moves' but the trace would need to remain unchanged. So I was thinking I need to have two copies of the instrument running in parallel and sample the variable at a given moment in time. Maybe I'll need to have a break-point function or something to define the times at which the variables are sampled. The dispersion could also have an effect on the variables (so for instance dispersion by decreasing grain density may be more effective than simple amplitude decay). Need to think about it a bit more. Annoyingly this is how I do it in protools but it would be much more efficient to programme it in instead of spending hours tweaking automation! P On 4 August 2012 20:55, peiman khosravi <peimankhosravi@gmail.com> wrote: OK I'm taking another look at your idea. What I was doing was way too convoluted. |
Date | 2012-08-04 21:34 |
From | Justin Smith |
Subject | Re: [Csnd] panner with a twist |
Yeah, I had imagined you could just make the spread be a slowly updating function of the movement, and that might create an impression of a trace left by a moving sound. If you want the output traces to follow old output, you could also put a reverb in (at the instrument level), on each of the vbap outputs before writing the outptut. Combining with my previous suggestion we get something like: kprev_az init 0 kdelta = abs (kazim-kprev_az) kprev_az = kazim kd portk kdelta, 3 kspread kd*ispreadfactor ; instead of this, you could do an exponential or table lookup based on kdelta ar1, ar2, ar3, ar4 vbap4 asig, kazim, kelev, kspread at1 nreverb ar1, 10, .8 at2 nreverb ar2, 10, .8 at3 nreverb ar3, 10, .8 at4 nreverb ar4, 10, .8 ktlv = ampdb(kd*itracefactor - 30) outq ar1+at1*ktlv, ar2+at2*ktlv, ar3+at3*ktlv, ar4+at4*ktlv It occurs to me that for this kind of effect, you could save a bunch of cpu by getting not audio signals as output of vbap, but amplitude scales for each channel, then the reverb here would only need to be calculated once Otherwise you could use schedkwhen to periodically launch a granulator with a snapshot of the current parameters while pan is changing. This would be a sort of meta-granulation if you put a volume envelope on each granulator. On Sat, Aug 4, 2012 at 1:02 PM, peiman khosravi |
Date | 2012-08-04 21:56 |
From | peiman khosravi |
Subject | Re: [Csnd] panner with a twist |
OK I see, this code is really useful, thanks. Could you just clarify why are you using the spread factor here? Wouldn't it be sufficient to deal with each speaker independently? Thanks Peiman On 4 August 2012 21:34, Justin Smith <noisesmith@gmail.com> wrote: Yeah, I had imagined you could just make the spread be a slowly |
Date | 2012-08-04 22:09 |
From | Justin Smith |
Subject | Re: [Csnd] panner with a twist |
It just seems like separation of concerns to me - vbap is already there for spreading signals between speakers, why use another method as well? And when I put it that way, perhaps instead of changing the spread you could use a second instance of vbap, where its azimuth input is run through portk and maybe even a delay line (still using the reverb also if you want lingering artifacts). Or maybe just the reverb without a second vbap or a change in spread would be best. On Sat, Aug 4, 2012 at 1:56 PM, peiman khosravi |
Date | 2012-08-04 22:16 |
From | peiman khosravi |
Subject | Re: [Csnd] panner with a twist |
But if the sound is just leaving behind a trace then the trace would only be in one speaker and not more spread. I feel like I'm missing something though (?). P On 4 August 2012 22:09, Justin Smith <noisesmith@gmail.com> wrote: It just seems like separation of concerns to me - vbap is already |
Date | 2012-08-05 02:23 |
From | peiman khosravi |
Subject | Re: [Csnd] panner with a twist |
I haven't heard it in the studio but it seems to work OK in stereo. P <CsoundSynthesizer> <CsOptions> -W -o dac -d </CsOptions> <CsoundSynthesizer> <CsInstruments> sr = 44100 ksmps = 1 nchnls = 2 instr test kpan linseg 0, .2, 0, .2, 2, .1, 0, .1, 2, .1, 0, 3, 0 aamp linseg 0, .2, 0, 1, 1, .1, 0, .1, .5, .1, 0 kpitch linseg 20,.2, 405, .1, 400, .1, 431, .1, 300, .1, 410, 1, 400 ;printk2 kpitch aout gausstrig 10000, kpitch, .03 ;kpan = kpan+1 ;printk2 kpan if kpan<=1 then kpan1 = 1-kpan else kpan2 = kpan-1 endif kprev1 init 0 knew1 = kpan1 if kprev1 == 1 && knew1 < 1 then kzero1 = 1 reinit decay1 endif kprev1 = knew1 kprev2 init 0 knew2 = kpan2 if kprev2 == 1 && knew2 < 1 then kzero2 = 1 reinit decay2 endif kprev2 = knew2 kzero1 init 0 decay1: atrace1 expseg 1, 10, 0.000001 atrace1 = atrace1*kzero1 rireturn kzero2 init 0 decay2: atrace2 expseg 1, 10, 0.000001 atrace2 = atrace2*kzero2 rireturn ktrace1=1 ktrace2=1 atrace1 = aout*atrace1*ktrace1 atrace2 = aout*atrace2*ktrace2 aoutL, aoutR pan2 aout*aamp, kpan*.5, 2 ;printk2 kpan1 ;printk2 kpan2 atraceL = (atrace1*(1-kpan1))+(aoutL) atraceR = (atrace2*(1-kpan2))+(aoutR) outs atraceL, atraceR ;outs aoutL, aoutR endin </CsInstruments> <CsScore> f1 0 16384 10 1 i "test" 0 30 </CsScore> </CsoundSynthesizer> On 4 August 2012 22:16, peiman khosravi <peimankhosravi@gmail.com> wrote: But if the sound is just leaving behind a trace then the trace would only be in one speaker and not more spread. I feel like I'm missing something though (?). |