Csound Csound-dev Csound-tekno Search About

Re: [Csnd] [EXTERNAL] [Csnd] fout in Csound WASM

Date2023-01-20 13:05
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] fout in Csound WASM
On the desktop, fout closes the file when the instrument is deinitialised (the instance stops running). Perhaps that's the behaviour we should seek to emulate?

Prof. Victor Lazzarini
Maynooth University
Ireland

On 20 Jan 2023, at 12:47, Hlöðver Sigurðsson <hlolli@gmail.com> wrote:


Yes that's exactly what happens. The file buffers are collected, but the file headers are written to the open file handler at the end of the performance, maybe this could be improved such that the file headers are written first and the buffers are thereafter written contiguously, without a seek to position 0.

On Fri, 20 Jan 2023 at 12:55, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
ah, that might the difference. It could be that the file is not properly closed before the performance is finished.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 20 Jan 2023, at 11:42, Rory Walsh <rorywalsh@ear.ie> wrote:
>
> I didn't try that. I was specifically looking to save a performance. I'm using the "realtimePerformanceEnded" event, but I guess a button click would work too?
>
> On Fri, 20 Jan 2023 at 11:32, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
> The file seems to be seen and opened, it just doesn’t seem to have much data in it.
> The code I have works on the desktop so I would have expected to work on WASM if fout is able to write data.
>
> In your example do you have to stop Csound before making the data available for download? Or can you record
> and download while Csound continues to run?
> ========================
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
> > On 20 Jan 2023, at 11:14, Rory Walsh <rorywalsh@ear.ie> wrote:
> >
> > Sorry, here:
> >
> > https://editor.p5js.org/rorywalsh/sketches/9VmTcOfPX
> >
> > But in this example I don't try to access the file I just wrote in Csound. I see no examples of doing this in the test files either, so I'm not sure it's possible?
> > https://github.com/csound/csound/blob/master/wasm/browser/tests/tests.js
> >
> >
> > On Fri, 20 Jan 2023 at 11:02, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
> > Anyway, if that works, then I don’t know why my code doesn’t.
> >
> > ========================
> > Prof. Victor Lazzarini
> > Maynooth University
> > Ireland
> >
> > > On 20 Jan 2023, at 11:01, Victor Lazzarini <Victor.Lazzarini@MU.IE> wrote:
> > >
> > > here where?
> > > ========================
> > > Prof. Victor Lazzarini
> > > Maynooth University
> > > Ireland
> > >
> > >> On 20 Jan 2023, at 10:21, Rory Walsh <rorywalsh@ear.ie> wrote:
> > >>
> > >> WARNINGThis email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> > >> Here is an example which writes a file using fout and then presents a link for download. Thanks to Hlöðver for his help with this one.
> > >>
> > >> On Fri, 20 Jan 2023 at 09:00, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
> > >> Checking with filelen, the file is only 3 ms long
> > >> ========================
> > >> Prof. Victor Lazzarini
> > >> Maynooth University
> > >> Ireland
> > >>
> > >>> On 20 Jan 2023, at 08:56, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote:
> > >>>
> > >>> Is fout supposed to work on Csound WASM? It seems to write a file that we can open, but the data in it does not seem to be correct
> > >>> (just a buzz). Here’s some test code
> > >>>
> > >>> 0dbfs = 1
> > >>> nchnls = 1
> > >>>
> > >>>
> > >>> instr 2
> > >>> ain inch 1
> > >>> fout "./test.wav",-1,ain
> > >>> out ain
> > >>> endin
> > >>> schedule(2,0,10)
> > >>>
> > >>> instr 3
> > >>> a1 diskin "./test.wav",1,0,1
> > >>>  out a1
> > >>> endin
> > >>> schedule(3,11,10)
> > >>>
> > >>>
> > >>> ========================
> > >>> Prof. Victor Lazzarini
> > >>> Maynooth University
> > >>> Ireland
> > >>>
> > >>>
> > >>> Csound mailing list
> > >>> Csound@listserv.heanet.ie
> > >>> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7Cb9405fff54b94c3e5c1008dafad5bb8e%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638098093126636911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oMn%2FS%2F0M9dPHQilafwDByDtu6OQdQXMtfFeRNKDgLLA%3D&reserved=0
> > >>> Send bugs reports to
> > >>>       https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7Cb9405fff54b94c3e5c1008dafad5bb8e%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638098093126636911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2NxX01IYVwS9vvz8X5M3L5gEN7%2B7rvyBEqswWEH3H%2Fg%3D&reserved=0
> > >>> Discussions of bugs and features can be posted here
> > >>
> > >>
> > >> Csound mailing list
> > >> Csound@listserv.heanet.ie
> > >> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7Cb9405fff54b94c3e5c1008dafad5bb8e%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638098093126636911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oMn%2FS%2F0M9dPHQilafwDByDtu6OQdQXMtfFeRNKDgLLA%3D&reserved=0
> > >> Send bugs reports to
> > >>        https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7Cb9405fff54b94c3e5c1008dafad5bb8e%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638098093126636911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2NxX01IYVwS9vvz8X5M3L5gEN7%2B7rvyBEqswWEH3H%2Fg%3D&reserved=0
> > >> Discussions of bugs and features can be posted here
> > >> Csound mailing list Csound@listserv.heanet.ie https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7Cb9405fff54b94c3e5c1008dafad5bb8e%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638098093126636911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oMn%2FS%2F0M9dPHQilafwDByDtu6OQdQXMtfFeRNKDgLLA%3D&reserved=0 Send bugs reports to https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7Cb9405fff54b94c3e5c1008dafad5bb8e%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638098093126636911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2NxX01IYVwS9vvz8X5M3L5gEN7%2B7rvyBEqswWEH3H%2Fg%3D&reserved=0 Discussions of bugs and features can be posted here
> > >
> > >
> > > Csound mailing list
> > > Csound@listserv.heanet.ie
> > > https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistserv.heanet.ie%2Fcgi-bin%2Fwa%3FA0%3DCSOUND&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7Cb9405fff54b94c3e5c1008dafad5bb8e%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638098093126636911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oMn%2FS%2F0M9dPHQilafwDByDtu6OQdQXMtfFeRNKDgLLA%3D&reserved=0
> > > Send bugs reports to
> > >        https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcsound%2Fcsound%2Fissues&data=05%7C01%7CVictor.Lazzarini%40mu.ie%7Cb9405fff54b94c3e5c1008dafad5bb8e%7C1454f5ccbb354685bbd98621fd8055c9%7C0%7C0%7C638098093126636911%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=2NxX01IYVwS9vvz8X5M3L5gEN7%2B7rvyBEqswWEH3H%2Fg%3D&reserved=0
> > > 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
>
>
> 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
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