Csound Csound-dev Csound-tekno Search About

[Csnd] Turn metronome on/off

Date2019-01-12 10:00
FromRichard
Subject[Csnd] Turn metronome on/off

I have a metronome triggering instrument (2) that worked when I had 'alwayson 2' in the header.
Now I want to turn instr 2 on and off depending on a channel, like so:

; turn metro on/off
gkmetronoff  chnget "metronoff"
ktrig2 changed gkmetronoff
 if ktrig2 == 1 then
    ;printk2 ktrig2
    turnon 2
 else
    ;printk2 ktrig2
    turnoff2 2,0,1
 endif
endin

but the metronome stays silent even though ktrig2 gets a value of 1, so turnon 2 should do it.
I have uncommented the alwayson 2 in the header, still I see 'new alloc for instr 2:' when I start the csd.
That should not happen untill the metronoff channel gets a 1....

Richard


Date2019-01-12 11:39
Fromjoachim heintz
SubjectRe: [Csnd] Turn metronome on/off
turnon is made for init-time:
   turnon insnum [, itime]

i suppose when you use the event opcode it should work.

perhaps you need to change your if-condition like this, too:

if ktrig2 == 1 then
  if gkmetronoff == 1 then
   event "i", ...
  else
   turnoff2 ...
  endif
endif



On 12/01/19 11:00, Richard wrote:
> I have a metronome triggering instrument (2) that worked when I had
> 'alwayson 2' in the header.
> Now I want to turn instr 2 on and off depending on a channel, like so:
>
> ; turn metro on/off
> gkmetronoff  chnget "metronoff"
> ktrig2 changed gkmetronoff
>  if ktrig2 == 1 then
>     ;printk2 ktrig2
>     turnon 2
>  else
>     ;printk2 ktrig2
>     turnoff2 2,0,1
>  endif
> endin
>
> but the metronome stays silent even though ktrig2 gets a value of 1, so
> turnon 2 should do it.
> I have uncommented the alwayson 2 in the header, still I see 'new alloc
> for instr 2:' when I start the csd.
> That should not happen untill the metronoff channel gets a 1....
>
> Richard
>
> Csound mailing list Csound@listserv.heanet.ie
> 
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2019-01-12 11:53
FromRichard
SubjectRe: [Csnd] Turn metronome on/off
Event only works if I have the turnoff2 commented out. Apparently first 
the else is executed (gkmetronoff = 0), turning instr 2 off,
but then it won't turn on again with the event "i"...

On 12/01/2019 12:39, joachim heintz wrote:
> turnon is made for init-time:
>   turnon insnum [, itime]
>
> i suppose when you use the event opcode it should work.
>
> perhaps you need to change your if-condition like this, too:
>
> if ktrig2 == 1 then
>  if gkmetronoff == 1 then
>   event "i", ...
>  else
>   turnoff2 ...
>  endif
> endif
>
>
>
> On 12/01/19 11:00, Richard wrote:
>> I have a metronome triggering instrument (2) that worked when I had
>> 'alwayson 2' in the header.
>> Now I want to turn instr 2 on and off depending on a channel, like so:
>>
>> ; turn metro on/off
>> gkmetronoff  chnget "metronoff"
>> ktrig2 changed gkmetronoff
>>  if ktrig2 == 1 then
>>     ;printk2 ktrig2
>>     turnon 2
>>  else
>>     ;printk2 ktrig2
>>     turnoff2 2,0,1
>>  endif
>> endin
>>
>> but the metronome stays silent even though ktrig2 gets a value of 1, so
>> turnon 2 should do it.
>> I have uncommented the alwayson 2 in the header, still I see 'new alloc
>> for instr 2:' when I start the csd.
>> That should not happen untill the metronoff channel gets a 1....
>>
>> Richard
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> 
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features
>> can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2019-01-12 13:17
Fromjoachim heintz
SubjectRe: [Csnd] Turn metronome on/off
can you send a (perhaps reduced) csd which shows the problem?

On 12/01/19 12:53, Richard wrote:
> Event only works if I have the turnoff2 commented out. Apparently first
> the else is executed (gkmetronoff = 0), turning instr 2 off,
> but then it won't turn on again with the event "i"...
>
> On 12/01/2019 12:39, joachim heintz wrote:
>> turnon is made for init-time:
>>   turnon insnum [, itime]
>>
>> i suppose when you use the event opcode it should work.
>>
>> perhaps you need to change your if-condition like this, too:
>>
>> if ktrig2 == 1 then
>>  if gkmetronoff == 1 then
>>   event "i", ...
>>  else
>>   turnoff2 ...
>>  endif
>> endif
>>
>>
>>
>> On 12/01/19 11:00, Richard wrote:
>>> I have a metronome triggering instrument (2) that worked when I had
>>> 'alwayson 2' in the header.
>>> Now I want to turn instr 2 on and off depending on a channel, like so:
>>>
>>> ; turn metro on/off
>>> gkmetronoff  chnget "metronoff"
>>> ktrig2 changed gkmetronoff
>>>  if ktrig2 == 1 then
>>>     ;printk2 ktrig2
>>>     turnon 2
>>>  else
>>>     ;printk2 ktrig2
>>>     turnoff2 2,0,1
>>>  endif
>>> endin
>>>
>>> but the metronome stays silent even though ktrig2 gets a value of 1, so
>>> turnon 2 should do it.
>>> I have uncommented the alwayson 2 in the header, still I see 'new alloc
>>> for instr 2:' when I start the csd.
>>> That should not happen untill the metronoff channel gets a 1....
>>>
>>> Richard
>>>
>>> Csound mailing list Csound@listserv.heanet.ie
>>> 
>>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>>> https://github.com/csound/csound/issues Discussions of bugs and features
>>> can be posted here
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>> Send bugs reports to
>>        https://github.com/csound/csound/issues
>> Discussions of bugs and features can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
>

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2019-01-12 13:22
Fromthorin kerr
SubjectRe: [Csnd] Turn metronome on/off
turnoff2 runs at k-rate. The else is getting executed every kcycle except when 'changed' flicks ktrig2 to 1 for a single kcycle only. So 'event' doesn't get much of a chance to work, because in the very next kcycle turnoff2 switches it off.


On Sat, 12 Jan. 2019, 9:53 pm Richard <zappfinger@gmail.com wrote:
Event only works if I have the turnoff2 commented out. Apparently first
the else is executed (gkmetronoff = 0), turning instr 2 off,
but then it won't turn on again with the event "i"...

On 12/01/2019 12:39, joachim heintz wrote:
> turnon is made for init-time:
>   turnon insnum [, itime]
>
> i suppose when you use the event opcode it should work.
>
> perhaps you need to change your if-condition like this, too:
>
> if ktrig2 == 1 then
>  if gkmetronoff == 1 then
>   event "i", ...
>  else
>   turnoff2 ...
>  endif
> endif
>
>
>
> On 12/01/19 11:00, Richard wrote:
>> I have a metronome triggering instrument (2) that worked when I had
>> 'alwayson 2' in the header.
>> Now I want to turn instr 2 on and off depending on a channel, like so:
>>
>> ; turn metro on/off
>> gkmetronoff  chnget "metronoff"
>> ktrig2 changed gkmetronoff
>>  if ktrig2 == 1 then
>>     ;printk2 ktrig2
>>     turnon 2
>>  else
>>     ;printk2 ktrig2
>>     turnoff2 2,0,1
>>  endif
>> endin
>>
>> but the metronome stays silent even though ktrig2 gets a value of 1, so
>> turnon 2 should do it.
>> I have uncommented the alwayson 2 in the header, still I see 'new alloc
>> for instr 2:' when I start the csd.
>> That should not happen untill the metronoff channel gets a 1....
>>
>> Richard
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> <mailto:Csound@listserv.heanet.ie>
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features
>> can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2019-01-12 14:04
FromRichard
SubjectRe: [Csnd] Turn metronome on/off

Ok, this is starting to work, thanks. I use 2 channels now, to turn the metronome on and off, like so:

; turn metro on/off
gkmetroon  chnget "metroon"
gkmetroff  chnget "metroff"
ktrig2 changed gkmetroon
if ktrig2 == 1 then
   event     "i", 2, 0, -1
endif

ktrig3 changed gkmetroff
if ktrig3 == 1 then
   turnoff2 2,0,1
endif
endin


On 12/01/2019 14:22, thorin kerr wrote:
turnoff2 runs at k-rate. The else is getting executed every kcycle except when 'changed' flicks ktrig2 to 1 for a single kcycle only. So 'event' doesn't get much of a chance to work, because in the very next kcycle turnoff2 switches it off.


On Sat, 12 Jan. 2019, 9:53 pm Richard <zappfinger@gmail.com wrote:
Event only works if I have the turnoff2 commented out. Apparently first
the else is executed (gkmetronoff = 0), turning instr 2 off,
but then it won't turn on again with the event "i"...

On 12/01/2019 12:39, joachim heintz wrote:
> turnon is made for init-time:
>   turnon insnum [, itime]
>
> i suppose when you use the event opcode it should work.
>
> perhaps you need to change your if-condition like this, too:
>
> if ktrig2 == 1 then
>  if gkmetronoff == 1 then
>   event "i", ...
>  else
>   turnoff2 ...
>  endif
> endif
>
>
>
> On 12/01/19 11:00, Richard wrote:
>> I have a metronome triggering instrument (2) that worked when I had
>> 'alwayson 2' in the header.
>> Now I want to turn instr 2 on and off depending on a channel, like so:
>>
>> ; turn metro on/off
>> gkmetronoff  chnget "metronoff"
>> ktrig2 changed gkmetronoff
>>  if ktrig2 == 1 then
>>     ;printk2 ktrig2
>>     turnon 2
>>  else
>>     ;printk2 ktrig2
>>     turnoff2 2,0,1
>>  endif
>> endin
>>
>> but the metronome stays silent even though ktrig2 gets a value of 1, so
>> turnon 2 should do it.
>> I have uncommented the alwayson 2 in the header, still I see 'new alloc
>> for instr 2:' when I start the csd.
>> That should not happen untill the metronoff channel gets a 1....
>>
>> Richard
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> <mailto:Csound@listserv.heanet.ie>
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features
>> can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2019-01-13 19:36
FromTarmo Johannes
SubjectRe: [Csnd] Turn metronome on/off

Hi,

 

If you can leave the metronome instrument always running, then perhaps one solution with lesser lines could be:

 

 

gkmetronoff chnget "metronoff"

ktrig = metro(krate) * gkmetronoff

 

Greetings,

tarmo

 

 

On laupäev, 12. jaanuar 2019 16:04.11 EET you wrote:

Ok, this is starting to work, thanks. I use 2 channels now, to turn the metronome on and off, like so:

; turn metro on/off

gkmetroon chnget "metroon"

gkmetroff chnget "metroff"

ktrig2 changed gkmetroon

if ktrig2 == 1 then

event "i", 2, 0, -1

endif

 

ktrig3 changed gkmetroff

if ktrig3 == 1 then

turnoff2 2,0,1

endif

endin


On 12/01/2019 14:22, thorin kerr wrote:

turnoff2 runs at k-rate. The else is getting executed every kcycle except when 'changed' flicks ktrig2 to 1 for a single kcycle only. So 'event' doesn't get much of a chance to work, because in the very next kcycle turnoff2 switches it off.



On Sat, 12 Jan. 2019, 9:53 pm Richard <zappfinger@gmail.com wrote:

Event only works if I have the turnoff2 commented out. Apparently first
the else is executed (gkmetronoff = 0), turning instr 2 off,
but then it won't turn on again with the event "i"...

On 12/01/2019 12:39, joachim heintz wrote:
> turnon is made for init-time:
>   turnon insnum [, itime]
>
> i suppose when you use the event opcode it should work.
>
> perhaps you need to change your if-condition like this, too:
>
> if ktrig2 == 1 then
>  if gkmetronoff == 1 then
>   event "i", ...
>  else
>   turnoff2 ...
>  endif
> endif
>
>
>
> On 12/01/19 11:00, Richard wrote:
>> I have a metronome triggering instrument (2) that worked when I had
>> 'alwayson 2' in the header.
>> Now I want to turn instr 2 on and off depending on a channel, like so:
>>
>> ; turn metro on/off
>> gkmetronoff  chnget "metronoff"
>> ktrig2 changed gkmetronoff
>>  if ktrig2 == 1 then
>>     ;printk2 ktrig2
>>     turnon 2
>>  else
>>     ;printk2 ktrig2
>>     turnoff2 2,0,1
>>  endif
>> endin
>>
>> but the metronome stays silent even though ktrig2 gets a value of 1, so
>> turnon 2 should do it.
>> I have uncommented the alwayson 2 in the header, still I see 'new alloc
>> for instr 2:' when I start the csd.
>> That should not happen untill the metronoff channel gets a 1....
>>
>> Richard
>>
>> Csound mailing list Csound@listserv.heanet.ie
>> <mailto:Csound@listserv.heanet.ie>
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features
>> can be posted here
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>        https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here