Сохранить звуковой файл на сервере

Работаю с p5.sound.js. Необходимо сохранить .wav файл на сервер, или просто вывести записанный аудио-сигнал через тег audio. Вместо этого файл просто скачивается через браузер.
var mic, recorder, soundFile;

var state = 0; // mousePress will increment from Record, to Stop, to Play

var mic, recorder, soundFile;

var state = 0; // mousePress will increment from Record, to Stop, to Play

function setup() {
  createCanvas(400,400);
  background(200);
  fill(0);
  text('Enable mic and click the mouse to begin recording', 20, 20);


  mic = new p5.AudioIn();

  mic.start();


  recorder = new p5.SoundRecorder();


  recorder.setInput(mic);


  soundFile = new p5.SoundFile();
}

function mousePressed() {

  if (state === 0 && mic.enabled) {


    recorder.record(soundFile);

    background(255,0,0);
    text('Recording now! Click to stop.', 20, 20);
    state++;
  }

  else if (state === 1) {
    recorder.stop(); // stop recorder, and send the result to soundFile

    background(0,255,0);
    text('Recording stopped. Click to play & save', 20, 20);
    state++;
  }

  else if (state === 2) {
    soundFile.play(); // play the result!
    saveSound(soundFile, 'mySound.wav'); // save file
    state++;
  }
}

Комментарии

Популярные сообщения из этого блога

Skipping acquire of configured file 'contrib/binary-i386/Packages' as repository … doesn't support architecture 'i386'

Connection string for MariaDB using ODBC

Celery like system based on django channels