Csound Csound-dev Csound-tekno Search About

[Csnd] wasm and sampling rate

Date2018-01-14 15:28
FromGuillermo Senna
Subject[Csnd] wasm and sampling rate
Hi,

I've noticed that running the wasm version (at least with Firefox)
doesn't resample its output according to the web browser sample rate. Is
there a way around this issue?

Cheers.

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

Date2018-01-14 18:39
FromSteven Yi
SubjectRe: [Csnd] wasm and sampling rate
Interesting, I thought sample rate matching was addressed already and
wasn't even aware this was happening. Looking at web projects I've got
right now, looks like I having things always defaulting to sr=48000,
which happens to match up with the default AudioContext sample rates
I'm seeing. That's seems to be okay but it's just dumb luck.

I imagine resampling would a bit costly.  Would it be enough to set
Csound to the same sample rate as the browser (or vice versa?) ?   If
the former, you could try getting the audiocontext's sample rate and
use the csoundObj setOption() function. You could query it using
something like:

cs = new CsoundObj();
a = new (window.AudioContext || window.webkitAudioContext)();
cs.setOption("--sample-rate=" + a.sampleRate);
// insert code to compile orc or csd or whatever
cs.start();



On Sun, Jan 14, 2018 at 10:28 AM, Guillermo Senna  wrote:
> Hi,
>
> I've noticed that running the wasm version (at least with Firefox)
> doesn't resample its output according to the web browser sample rate. Is
> there a way around this issue?
>
> Cheers.
>
> 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

Date2018-01-14 19:06
FromGuillermo Senna
SubjectRe: [Csnd] wasm and sampling rate
Yeah, I solved it by forcing the sample rate of csound.Csound with
setOption. But your solution is what I was actually hoping to achieve.
Thanks! I think it's a reasonable solution for now as long as you are
aware of the issue because if instead of using the sr constant inside an
instrument you actually type the value you think you've given in the
header things can go really bad.

Anyway you can always have a button in the website to "Render offline"
and NOT force the sample rate with setOption, in which case setting the
constant "sr" from the orchestra works as expected.

On another matter, Steven, is it still OK to use the csound object from
csound.js instead of directly using CsoundObj?



On 14/01/18 15:39, Steven Yi wrote:
> Interesting, I thought sample rate matching was addressed already and
> wasn't even aware this was happening. Looking at web projects I've got
> right now, looks like I having things always defaulting to sr=48000,
> which happens to match up with the default AudioContext sample rates
> I'm seeing. That's seems to be okay but it's just dumb luck.
>
> I imagine resampling would a bit costly.  Would it be enough to set
> Csound to the same sample rate as the browser (or vice versa?) ?   If
> the former, you could try getting the audiocontext's sample rate and
> use the csoundObj setOption() function. You could query it using
> something like:
>
> cs = new CsoundObj();
> a = new (window.AudioContext || window.webkitAudioContext)();
> cs.setOption("--sample-rate=" + a.sampleRate);
> // insert code to compile orc or csd or whatever
> cs.start();
>
>
>
> On Sun, Jan 14, 2018 at 10:28 AM, Guillermo Senna  wrote:
>> Hi,
>>
>> I've noticed that running the wasm version (at least with Firefox)
>> doesn't resample its output according to the web browser sample rate. Is
>> there a way around this issue?
>>
>> Cheers.
>>
>> 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

Date2018-01-14 20:34
FromSteven Yi
SubjectRe: [Csnd] wasm and sampling rate
I don't use csound.js, but after a quick look, it seems to me the same
whether you use the CsoundObj created by csound.js or instantiate one
directly.

On Sun, Jan 14, 2018 at 2:06 PM, Guillermo Senna  wrote:
> Yeah, I solved it by forcing the sample rate of csound.Csound with
> setOption. But your solution is what I was actually hoping to achieve.
> Thanks! I think it's a reasonable solution for now as long as you are
> aware of the issue because if instead of using the sr constant inside an
> instrument you actually type the value you think you've given in the
> header things can go really bad.
>
> Anyway you can always have a button in the website to "Render offline"
> and NOT force the sample rate with setOption, in which case setting the
> constant "sr" from the orchestra works as expected.
>
> On another matter, Steven, is it still OK to use the csound object from
> csound.js instead of directly using CsoundObj?
>
>
>
> On 14/01/18 15:39, Steven Yi wrote:
>> Interesting, I thought sample rate matching was addressed already and
>> wasn't even aware this was happening. Looking at web projects I've got
>> right now, looks like I having things always defaulting to sr=48000,
>> which happens to match up with the default AudioContext sample rates
>> I'm seeing. That's seems to be okay but it's just dumb luck.
>>
>> I imagine resampling would a bit costly.  Would it be enough to set
>> Csound to the same sample rate as the browser (or vice versa?) ?   If
>> the former, you could try getting the audiocontext's sample rate and
>> use the csoundObj setOption() function. You could query it using
>> something like:
>>
>> cs = new CsoundObj();
>> a = new (window.AudioContext || window.webkitAudioContext)();
>> cs.setOption("--sample-rate=" + a.sampleRate);
>> // insert code to compile orc or csd or whatever
>> cs.start();
>>
>>
>>
>> On Sun, Jan 14, 2018 at 10:28 AM, Guillermo Senna  wrote:
>>> Hi,
>>>
>>> I've noticed that running the wasm version (at least with Firefox)
>>> doesn't resample its output according to the web browser sample rate. Is
>>> there a way around this issue?
>>>
>>> Cheers.
>>>
>>> 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