• PROGRESS!! It's working, whoop! ... Still a few glitches to iron out but the way it sounds actually works better for my project (will share when done).

    Main issue, a large raw file (+9mb) plays ok, but when I stop and restart it I get out of memory error. Can I free the memory taken by the file?

    Example block:

    var AUDIOUT = A1;
    
    function TRamp_playSoundFile(file)
    {
      var f = E.openFile("/audio/" + file,"r");
      w = undefined;
      w = new Waveform(2048, {doubleBuffer:true});
      // load first bits of sound file
      w.buffer.set(f.read(w.buffer.length));
      w.buffer2.set(f.read(w.buffer.length));
      var fileBuf = f.read(w.buffer.length);
      // when one buffer finishes playing, load the next one
      w.on("buffer", function(buf) {
        buf.set(fileBuf);
        fileBuf = f.read(buf.length);
        if (fileBuf===undefined)
        {
          w.stop(); // end of file
          f.close();
          TRamp_stopSoundFile();
        }
      });
      // start output
      analogWrite(AUDIOUT, 0.5, {freq:20000});
      w.startOutput(AUDIOUT,4000,{repeat:true}­);
    }
    
    function TRamp_stopSoundFile()
    {
      AUDIOUT.write(0);
      w = undefined;
    }
    
About

Avatar for pwhitrow @pwhitrow started