[Csnd] Csound WASM fs

I was trying to figure out the way to use the fs to copy in a CSD etc, the code I tried

csd = await fetch("./my.csd")
dat = await csd.arrayBuffer();
await csound.fs.writeFile("my.csd", new Uint8Array(dat));
await csound.compileCsd("my.csd");
await csound.start();

does that look right? The csd is in the same server directory as the html page.

Somehow it seems to get stuck in compileCsd().

Prof. Victor Lazzarini
Maynooth University
Ireland
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        Issues · csound/csound · GitHub
Discussions of bugs and features can be posted here

That’s working fine here now. It’s all a matter of getting all the async stuff lined up properly.
Got my MIDI file player working now with Csound WASM, you can check it here

https://vlazzarini.github.io/wasm/midiplayer.html

and here’s a short video

Looks like it works very smoothly! But I am only hearing the right channel in the video.

Sorry, I was wrong, but it does seem stronger in the right channel. Same thing with a local file, but less of a difference between the channels.

amazing --- also the other examples on Csound Wasm Examples
thanks for sharing!
  j

It’s whatever panning the soundfonts have got, I guess and probably the midifiles too maybe.

Prof. Victor Lazzarini
Maynooth University
Ireland

I think that what Steven and Hlodver have done really simplified the process. Converting old examples was not too difficult even when it involved more or less a total rewrite.

Prof. Victor Lazzarini
Maynooth University
Ireland

i have been messing about with this as well i have modified victor’s code a great deal actually to get it the way I use it (browser live coding/algorithmic stuff)

i did perhaps find an opcode bug though somewhere in the pitch to midi conversion, it’s off by a note if i send (.0, .02, .04, .05, .07, .09, .11) when switching octaves but if i send (60, 62, 64, 65, 67, 69, 71) it works fine

wait is there a new release of csound-wasm? i’m still stuck on 6.15? (i think)

npm install @csound/browser and you get the latest.

Prof. Victor Lazzarini
Maynooth University
Ireland

maybe you are thinking of a different code, this one from the midiplayer does not do any pitch to midi conversion. It just sends midi messages to an sf instrument. It’s an adaptation of the fluidcomplex.csd manual example made to work with sfplay.

Prof. Victor Lazzarini
Maynooth University
Ireland

i am aware, i more or less just used it as an example to learn how sfplay worked since fluid opcodes aren’t in wasm… i am actually passing schedule opcodes to it, pulling numbers from an array so p4 could be 60 (+12/-12) or 8.0 (+0.12/-0.12) but you would have to pass the pchtom opcode to it if you are using pch values. i think i have nailed it down to that opcode and not the array because if i put the same array through cpspch and a regular ol oscil it works fine.