Csound Csound-dev Csound-tekno Search About

[Csnd] ftgen01 in WASM

Date2017-09-01 20:25
FromHlöð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?

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
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

Date2017-09-01 21:05
FromVictor Lazzarini
SubjectRe: [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  wrote:
> 
> 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?
> 
> 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
> 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

Date2017-09-02 12:14
FromHlöðver Sigurðsson
SubjectRe: [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.
========================
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 <hlolli@gmail.com> wrote:
>
> 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?
>
> 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
> 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

Date2017-09-02 12:51
FromHlöðver Sigurðsson
SubjectRe: [Csnd] ftgen01 in WASM

On 2 September 2017 at 13:14, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
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.
========================
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 <hlolli@gmail.com> wrote:
>
> 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?
>
> 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
> 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

Date2017-09-02 13:11
FromHlöðver Sigurðsson
SubjectRe: [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:

On 2 September 2017 at 13:14, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
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.
========================
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 <hlolli@gmail.com> wrote:
>
> 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?
>
> 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
> 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

Date2017-09-02 13:24
FromHlöðver Sigurðsson
SubjectRe: [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:
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:

On 2 September 2017 at 13:14, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
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.
========================
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 <hlolli@gmail.com> wrote:
>
> 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?
>
> 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
> 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