Csound Csound-dev Csound-tekno Search About

[Csnd-dev] WebAudio: ScriptProcessorNode bufferSize

Date2018-08-01 16:31
FromSteven Yi
Subject[Csnd-dev] WebAudio: ScriptProcessorNode bufferSize
Hi All,

FYI: I was doing some testing on iOS to prepare for the ICMC workshop
I'm giving and found that the audio was really choppy.  I did some
research and found that we use 0 for the buffersize when creating a
ScriptProcessorNode.  This, by default, let's the platform determine
the buffersize. In theory that makes sense, but what I found was:

1. On Desktop Firefox, I got a size of 4096
2. On Desktop Edge, I got a size of 2048
3. On iOS Safari, I got a size of 256 (!!!!!)

The buffersize is way too small to deal with the SPN being run in the
main thread and one gets pretty bad choppiness, especially when
interacting with the web page. In csound-live-code, I made the
following change to hardcode to always use 4096:

https://github.com/kunstmusik/csound-live-code/commit/89fa2740c6abe71a96e10c91e47931fd2523b1c1

I had done some further browser sniffing to set to 0 for non iOS
browsers, but in this context for live coding using 4096 is fine on
all of the target SPN browsers, so I went with just 4096.

This should probably be made into a config option, but I am short on
time at the moment. I have filed an issue to look into this:

https://github.com/csound/csound/issues/988

Thanks,