Initializing CsoundObj in Web Csound

Hi,

I’m seeing two ways people are initializing CsoundObj in Web Csound.

  1. CsoundObj.importScripts("./csound/").then(() => {setupCsound();}); (example here)
  2. CsoundObj.initialize().then(() => {startCsound();}); (example here)

Can someone explain the difference between the two in terms of how they initialize CsoundObj?

Thanks!
Jason

importScripts() was what was in the API for a long while, but I modified it in 6.15.0 to initialize() and added the ability to send in an AudioContext to use, which was important for making the Csound nodes work in a larger Webaudio graph.

That said, the new version of WebAudio Csound has undergone many changes for 6.16.0 and the process has changed again. New code looks like:

const cs = await Csound();  // may pass in arguments as object to Csound

Or since it is a promise you can use:

Csound().then(() => {
});

6.16.0-beta is already published to NPM for testing though we are waiting for a few more changes to publish beta4, which we’ll then announce for testing. We’ll have the above documented in tutorials.

Fantastic, thanks for the explanation, Steven! Makes sense. I’m looking forward to 6.16.0!

Jason