[PD] Loading arrays with arbitrary wave forms

David dfkettle at gmail.com
Thu Apr 10 02:48:15 CEST 2014


Thanks again to everyone that replied. I looked at the examples, but to be
honest I didn't really understand them completely, and I got a few error
messages when I tried to run them. I have pd-extended installed, but maybe
I'm missing some externals used by the examples. Anyway, I decided to go
with plan B, and use another software package to generate sound files and
then load them into PD. I'm using Octave, an open-source math program that
is mostly compatible with Matlib. It has some built-in functions to read
and write audio files (mono only), but I can generate audio files in just a
few lines of code, like this:

  x = linspace(0,2*pi,1024);
  y = sin(cos(sin(x) * pi) * pi);
  plot(x,y);
  title('y = sin(cos(sin x) * pi) * pi)');
  wavwrite(y,44100,16,'C:\\Data\\Octave\\sincossin.wav');

The first two lines generate the data (1024 samples in length), the next
two lines draw a graph in a separate window, and the last line writes the
data to a file. I really recommend it if you want to generate audio samples
using math functions.

Then I load the file into PD with the attached patch. Since I know my files
are 1024 samples long, I can just allocate an array of the correct size and
not have to worry about complications.

I attached my patch and a sample file (generated using the code above) if
you're interested.

David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20140409/b59d435d/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sincossin.wav
Type: audio/x-wav
Size: 2092 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20140409/b59d435d/attachment-0001.wav>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: load_file.pd
Type: text/x-puredata
Size: 1471 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20140409/b59d435d/attachment-0001.bin>


More information about the Pd-list mailing list