Csound Csound-dev Csound-tekno Search About

[Csnd] Init-time only instruments

Date2019-10-19 12:26
FromBernard Geyer
Subject[Csnd] Init-time only instruments
Sometimes we need an instrument that is used only at init-time (f.e. just to
start or stop other instruments)

What is that best way to do that ?
I was reading somewhere that we can use 0 for the duration, but sometimes it
works, sometimes not.

So I made the following tests:
instr Test
  printf_i "%s\n", 1, "...TEST!"
endin

instr Play1
 schedule "Test", 0, 0
endin

instr Play2
 event_i "i", "Test", 0, 0
endin


instr Play3
 event "i", "Test", 0, 0
endin

instr Play4
 scoreline {{i "Test" 0 0}}, 1
endin


and I tested it in 

Here are the results:

i "Test" 0 0 ; works

i "Play1" 0 0 ; does nothing
i "Play2" 0 0 ; does nothing
i "Play3" 0 0 ; does nothing
i "Play4" 0 0 ; does nothing

; but if I give a short value instead of 0:

i "Play1" 0 0.1 ; works
i "Play2" 0 0.1 ; works
i "Play3" 0 0.1 ; repeats "Test", depending on duration of "Play3"
i "Play4" 0 0.1 ; repeats "Test", depending on duration of "Play4"

I’m also surprised to read the following, in the help-file of schedule:
« If the duration is zero or negative the new event is of MIDI type, and
inherits the release sub-event from the scheduling instruction »





--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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-10-19 12:51
From"Jeanette C."
SubjectRe: [Csnd] Init-time only instruments
Hello Bernhard,
when I need an instrument like that, I use turnoff:
instr Init
   print_i "%f %f", p2, p3
   turnoff
endin

Then I can call it with any length and it will only execute the init commands 
and then stop.

HTH, best wishes,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * SoundCloud: https://soundcloud.com/jeanette_c
  * Twitter: https://twitter.com/jeanette_c_s
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

Just call out my name, and I will be there... <3
(Britney Spears)

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-10-19 13:04
FromVictor Lazzarini
SubjectRe: [Csnd] Init-time only instruments
It's an interesting point you make. They all should work with duration 0. I have the impression the instrument order might have something to do with the behaviour you see,
but I am not completely sure, need to test it.

Prof. Victor Lazzarini
Maynooth University
Ireland

> On 19 Oct 2019, at 12:17, Bernard Geyer  wrote:
> 
> Sometimes we need an instrument that is used only at init-time (f.e. just to
> start or stop other instruments)
> 
> What is that best way to do that ?
> I was reading somewhere that we can use 0 for the duration, but sometimes it
> works, sometimes not.
> 
> So I made the following tests:
> instr Test
>  printf_i "%s\n", 1, "...TEST!"
> endin
> 
> instr Play1
> schedule "Test", 0, 0
> endin
> 
> instr Play2
> event_i "i", "Test", 0, 0
> endin
> 
> 
> instr Play3
> event "i", "Test", 0, 0
> endin
> 
> instr Play4
> scoreline {{i "Test" 0 0}}, 1
> endin
> 
> 
> and I tested it in 
> 
> Here are the results:
> 
> i "Test" 0 0 ; works
> 
> i "Play1" 0 0 ; does nothing
> i "Play2" 0 0 ; does nothing
> i "Play3" 0 0 ; does nothing
> i "Play4" 0 0 ; does nothing
> 
> ; but if I give a short value instead of 0:
> 
> i "Play1" 0 0.1 ; works
> i "Play2" 0 0.1 ; works
> i "Play3" 0 0.1 ; repeats "Test", depending on duration of "Play3"
> i "Play4" 0 0.1 ; repeats "Test", depending on duration of "Play4"
> 
> I’m also surprised to read the following, in the help-file of schedule:
> « If the duration is zero or negative the new event is of MIDI type, and
> inherits the release sub-event from the scheduling instruction »
> 
> 
> 
> 
> 
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
> 
> 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-10-19 13:08
FromJohn ff
SubjectRe: [Csnd] Init-time only instruments
You should take notice of the instrument order.  Some of your cases schedule for too late.

But turnoff if the sane thing to do

⁣Sent from TypeApp ​

On Oct 19, 2019, 12:17, at 12:17, Bernard Geyer  wrote:
>Sometimes we need an instrument that is used only at init-time (f.e.
>just to
>start or stop other instruments)
>
>What is that best way to do that ?
>I was reading somewhere that we can use 0 for the duration, but
>sometimes it
>works, sometimes not.
>
>So I made the following tests:
>instr Test
>  printf_i "%s\n", 1, "...TEST!"
>endin
>
>instr Play1
> schedule "Test", 0, 0
>endin
>
>instr Play2
> event_i "i", "Test", 0, 0
>endin
>
>
>instr Play3
> event "i", "Test", 0, 0
>endin
>
>instr Play4
> scoreline {{i "Test" 0 0}}, 1
>endin
>
>
>and I tested it in 
>
>Here are the results:
>
>i "Test" 0 0 ; works
>
>i "Play1" 0 0 ; does nothing
>i "Play2" 0 0 ; does nothing
>i "Play3" 0 0 ; does nothing
>i "Play4" 0 0 ; does nothing
>
>; but if I give a short value instead of 0:
>
>i "Play1" 0 0.1 ; works
>i "Play2" 0 0.1 ; works
>i "Play3" 0 0.1 ; repeats "Test", depending on duration of "Play3"
>i "Play4" 0 0.1 ; repeats "Test", depending on duration of "Play4"
>
>I’m also surprised to read the following, in the help-file of schedule:
>« If the duration is zero or negative the new event is of MIDI type,
>and
>inherits the release sub-event from the scheduling instruction »
>
>
>
>
>
>--
>Sent from:
>http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
>
>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-10-19 13:58
FromBernard Geyer
SubjectRe: [Csnd] Init-time only instruments
I  don't understand what the instrument order means here.
When I put instr Test on the end, the result is identical.

And when I use 
i "Play1" 0 0
or
i "Play2" 0 0
in csoundQT, the program sometimes freezes, and I have to force it to quit.





--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

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-10-19 14:02
Fromjoachim heintz
SubjectRe: [Csnd] Init-time only instruments
yes, this (that the instrument order) has no influence on the result, is 
the only thing which is not as expected for me.  i would have expected 
that it makes a difference, but obviously the call to "Test" is 
performed in the next k-cycle, not just appended to this (init) pass. 
(perhaps this is mentioned anywhere in the manual, but i don't find it.)

the reason you get no result for the examples with duration zero is, 
that you have a score line, and csound stops performance after the 
scoreline has performed.  when you add

e 1

at the end of your score, you tell csound to perform for one second. 
then you see twice the printing (for Play1 and Play2).

the result for Play3 and Play4 is definitely as expected.  event and 
scoreline are opcodes which work at k-time, not at i-time.  when you 
call these instruments with duration zero, nothing will happen.  when 
you call them with any bigger duration, they will repeat the call of 
Test once every control cycle they are running.

	joachim




On 19/10/19 14:58, Bernard Geyer wrote:
> I  don't understand what the instrument order means here.
> When I put instr Test on the end, the result is identical.
>
> And when I use
> i "Play1" 0 0
> or
> i "Play2" 0 0
> in csoundQT, the program sometimes freezes, and I have to force it to quit.
>
>
>
>
>
> --
> Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html
>
> 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