vult-dsp / vult

Vult is a transcompiler well suited to write high-performance DSP code
https://vult-dsp.github.io/vult
Other
490 stars 25 forks source link

Converting PD examples to Teensy #26

Closed zs-sz closed 5 years ago

zs-sz commented 5 years ago

Hi there

Is it possible to convert the PD examples to teensy objects? I tried it with the ladder filter but no matter what I do it always throw some errors (not enough args in the Process func for a start).

If its possible could you point out what needs to be removed in general? Also I resolved the missing util refs by simply copying the relevant functions which probably not the best solution (but I can totally live with it if it works).

Thanks in advance!

zs-sz commented 5 years ago

I've managed to compile the ladder.vult file by removing the extra args and defining them in process based on the phasedist.vult example. However if I patch the filter after the oscillator I got no sound at all.

edges:

SynthTest voice; LadderFilter filter1; AudioConnection patchCord0(voice, 0, filter1, 0); AudioConnection patchCord1(filter1, 0, i2s1, 0); AudioConnection patchCord2(filter1, 0, i2s1, 1);

Am I doing something wrong?

modlfo commented 5 years ago

There's a problem in the 0.3.x version of the Vult compiler when generating templates for the Teensy. It only works for sound generators. I think I fixed the problem in the branch 0.4 but I haven't made a release yet.

If you are proficient in C++, it's possible to fix the problem manually. It's necessary to request the input buffer, take a look at the example in https://github.com/PaulStoffregen/Audio/blob/master/effect_chorus.cpp#L70

I'll need to run a more extensive testing of the v0.4 before releasing. Specially in the template generator part.

modlfo commented 5 years ago

I have to add that not all the PD examples are possible to convert (in efficient code) to the Teensy 3.2. Some of the examples require numeric calculations using floating point. In order to be efficient in the Teensy 3.2 the numeric calculations need to be in fixed point.

When generating the code in fixed point, if an example is not possible to convert, you will get an error saying that a number cannot be represented in fixed point.

zs-sz commented 5 years ago

@modlfo Thanx for the help once again. I'll try to modify the transpiled code.

The floating/fixed issue you mentioned still applies for the teensy 3.6? I checked this post yesterday: https://forum.pjrc.com/threads/38325-Excellent-results-with-Floating-Point-FFT-IFFT-Processing-and-Teensy-3-6

For a last favor could you point out which example is the the most likely to fail, so I could give it a try? I'll post the results if its any use to you(or others).

modlfo commented 5 years ago

They should run fine with floating point in the 3.6.

zs-sz commented 5 years ago

Cool. Thnx