P5.sound playing sound from samples


#1

Hi,I have an image of sound wave,and I want to make it play using P5.js.


So I sample it then I get a number array ,like {0.51,0.52,0.43…}. Is there a way to play the sound using P5.js from the array,or should I do FFT and use multiple sine oscillators to play the sound?


#2

I don’t have experience with this, but I would imagine at the very least you could map your array of values to midi tones and use midiToFreq to rapidly run up and down the scale.

https://p5js.org/reference/#/p5/midiToFreq

Or you could continuously adjust an oscillator – I see some other options in the p5.sound reference: https://p5js.org/reference/#/libraries/p5.sound

Are you trying to play that curve over the course of e.g. 1-5 seconds, or are you trying to play it in like 0.05 seconds?