Csound Csound-dev Csound-tekno Search About

[Csnd] how to change the tonic key and frequency via midi

Date2011-02-21 21:33
FromStefan 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>



Date2011-02-22 05:50
FromJim 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

Date2011-02-22 07:41
FromStefan Thomas
SubjectRe: [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>

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
--
View this message in context: http://csound.1045644.n5.nabble.com/how-to-change-the-tonic-key-and-frequency-via-midi-tp3394717p3395010.html
Sent from the Csound - General mailing list archive at Nabble.com.


Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"



Date2011-02-22 08:07
FromOeyvind Brandtsegg
SubjectRe: [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 :
> Dear Jim,
> I tried to modify the content of my table with tableiw, but unfortunately
> without any success.
> I tried it with:
> 
> 
> -odevaudio -Ma -b400 -m0d
> 
> ; ==============================================
> 
>
> 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
>
> 
> ; ==============================================
> 
> f 0 36
> i1 0 36
>
>
> 
> 
>
>
>
> 2011/2/22 Jim Aikin 
>>
>> 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
>> --
>> View this message in context:
>> http://csound.1045644.n5.nabble.com/how-to-change-the-tonic-key-and-frequency-via-midi-tp3394717p3395010.html
>> Sent from the Csound - General mailing list archive at Nabble.com.
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2011-02-22 08:42
FromStefan Thomas
SubjectRe: [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
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 <kontrapunktstefan@googlemail.com>:
> 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>
>>
>> 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
>> --
>> View this message in context:
>> http://csound.1045644.n5.nabble.com/how-to-change-the-tonic-key-and-frequency-via-midi-tp3394717p3395010.html
>> Sent from the Csound - General mailing list archive at Nabble.com.
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>
>


Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"



Date2011-02-22 12:33
FromOeyvind Brandtsegg
SubjectRe: [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 :
> 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 
>>
>> 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 :
>> > Dear Jim,
>> > I tried to modify the content of my table with tableiw, but
>> > unfortunately
>> > without any success.
>> > I tried it with:
>> > 
>> > 
>> > -odevaudio -Ma -b400 -m0d
>> > 
>> > ; ==============================================
>> > 
>> >
>> > 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
>> >
>> > 
>> > ; ==============================================
>> > 
>> > f 0 36
>> > i1 0 36
>> >
>> >
>> > 
>> > 
>> >
>> >
>> >
>> > 2011/2/22 Jim Aikin 
>> >>
>> >> 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
>> >> --
>> >> View this message in context:
>> >>
>> >> http://csound.1045644.n5.nabble.com/how-to-change-the-tonic-key-and-frequency-via-midi-tp3394717p3395010.html
>> >> Sent from the Csound - General mailing list archive at Nabble.com.
>> >>
>> >>
>> >> Send bugs reports to the Sourceforge bug tracker
>> >>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> >> Discussions of bugs and features can be posted here
>> >> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>> >> "unsubscribe
>> >> csound"
>> >>
>> >
>> >
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2011-02-23 05:55
FromStefan Thomas
SubjectRe: [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.
all clear ? :-)
Oeyvind


2011/2/22 Stefan Thomas <kontrapunktstefan@googlemail.com>:
> 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
>> 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 <kontrapunktstefan@googlemail.com>:
>> > 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>
>> >>
>> >> 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
>> >> --
>> >> View this message in context:
>> >>
>> >> http://csound.1045644.n5.nabble.com/how-to-change-the-tonic-key-and-frequency-via-midi-tp3394717p3395010.html
>> >> Sent from the Csound - General mailing list archive at Nabble.com.
>> >>
>> >>
>> >> Send bugs reports to the Sourceforge bug tracker
>> >>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> >> Discussions of bugs and features can be posted here
>> >> To unsubscribe, send email sympa@lists.bath.ac.uk with body
>> >> "unsubscribe
>> >> csound"
>> >>
>> >
>> >
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>
>


Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"