Csound Csound-dev Csound-tekno Search About

[Csnd] tempoval at i-time?

Date2008-02-11 22:28
Fromjoachim heintz
Subject[Csnd] tempoval at i-time?
Hello all -

I would like to change some values (time segments and xtratim)  
depending on the tempo.
Is it possible to get the score t-statement at init-time?
(The tempoval opcode works just at k-rate and gives 0 at i-time.)

Thanks -

	joachim

Date2008-02-11 23:22
FromJacob Joaquin
Subject[Csnd] Re: tempoval at i-time?
>From my personal experience, the tempo opcodes don't work.  To get around
some of the tempo related issues, I use a serious hack.

Instead of passing the duration in beats to p3, I pass a value of "1".  This
value gets translated into seconds per beat.  From this, it's possible to
deduce the current tempo.  For example, if the tempo is 120, p3 will equal
0.5.  I then specify the duration of the instance, in beats, in another
p-field.  I then utilize xtratim and turnoff to alter the duration of the
instance.

I quickly put together the following example (so hopefully it isn't buggy.) 
The frequency trills 4 times per beat, and is played at tempos 60 and 90.


/* ------------------------- */


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

instr 1
	ispb = p3         ; Seconds per beat.  Enter "1" in score.
	idur = p4 * ispb  ; Duration in beats.

	; If idur is greater than ispb, add time
	xtratim ( idur > ispb ? idur - ispb : 0 )

	; If idur is less than ispb, turn off earlier
	ktimer linseg 0, idur, 1 

	if( 	ktimer < 1 || ( idur > ispb ) ) kgoto continue
		turnoff
	continue:

	kosc oscil 0.5, 4 / ispb, 2  ; Four times per beat
	kosc =     kosc + 0.5
	aosc oscil 0dbfs, 440 + 440 * kosc, 1
	out aosc
endin



f 1 0 [2^16+1] 10 1
f 2 0 [2^8+1] -7 1 [2^7] 1 0 -1 [2^7] -1

t 0 60
i 1 0 1 2
s
t 0 90
i 1 0 1 2


/* ------------------------- */



Not sure if this will help you or not.

Best, 
Jake 
---- 
The Csound Blog 
http://www.thumbuki.com/csound/blog/




joachim heintz wrote:
> 
> Hello all -
> 
> I would like to change some values (time segments and xtratim)  
> depending on the tempo.
> Is it possible to get the score t-statement at init-time?
> (The tempoval opcode works just at k-rate and gives 0 at i-time.)
> 
> Thanks -
> 
> 	joachim
> 
> 
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
> 
> 

-- 
View this message in context: http://www.nabble.com/tempoval-at-i-time--tp15422272p15423161.html
Sent from the Csound - General mailing list archive at Nabble.com.


Date2008-02-12 09:53
Fromjoachim heintz
Subject[Csnd] Re: Re: tempoval at i-time?
Thanks, Jake. It's a bit too complicated for my case, but an  
interesting solution anyway.
	joachim



Am 12.02.2008 um 00:22 schrieb Jacob Joaquin:

>
> From my personal experience, the tempo opcodes don't work.  To get  
> around
> some of the tempo related issues, I use a serious hack.
>
> Instead of passing the duration in beats to p3, I pass a value of  
> "1".  This
> value gets translated into seconds per beat.  From this, it's  
> possible to
> deduce the current tempo.  For example, if the tempo is 120, p3  
> will equal
> 0.5.  I then specify the duration of the instance, in beats, in  
> another
> p-field.  I then utilize xtratim and turnoff to alter the duration  
> of the
> instance.
>
> I quickly put together the following example (so hopefully it isn't  
> buggy.)
> The frequency trills 4 times per beat, and is played at tempos 60  
> and 90.
>
>
> /* ------------------------- */
> 
> 
> sr     = 44100
> kr     = 4410
> ksmps  = 10
> nchnls = 1
>
> instr 1
> 	ispb = p3         ; Seconds per beat.  Enter "1" in score.
> 	idur = p4 * ispb  ; Duration in beats.
>
> 	; If idur is greater than ispb, add time
> 	xtratim ( idur > ispb ? idur - ispb : 0 )
>
> 	; If idur is less than ispb, turn off earlier
> 	ktimer linseg 0, idur, 1
>
> 	if( 	ktimer < 1 || ( idur > ispb ) ) kgoto continue
> 		turnoff
> 	continue:
>
> 	kosc oscil 0.5, 4 / ispb, 2  ; Four times per beat
> 	kosc =     kosc + 0.5
> 	aosc oscil 0dbfs, 440 + 440 * kosc, 1
> 	out aosc
> endin
>
> 
> 
> f 1 0 [2^16+1] 10 1
> f 2 0 [2^8+1] -7 1 [2^7] 1 0 -1 [2^7] -1
>
> t 0 60
> i 1 0 1 2
> s
> t 0 90
> i 1 0 1 2
> 
> 
> /* ------------------------- */
>
>
>
> Not sure if this will help you or not.
>
> Best,
> Jake
> ----
> The Csound Blog
> http://www.thumbuki.com/csound/blog/
>
>
>
>
> joachim heintz wrote:
>>
>> Hello all -
>>
>> I would like to change some values (time segments and xtratim)
>> depending on the tempo.
>> Is it possible to get the score t-statement at init-time?
>> (The tempoval opcode works just at k-rate and gives 0 at i-time.)
>>
>> Thanks -
>>
>> 	joachim
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>> "unsubscribe
>> csound"
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/tempoval-at-i- 
> time--tp15422272p15423161.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"


Date2008-02-12 14:29
From"Dr. Richard Boulanger"
Subject[Csnd] Re: Re: tempoval at i-time?
I helped me and my students for sure!  Thanks jake.  Cool solution.

-dB

On Feb 11, 2008, at 6:22 PM, Jacob Joaquin wrote:

/* ------------------------- */
<CsoundSynthesizer>
<CsInstruments>
sr     = 44100
kr     = 4410
ksmps  = 10
nchnls = 1

instr 1
ispb = p3         ; Seconds per beat.  Enter "1" in score.
idur = p4 * ispb  ; Duration in beats.

; If idur is greater than ispb, add time
xtratim ( idur > ispb ? idur - ispb : 0 )

; If idur is less than ispb, turn off earlier
ktimer linseg 0, idur, 1 

if( ktimer < 1 || ( idur > ispb ) ) kgoto continue
turnoff
continue:

kosc oscil 0.5, 4 / ispb, 2  ; Four times per beat
kosc =     kosc + 0.5
aosc oscil 0dbfs, 440 + 440 * kosc, 1
out aosc
endin

</CsInstruments>
<CsScore>
f 1 0 [2^16+1] 10 1
f 2 0 [2^8+1] -7 1 [2^7] 1 0 -1 [2^7] -1

t 0 60
i 1 0 1 2
s
t 0 90
i 1 0 1 2
</CsScore>
</CsoundSynthesizer>
/* ------------------------- */