# P5.sound playing sound from samples

**URL:** <https://discourse.processing.org/t/p5-sound-playing-sound-from-samples/4414>\
**Category:** Libraries\
**Created:** [October 13, 2018, 4:04am UTC](https://discourse.processing.org/t/p5-sound-playing-sound-from-samples/4414 "2018-10-13T04:04:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![a931eric](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@a931eric](https://discourse.processing.org/u/a931eric)\
**Post date:** [October 13, 2018, 4:04am UTC](https://discourse.processing.org/t/p5-sound-playing-sound-from-samples/4414/1 "2018-10-13T04:04:47Z")

</div>

Hi,I have an image of sound wave,and I want to make it play using P5.js.  
 ![%E6%9C%AA%E5%91%BD%E5%90%8D](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d87ece2a6ed9c1767f7d97774fed36468d95ae23.png)  
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?

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [October 24, 2018, 7:04pm UTC](https://discourse.processing.org/t/p5-sound-playing-sound-from-samples/4414/2 "2018-10-24T19:04:48Z")

</div>

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](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](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?
