[Csnd] ftgen01 in WASM
Date | 2017-09-01 20:25 |
From | Hlöðver Sigurðsson |
Subject | [Csnd] ftgen01 in WASM |
I'm running wasm in nodejs and I'm encountering quite typical js problem, it (obviously maybe) can't read any file from my filesystem, so I wonder if node can be of any help here, like serving my samples on a localhost server?
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
The error message is here for what it's worth: ftable 1000: deferred alloc for /home/hlolli/.samples/xx/note-012.wav soundin cannot open /home/hlolli/.samples/xx/note-012.wav ftable 1000: Failed to open file /home/hlolli/.samples/xx/note-012.wav f1000 0.00 0.00 1.00 "/home/hlolli/.samples/xx/note-012.wav" ... INIT ERROR in instr 0: ftgen error gi_ ftgen.iS 1000 0 0 1 "/home/hlolli/.samples/xx/note-012.wav" 0 0 0 best, Hlöðver |
Date | 2017-09-01 21:05 |
From | Victor Lazzarini |
Subject | Re: [Csnd] ftgen01 in WASM |
you need to copy it to the server. See the code in csound.js that does it as an example. ======================== Prof. Victor Lazzarini Dean of Arts, Celtic Studies, and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 1 Sep 2017, at 20:25, Hlöðver Sigurðsson |
Date | 2017-09-02 12:14 |
From | Hlöðver Sigurðsson |
Subject | Re: [Csnd] ftgen01 in WASM |
I am still struggling with this, I see the example of how a soundfont file is downloaded from a server, turned into stream and written to a local file as is done with this function function CopyUrlToLocal(url, name, callback = null) { var xmlHttpRequest = new XMLHttpRequest(); xmlHttpRequest.onload = function() { var data = new Uint8Array(xmlHttpRequest.response); var stream = FS.open(name, 'w+'); FS.write(stream, data, 0, data.length, 0); FS.close(stream); if (callback != null) callback(); }; xmlHttpRequest.open("get", url, true); xmlHttpRequest.responseType = "arraybuffer"; xmlHttpRequest.send(null); } Since I'm using Node, I don't see the reason to use a server, the files are already local so I'm trying to find what is the working directory of my csound-wasm instance. pwd() opcode doesn't work. I'll continue to read more about filesystem and wasm on node and see if I can solve this. I also tried starting a localhost server, but noticed soon that ip-addresses for filepaths are not leagal in csound (not that I would assume it should be supported). On 1 September 2017 at 22:05, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote: you need to copy it to the server. See the code in csound.js that does it as an example. |
Date | 2017-09-02 12:51 |
From | Hlöðver Sigurðsson |
Subject | Re: [Csnd] ftgen01 in WASM |
Found good resources here: and I think I'll try applying the FS, see where that takes me... On 2 September 2017 at 13:14, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
|
Date | 2017-09-02 13:11 |
From | Hlöðver Sigurðsson |
Subject | Re: [Csnd] ftgen01 in WASM |
Bingo, got it! For node one needs to mount a directory, so FS.mkdir('/mount'); FS.mount(NODEFS, { root: '/path/to/any/directory' }, '/mount'); then ftgen01 can acces the file "mount/audiofile.wav" Easy :) On 2 September 2017 at 13:51, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
|
Date | 2017-09-02 13:24 |
From | Hlöðver Sigurðsson |
Subject | Re: [Csnd] ftgen01 in WASM |
And unrelated (can start a new thread), my sample bank exceeds the memory allowance of the wasm Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 On 2 September 2017 at 14:11, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
|