Csound Csound-dev Csound-tekno Search About

[Csnd] Parameter for diskin filename?

Date2008-07-11 15:32
FromJonas Nyström
Subject[Csnd] Parameter for diskin filename?
AttachmentsNone  None  

Date2008-07-11 23:23
FromJacob Joaquin
Subject[Csnd] Re: Parameter for diskin filename?
Yes. You can pass a string to an instrument in a p-field, and catch it in the
instrument with strget. Here's a modified version of your instrument,
followed by an i-event:


instr 1
   ivol = p4
   ipan = p5 * 1.570796327

   Sfile strget p6  ; Get file name
   aleft, aright diskin Sfile, 1

   aleft = aleft * ivol * cos(ipan)
   aright = aright * ivol * sin(ipan)
   outs aleft, aright
endin
--------
i 1 0 4 2 0.5 "./foo.aif"


However... Notice that I changed the instrument name from "TestInstrument"
to 1. This is because as of right now, you can only pass one string per
i-event in the score, and a named instrument counts as one. So there is
definitely a trade off. If you are still interested in using names along
with strings, consider using macros:

A Micro Intro to Macros
http://www.thumbuki.com/csound/files/thumbuki20070420.csd

Best,
Jake




Cambiata wrote:
> 
> Hi!
> 
> Can I use a parameter for spceifying the diskin filename in an instrument?
> 
> 
> ; ---------------------------------------------------
> sr = 44100
> kr = 44100
> ksmps = 1
> nchnls = 2
> ; ---------------------------------------------------
> instr TestInstrument
>    ivol = p4
>    ipan = p5 * 1.570796327
>    ; ---------------------------------------------------
>    ; can I replace the "foo" filename below with a parameter concatenated
> with ".wav"?
>    ;
>    aleft, aright diskin "foo.wav", 1
>    ; ---------------------------------------------------
>    aleft = aleft * ivol * cos(ipan)
>    aright = aright * ivol * sin(ipan)
>    outs aleft, aright
> endin
> ; ---------------------------------------------------
> 
> 
> Jonas
> 
> 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/Parameter-for-diskin-filename--tp18405271p18413618.html
Sent from the Csound - General mailing list archive at Nabble.com.


Date2008-07-12 02:22
FromDarren Nelsen
Subject[Csnd] Re: Re: Parameter for diskin filename?
This is what I come to this list for. Great tip!

Darren

On Jul 11, 2008, at 6:23 PM, Jacob Joaquin wrote:

>
> Yes. You can pass a string to an instrument in a p-field, and catch  
> it in the
> instrument with strget. Here's a modified version of your instrument,
> followed by an i-event:
>
>
> instr 1
>   ivol = p4
>   ipan = p5 * 1.570796327
>
>   Sfile strget p6  ; Get file name
>   aleft, aright diskin Sfile, 1
>
>   aleft = aleft * ivol * cos(ipan)
>   aright = aright * ivol * sin(ipan)
>   outs aleft, aright
> endin
> --------
> i 1 0 4 2 0.5 "./foo.aif"
>
>
> However... Notice that I changed the instrument name from  
> "TestInstrument"
> to 1. This is because as of right now, you can only pass one string  
> per
> i-event in the score, and a named instrument counts as one. So there  
> is
> definitely a trade off. If you are still interested in using names  
> along
> with strings, consider using macros:
>
> A Micro Intro to Macros
> http://www.thumbuki.com/csound/files/thumbuki20070420.csd
>
> Best,
> Jake
>
>
>
>
> Cambiata wrote:
>>
>> Hi!
>>
>> Can I use a parameter for spceifying the diskin filename in an  
>> instrument?
>>
>>
>> ; ---------------------------------------------------
>> sr = 44100
>> kr = 44100
>> ksmps = 1
>> nchnls = 2
>> ; ---------------------------------------------------
>> instr TestInstrument
>>   ivol = p4
>>   ipan = p5 * 1.570796327
>>   ; ---------------------------------------------------
>>   ; can I replace the "foo" filename below with a parameter  
>> concatenated
>> with ".wav"?
>>   ;
>>   aleft, aright diskin "foo.wav", 1
>>   ; ---------------------------------------------------
>>   aleft = aleft * ivol * cos(ipan)
>>   aright = aright * ivol * sin(ipan)
>>   outs aleft, aright
>> endin
>> ; ---------------------------------------------------
>>
>>
>> Jonas
>>
>>

Date2008-07-12 02:24
From"David Akbari"
Subject[Csnd] Re: Re: Parameter for diskin filename?
AttachmentsNone  

Date2008-07-12 22:16
FromJonas Nyström
Subject[Csnd] Re: Re: Re: Parameter for diskin filename?
AttachmentsNone  None