Pure Data to Teensy C++ Code

I'm wondering if anyone on the forum has experience converting Pure Data code to C++. I'm not a Pure Data user, but have been using MaxMSP, which was also created by Miller Puckette, and is quite similar to pd, though now far more extensive (MaxMSP and its company Cycling 74, which some years back was sold to Ableton).

PD itself runs on most modern platforms and OSs (Mac, Linux, Windows, ...) and there are gobs of PD patches available on the web. And there is a compiler called Heavy Compiler Collection (hvcc) that can convert PD "patches" to C++ code. There are apparently a number of versions out there, some of which require Python, others Visual Studio, and a host of other installed components for support; most promising is an online version (https://www.rebeltech.org/2018/09/12/compile-pure-data-patches-with-free-online-heavy-compiler/) which avoids such requirements and dependencies. MaxMSP itself now includes a utility "gen~", a $200 paid extra, which supports multiple output formats including C++, but unfortunately requires the use of XCode, with its steep learning curve.

I'm presently designing a new Teensy 4.1 audio device (much more on this to come) with an open architecture, and have left an open slot for a 3rd efx processor (currently has stereo reverb and ping-pong delay). There are a number of PD patches I've come across that would be an excellent choice (for example this granular processor:
). And there are likely scores of pd patches that would also be great on Teensy 4.1.

Admittedly, there are issues to be worked out, as the C++ produced by hvcc will not be Teensy-specific. But I'm assuming these can be dealt with and adapted to the Teensy Audio environment. I'd very much appreciate any comments or suggestions from forum users who have experience in this regard, especially anyone who has actually converted a PD patch for use on Teensy.
 
Any updates? I'm also looking into this. It should be possible to run a pd/hvcc patch on teensy, but I haven't seen it done. I killed my teensy accidentally lol so I can't try to do it right now but I'll probably get on it eventually.
 
Hey there, I currently maintain HVCC over at https://github.com/Wasted-Audio/hvcc

It is most certainly possible to use the exported C/C++ code on Teensy as we've had several users do this in the past.
The reason that we don't target Teensy directly (with something we call a "generator" that wraps the code for a target platform) is because there is no clear platform with middleware for it (like OWL and Daisy for STM32).

If someone has a dedicated product and code library for this I'd be happy to investigate how to integrate with it. Otherwise you will have to create your own custom integration for your project.

The main things you'll need are setting up a Heavy context instance, a `process()` function that handles your audio buffers, calls to send control data to internal receivers, and optionally callback functions for sending out control data and print messages (useful for serial debugging). MIDI I/O is handled similarly.

The API is described in the online documentation: https://wasted-audio.github.io/hvcc/latest/reference/c/
 
I'm wondering if anyone on the forum has experience converting Pure Data code to C++. I'm not a Pure Data user, but have been using MaxMSP, which was also created by Miller Puckette, and is quite similar to pd, though now far more extensive (MaxMSP and its company Cycling 74, which some years back was sold to Ableton).

PD itself runs on most modern platforms and OSs (Mac, Linux, Windows, ...) and there are gobs of PD patches available on the web. And there is a compiler called Heavy Compiler Collection (hvcc) that can convert PD "patches" to C++ code. There are apparently a number of versions out there, some of which require Python, others Visual Studio, and a host of other installed components for support; most promising is an online version (https://www.rebeltech.org/2018/09/12/compile-pure-data-patches-with-free-online-heavy-compiler/) which avoids such requirements and dependencies. MaxMSP itself now includes a utility "gen~", a $200 paid extra, which supports multiple output formats including C++, but unfortunately requires the use of XCode, with its steep learning curve.

I'm presently designing a new Teensy 4.1 audio device (much more on this to come) with an open architecture, and have left an open slot for a 3rd efx processor (currently has stereo reverb and ping-pong delay). There are a number of PD patches I've come across that would be an excellent choice (for example this granular processor:
). And there are likely scores of pd patches that would also be great on Teensy 4.1.

Admittedly, there are issues to be worked out, as the C++ produced by hvcc will not be Teensy-specific. But I'm assuming these can be dealt with and adapted to the Teensy Audio environment. I'd very much appreciate any comments or suggestions from forum users who have experience in this regard, especially anyone who has actually converted a PD patch for use on Teensy.
Have you tried feeding the code into ChatGPT? It does a wonderful job doing just this, I've used it a lot for my Teensy 4.1 project.
 
Hi, I am developing hvcc based Pure Data audio platform for RPi Pico devices called PikoPD. These little couple $ fellas can run interesting pd patches converted to C++. It supports different periferals, sensors and midi (serial, usb, midi host). Also there are some experimental features like OSC message sending over wifi to control pd patch running on the device.

https://github.com/ledlaux/pikoPD

It was inspired by Daisy Seed platform. You can define your pins in a simple json config file (or interactive webtool) and build system generates firmware from the code template. It's simple and maybe can be ported/adapted to Teensy.
 
Last edited:
Back
Top