Csound Csound-dev Csound-tekno Search About

[Csnd] setting sr to a variable

Date2023-09-03 16:37
Fromlj
Subject[Csnd] setting sr to a variable
Hi, all.

I wanted to see if I could set the orchestra sr to the sample rate of a 
sound file that is going to be read by diskin2 in the orchestra.

I included these lines in the header, hoping they would work:

giSr   =    filesr("MyFile.wav"))
sr      =  giSr

giSr is properly evaluated, but sr is set to 0 and Csound crashes. 
Obviously, this is not so easy as I wished it would be. Is there a 
reason for this not to work?

In case it's relevant, I'm using Csound 6.18 as distributed by Arch Linux.



--

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-09-03 17:16
FromSteven Yi
SubjectRe: [Csnd] setting sr to a variable
Yes, this shouldn't work, sr is used to set up things prior to runtime and can not be changed without restarting csound. I think the best you could do is to read the sample rate of the file prior to starting csound, then using --sample-rate=[the sample rate] as a commandline flag option. 


On Sun, Sep 3, 2023 at 11:37 AM lj <ljc@internet.com.uy> wrote:
Hi, all.

I wanted to see if I could set the orchestra sr to the sample rate of a
sound file that is going to be read by diskin2 in the orchestra.

I included these lines in the header, hoping they would work:

giSr   =    filesr("MyFile.wav"))
sr      =  giSr

giSr is properly evaluated, but sr is set to 0 and Csound crashes.
Obviously, this is not so easy as I wished it would be. Is there a
reason for this not to work?

In case it's relevant, I'm using Csound 6.18 as distributed by Arch Linux.



--

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-09-03 17:38
FromDave Seidel
SubjectRe: [Csnd] setting sr to a variable
If within an instrument or a UDO, you could use setksmps, perhaps? Assuming the argument to setksmps could be an i-rate variable as opposed to a literal value?

On Sun, Sep 3, 2023 at 12:17 PM Steven Yi <stevenyi@gmail.com> wrote:
Yes, this shouldn't work, sr is used to set up things prior to runtime and can not be changed without restarting csound. I think the best you could do is to read the sample rate of the file prior to starting csound, then using --sample-rate=[the sample rate] as a commandline flag option. 


On Sun, Sep 3, 2023 at 11:37 AM lj <ljc@internet.com.uy> wrote:
Hi, all.

I wanted to see if I could set the orchestra sr to the sample rate of a
sound file that is going to be read by diskin2 in the orchestra.

I included these lines in the header, hoping they would work:

giSr   =    filesr("MyFile.wav"))
sr      =  giSr

giSr is properly evaluated, but sr is set to 0 and Csound crashes.
Obviously, this is not so easy as I wished it would be. Is there a
reason for this not to work?

In case it's relevant, I'm using Csound 6.18 as distributed by Arch Linux.



--

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-09-03 17:45
Fromlj
SubjectRe: [Csnd] setting sr to a variable
On 2023-09-03 13:16, Steven Yi wrote:
> Yes, this shouldn't work, sr is used to set up things prior to runtime 
> and can not be changed without restarting csound. I think the best you 
> could do is to read the sample rate of the file prior to starting 
> csound, then using --sample-rate=[the sample rate] as a commandline 
> flag option.

Yes, I'd guessed as much, thanks for the response.



--

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-09-03 17:58
Fromjoachim heintz
SubjectRe: [Csnd] setting sr to a variable
but setksmps sets the block size, not the sample rate.
i think the only solution is what steven mentioned.


On 03/09/2023 13:38, Dave Seidel wrote:
> If within an instrument or a UDO, you could use setksmps, perhaps? 
> Assuming the argument to setksmps could be an i-rate variable as opposed 
> to a literal value?
> 
> On Sun, Sep 3, 2023 at 12:17 PM Steven Yi  > wrote:
> 
>     Yes, this shouldn't work, sr is used to set up things prior to
>     runtime and can not be changed without restarting csound. I think
>     the best you could do is to read the sample rate of the file prior
>     to starting csound, then using --sample-rate=[the sample rate] as a
>     commandline flag option.
> 
> 
>     On Sun, Sep 3, 2023 at 11:37 AM lj      > wrote:
> 
>         Hi, all.
> 
>         I wanted to see if I could set the orchestra sr to the sample
>         rate of a
>         sound file that is going to be read by diskin2 in the orchestra.
> 
>         I included these lines in the header, hoping they would work:
> 
>         giSr   =    filesr("MyFile.wav"))
>         sr      =  giSr
> 
>         giSr is properly evaluated, but sr is set to 0 and Csound crashes.
>         Obviously, this is not so easy as I wished it would be. Is there a
>         reason for this not to work?
> 
>         In case it's relevant, I'm using Csound 6.18 as distributed by
>         Arch Linux.
> 
> 
> 
>         --
> 
>         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-09-03 18:12
FromDave Seidel
SubjectRe: [Csnd] setting sr to a variable
Ah yes, thanks for the correction.

On Sun, Sep 3, 2023 at 12:58 PM joachim heintz <jh@joachimheintz.de> wrote:
but setksmps sets the block size, not the sample rate.
i think the only solution is what steven mentioned.


On 03/09/2023 13:38, Dave Seidel wrote:
> If within an instrument or a UDO, you could use setksmps, perhaps?
> Assuming the argument to setksmps could be an i-rate variable as opposed
> to a literal value?
>
> On Sun, Sep 3, 2023 at 12:17 PM Steven Yi <stevenyi@gmail.com
> <mailto:stevenyi@gmail.com>> wrote:
>
>     Yes, this shouldn't work, sr is used to set up things prior to
>     runtime and can not be changed without restarting csound. I think
>     the best you could do is to read the sample rate of the file prior
>     to starting csound, then using --sample-rate=[the sample rate] as a
>     commandline flag option.
>
>
>     On Sun, Sep 3, 2023 at 11:37 AM lj <ljc@internet.com.uy
>     <mailto:ljc@internet.com.uy>> wrote:
>
>         Hi, all.
>
>         I wanted to see if I could set the orchestra sr to the sample
>         rate of a
>         sound file that is going to be read by diskin2 in the orchestra.
>
>         I included these lines in the header, hoping they would work:
>
>         giSr   =    filesr("MyFile.wav"))
>         sr      =  giSr
>
>         giSr is properly evaluated, but sr is set to 0 and Csound crashes.
>         Obviously, this is not so easy as I wished it would be. Is there a
>         reason for this not to work?
>
>         In case it's relevant, I'm using Csound 6.18 as distributed by
>         Arch Linux.
>
>
>
>         --
>
>         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