# Sound: playing arbitrary waveform

**URL:** <https://discourse.processing.org/t/sound-playing-arbitrary-waveform/20197>\
**Category:** Libraries\
**Created:** [April 27, 2020, 8:52am UTC](https://discourse.processing.org/t/sound-playing-arbitrary-waveform/20197 "2020-04-27T08:52:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eamoex](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@Eamoex](https://discourse.processing.org/u/Eamoex)\
**Post date:** [April 27, 2020, 8:52am UTC](https://discourse.processing.org/t/sound-playing-arbitrary-waveform/20197/1 "2020-04-27T08:52:15Z")

</div>

Hello, I make electronic music and I’m using a physical synth (Elektron Digitakt) which can take arbitrary single-cycle waveforms to create continuous sounds. For instance, as with the audio library of processing, we have the ability to “sound” a sine wave (i.e. “playing” a _single-cycle_ sine wave in an _extremely fast_ loop), this synth can take any arbitrary waveform and play it in the same way, allowing for complex harmonics/frequency spectrums.

Now I would like to build a sketch which allows me to graphically manipulate a custom single-cycle wave, i.e. instead of having a pure sine, to create a complex arbitrary waveform by morphing different wave shapes (sine, triangle, square) at different frequencies and phases. This part I can handle, see picture:

 ![wave3](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b7140b56342e82d7ba9ec1ed37bd7d33a3daf90e.png)

What would be nice is if Processing was able to actually “play” my arbitrary, graphic wave, just like it “plays” a sine with the audio library methods. So it would be possible to have a preview (or _pre-hear_?) of the audible harmonics of that custom waveform.

The waveform data is stored in a FloatList of 1024 samples, with max 1.0 and min -1.0. Is there a way to make this from here? I’m not necessarily thinking real-time sound synthesis, although it would be great. For example, writing a 2-second sample to disk from the arbitrary waveform and playing it on demand would be enough.

Any suggestions welcome!

---

<div class="post-metadata">

**Author:** ![Eamoex](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@Eamoex](https://discourse.processing.org/u/Eamoex)\
**Post date:** [April 27, 2020, 11:30am UTC](https://discourse.processing.org/t/sound-playing-arbitrary-waveform/20197/2 "2020-04-27T11:30:44Z")

</div>

Ooooooh. Oooh. OK.

Just found about the AudioSample class. It looks like it’s able to do what I’m looking for. I’ll check it out and report back.

EDIT: I have to say that searches for “sound” and “audio” on Processing’s Reference webpage did not return any result. I had to google “write sound file processing” to reach [the AudioSample class reference](https://processing.org/reference/libraries/sound/AudioSample.html).

---

<div class="post-metadata">

**Author:** ![tribblesontoast](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tribblesontoast](https://discourse.processing.org/u/tribblesontoast)\
**Post date:** [April 27, 2020, 11:57am UTC](https://discourse.processing.org/t/sound-playing-arbitrary-waveform/20197/3 "2020-04-27T11:57:35Z")

</div>

You could also use [minim](http://code.compartmental.net/minim/) which is already included with processing 2 and above if i am correct.

---

<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:** [May 3, 2020, 6:52pm UTC](https://discourse.processing.org/t/sound-playing-arbitrary-waveform/20197/4 "2020-05-03T18:52:54Z")

</div>

> [@tribblesontoast](#):
>
> which is already included with processing 2 and above if i am correct

minim is available through contributions manager – although it isn’t pre-installed. I’d recommend it for a project like this. Processing Sound is not primarily intended for synthesis – minim is.

[http://code.compartmental.net/tools/minim/](http://code.compartmental.net/tools/minim/)

---

<div class="post-metadata">

**Author:** ![Eamoex](https://avatars.discourse-cdn.com/v4/letter/e/e495f1/32.png) [@Eamoex](https://discourse.processing.org/u/Eamoex)\
**Post date:** [May 4, 2020, 8:18am UTC](https://discourse.processing.org/t/sound-playing-arbitrary-waveform/20197/5 "2020-05-04T08:18:09Z")

</div>

Indeed. Minim looks the part. I only ever used it for spectrum analysis/Fourier transform, but synthesis looks great, in particular in version 2.2.2 with the uGens objects. Thanks for the heads up!
