Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Extension that converts lists into audio
- ametrine_
-
Scratcher
1000+ posts
Extension that converts lists into audio
i'm working on an offsite project that can generate audio using lists, and i need to make an extension that can play those lists as audio. i know how to get the list as an argument, but i'm having trouble finding a method to play sound that will work with scratch. i'm also unsure what method the “play sound” blocks use. any ideas?
Last edited by ametrine_ (Yesterday 20:07:58)
- Jonathan50
-
Scratcher
1000+ posts
Extension that converts lists into audio
https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API
https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer#example
TL;DR seems the result of getChannelData is mutable.
You can look at the code for scratch-audio; it's not very long (SoundPlayer.js actually makes an AudioNode and plays sounds, and AudioEngine.js has code for making AudioBuffers to be played)
https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer#example
TL;DR seems the result of getChannelData is mutable.
i'm also unsure what method the “play sound” blocks use.You would need to do something slightly different given when Scratch plays a sound, it's from a preexisting file rather than just a list of samples (of amplitude). But playing is exactly the same.
You can look at the code for scratch-audio; it's not very long (SoundPlayer.js actually makes an AudioNode and plays sounds, and AudioEngine.js has code for making AudioBuffers to be played)
Last edited by Jonathan50 (Today 06:23:30)
- Discussion Forums
- » Advanced Topics
-
» Extension that converts lists into audio