Csound Csound-dev Csound-tekno Search About

[Csnd] xtratim vs. setting p4

Date2023-03-08 14:40
FromDave Seidel
Subject[Csnd] xtratim vs. setting p4
Hi all.

I have a piece I'm working on where I have a main instrument that runs for a while fires off a sequential series of either a sample-based instrument or an oscillator-based instrument. The sample files are of varied lengths. I don't know until I load a file (or query it using filelen) how long it is, so I want the sample-playing instrument to be able to ensure that its duration is sufficient to play the entire sample before ending,

I can use xtratim for this, but I have a vague memory that people sometimes set the value of p4 within an instrument to change its duration. Does this work, and Is it a safe thing to do?

Thanks,
Dave

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

Date2023-03-08 15:40
FromST Music
SubjectRe: [Csnd] xtratim vs. setting p4
Hey Dave, 
   not sure I'm 100% getting the question but if you're using a trigger instrument as your main instrument a simple if statement works inside the sample instr. Note in this example it doesn't matter if schedkwhen duration is .1 or 10 seconds it still plays the full sample once like the traditional "one shot" setting in a sampler.

Also note the trigger instr is only set for 1 second, just too illustrate that no matter what the full sample will play. 

<CsoundSynthesizer>
<CsOptions>
-odac
;-o/sdcard/*******.wav
</CsOptions>
;================================
<CsInstruments>

sr = 48000
ksmps = 10
nchnls = 1
0dbfs  = 1

instr trigger
ktrig metro 1
schedkwhen ktrig, 0, 0, 1, 0, .1
endin

instr 1
ilen = filelen("fox.wav")
    if (p3 < ilen) then
        p3 = ilen
    endif
asig diskin "fox.wav"
out asig
endin

</CsInstruments>
;================================
<CsScore>

i"trigger" 0 1

</CsScore>
</CsoundSynthesizer>

Take care, 
Scott 

On Wed, Mar 8, 2023, 9:42 AM Dave Seidel, <dave.seidel@gmail.com> wrote:
Hi all.

I have a piece I'm working on where I have a main instrument that runs for a while fires off a sequential series of either a sample-based instrument or an oscillator-based instrument. The sample files are of varied lengths. I don't know until I load a file (or query it using filelen) how long it is, so I want the sample-playing instrument to be able to ensure that its duration is sufficient to play the entire sample before ending,

I can use xtratim for this, but I have a vague memory that people sometimes set the value of p4 within an instrument to change its duration. Does this work, and Is it a safe thing to do?

Thanks,
Dave

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

Date2023-03-08 15:42
FromST Music
SubjectRe: [Csnd] xtratim vs. setting p4
P.S. I meant the trigger instr is only 1 second long in the score.

Scott

On Wed, Mar 8, 2023, 10:40 AM ST Music, <stunes6556@gmail.com> wrote:
Hey Dave, 
   not sure I'm 100% getting the question but if you're using a trigger instrument as your main instrument a simple if statement works inside the sample instr. Note in this example it doesn't matter if schedkwhen duration is .1 or 10 seconds it still plays the full sample once like the traditional "one shot" setting in a sampler.

Also note the trigger instr is only set for 1 second, just too illustrate that no matter what the full sample will play. 

<CsoundSynthesizer>
<CsOptions>
-odac
;-o/sdcard/*******.wav
</CsOptions>
;================================
<CsInstruments>

sr = 48000
ksmps = 10
nchnls = 1
0dbfs  = 1

instr trigger
ktrig metro 1
schedkwhen ktrig, 0, 0, 1, 0, .1
endin

instr 1
ilen = filelen("fox.wav")
    if (p3 < ilen) then
        p3 = ilen
    endif
asig diskin "fox.wav"
out asig
endin

</CsInstruments>
;================================
<CsScore>

i"trigger" 0 1

</CsScore>
</CsoundSynthesizer>

Take care, 
Scott 

On Wed, Mar 8, 2023, 9:42 AM Dave Seidel, <dave.seidel@gmail.com> wrote:
Hi all.

I have a piece I'm working on where I have a main instrument that runs for a while fires off a sequential series of either a sample-based instrument or an oscillator-based instrument. The sample files are of varied lengths. I don't know until I load a file (or query it using filelen) how long it is, so I want the sample-playing instrument to be able to ensure that its duration is sufficient to play the entire sample before ending,

I can use xtratim for this, but I have a vague memory that people sometimes set the value of p4 within an instrument to change its duration. Does this work, and Is it a safe thing to do?

Thanks,
Dave

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

Date2023-03-08 15:54
FromST Music
SubjectRe: [Csnd] xtratim vs. setting p4
Actually, the if statement isn't even necessary...

instr 1
ilen = filelen("fox.wav")
p3 = filelen
asig diskin "fox.wav"
out asig
endin

Scott 

On Wed, Mar 8, 2023, 10:42 AM ST Music, <stunes6556@gmail.com> wrote:
P.S. I meant the trigger instr is only 1 second long in the score.

Scott

On Wed, Mar 8, 2023, 10:40 AM ST Music, <stunes6556@gmail.com> wrote:
Hey Dave, 
   not sure I'm 100% getting the question but if you're using a trigger instrument as your main instrument a simple if statement works inside the sample instr. Note in this example it doesn't matter if schedkwhen duration is .1 or 10 seconds it still plays the full sample once like the traditional "one shot" setting in a sampler.

Also note the trigger instr is only set for 1 second, just too illustrate that no matter what the full sample will play. 

<CsoundSynthesizer>
<CsOptions>
-odac
;-o/sdcard/*******.wav
</CsOptions>
;================================
<CsInstruments>

sr = 48000
ksmps = 10
nchnls = 1
0dbfs  = 1

instr trigger
ktrig metro 1
schedkwhen ktrig, 0, 0, 1, 0, .1
endin

instr 1
ilen = filelen("fox.wav")
    if (p3 < ilen) then
        p3 = ilen
    endif
asig diskin "fox.wav"
out asig
endin

</CsInstruments>
;================================
<CsScore>

i"trigger" 0 1

</CsScore>
</CsoundSynthesizer>

Take care, 
Scott 

On Wed, Mar 8, 2023, 9:42 AM Dave Seidel, <dave.seidel@gmail.com> wrote:
Hi all.

I have a piece I'm working on where I have a main instrument that runs for a while fires off a sequential series of either a sample-based instrument or an oscillator-based instrument. The sample files are of varied lengths. I don't know until I load a file (or query it using filelen) how long it is, so I want the sample-playing instrument to be able to ensure that its duration is sufficient to play the entire sample before ending,

I can use xtratim for this, but I have a vague memory that people sometimes set the value of p4 within an instrument to change its duration. Does this work, and Is it a safe thing to do?

Thanks,
Dave

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

Date2023-03-08 16:08
FromDave Seidel
SubjectRe: [Csnd] xtratim vs. setting p4
Thanks Scott! Of course I meant P3 rather than P4  in my iriuginbakl post.

On Wed, Mar 8, 2023 at 10:56 AM ST Music <stunes6556@gmail.com> wrote:
Actually, the if statement isn't even necessary...

instr 1
ilen = filelen("fox.wav")
p3 = filelen
asig diskin "fox.wav"
out asig
endin

Scott 

On Wed, Mar 8, 2023, 10:42 AM ST Music, <stunes6556@gmail.com> wrote:
P.S. I meant the trigger instr is only 1 second long in the score.

Scott

On Wed, Mar 8, 2023, 10:40 AM ST Music, <stunes6556@gmail.com> wrote:
Hey Dave, 
   not sure I'm 100% getting the question but if you're using a trigger instrument as your main instrument a simple if statement works inside the sample instr. Note in this example it doesn't matter if schedkwhen duration is .1 or 10 seconds it still plays the full sample once like the traditional "one shot" setting in a sampler.

Also note the trigger instr is only set for 1 second, just too illustrate that no matter what the full sample will play. 

<CsoundSynthesizer>
<CsOptions>
-odac
;-o/sdcard/*******.wav
</CsOptions>
;================================
<CsInstruments>

sr = 48000
ksmps = 10
nchnls = 1
0dbfs  = 1

instr trigger
ktrig metro 1
schedkwhen ktrig, 0, 0, 1, 0, .1
endin

instr 1
ilen = filelen("fox.wav")
    if (p3 < ilen) then
        p3 = ilen
    endif
asig diskin "fox.wav"
out asig
endin

</CsInstruments>
;================================
<CsScore>

i"trigger" 0 1

</CsScore>
</CsoundSynthesizer>

Take care, 
Scott 

On Wed, Mar 8, 2023, 9:42 AM Dave Seidel, <dave.seidel@gmail.com> wrote:
Hi all.

I have a piece I'm working on where I have a main instrument that runs for a while fires off a sequential series of either a sample-based instrument or an oscillator-based instrument. The sample files are of varied lengths. I don't know until I load a file (or query it using filelen) how long it is, so I want the sample-playing instrument to be able to ensure that its duration is sufficient to play the entire sample before ending,

I can use xtratim for this, but I have a vague memory that people sometimes set the value of p4 within an instrument to change its duration. Does this work, and Is it a safe thing to do?

Thanks,
Dave

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

Date2023-03-08 16:18
FromST Music
SubjectRe: [Csnd] xtratim vs. setting p4
No problem, hth & yes, figured you meant p3.

And I often don't see the forest for the trees at first glance - even the ifn isn't really necessary, you can just use
p3 = filelen("whatever.wav")

On Wed, Mar 8, 2023, 11:09 AM Dave Seidel, <dave.seidel@gmail.com> wrote:
Thanks Scott! Of course I meant P3 rather than P4  in my iriuginbakl post.

On Wed, Mar 8, 2023 at 10:56 AM ST Music <stunes6556@gmail.com> wrote:
Actually, the if statement isn't even necessary...

instr 1
ilen = filelen("fox.wav")
p3 = filelen
asig diskin "fox.wav"
out asig
endin

Scott 

On Wed, Mar 8, 2023, 10:42 AM ST Music, <stunes6556@gmail.com> wrote:
P.S. I meant the trigger instr is only 1 second long in the score.

Scott

On Wed, Mar 8, 2023, 10:40 AM ST Music, <stunes6556@gmail.com> wrote:
Hey Dave, 
   not sure I'm 100% getting the question but if you're using a trigger instrument as your main instrument a simple if statement works inside the sample instr. Note in this example it doesn't matter if schedkwhen duration is .1 or 10 seconds it still plays the full sample once like the traditional "one shot" setting in a sampler.

Also note the trigger instr is only set for 1 second, just too illustrate that no matter what the full sample will play. 

<CsoundSynthesizer>
<CsOptions>
-odac
;-o/sdcard/*******.wav
</CsOptions>
;================================
<CsInstruments>

sr = 48000
ksmps = 10
nchnls = 1
0dbfs  = 1

instr trigger
ktrig metro 1
schedkwhen ktrig, 0, 0, 1, 0, .1
endin

instr 1
ilen = filelen("fox.wav")
    if (p3 < ilen) then
        p3 = ilen
    endif
asig diskin "fox.wav"
out asig
endin

</CsInstruments>
;================================
<CsScore>

i"trigger" 0 1

</CsScore>
</CsoundSynthesizer>

Take care, 
Scott 

On Wed, Mar 8, 2023, 9:42 AM Dave Seidel, <dave.seidel@gmail.com> wrote:
Hi all.

I have a piece I'm working on where I have a main instrument that runs for a while fires off a sequential series of either a sample-based instrument or an oscillator-based instrument. The sample files are of varied lengths. I don't know until I load a file (or query it using filelen) how long it is, so I want the sample-playing instrument to be able to ensure that its duration is sufficient to play the entire sample before ending,

I can use xtratim for this, but I have a vague memory that people sometimes set the value of p4 within an instrument to change its duration. Does this work, and Is it a safe thing to do?

Thanks,
Dave

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

Date2023-03-08 16:21
FromDave Seidel
SubjectRe: [Csnd] xtratim vs. setting p4
Nice and concise.

On Wed, Mar 8, 2023 at 11:19 AM ST Music <stunes6556@gmail.com> wrote:
No problem, hth & yes, figured you meant p3.

And I often don't see the forest for the trees at first glance - even the ifn isn't really necessary, you can just use
p3 = filelen("whatever.wav")

On Wed, Mar 8, 2023, 11:09 AM Dave Seidel, <dave.seidel@gmail.com> wrote:
Thanks Scott! Of course I meant P3 rather than P4  in my iriuginbakl post.

On Wed, Mar 8, 2023 at 10:56 AM ST Music <stunes6556@gmail.com> wrote:
Actually, the if statement isn't even necessary...

instr 1
ilen = filelen("fox.wav")
p3 = filelen
asig diskin "fox.wav"
out asig
endin

Scott 

On Wed, Mar 8, 2023, 10:42 AM ST Music, <stunes6556@gmail.com> wrote:
P.S. I meant the trigger instr is only 1 second long in the score.

Scott

On Wed, Mar 8, 2023, 10:40 AM ST Music, <stunes6556@gmail.com> wrote:
Hey Dave, 
   not sure I'm 100% getting the question but if you're using a trigger instrument as your main instrument a simple if statement works inside the sample instr. Note in this example it doesn't matter if schedkwhen duration is .1 or 10 seconds it still plays the full sample once like the traditional "one shot" setting in a sampler.

Also note the trigger instr is only set for 1 second, just too illustrate that no matter what the full sample will play. 

<CsoundSynthesizer>
<CsOptions>
-odac
;-o/sdcard/*******.wav
</CsOptions>
;================================
<CsInstruments>

sr = 48000
ksmps = 10
nchnls = 1
0dbfs  = 1

instr trigger
ktrig metro 1
schedkwhen ktrig, 0, 0, 1, 0, .1
endin

instr 1
ilen = filelen("fox.wav")
    if (p3 < ilen) then
        p3 = ilen
    endif
asig diskin "fox.wav"
out asig
endin

</CsInstruments>
;================================
<CsScore>

i"trigger" 0 1

</CsScore>
</CsoundSynthesizer>

Take care, 
Scott 

On Wed, Mar 8, 2023, 9:42 AM Dave Seidel, <dave.seidel@gmail.com> wrote:
Hi all.

I have a piece I'm working on where I have a main instrument that runs for a while fires off a sequential series of either a sample-based instrument or an oscillator-based instrument. The sample files are of varied lengths. I don't know until I load a file (or query it using filelen) how long it is, so I want the sample-playing instrument to be able to ensure that its duration is sufficient to play the entire sample before ending,

I can use xtratim for this, but I have a vague memory that people sometimes set the value of p4 within an instrument to change its duration. Does this work, and Is it a safe thing to do?

Thanks,
Dave

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
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

Date2023-03-08 20:25
FromMichael Gogins
SubjectRe: [Csnd] xtratim vs. setting p4
P3 not p4. You can also turn instruments on indefinitely and turn them off with a releasing envelope when you are done. 

On Wed, Mar 8, 2023, 09:42 Dave Seidel <dave.seidel@gmail.com> wrote:
Hi all.

I have a piece I'm working on where I have a main instrument that runs for a while fires off a sequential series of either a sample-based instrument or an oscillator-based instrument. The sample files are of varied lengths. I don't know until I load a file (or query it using filelen) how long it is, so I want the sample-playing instrument to be able to ensure that its duration is sufficient to play the entire sample before ending,

I can use xtratim for this, but I have a vague memory that people sometimes set the value of p4 within an instrument to change its duration. Does this work, and Is it a safe thing to do?

Thanks,
Dave

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

Date2023-03-08 20:41
FromDave Seidel
SubjectRe: [Csnd] xtratim vs. setting p4
Thanks, I corrected that error in a reply above. I do use the technique of launching instruments with duration of -1 and then stopping them later with a release envelope, but it requires a little more overhead (creating fractional instruments and keeping track of them) and it's overkill for this particular application. I've tried both xtratrim and setting p3, and both solutions are working fine for me. I settled for xtratrim because I think it makes the intent of the code a bit clearer.

On Wed, Mar 8, 2023 at 3:27 PM Michael Gogins <michael.gogins@gmail.com> wrote:
P3 not p4. You can also turn instruments on indefinitely and turn them off with a releasing envelope when you are done. 

On Wed, Mar 8, 2023, 09:42 Dave Seidel <dave.seidel@gmail.com> wrote:
Hi all.

I have a piece I'm working on where I have a main instrument that runs for a while fires off a sequential series of either a sample-based instrument or an oscillator-based instrument. The sample files are of varied lengths. I don't know until I load a file (or query it using filelen) how long it is, so I want the sample-playing instrument to be able to ensure that its duration is sufficient to play the entire sample before ending,

I can use xtratim for this, but I have a vague memory that people sometimes set the value of p4 within an instrument to change its duration. Does this work, and Is it a safe thing to do?

Thanks,
Dave

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

Date2023-03-09 00:19
FromMichael Gogins
SubjectRe: [Csnd] xtratim vs. setting p4
OK, that's good to know. I think this stuff could be much better documented. 

On Wed, Mar 8, 2023, 15:43 Dave Seidel <dave.seidel@gmail.com> wrote:
Thanks, I corrected that error in a reply above. I do use the technique of launching instruments with duration of -1 and then stopping them later with a release envelope, but it requires a little more overhead (creating fractional instruments and keeping track of them) and it's overkill for this particular application. I've tried both xtratrim and setting p3, and both solutions are working fine for me. I settled for xtratrim because I think it makes the intent of the code a bit clearer.

On Wed, Mar 8, 2023 at 3:27 PM Michael Gogins <michael.gogins@gmail.com> wrote:
P3 not p4. You can also turn instruments on indefinitely and turn them off with a releasing envelope when you are done. 

On Wed, Mar 8, 2023, 09:42 Dave Seidel <dave.seidel@gmail.com> wrote:
Hi all.

I have a piece I'm working on where I have a main instrument that runs for a while fires off a sequential series of either a sample-based instrument or an oscillator-based instrument. The sample files are of varied lengths. I don't know until I load a file (or query it using filelen) how long it is, so I want the sample-playing instrument to be able to ensure that its duration is sufficient to play the entire sample before ending,

I can use xtratim for this, but I have a vague memory that people sometimes set the value of p4 within an instrument to change its duration. Does this work, and Is it a safe thing to do?

Thanks,
Dave

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

Date2023-03-09 01:30
FromDave Seidel
SubjectRe: [Csnd] xtratim vs. setting p4
Agreed. 

On Wed, Mar 8, 2023, 7:20 PM Michael Gogins <michael.gogins@gmail.com> wrote:
OK, that's good to know. I think this stuff could be much better documented. 

On Wed, Mar 8, 2023, 15:43 Dave Seidel <dave.seidel@gmail.com> wrote:
Thanks, I corrected that error in a reply above. I do use the technique of launching instruments with duration of -1 and then stopping them later with a release envelope, but it requires a little more overhead (creating fractional instruments and keeping track of them) and it's overkill for this particular application. I've tried both xtratrim and setting p3, and both solutions are working fine for me. I settled for xtratrim because I think it makes the intent of the code a bit clearer.

On Wed, Mar 8, 2023 at 3:27 PM Michael Gogins <michael.gogins@gmail.com> wrote:
P3 not p4. You can also turn instruments on indefinitely and turn them off with a releasing envelope when you are done. 

On Wed, Mar 8, 2023, 09:42 Dave Seidel <dave.seidel@gmail.com> wrote:
Hi all.

I have a piece I'm working on where I have a main instrument that runs for a while fires off a sequential series of either a sample-based instrument or an oscillator-based instrument. The sample files are of varied lengths. I don't know until I load a file (or query it using filelen) how long it is, so I want the sample-playing instrument to be able to ensure that its duration is sufficient to play the entire sample before ending,

I can use xtratim for this, but I have a vague memory that people sometimes set the value of p4 within an instrument to change its duration. Does this work, and Is it a safe thing to do?

Thanks,
Dave

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
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

Date2023-03-09 05:37
Fromjoachim heintz
SubjectRe: [Csnd] xtratim vs. setting p4
we all should do this step by step when we come across lacks or faults.
once you logged in to gihub, you can directly type your suggestion in 
the browser, and then send as pull request.  in this case probably this 
page:
https://github.com/csound/manual/blob/master/opcodes/xtratim.xml

best -
	joachim


On 09/03/2023 02:30, Dave Seidel wrote:
> Agreed.
> 
> On Wed, Mar 8, 2023, 7:20 PM Michael Gogins  > wrote:
> 
>     OK, that's good to know. I think this stuff could be much better
>     documented.
> 
>     On Wed, Mar 8, 2023, 15:43 Dave Seidel      > wrote:
> 
>         Thanks, I corrected that error in a reply above. I do use the
>         technique of launching instruments with duration of -1 and then
>         stopping them later with a release envelope, but it requires a
>         little more overhead (creating fractional instruments and
>         keeping track of them) and it's overkill for this particular
>         application. I've tried both xtratrim and setting p3, and both
>         solutions are working fine for me. I settled for xtratrim
>         because I think it makes the intent of the code a bit clearer.
> 
>         On Wed, Mar 8, 2023 at 3:27 PM Michael Gogins
>         > wrote:
> 
>             P3 not p4. You can also turn instruments on indefinitely and
>             turn them off with a releasing envelope when you are done.
> 
>             On Wed, Mar 8, 2023, 09:42 Dave Seidel
>             > wrote:
> 
>                 Hi all.
> 
>                 I have a piece I'm working on where I have a main
>                 instrument that runs for a while fires off a sequential
>                 series of either a sample-based instrument or an
>                 oscillator-based instrument. The sample files are of
>                 varied lengths. I don't know until I load a file (or
>                 query it using filelen) how long it is, so I want the
>                 sample-playing instrument to be able to ensure that its
>                 duration is sufficient to play the entire sample before
>                 ending,
> 
>                 I can use xtratim for this, but I have a vague memory
>                 that people sometimes set the value of p4 within an
>                 instrument to change its duration. Does this work, and
>                 Is it a safe thing to do?
> 
>                 Thanks,
>                 Dave
> 
>                 ---
>                 http://mysterybear.net 
>                 https://mysterybear.bandcamp.com
>                 
>                 _https://www.youtube.com/c/DaveSeidel
>                 _
>                 https://www.instagram.com/daveseidel/
>                 
>                 https://www.facebook.com/mysterybear
>                 
>                 https://soundcloud.com/mysterybear
>                 
>                 https://github.com/DaveSeidel
>                 
>                 https://mstdn.social/@DaveSeidel
>                 
>                 (@DaveSeidel@mstdn.social)
> 
>                 Involution on XI Records:
>                 https://mysterybear.bandcamp.com/album/involution
> 
>                 
>                 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 
> 
> 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

Date2023-03-09 13:19
FromMichael Gogins
SubjectRe: [Csnd] xtratim vs. setting p4
This is what I found after a lot of experience and experiments. There may be mistakes or more to learn. Please comment.


Handling standard score events, "note on" and "note off" events, and MIDI events in the same instrument definition is tricky.

  1. For Csound instruments following my Silence pattern, MIDI inter-op command line options must be used: --midi-key=4 --midi-velocity=5.
  2. For notes with indefinite durations, p1 must have a tag (ID), e.g. 1.036 for instrument 1. For "note on" messages, p3 must be negative, and normally is -1. For "note off" messages, p1 must be exactly the same as the p1 of the matching "note on" event, and p3 must be 0.
  3. In the instrument definition, instruments with indefinite duration (whether from MIDI or from "note on" events), must not use p3 as a duration, e.g. for the sustain segment of an envelope, but rather create an i_sustain or i_decayvalue that is as long as makes sense for that instrument. That would be as long as possible for a sustained instrument, or the maximum reasonable decay for an emulation of a struck or plucked resonator.
  4. The instrument should usually have a releasing envelope to get rid of clicks. The attack and release segments of this envelope should be continuous, as it is very easy to get clicks with short linear envelopes. This can be done using cossegr. The attack and release segments should be as long as necessary to mask unwanted artifacts, and this should be determined by experiment.
  5. The "physical envelope" and the "declicking envelope" should be multiplied to produce a final envelope, and this should be low-pass filtered to blur as many discontinuities as possible. Filter cutoff and rolloff also should be determined by experiment.
  6. The xtratim opcode should be used to carry the duration of the note well past the end of the release segment.
  7. Some sounds have inherent discontinuities that can and will cause clicks. In particular aliasing can cause clicks.
  8. For instruments requiring arbitrary delays or complex envelopes, setksmps 1 should be used.


-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Thu, Mar 9, 2023 at 12:38 AM joachim heintz <jh@joachimheintz.de> wrote:
we all should do this step by step when we come across lacks or faults.
once you logged in to gihub, you can directly type your suggestion in
the browser, and then send as pull request.  in this case probably this
page:
https://github.com/csound/manual/blob/master/opcodes/xtratim.xml

best -
        joachim


On 09/03/2023 02:30, Dave Seidel wrote:
> Agreed.
>
> On Wed, Mar 8, 2023, 7:20 PM Michael Gogins <michael.gogins@gmail.com
> <mailto:michael.gogins@gmail.com>> wrote:
>
>     OK, that's good to know. I think this stuff could be much better
>     documented.
>
>     On Wed, Mar 8, 2023, 15:43 Dave Seidel <dave.seidel@gmail.com
>     <mailto:dave.seidel@gmail.com>> wrote:
>
>         Thanks, I corrected that error in a reply above. I do use the
>         technique of launching instruments with duration of -1 and then
>         stopping them later with a release envelope, but it requires a
>         little more overhead (creating fractional instruments and
>         keeping track of them) and it's overkill for this particular
>         application. I've tried both xtratrim and setting p3, and both
>         solutions are working fine for me. I settled for xtratrim
>         because I think it makes the intent of the code a bit clearer.
>
>         On Wed, Mar 8, 2023 at 3:27 PM Michael Gogins
>         <michael.gogins@gmail.com <mailto:michael.gogins@gmail.com>> wrote:
>
>             P3 not p4. You can also turn instruments on indefinitely and
>             turn them off with a releasing envelope when you are done.
>
>             On Wed, Mar 8, 2023, 09:42 Dave Seidel
>             <dave.seidel@gmail.com <mailto:dave.seidel@gmail.com>> wrote:
>
>                 Hi all.
>
>                 I have a piece I'm working on where I have a main
>                 instrument that runs for a while fires off a sequential
>                 series of either a sample-based instrument or an
>                 oscillator-based instrument. The sample files are of
>                 varied lengths. I don't know until I load a file (or
>                 query it using filelen) how long it is, so I want the
>                 sample-playing instrument to be able to ensure that its
>                 duration is sufficient to play the entire sample before
>                 ending,
>
>                 I can use xtratim for this, but I have a vague memory
>                 that people sometimes set the value of p4 within an
>                 instrument to change its duration. Does this work, and
>                 Is it a safe thing to do?
>
>                 Thanks,
>                 Dave
>
>                 ---
>                 http://mysterybear.net <http://mysterybear.net>
>                 https://mysterybear.bandcamp.com
>                 <https://mysterybear.bandcamp.com>
>                 _https://www.youtube.com/c/DaveSeidel
>                 <https://www.youtube.com/c/DaveSeidel>_
>                 https://www.instagram.com/daveseidel/
>                 <https://www.instagram.com/daveseidel/>
>                 https://www.facebook.com/mysterybear
>                 <https://github.com/DaveSeidel>
>                 https://soundcloud.com/mysterybear
>                 <https://soundcloud.com/mysterybear>
>                 https://github.com/DaveSeidel
>                 <https://github.com/DaveSeidel>
>                 https://mstdn.social/@DaveSeidel
>                 <https://mstdn.social/@DaveSeidel>
>                 (@DaveSeidel@mstdn.social)
>
>                 Involution on XI Records:
>                 https://mysterybear.bandcamp.com/album/involution
>
>                 <http://recordings.irritablehedgehog.com/album/dave-seidel-60-hz>
>                 Csound mailing list Csound@listserv.heanet.ie
>                 <mailto:Csound@listserv.heanet.ie>
>                 https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>                 <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send
>                 bugs reports to https://github.com/csound/csound/issues
>                 <https://github.com/csound/csound/issues> Discussions of
>                 bugs and features can be posted here
>
>             Csound mailing list Csound@listserv.heanet.ie
>             <mailto:Csound@listserv.heanet.ie>
>             https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>             <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs
>             reports to https://github.com/csound/csound/issues
>             <https://github.com/csound/csound/issues> Discussions of
>             bugs and features can be posted here
>
>         Csound mailing list Csound@listserv.heanet.ie
>         <mailto:Csound@listserv.heanet.ie>
>         https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>         <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs
>         reports to https://github.com/csound/csound/issues
>         <https://github.com/csound/csound/issues> Discussions of bugs
>         and features can be posted here
>
>     Csound mailing list Csound@listserv.heanet.ie
>     <mailto:Csound@listserv.heanet.ie>
>     https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
>     <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs reports
>     to https://github.com/csound/csound/issues
>     <https://github.com/csound/csound/issues> Discussions of bugs and
>     features can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie
> <mailto:Csound@listserv.heanet.ie>
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> <https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND> Send bugs reports to
> https://github.com/csound/csound/issues
> <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