Load sound files in PureData

Hi! Lich is coming to the family next weekend, so I’m starting to “study”!
My question is simple. Can I upload a sound file like .wav to the Lich or only patch files?.
To put it simple, can I program a pd patch that plays a file? I know you can store audio in a buffer so I think this is very possible.

I’m hope it does because it’s one of my projects. Not just a player, but a patch working with sound files.


[edit] I reading the list of supported pure data objects and I can’t find the object [open] so I’m loosing hope…

Hello @atk90x ,

You can upload files on devices as a part of firmware functionality, but your question is really about playing them rather than uploading.

Currently we support WAV playback from patches written in C++ and in FAUST. It’s very likely that PD/gen~ will get support for this eventually too.

As you probably have realized, we can’t use the same PD environment that runs on desktop, but rather a compiler called Heavy (HVCC), since it has to run on a microcontroller. That compiler was developed by third party as a closed source product, abandoned and published under open source license later. We’re using a forked version of that that adds some feature that OWL needs, but there’s no active development going on our side. However, upstream HVCC was later picked up by another developer who is on forum here - @dreamer . There’s currently some ongoing work that would allow us to switch to his fork of HVCC. I think that there’s a good chance that WAV playback could be added after that.

I would add that we’ve discussed this a bit in the past and WAV playback is likely the most wanted addition to PD. Currently you have 8 Mb of external flash that could be used to store files. But we’ll probably add support for reading for files from USB drives too.


It might be possible to load such files into a Pd table, from the wrapper side.
Actually implementing something like [readsf~] would be pretty daunting to do for all supported targets and I honestly don’t know where to start.

Any ideas for this are welcome in the discussions page over on https://github.com/Wasted-Audio/hvcc :wink:

Thank you very much for the info! I guess I can’t leave completely my Bella yet…
Anyway, how would be the procedure to load sound files as you said (firmware functionality)?
Just to leave this post for future generations :slight_smile:
Thanks for your efforts @dreamer and @antisvin

On OWL side (in C++), we have necessary code to read WAV files and output decoded audio in float format to a buffer.

I’ve read a bit about how readsf~ works and it looks like that object is also acting as a player that you can control. It certainly looks complex. However there seems to be approach that looks more suitalbe for us:

This is basically the same “read file into table by name” that is well supported in C++. Obviously this loading should only be done when the patch loads and not in runtime. Would be curious to hear how realistic it sounds from HVCC side.

There’s ongoing work for a resource manager that would let you do it in the browser. It’s in its final stages currently.

Also, uploading by MIDI is also possible after encoding it in SySex data.

1 Like

Yup, pretty much what I was thinking. Have the wrapper load the file into the special table when loading the patch.

Certainly not a runtime thing indeed. And still plenty of mechanics to figure out here (preferably something that works outside of OWL too), but should be doable at least.

It’s also possible to include a short sample in the patch itself, saved as an array within Pure data.
I believe this is an example

The tables are in the wavetable subpatch.


Hmhm, but the question was specifically about loading them from flash storage. That way one could replace the files at a later date without having to rebuild the entire patch. I see some use in that.

How does Bela do it these days? They used to have some system where you modified a bit of C++ code (render.cpp probably) to pre-load data into tables that could then be accessed from Pd.

edit: bits of info here pd heavy preset handling (with tables) - Bela
edit edit: this is what I was looking for Large Arrays & Enzien Heavy - Bela

Exactly! I’m experimenting with text/speech/poetry using several little samples (words) and scrumble them. @mars I don’t know about Bela/C++ but with Bela/Pd you just throw the files to the IDE (I’m sure you already know this, just in case :wink: )

As a summary:

  • soundfiler object accepts a message that contains one or more (comma-separated) read commands
  • each read command includes an optional -resize flag (resizes table, otherwise we limit amount of read samples to table size), file name and table name
  • we have the necessary code for parsing WAVs on OWL
  • Bela uses libsoundfile for parsing and it’s portable, the same implementation probably can be reused for most HVCC backends
  • loading data into tables can be reused from Bela and likely would be the same for all HVCC backends

So the missing bit is to add support for soundfiler object in HVCC. I suppose that its needs to parse the read commands and add an array of resize + filename + tablename to context. But we already could make a POC implementation that uses hardcoded list of files.

I’ve also noticed that vanilla PD outputs loaded data size in soundfiler’s outlet. Not sure if we can implement this, but it’s likely not a very important feature.

A post was split to a new topic: Loading resources in gen~