Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add save() and saveBlob() methods to SoundFile. Move .wav conversion to helpers.js #315

Merged
merged 2 commits into from
Aug 18, 2018

Conversation

therewasaguy
Copy link
Member

  • move .wav conversion from p5.SoundRecorder to helpers module
  • add save and saveBlob method to SoundFile
  • document the global saveSound method (it was listed under p5.SoundRecorder but is actually part of p5.prototype)
  • p5.SoundFile's saveBlob method can probably replace the global saveSoundAsBlob added in Added saveSoundToBlob() to soundRecorder.js #312@wahengchang does this sound like a good approach to you?

@wahengchang
Copy link
Contributor

I think most of the users have the needs of sound preview, sound synthesis or wave visualization. so I think we need the blob url for preview sound, and the blob object to manipulate sound:

  • saveFile() // as savefile() p5.sound.js already have
  • getBlob() // return a blob object, which is going to use to upload file (may be S3, or google cloud)
  • getBlobUrl() . // temporary usage, such as sound preview, sound synthesis, or preview sound wave

getBlob()

  p5.SoundFile.prototype.getBlob = function() {
    const dataView = convertToWav(this.buffer);
   return new Blob([dataView], { type: 'audio/wav' })
  }

getBlobUrl()

  p5.SoundFile.prototype.getBlobUrl = function() {
    const dataView = convertToWav(this.buffer);
    const audioBlob = new Blob([dataView], { type: 'audio/wav' });
    return URL.createObjectURL(audioBlob);
  }

@therewasaguy
Copy link
Member Author

Thank you @wahengchang! I like getBlob that's a better name than saveBlob. I wonder if it is really necessary to have getBlobUrl if the audio is already in a SoundFile, maybe we can let users do that with URL.createObjectURL on their own if/as needed?

@therewasaguy therewasaguy merged commit dd0779e into processing:master Aug 18, 2018
@wahengchang
Copy link
Contributor

agree, getBlob() is good enough !

@therewasaguy therewasaguy mentioned this pull request Sep 8, 2018
mrjoshida pushed a commit to mrjoshida/p5.js-sound that referenced this pull request Sep 30, 2018
* 'master' of ssh://github.com/mrjoshida/p5.js-sound:
  rebuild lib
  dispose of ConvolverNode before resetting buffer (processing#321)
  rebuild lib with reference example fix processing#320
  move loadSound call to preload
  prevent crashes during completion of callbacks on disposed SoundFiles
  0.3.9
  add soundfile.save example
  add `save()` and `getBlob()` methods to SoundFile. Move .wav conversion to helpers.js (processing#315)
  Added saveSoundToBlob() to soundRecorder.js
  Document properties of AudioIn
  update master limiter - sharp knee
  monosynth: remove unused _isOn
  monosynth: remove unused filter, patch velocity
  Missed this fragment during the renaming
  corrected formatting by replacing tabs with four spaces
  fixed issue: processing/p5.js-sound#297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants