Csound Csound-dev Csound-tekno Search About

[Csnd] turnoff signals with loscil

Date2009-10-23 02:27
FromEmerson Aagaard
Subject[Csnd] turnoff signals with loscil
Hello list,

I'm trying to make a very simple loscil instrument that will loop for a period of a specified duration, but before the end of this duration will "release", or basically stop looping and continue through the sample to the end. I read about this in the manual, and it says that this is possible to achieve this by sending the instrument a turnoff signal from the score. So far, however, I haven't found any way to send a turnoff signal from the score, and it looks like I would need to use if statements? I feel like this is more complicated than it needs to be (not a criticism of Csound if that's the way it is, but I'm saying like I feel I'm missing something obvious here).

Thanks in advance for any help, and thanks to everyone again for the response to my query about linux,
Emerson

Date2009-10-23 08:09
FromAndres Cabrera
Subject[Csnd] Re: turnoff signals with loscil
Hi,

You can turn off an instrument with a negative number in an i
statement in the score. Note that this will only turn off instruments
with indefinite duration (always on). To create a note with indefinite
duration use a negative number in the duration. Notice that you'll
have to use abs() to get line to work in instr 1:






sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1

instr 1
kfreq line 300, abs(p3), 1000
aout oscil 0.2, kfreq, 1
outs aout, aout
endin



f 1 0 1024 10 1
i 1 0 -30

i -1 ^+1 1

i 1.1 ^+1 -20
i 1.2 ^+1 -20

i -1.2 ^+1 1
i -1.1 ^+1 1
e



For more details see:
http://www.csounds.com/manual/html/i.html

Cheers,
Andrés



On Fri, Oct 23, 2009 at 2:27 AM, Emerson Aagaard
 wrote:
> Hello list,
>
> I'm trying to make a very simple loscil instrument that will loop for a
> period of a specified duration, but before the end of this duration will
> "release", or basically stop looping and continue through the sample to the
> end. I read about this in the manual, and it says that this is possible to
> achieve this by sending the instrument a turnoff signal from the score. So
> far, however, I haven't found any way to send a turnoff signal from the
> score, and it looks like I would need to use if statements? I feel like this
> is more complicated than it needs to be (not a criticism of Csound if that's
> the way it is, but I'm saying like I feel I'm missing something obvious
> here).
>
> Thanks in advance for any help, and thanks to everyone again for the
> response to my query about linux,
> Emerson



-- 


Andrés


Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2009-10-24 06:26
FromEmerson Aagaard
Subject[Csnd] Re: Re: turnoff signals with loscil
Thanks for the assistance, Andres, but it's still not working how I want it to.

Using your example, as well as the one in the manual, the note does turn off, but it is sudden, and it doesn't release. I'm not sure if I need to use an envelope or what, but I don't want to make any changes in amplitude; the sample decays naturally (and just for reference, I'm using Dr. B's "sing.aif" that's in the csound tootorials).

Hope this is clear?
Just in case, here's my csd.

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

instr 112

a1 loscil p4, p5, p6, 440, 1, 36962, 57090
out a1
endin

</CsInstruments>
<CsScore>
f4 0 0 1 "samples\sing.aif" 0 4 0

i112 0 -6 10000 440 4
i-112 4 3 10000 440 4
e
</CsScore>
</CsoundSynthesizer>

Emerson

Date2009-10-24 08:29
FromAndres Cabrera
Subject[Csnd] Re: Re: Re: turnoff signals with loscil
Hi,

Yes, you need an envelope. It will start the release phase when the
note is turned off. You need special envelopes which have an
additional release segment like linenr, linsegr or madsr.

Cheers,
Andrés

On Sat, Oct 24, 2009 at 6:26 AM, Emerson Aagaard
 wrote:
> Thanks for the assistance, Andres, but it's still not working how I want it
> to.
>
> Using your example, as well as the one in the manual, the note does turn
> off, but it is sudden, and it doesn't release. I'm not sure if I need to use
> an envelope or what, but I don't want to make any changes in amplitude; the
> sample decays naturally (and just for reference, I'm using Dr. B's
> "sing.aif" that's in the csound tootorials).
>
> Hope this is clear?
> Just in case, here's my csd.
>
> 
> 
> 
> 
> sr = 44100
> kr = 4410
> ksmps = 10
> nchnls = 1
> instr 112
> a1 loscil p4, p5, p6, 440, 1, 36962, 57090
> out a1
> endin
> 
> 
> f4 0 0 1 "samples\sing.aif" 0 4 0
> i112 0 -6 10000 440 4
> i-112 4 3 10000 440 4
> e
> 
> 
>
> Emerson



-- 


Andrés


Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2009-10-24 16:32
FromJacob Joaquin
Subject[Csnd] Re: Re: Re: turnoff signals with loscil
I think I have a possible solution.  I want to make sure that I
understand the problem correctly first.

You want to loop a sound. You will specify how long the sound will
play. At the end of this duration, if the loop has not completed, you
want the loop to finish playing before the instrument stops.

For example, let's say you have a four second loop.  You tell it to
play for six seconds, which is two seconds shy of finishing the loop
on the second pass.  So the instrument needs to be smart enough to add
an extra two seconds to the loop so it can finish out.

If that is correct, the opcode xtratim can be used to extend the
duration of the instrument.  If not, please clarify the problem.  Hope
this helps.

Best,
Jake




On Fri, Oct 23, 2009 at 10:26 PM, Emerson Aagaard
 wrote:
> Thanks for the assistance, Andres, but it's still not working how I want it
> to.
>
> Using your example, as well as the one in the manual, the note does turn
> off, but it is sudden, and it doesn't release. I'm not sure if I need to use
> an envelope or what, but I don't want to make any changes in amplitude; the
> sample decays naturally (and just for reference, I'm using Dr. B's
> "sing.aif" that's in the csound tootorials).
>
> Hope this is clear?
> Just in case, here's my csd.
>
> 
> 
> 
> 
> sr = 44100
> kr = 4410
> ksmps = 10
> nchnls = 1
> instr 112
> a1 loscil p4, p5, p6, 440, 1, 36962, 57090
> out a1
> endin
> 
> 
> f4 0 0 1 "samples\sing.aif" 0 4 0
> i112 0 -6 10000 440 4
> i-112 4 3 10000 440 4
> e
> 
> 
>
> Emerson


Date2009-10-24 22:17
FromEmerson Aagaard
Subject[Csnd] Re: Re: Re: Re: turnoff signals with loscil
Thanks Andres, I'll give it a shot.

Jacob, that's sort of what I'm after, except what I want to happen is instead of just the loop finishing, I want the entire sound to finish (the loop is in the middle of the sound file).

So I would want to happen, if I use the same sort of example, is that I have a 4 second sound-file, and I'm looping 2 seconds let's say, and I play it for 6, and want to start a release on the 4th second. It would finish it's current "pass" of the loop and then continue on to the end of the sound file.

Hope this makes sense, and again, thanks for the help, guys.
Emerson

Date2009-10-28 16:05
FromJacob Joaquin
Subject[Csnd] Re: Re: Re: Re: Re: turnoff signals with loscil
I think this does what you want.  Sorry it took so long to get back.





sr     = 44100
kr     = 44100
ksmps  = 1
nchnls = 1
0dbfs  = 1.0

instr 1
    idur = p3         ; Duration
    iamp = p4         ; Amplitude
    ibegin_loop = p5  ; In sample frames
    iend_loop = p6    ; In sample frames
    ifn = p7          ; F-table with stored sample

    iattack = ibegin_loop / sr
    iloop_width = (iend_loop - ibegin_loop) / sr
    isustain = idur * sr - ibegin_loop
    isustain = isustain - (isustain % (iend_loop - ibegin_loop))
    isustain = isustain / sr
    idecay = (ftlen(ifn) - iend_loop) / sr

    event_i "i", 2, 0, iattack, iamp, 0, ifn
    event_i "i", 3, iattack, isustain, iamp, ibegin_loop, iend_loop, ifn
    event_i "i", 2, iattack + isustain, idecay, iamp, iend_loop, ifn

    turnoff
endin

instr 2
    idur = p3     ; Duration
    iamp = p4     ; Amplitude
    ioffset = p5  ; In sample frames
    ifn = p6      ; F-table with stored sample

    aphasor phasor 1 / idur
    a1 table3 aphasor * idur * sr, 4, 0, ioffset
    out a1 * iamp
endin

instr 3
    idur = p3         ; Duration
    iamp = p4         ; Amplitude
    ibegin_loop = p5  ; In sample frames
    iend_loop = p6    ; In sample frames
    ifn = p7          ; F-table with stored sample

    aphasor phasor sr / (iend_loop - ibegin_loop)
    a1 table3 aphasor * (iend_loop - ibegin_loop), 4, 0, ibegin_loop
    out a1 * iamp
endin



f 4 0 [2 ^ 17] 1 "sing.aif" 0 4 0

i 1 0 2 0.4 40191 40385 4
i 1 3 2 0.4 67611 67806 4
i 1 6 3 0.4 68956 69150 4

e 10




Best,
Jake