Sound: playing arbitrary waveform

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:

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!

1 Like

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.

You could also use minim which is already included with processing 2 and above if i am correct.

1 Like

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.

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!

1 Like