[Csnd] how to change the tonic key and frequency via midi
Date | 2011-02-21 21:33 |
From | Stefan Thomas |
Subject | [Csnd] how to change the tonic key and frequency via midi |
Dear community, I would like to change the key-number and base frequency of a scale I use in conjunction with cpstmid via the modwheel. Altough I don't get an error message, I can't hear any difference. I can't see the mistake in the below quoted code: <CsoundSynthesizer> <CsOptions> -odevaudio -Ma -b400 -m0d </CsOptions> <CsInstruments> sr = 48000 ksmps = 100 nchnls = 2 0dbfs = 1 gisine ftgen 0,0,2^10, 10, 1 gibasefrq init 209.668 gibasekey init 56 ; the "tonic key" of the scale gituningtable ftgen 0, 0, 64, -2, 12, 2 , gibasefrq, gibasekey, 1.0, 1.069608, 1.123759, 1.170466, 1.249593, 1.268684, 1.369991, 1.499172, 1.561482, 1.625, 1.754731, 1.951218, 2.000000 gkmodwheel init 0 massign 0, 101 instr 1 ; global controller ichannelinstrumentone = 1 icontrollerinstrumentone = 1 ; oder irgend ein anderer controller! gkmodwheel ctrl7 ichannelinstrumentone, icontrollerinstrumentone, 0, 1 ; controller 1 is the modwheel endin instr 101 ; the sounding instrument imodwheel = i(gkmodwheel) if (imodwheel >0) then gibasefrq = 262 gibasekey = 60 else gibasefrq = 209.668 gibasekey = 56 endif iamp ampmidi 1 icps cpstmid gituningtable asig poscil iamp, icps, gisine outs asig, asig endin </CsInstruments> <CsScore> f 0 36 i1 0 36 </CsScore> </CsoundSynthesizer> |
Date | 2011-02-22 05:50 |
From | Jim Aikin |
Subject | [Csnd] Re: how to change the tonic key and frequency via midi |
Maybe I'm missing something obvious. (It's late and I'm tired.) But it seems to me you need to use tableiw before you call cpstmid. The table is created when the orchestra is compiled (that is, it's an init-time operation of instr 0), and you're not doing anything to change its contents later on. --JA |
Date | 2011-02-22 07:41 |
From | Stefan Thomas |
Subject | Re: [Csnd] Re: how to change the tonic key and frequency via midi |
Dear Jim, I tried to modify the content of my table with tableiw, but unfortunately without any success. I tried it with: <CsoundSynthesizer> <CsOptions> -odevaudio -Ma -b400 -m0d </CsOptions> ; ============================================== <CsInstruments> sr = 48000 ksmps = 100 nchnls = 2 0dbfs = 1 gisine ftgen 0,0,2^10, 10, 1 gibasefrq init 209.668 gibasekey init 56 ; the "tonic key" of the scale gituningtable ftgen 0, 0, 64, -2, 12, 2 , gibasefrq, gibasekey, 1.0, 1.069608, 1.123759, 1.170466, 1.249593, 1.268684, 1.369991, 1.499172, 1.561482, 1.625, 1.754731, 1.951218, 2.000000 gkmodwheel init 0 massign 0, 101 instr 1 ; global controller ichannelinstrumentone = 1 icontrollerinstrumentone = 1 ; oder irgend ein anderer controller! gkmodwheel ctrl7 ichannelinstrumentone, icontrollerinstrumentone, 0, 1 ; controller 1 is the modwheel endin instr 101 ; the sounding instrument ibasekey = gibasekey ibasefrq = gibasefrq tableiw ibasefrq, 64, gituningtable, 0 tableiw ibasekey, 64, gituningtable, 0 imodwheel = i(gkmodwheel) if (imodwheel >0) then ibasefrq = 262 ibasekey = 60 else ibasefrq = 209.668 ibasekey = 56 endif iamp ampmidi 1 icps cpstmid gituningtable asig poscil iamp, icps, gisine outs asig, asig endin </CsInstruments> ; ============================================== <CsScore> f 0 36 i1 0 36 </CsScore> </CsoundSynthesizer>
2011/2/22 Jim Aikin <midiguru23@sbcglobal.net>
|
Date | 2011-02-22 08:07 |
From | Oeyvind Brandtsegg |
Subject | Re: [Csnd] Re: how to change the tonic key and frequency via midi |
I think you would want to write the basefreq and basekay values into index 2 and 3 of the gituningtable, if I unederstand the mater correctly. I haven't used cpstmid, but this is how it looks to me from the manual.. The code below has not been tested, hope it helps. Oeyvind imodwheel = i(gkmodwheel) if (imodwheel >0) then ibasefrq = 262 ibasekey = 60 else ibasefrq = 209.668 ibasekey = 56 endif tableiw ibasefrq, 2, gituningtable, 0 tableiw ibasekey, 3, gituningtable, 0 2011/2/22 Stefan Thomas |
Date | 2011-02-22 08:42 |
From | Stefan Thomas |
Subject | Re: [Csnd] Re: how to change the tonic key and frequency via midi |
Dear Oeyvind, thanks, Your code works perfectly! There's is only one thing, I didn't understand: Why is gibasefrq the 2nd index of the table and not the third or fourth? I would have thought, that 2 (the octave) would by number 2, and 12 (the number of notes per octave) would be the first number. 2011/2/22 Oeyvind Brandtsegg <oyvind.brandtsegg@ntnu.no> I think you would want to write the basefreq and basekay values into |
Date | 2011-02-22 12:33 |
From | Oeyvind Brandtsegg |
Subject | Re: [Csnd] Re: how to change the tonic key and frequency via midi |
Yes, but it's zero indexed, so the first value is at index 0. all clear ? :-) Oeyvind 2011/2/22 Stefan Thomas |
Date | 2011-02-23 05:55 |
From | Stefan Thomas |
Subject | Re: [Csnd] Re: how to change the tonic key and frequency via midi |
Yes, thanks, everything is clear now! 2011/2/22 Oeyvind Brandtsegg <oyvind.brandtsegg@ntnu.no> Yes, but it's zero indexed, so the first value is at index 0. |