Csound Csound-dev Csound-tekno Search About

[Csnd] MP3 playback grainy in Csound WASM (@csound/browser 6.18.7)

Date2026-02-06 22:31
FromSzymon Walendowski
Subject[Csnd] MP3 playback grainy in Csound WASM (@csound/browser 6.18.7)
Hello everyone,

I am a student of Dr. B's and I am trying to build with csound wasm. I've had success in general, for instance creating this webapp: https://noisysound.art/.

However, I can't figure out how to get mp3 files to play without severe distortion. I tried diskin and diskin2, and it always works locally but never on the web version. Is it the way I load it in? I do something like this to put the audio files in the virtual file system:

// Load file
const arrayBuffer = await file.arrayBuffer();
const droppedFileData = new Uint8Array(arrayBuffer);
await cs.fs.writeFile(`/${file.name}`, droppedFileData);

Thanks for your help and apologies for the possibly trivial question.

Best,

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

Date2026-02-07 00:11
FromPartev Sarkissian <0000060b2ef1338e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] MP3 playback grainy in Csound WASM (@csound/browser 6.18.7)

May be a bit resolution or sample rate mis match between Csound and your source file. 


-Partev 



On Friday, February 6, 2026 at 10:41:44 PM GMT, Szymon Walendowski <walendowski.szymon@gmail.com> wrote:


Hello everyone,

I am a student of Dr. B's and I am trying to build with csound wasm. I've had success in general, for instance creating this webapp: https://noisysound.art/.

However, I can't figure out how to get mp3 files to play without severe distortion. I tried diskin and diskin2, and it always works locally but never on the web version. Is it the way I load it in? I do something like this to put the audio files in the virtual file system:

// Load file
const arrayBuffer = await file.arrayBuffer();
const droppedFileData = new Uint8Array(arrayBuffer);
await cs.fs.writeFile(`/${file.name}`, droppedFileData);

Thanks for your help and apologies for the possibly trivial question.

Best,

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

Date2026-02-07 10:50
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] MP3 playback grainy in Csound WASM (@csound/browser 6.18.7)
yes, I can hear something wrong in the playback. I think this is a problem with
libsndfile on wasm (it needs to be investigated).

As a solution, you could load the mp3 file onto a table and then read it with
an oscillator etc. This doesn’t use libsndfile so it sounds OK.


  
  -odac
  
  
    0dbfs=1
    nchnls=2
    instr 1
      a1 poscil 1, sr/ftlen(1), 1
      outs a1, a1
    endin
  
  
    f1 0 88200 49  "beats.mp3"  0  1
    i1 0 10
  


Alternatively you could use mp3in but for some reason this is excluded in the published
version of 6.18 wasm (?). It is there in version 7.0.0-beta

========================
Prof. Victor Lazzarini
Maynooth University
Ireland


> On 6 Feb 2026, at 22:31, Szymon Walendowski  wrote:
>
> You don't often get email from walendowski.szymon@gmail.com. Learn why this is important *Warning*
> This 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.
> Hello everyone,
>
> I am a student of Dr. B's and I am trying to build with csound wasm. I've had success in general, for instance creating this webapp: https://noisysound.art/.
>
> However, I can't figure out how to get mp3 files to play without severe distortion. I tried diskin and diskin2, and it always works locally but never on the web version. Is it the way I load it in? I do something like this to put the audio files in the virtual file system:
>
> // Load file
> const arrayBuffer = await file.arrayBuffer();
> const droppedFileData = new Uint8Array(arrayBuffer);
> await cs.fs.writeFile(`/${file.name}`, droppedFileData);
>
> Thanks for your help and apologies for the possibly trivial question.
>
> Best,
>
> Szymon Walendowski
> 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 information contained in this email may be confidential and privileged. It is intended only for the addressee(s) stated above. If you are not an addressee any use, dissemination, distribution, publication or copying of the information contained in this email is strictly prohibited. If you have received this email in error, please immediately notify us by email at dataprotection@mu.ie and delete this email from your system.

Please note that Maynooth University is subject to Freedom of Information and Data Protection laws. We may be required to disclose the content of emails under the FOI Act 2014, the Data Protection Act 2018 or GDPR.

Is don seolaí / do na seolaithe thuasluaite amháin an ríomhphost seo. D’fhéadfadh an t-eolas atá ann a bheith rúnda agus faoi phribhléid. Mura seolaí tú, tá cosc iomlán ar aon eolas atá sa ríomhphost seo a úsáid, a scaipeadh, a dháileadh, a fhoilsiú nó a chóipeáil. Má fuair tú an ríomhphost seo trí thimpiste, cuir sin in iúl dúinn láithreach trí ríomhphost a chur chuig  dataprotection@mu.ie  agus scrios an ríomhphost seo ó do chóras.

Tabhair faoi deara go bhfuil Ollscoil Mhá Nuad faoi réir dhlíthe um Shaoráil Faisnéise agus um Chosaint Sonraí. D’fhéadfadh ceangal a bheith orainn ábhar ríomhphoist a nochtadh faoin Acht um Shaoráil Faisnéise 2014, faoin Acht um Chosaint Sonraí 2018 nó faoi GDPR.

Registered charity number 20037130



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

Date2026-02-07 11:00
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] [Csnd] MP3 playback grainy in Csound WASM (@csound/browser 6.18.7)
Here’s an example with Csound 7.0

https://editor.p5js.org/vlazzarini/sketches/EVRoNYZFM

you can hear the difference between mp3in and diskin. The latter uses
libsndfile, the former uses our own decoder.
Something wrong with libsndfile.

========================
Prof. Victor Lazzarini
Maynooth University
Ireland






> On 7 Feb 2026, at 10:50, Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE> wrote:
>
> yes, I can hear something wrong in the playback. I think this is a problem with
> libsndfile on wasm (it needs to be investigated).
>
> As a solution, you could load the mp3 file onto a table and then read it with
> an oscillator etc. This doesn’t use libsndfile so it sounds OK.
>
> 
>  
>  -odac
>  
>  
>    0dbfs=1
>    nchnls=2
>    instr 1
>      a1 poscil 1, sr/ftlen(1), 1
>      outs a1, a1
>    endin
>  
>  
>    f1 0 88200 49  "beats.mp3"  0  1
>    i1 0 10
>  
> 
>
> Alternatively you could use mp3in but for some reason this is excluded in the published
> version of 6.18 wasm (?). It is there in version 7.0.0-beta
>
> ========================
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>
>> On 6 Feb 2026, at 22:31, Szymon Walendowski  wrote:
>>
>> You don't often get email from walendowski.szymon@gmail.com. Learn why this is important *Warning*
>> This 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.
>> Hello everyone,
>>
>> I am a student of Dr. B's and I am trying to build with csound wasm. I've had success in general, for instance creating this webapp: https://noisysound.art/.
>>
>> However, I can't figure out how to get mp3 files to play without severe distortion. I tried diskin and diskin2, and it always works locally but never on the web version. Is it the way I load it in? I do something like this to put the audio files in the virtual file system:
>>
>> // Load file
>> const arrayBuffer = await file.arrayBuffer();
>> const droppedFileData = new Uint8Array(arrayBuffer);
>> await cs.fs.writeFile(`/${file.name}`, droppedFileData);
>>
>> Thanks for your help and apologies for the possibly trivial question.
>>
>> Best,
>>
>> Szymon Walendowski
>> 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 information contained in this email may be confidential and privileged. It is intended only for the addressee(s) stated above. If you are not an addressee any use, dissemination, distribution, publication or copying of the information contained in this email is strictly prohibited. If you have received this email in error, please immediately notify us by email at dataprotection@mu.ie and delete this email from your system.
>
> Please note that Maynooth University is subject to Freedom of Information and Data Protection laws. We may be required to disclose the content of emails under the FOI Act 2014, the Data Protection Act 2018 or GDPR.
>
> Is don seolaí / do na seolaithe thuasluaite amháin an ríomhphost seo. D’fhéadfadh an t-eolas atá ann a bheith rúnda agus faoi phribhléid. Mura seolaí tú, tá cosc iomlán ar aon eolas atá sa ríomhphost seo a úsáid, a scaipeadh, a dháileadh, a fhoilsiú nó a chóipeáil. Má fuair tú an ríomhphost seo trí thimpiste, cuir sin in iúl dúinn láithreach trí ríomhphost a chur chuig  dataprotection@mu.ie  agus scrios an ríomhphost seo ó do chóras.
>
> Tabhair faoi deara go bhfuil Ollscoil Mhá Nuad faoi réir dhlíthe um Shaoráil Faisnéise agus um Chosaint Sonraí. D’fhéadfadh ceangal a bheith orainn ábhar ríomhphoist a nochtadh faoin Acht um Shaoráil Faisnéise 2014, faoin Acht um Chosaint Sonraí 2018 nó faoi GDPR.
>
> Registered charity number 20037130
>
>
>
> 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 information contained in this email may be confidential and privileged. It is intended only for the addressee(s) stated above. If you are not an addressee any use, dissemination, distribution, publication or copying of the information contained in this email is strictly prohibited. If you have received this email in error, please immediately notify us by email at dataprotection@mu.ie and delete this email from your system.

Please note that Maynooth University is subject to Freedom of Information and Data Protection laws. We may be required to disclose the content of emails under the FOI Act 2014, the Data Protection Act 2018 or GDPR.

Is don seolaí / do na seolaithe thuasluaite amháin an ríomhphost seo. D’fhéadfadh an t-eolas atá ann a bheith rúnda agus faoi phribhléid. Mura seolaí tú, tá cosc iomlán ar aon eolas atá sa ríomhphost seo a úsáid, a scaipeadh, a dháileadh, a fhoilsiú nó a chóipeáil. Má fuair tú an ríomhphost seo trí thimpiste, cuir sin in iúl dúinn láithreach trí ríomhphost a chur chuig  dataprotection@mu.ie  agus scrios an ríomhphost seo ó do chóras.

Tabhair faoi deara go bhfuil Ollscoil Mhá Nuad faoi réir dhlíthe um Shaoráil Faisnéise agus um Chosaint Sonraí. D’fhéadfadh ceangal a bheith orainn ábhar ríomhphoist a nochtadh faoin Acht um Shaoráil Faisnéise 2014, faoin Acht um Chosaint Sonraí 2018 nó faoi GDPR.

Registered charity number 20037130



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