[Csnd] choosing register with invalue
| Date | 2012-12-16 20:39 |
| From | Stefan Thomas |
| Subject | [Csnd] choosing register with invalue |
| Dear community, I want to build a csd file, that can play different different intervals in different (de)tunings. My idea is to create an master-instrument that gets the base frequency and the register from the invalue opcode and sends it with event_i opcode to another instrument. Unfortunately, the below quoted code doesn't work as expected. It doesn't matter which register value I choose, I always get the same register. I'm sure I made a stupit mistake, but I can't see it. Here's my code: <CsoundSynthesizer> <CsOptions> -odac </CsOptions> ; ============================================== <CsInstruments> sr = 48000 ksmps = 100 nchnls = 2 0dbfs = 1 giSine ftgen 0,0,8192,10,1 instr 1 iamp = 0.3 instrument = 2 idelay = 0 idur = 5 iamp = 0.3 iatt = 0.01 irel = 0.1
kmultiplikator invalue "register" if (kmultiplikator == 0) then ioktave = 0.25 elseif (kmultiplikator == 1) then ioktave = 0.5 elseif (kmultiplikator == 2) then ioktave = 1 elseif (kmultiplikator == 3) then ioktave = 2 elseif (kmultiplikator == 4) then ioktave = 4 endif ifreq = 261 ifreqone = ioktave*ifreq event_i "i", instrument, idelay, idur, iamp, ifreq,iatt, irel endin instr 2 idur = p3 iamp = p4 ifreq = p5 iatt = p6 irel = p7 a1 poscil iamp, ifreq, giSine aenv linseg 0,iatt, 1, idur-iatt-irel,1, irel,0 aout = aenv*a1 outs aout, aout endin </CsInstruments> ; ============================================== <CsScore> i1 0 5 </CsScore> </CsoundSynthesizer> |
| Date | 2012-12-16 21:09 |
| From | Rory Walsh |
| Subject | Re: [Csnd] choosing register with invalue |
When do you send the data to the channel named 'register'(I don't see any outvalue opcode)? This code works as expected because no data is ever sent to a channel called 'register'. Therefore kmultiplikator will always be 0. How are you intending to control this instrument? Is it for real time playback or will you be running a score? On 16 December 2012 20:39, Stefan Thomas |
| Date | 2012-12-16 21:38 |
| From | Stefan Thomas |
| Subject | Re: [Csnd] choosing register with invalue |
| Dear Rory, I could solve the problem. I did it with: kregister invalue "register" iregister = i(kregister) if (iregister == 0) then ioktave = 0.25 elseif (iregister == 1) then ioktave = 0.5 elseif (iregister == 2) then ioktave = 1 elseif (iregister == 3) then ioktave = 2 elseif (iregister == 4) then ioktave = 4 endif I use it for realtime output in qutecsound!2012/12/16 Rory Walsh <rorywalsh@ear.ie> When do you send the data to the channel named 'register'(I don't see |
| Date | 2012-12-16 23:50 |
| From | Rory Walsh |
| Subject | Re: [Csnd] choosing register with invalue |
I see, I wasn't quite sure where the channel data was coming from. So it was the event_i and not a problem with the channel. Good luck. Rory. On 16 December 2012 21:38, Stefan Thomas |