Adapting Mutable Plaits source code to genexpr

.quasar's icon

Mutable recently released the source code for their new oscillator module, Plaits. I'm trying to adapt the Grainlet Oscillator section (big fan of its granular formant engine) but so far I haven't had any success.

Basically the oscillator is described as "A phase-distorted single cycle sine * another continuously running sine,the whole thing synced to a main oscillator". Also there is some antialiasing using the polyblep method.

I've managed to adapt the Carrier() and Grainlet() functions but I keep on failing at adapting the part of the code where the functions are put together and the polyblep method is used.

Anyway, here's my whole adaptation (the whole source code is also included) if a kind soul happens to have the time to take a look at my adaptation.

Note : subsample() and Next() only seem to refer to the interpolation routine used for the params so I've not adapted them. Also, carrier_phase_ / formant_phase_ / next_sample_ are supposed to be oscillator state variables.

plaits_grainlet.maxpat
text/plain 35.80 KB

.quasar's icon

Ok, so I've corrected a few mistakes here and there and now the whole code works. However, my issue now is that I don't really see any difference between the whole adaptation using the polyblep method and a simple naive adaptation only using a synced Grainlet() function.

Quite sure I'm missing something... Here's the patch anyway

EDIT : now I do see the difference, definitely cleaner at high freq.

plaits_grainlet_2.maxpat
text/plain 36.11 KB

.quasar's icon

Here's another model I adapted from the Plaits source code, the variable saw oscillator .

I think it used to be called Csaw in Braids. Anyway, I quite like it, kinda reminds me of the variable saw on the Minilogue.

Variable Saw Oscillator plaits.maxpat
text/plain 39.13 KB

.quasar's icon

Thanks a lot ;) Will definitely try a few other ones.

.quasar's icon

Next is an adaptation of Plaits' VOSIM model. It's actually one of the only oscillator model not using polyblep antialiasing so it could be worthwhile to use poly~ to oversample it.

Here's the example patch with the model plus a quick and dirty proto sequencer.

plaits_vosim.maxpat
text/plain 177.32 KB

volker böhm's icon

yes, great stuff! keep it coming.
btw. if anybody is interested in this: i've started a project to incorporate the whole plaits system into a max external. It's coming along quite nicely, there's only one nasty problem left which keeps me from finalizing the thing.
here's a little sound demo:
https://soundcloud.com/geplanteobsoleszenz/firstplaits


.quasar's icon

@Volker Böhm : That's really cool ! Indeed I would be quite interested :) Any chance the project would eventually be available as a x64 Win external?

It's actually quite fun adapting the C code to genexpr. Braids' code was harder to translate into genexpr but Plait's is easier. I'll post my next one soon I hope!

volker böhm's icon

@.quasar: i'm on osx and can't compile for windows, but if i finish the project, i'll make the source available.

.quasar's icon

Thanks that'd be great ! ;)

Trying to adapt an entire engine now, tried a few times with the Additive / Harmonic Oscillator engine. Haven't succeeded yet but I'm not giving up!

.quasar's icon

Here's a loose adaptation of the additive/harmonic engine (still haven't managed to do a strict adaptation of the source code). Anyway I figure a way to implement the centroid / spectral bump and I had a bit of fun using mc.gen~. You'll need both the gendsp & maxpat files.

mc_harmonic.maxpat
text/plain 110.66 KB

mc_harmosc.gendsp
gendsp 17.59 KB

volker böhm's icon

for a macos alpha version see this post
https://cycling74.com/forums/-sharing-mutable-instruments'-plaits-module-macro-oscillator

.quasar's icon

Your post motivated me to share a new adaptation, this time of the "aux" output of the Waveshaper Engine (Slope/Triangle => Waveshaper => DiodeRingMod lookup table)

It is not a 100% faithful adaptation, I took a few liberties here and there (the oscil is yofiel's LTR asymmetric triangle, there are 4 params in the shaping section instead of just 3, i implemented myself the scaling functions for the gain compensation and indices instead of using the source code's taming function)

However, I'm using exactly the same shapers. I've exported the tables directly from the python code. Tell me if you're missing any abstraction, it's reasonably large patch so I might have forgotten to include something.

diode ringmod/folder lut

bump waveshaping lookup table

double bump waveshaping lut

inverse sin waveshaping lut

inverse tan waveshaping lut

Max Patch
Copy patch and select New From Clipboard in Max.

.

.quasar's icon

Here's an updated version of the patch, I realised I missed a sign inversion of the signal just before it was sent to the Diode/Folder. Like the last patch you'll need to have the waveshaping lookup tables downloaded and put in your library folder.

Max Patch
Copy patch and select New From Clipboard in Max.