Wednesday, 29 August 2012

Most complex modulation equation yet ...

Demo / meeting in 5 hours (well, it's a meeting but one simply has to show off one's baby in its best light), have not debugged this yet (as in, still digesting breakfast, considering second caffeine jolt of the day, have not yet plugged in the AXIOM), but this is what the revamped current PITCH equation for TEMPLATE 3 looks like.

28 - TWENTY EIGHT?!?! - terms for PITCHB to give it some interesting movement relative to PITCHA. With both LFOs contributing to the overall pitch modulation. Yikes. This could sound

a) horrible, like a rhythm-free drunk bashing an empty oil drum over the head with a plugged-in Les Paul
b) it could evoke the sound of heaven, 1,000 angels dancing on the head of a pin in perfect ratiometric circles, weeping shimmering silver tears of joy at the harmonic exquisiteness of it all. Whilst smiling and playing with lambs and baby bunnies and eating Cadbury's Flake in a field of cornflowers and Red Admirals.

My money's on A not B.

// PITCH 3 
// A modulated by LFO0 * MODWHEEL range +- 0.5 semitones
// B modulated by LFO0 * MODWHEEL plus - CC4 either gentle detunes (<0.5) * LFO1 modulation
//   ... or gross uptunes (>0.5) by up to 5 semitones
RECIPE PITCHA  LFO0 0.5 sub 0.1 mul MOD mul done
RECIPE PITCHB  CC4 0.5 sub clamp 2.0 mul 0.5 CC4 sub clamp -1 mul 0.2 mul 0.3 mul LFO1 mul add LFO0 0.5 sub 0.1 mul MOD mul 

As I said, not yet debugged so there's so much could be wrong with this. There's a good chance a short video will follow. Also I need to be careful with modulation, even with simple programs of 5 or 6 terms the 'updateModulation' function was consuming >10% of the cycles when run on the Mac.  I don't have the 'skillz' (as the kids say) to measure live CPU usage on Linux ... proper, full-on professional Linux developers have been known to call me a right wuss for daring to develop in the warm safety of my Mac.


  1. You can use the "top" command to see cpu usage of various processus under Linux!

  2. Dude, I'm not *that* dumb! Well, maybe ... but AFAIK there isn't a simialrly simple way to see a similar CPU load graph for threads within a process - this thing is very heavily threaded.

  3. Well, I obviously *am* that dumb - will try me a top -H in the morning, thanks for the tip, and 'man top' would have been a smart move a couple of days ago ...

  4. nice project. What language are you using?

  5. For the modulation it's not a language as such - it doesn't represent a Turing machine for sure - it's just a bunch of tokens/keywords and a lexer that turns everything into bytecodes, then a trivial interpreter using (as you would expect from a reverse Polish notation) a stack-based execution engine. Which is only about 20 lines of C++.

    I did something deeply awesome and brainwavy last week - feeling really proud of myself and my apparently mighty brainwaves I decided to remove the if / switch from the interpreter and perform a 'compile', substituting function pointers for bytecodes and absolutely trivializing the execution of modulation recipes. Genius. Just like Forth. Hence it will fly. I am awesome. etc.

    Sadly this amazing optimization resulted in a 20% degradation in modulation performance. And it wasn't just an X86 being useless at being asked to do such a RISC-centric thing, I ran it on the Pi, similar droop.

    I hate it when that happens.

  6. Wow... I would lov e to see some of that code... This is very cool!