• Hi, I need to make some simple PCM sound sample player, just several samples of animal sounds. It is possilbe to do it on arduino avr, but I need more flash.
    I wonder if that is possible to play that on espruino?

  • Yes, absolutely - it'll even handle more than one at once: https://www.espruino.com/Waveform

  • how is possible to stop that file after playing? I noticed that after playing a sample espruino has some clicking/biping (noice)

    in my project I need to play some animal sounds samples after button pressed,
    when samples are selected by the corresponding button, they should only be played once

    is 4000Hz max quality I can get by espruino?

  • Fri 2021.05.21

    is 4000Hz max quality I can get by espruino?

    I noticed this was posted beneath: 'Pico / Wifi / Original Espruino'

    To confirm, which of the STMicroelectronics, Nordic Semiconductor or Espressif chips, or which specific board is the inquiry for?

  • Espruino Original is what i use for this project, just for try, but for the final I would swap to pico or MDBT42Q

  • I am afraid it is not working as smoothly as on esp32 or even arduino uno,
    audacity can't convert my samples to 4000Hz, it looks like it is dead end

  • Sat 2021.05.22

    Found this:

    Streaming waveforms

    Now on the Pico: 'While the highest sampling rate I achieved with SD card was between 12 and 15 KHz, I can stream at 44.1 KHz from the flash RAM'

  • what is the highest rate on Original espruino?

  • Sat 2021.05.22

    from post #7     'audacity can't convert my samples to 4000Hz, it looks like it is dead end'

    What process is being used for recording the original content? I've just connected a mic and recorded straight to Audacity at around the same rate ~32kB as CD's are recorded.

    That said, I haven't used that Audacity output with how that tutorial presents.

    Does this assist with configuration?

    YouTube [How to Change the Sample Rate and Bit Depth in Audacity]

  • I have some mp3 samples from internet. I use audacity to decrease rate to 4000Hz but without success, any file I convert by audacity to raw file doesn't work from TF card. There is only some noice. When I use code for short files to run without TF card it is working only with Gordon's code from the web, but not when I convert my files by converter provided here https://www.espruino.com/File+Converter

  • Sat 2021.05.22

    It has been a few years since I've used the Waveforms examples, link in post #2 and the Converting files to Strings, link in post #11 which went with success and many are currently using those examples also.

    My version of Audacity defaults to 8000Hz. Has that option been tried while changing the rates within the code snippet?

    Which examples do work and which fail from the Waveforms page?

    Are you using the code snippet beneath: 'You can output a Sound file' ?

    'but not when I convert my files by converter provided here'

    Although I don't have the hardware to test in this case, I'd be willing to at least go through the conversion process you are using to see if the converted outputs match.

    Which format is being selected in the DDL box on the File Converter page, and would you mind uploading a small source sample, along with the options being used to create the Audacity output, the raw Audacity converted file and the output from the File Converter.

    A screen shot of the Audacity Preferences modal dialog would speed my configuration.

    From a positive match between our steps, others may be able to quickly zoom into other possible areas to consider.

  • First I convert my file in Audacity 3.0.2. from mp3 to 16-bit PCM. Then make it mono, next decrease the rate down to 4000Hz, after that i export it and choose "Other Uncompressed files" then Choose "RAW (header-less)" and "Unsigned 8 bit PCM".

    After that I use this converter
    and choose .raw file I've just created. In converter select window I choose base64, then I save code
    converted there to TF card.

    Next use this code

    var f = E.openFile("Horse-Angry.raw","r");
    var w = new Waveform(2048, {doubleBuffer:true});
    // load first bits of sound file
    var fileBuf = f.read(w.buffer.length);
    // when one buffer finishes playing, load the next one
    w.on("buffer", function(buf) {
      fileBuf = f.read(buf.length);
      if (fileBuf===undefined) w.stop(); // end of file
    // start output
    analogWrite(A0, 0.5, {freq:40000});

    to play it.

  • Wow, can you please share size of file and play duration?

  • raw file size is 15KB
    duration 2sec

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

PCM sound samples - is it possilbe to play some on espruino?

Posted by Avatar for bigplik @bigplik