Tuesday, 2 December 2014

Morphing wavetables

Caitlin 'ooh' => Caitlin 'aah' => Caitlin 'eeh' => Oboe - 4 wavetables being morphed, showing 4 complete cycles in total, sort of a complete single cycle of each if only the morphing weren't making it confusing.

Fragments of Caitlin and Tron oboe were captured - because I had them on my iPad right next to me - upsampled 32x then auto-correlated to find extremely sub-sample accurate loop points, then resampled to become wavetables of 1024 samples in length, stored as shorts. This process is pretty automated now. At 1024 samples long the tables support frequencies down to 43Hz without stretching, and 8 progressively filtered octave tables are used for antialiasing letting me reach up to 5500Hz, higher than the fundamental on a piano can go I think.

During the inner loop 2 octaves of 1024 shorts from 2 wavetables form the working set, which is unfortunately 8kbytes / 2 pages of data, which may bust the data cache on really crappy hardware that has a 4k L1 and no L2 - not sure what the cache organization is on the Pi ... actually, it must be more than this or it just wouldn't run at better than a snail's pace. But I don't want to drop to 512-sized tables or things will get muddy and interpolated in the nice 'fattest string of a 4-string bass guitar' region where you want some top end to still be there.

This is effectively exploiting MIP-mapping in audio, but not the Lance Williams pyramidal thing, all tables are the same length as it makes the addressing easier / more efficient. The inter-level filtering is all done in the time domain, the pyramidal MIP levels (filtered down using a 'nicer than rectangular window' filter) form the skeletal sample framework upon which the full-length 1024 wavetable at each octave is regrown via a simple cubic interpolator / SRC thing. The strongest positive-moving zero transition is lined up at sample location zero, as I need to have zero be a reliably click-free point. Everything is implemented in integer / fixed-point for all sorts of sensible reasons.

It has to date only run on my Mac, but should synthesize PDQ on even very slow hardware, and the 4-wave morph will allow for some nice movement / evolution over time, particularly with A, B and C oscillators evolving or cycling at different rates, different feet.

So this project now has 3 synths. The virtual analog PIANA, the sample replay PIANATRON, and this freshly-minted 'pure digital' wavetable synth, as-yet nameless. Names on a postcard please ... but the ANA bit of PIANA isn't relevant here as it is indended to be filterless / pure digital. I wonder how long before I back off on that and get all Moogy on its sorry little ass ...

Monday, 1 December 2014

Picture in the Paper

A couple of weekends ago I took part in an art thing in Bath, where local people who 'did stuff' were called together, based on 'the stuff' they do, to have a group portrait taken. 'Stuff' involved people who live on houseboats, people who keep bees, people who play Minecraft, people who look after the sick, and in my case people who lash together truly awesomely, insanely great things using the superpower of software development. My wording, not theirs. They seemed to think we were just 'software developers'.

Remarkably, for a city that just had a whole digital festival, a mere 4 people rolled up to have their picture in the paper. And no girls. Shame on you, Bath - try harder next time!

This photo is scheduled to spend the next 100 years in the new ICA Centre for the Arts building at the University of Bath, which looks like a truly brilliant facility.

Here's the picture. Isn't the dog CUTE?!?! And also, as my wife just pointed out, with the jacket on I look like somebody's dad who wandered into shot, with all the proper software developers - Bill and Ted shirt, big metal hair, massive comic book collection (check), truly awesome All Your Base script T-shirt (check), brilliantly executed combo of skinny jeans, hipster uniform, post-Beatles haircut, girl-conquering smile and INSANELY CUTE DOG (check) - lined up on my left. Then this grey-haired bloke in a jacket totally letting the side down. I just wish we'd had some women to balance it up, it adds way more fuel to my STEM Ambassador fires.

Big thanks to Claire Sharpe and everyone at LOW PROFILE, and everybody else in Bath and Plymouth who contributed to making this happen, and I am so looking forward to the party in February. Yay! 

p.s. here's our collective mugshot for identification purposes - 

Wednesday, 19 November 2014

Being Boiled now works with no overclocking - without using goto!

Now THAT is a pleasant surprise. Some giant CPU spikes but heck, the GUI is running in the background. And no timing hiccups. Pretty immense at 700MHz.

Some of this may be because the oscillator got an update today - it had been nagging me at the back of my head, and I decided I needed to scratch the naggy itch. I had been rather perversely proud of the fact that the inner loop oscillator function had 12 goto statements in it. I love using goto in C++, so many times it delivers the most elegant, highest-performance solution, and I added the new tweaklet, and smiled at all those lovely gotos and labels. Lovely, lovely little things they are.

Then I realized that the most recent tweak had in fact - THE HORROR - left an opportunity to remove all the gotos, with no performance degradation.

So I did. And here we are - a goto-less oscillator, running Being Boiled with no hiccups at a mere 700MHz. Neat. But I will miss them.

Thursday, 13 November 2014

Great STEM event at BTE Academy, Bristol this week

I think some of the poor students lost the will to live during my little presentation (NOTE TO SELF - cut out 2/3 of the slides and get to the noises MUCH FASTER next time, OK?) but generally a success. The teacher, Miss Wilson, was great, the youngsters were peachy keen, and we talked and played synthesizers.

And the synthesizers sounded just like this - you have to love a nice synthesizer!

Two really great questions - "Do you make a lot of money" (somebody ALWAYS asks that - my stock answer - "I used to, but not any more!") and then the winner, "Do all synthesizers use exclusively sin waves to make their sounds?" - which was a GENIUS question, and sadly I went on a bit about Fourier analysis in order to hedge my answer. Which was "Yes, and no - let me explain something ... "

Friday, 31 October 2014

The iPad just got eliminated from my portable STEM kit

I no longer need to drag an iPad with me on my STEM Ambassador school visits - although I probably will anyway, just for the heck of it - because the Pi itself is now running an oscilloscope. 

Running it at 60 FPS as well, at least at PAL 576i and 480p, I need to check how well I cope with the increased slug on memory bandwidth due to 720p. This is while running 6 PIANA synth instances, 4 stereo delays, a global reverb, and a copy of CodeSequence. Neat, eh?

The oscilloscope here is showing a stereo trace, and this is automagic - if I detect that the signal being generated is 'pretty much' mono, the two traces gracefully collapse back into one. So I can fire up the engines, play a synth with a sin, a saw, a square, show and listen to the different waveforms with a nice, clear single waveform on screen, and educate the kids. Yay!

This is now a demonstrable complete package for music composition, arrangement and performance, plus it has flashy, fast, OpenGL-accelerated, eyeball-melting visuals to go with its quite brilliant sound quality. Push this out to the projector behind the band and you have instant synthpop live rig. Note 'demonstrable' is a long way from 'releasable' so hold your horses out there, I need to secure funding before this can get finished, any ongoing work right now is purely in support of STEM outreach, rather than preparing for a release.

And it's not just flashy visuals for eye candy either, this is valuable for diagnostic work - I fixed a synthesis bug yesterday in about 2 minutes, which I only diagnosed by having this display running. I could see the waveform glitching in phase at an 'interesting' point in the wave, which instantly showed me where the problem was and identified an annoying and occasional little 'zip' in the audio. Worth its weight in gold, this bit of code. 

And the coolest bit is, the sequencer is a whole different application to PIANA, but if it tries to connect to PIANA and it finds it isn't running it launches it anyway, so I only need to boot the Pi and fire up the sequencer. 

As you can tell by the rather graunchy and bitty quality of the visuals, there is no photoshopping here. Actually there is a bit, I never post a makeup-free selfie, dahlings - but this image is, apart from removing a few specks of dust from the screen and playing with levels, exactly what I could see as the display was running. It looks GREAT, way better in motion that static, but stills don't do it justice. I know that for a fact, I took about 50 over a 2 minute period and only this one gave a decent impression of how amazing this thing looks. Even video doesn't do it justice, unless you can grab 720p60. 

In case you forgot, this is what is was playing - 

Saturday, 25 October 2014

Raspberry Pi Halloween project at the Lost Gardens of Heligan!

This is brilliant, so I have to write about it, plus I had absolutely nothing to do with it, so I'm not blowing my own trumpet.

We met Stuart Pemberton about four weeks ago when we were installing some art at the Lost Gardens of Heligan. Stuart is an electrical contractor at Heligan, and as we cut and trimmed wires, discussed onions, went up and down ladders (him, not me) and shot the breeze our common Raspberry Pi interest came up. Unlike me with my 34 long years of coding experience, Stuart is strictly a wires and volts guy, and had not yet written a line of code in any language. But he had stepped up to the plate in a big way and volunteered to get to grips with enough Python to put together a hardware / software project for Heligan Halloween - an interactive exhibit with infra-red sensors, audio playback and owls. And I like a nice owl, so I thought the whole thing was dead cool, and was very interested to hear how it all went on.

And here we are, four weeks later, back at Heligan to deinstall some art, and flipping heck, he's only gone and done it! Dude!!! In a remarkably serendipitous bit of timing,  Stuart had just finished attaching the final wire and run the final tests when we bumped into him at lunch yesterday, so we had to take a look.

There's a grey box with a Pi, an audio amplifier, a PIR sensor to detect passing warm bodies, and a loudspeaker up a tree. Some Python, an OMXplayer, a recording of a tawny owl hooting, and hey presto, instant Halloween attraction, with passing children enchanted by the hooting owl and wondering a) where it is and b) how come it hoots every time they walk by. Brilliant!

Here he is with his baby - the Pi, PIR and audio amp are in the grey box, hidden under leaves, the pair of 12V batteries powering the whole thing are also hidden under leaves slightly out of shot to the left.

Here's a badly-shot video of the thing - if you listen carefully the owl hoots a couple of times during this. 

This forms part of the Heligan Halloween celebrations, running from now until November 2nd (that's 2014 if for some reason you are reading this in the far future). It is along the Woodland Walk, not too far from the Mud Maid and the Giant's Head, and also close to an excellent and a wee bit creepy child-sized spider's web installation. So jump in the car and head for Cornwall right now. 

UPDATE!!! We just heard from Lorna at Heligan that in fact the project was too successful - gardeners and visitors wandering around at dusk were triggering the recording, which was then attracting actual female tawny owls to the tree! Nice if you want to see a female tawny at dusk, but not at all fair - not nice if you're a girl owl looking for a guy and all you can find is a loudspeaker, and of course it may stop other owl pairs breeding in the area if they think a dominant, hooty male is in residence. So the recording is now of a wolf. A nice, non-British sort of animal. And werewolves are very Halloween. We trust the wolf sound is sufficiently alien that none of the native wildlife is either concerned by, or taken in by the sound! 

Thursday, 16 October 2014

PIANA gets its sequencer

But what should it be called? Sequença? Joanna? Rihanna?? Maybe just plain old PIANOLA? I need to come up with a outlandish acronym that fits, I used to excel at that nonsense. The PIANa Orchestration LAnguage maybe??

But anyway - I have lashed up a sequencer, as promised about 2 years ago. I'm nothing if not quick. I've always been a fan of 'code-based' sequencers, ones where the music really looks and feels like code - I wrote my first one in 1988, and this isn't that dissimilar. Except the hardware it's running on is capable of so much more synthesis than an old T414 transputer could manage.

Anyway, 2 years of fermentation and 3 days of rapid coding have yielded a compiler, an 'instruction set' that is textual and human-readable - good for debugging - and it's pretty damn great.

So -

a piece of music is a 'program'. A program consists of 'sections', and a section is a set of 'patterns' that play out on different synths over different MIDI channels.

A pattern is griditized in time, with a maximum 32 steps per pattern. A pattern can contain noteOn, noteOff, pitch bend, program change and CC events right now. The only other smarts are within the program, where tempo can be set up and changed live as the piece plays, and looping is supported, both counted loops, nested, and 'repeat forever' loops that break out when a user callback is triggered. On the Pi this will involve hitting the ESC key. Profound or what.

So it's DEAD SIMPLE but it lets you knock up multi-part music very, very quickly. Which sounds brilliant, brilliant, brilliant. And I now don't need to use Logic to run multiple synths at once. Totally self-contained, it runs as a separate application to PIANA and communicates over an ALSA virtual MIDI port. Or over physical ports via USB. So I can use a Pi to sequence music running on an iPad, AND on the Pi, at the same time. And on a Pi, USB MIDI to another 2 or 3 or 4 Pis ... the Chamber Orchestra just got real, details to follow, and I didn't have to do any hardware.

Cool or what?

Now, it has not as yet run on a Pi, and will not for at least a week as I'm busy doing other stuff, out of town, the usual. But on the Mac it runs GREAT, and consumes so little CPU that Instruments can't even measure it. It spends pretty much all its time going usleep, and when it isn't going usleep it's pushing bytes down a USB port or a virtual MIDI port.

Here is the classic, lovely drummy intro to Being Boiled - yes, it's a bit long but this is an early incarnation, it will take living with this for a while to work out how to make programs more terse. Note the dynamic panning within the pattern by tweaking the 'pan' CC on selected drum hits. Neat.

But the most important thing is - it works. And it is  bloody brilliant.

// Being Boiled on a Pi
// 0 : kick 
// 1 : Ian Craig Marsh
// 2 : CLAP!
// 3 : synth 1
// 4 : synth 2

pattern loadPresetsToSynths (steps=8) { ... }

pattern boiledDrums (steps=32) {
0 : noteOn(note=C3, chan=1, vel=100);
0 : CC(CC=10,chan=0,value=64);
0 : noteOn(note=D5, chan=0, vel=80);
4 : noteOn(note=C2, chan=1, vel=80);
6 : noteOn(note=C2, chan=1, vel=80);
8 : noteOn(note=A4, chan=1, vel=127);
12 : noteOn(note=C3, chan=1, vel=100);
12 : CC(CC=10,chan=0,value=30);
12 : noteOn(note=E5, chan=0, vel=80);
14 : noteOn(note=C3, chan=1, vel=100);
14 : CC(CC=10,chan=0,value=97);
14 : noteOn(note=C5, chan=0, vel=80);
18 : noteOn(note=C2, chan=1, vel=80);
20 : noteOn(note=C2, chan=1, vel=80);
22 : noteOn(note=C2, chan=1, vel=80);
24 : noteOn(note=A4, chan=1, vel=127);
28 : noteOn(note=A4, chan=1, vel=127);

pattern boiledClap (steps=32) {
8  : noteOn(note=B3, chan=2, vel=120);
24 : noteOn(note=B3, chan=2, vel=120);
28 : noteOn(note=B3, chan=2, vel=120);

section loadPresetsToSynths {
loadPresetsToSynths(chan = 0);
section intro {
boiledDrums ( chan = 0 );
section introClap {
boiledDrums ( chan = 0 );
boiledClap ( chan = 0 );

program BeingBoiled {
tempo ( bpm=204.0, beat=4 );

[ loadPresetsToSynths ];

loop(14) {
[ intro ];
loop(80) {
[ introClap ];

I ought to point something out - I am aware that only people like me - nerds, basically - would think that code is the right way to sequence music. It totally isn't. But it's much faster than writing a GUI, and as a nerd I happen to like it ... but think of this as an instruction set, an intermediate format that can be compiled to, allowing 'power users' (a.k.a nerdy lunatics) to enter code, or sane people / creatives / musicians to use more appropriate user interface that encapsulates these same pattern/section/program concepts in a way that makes visual sense.

Monday, 6 October 2014

PIANA at the centre of my STEM outreach ...

Here's PIANA, amplified by a Minirig, in my 'insanely portable roadshow' setup. Cool!

UPDATE - here it is playing 7 synths at once with much better sound quality. 

Reinvigorated about STEM stuff

We went to the Bristol and Bath STEM Awards last week at Bristol Zoo, where Ambassadors, teachers, schools and companies won awards for their dedication to all things STEMmy. And I was impressed and humbled and figured, heck, I'd better finish off that packaged presentation and demo I've been working on. Here is a still from what ended up being a dry run - Raspberry Pi in the guise of a Kano doing synthesis, iPad being a really neat oscilloscope so the kids can see the waves, and all I need is to work out which teeny tiny TV to integrate onto the Kano so it can be portable. The Kano keyboard offers some really cute synth opportunities ...

Monday, 22 September 2014

Number one

I feel like Slade. Or Donny Osmond. Or some other long-forgotten crusty old chartbuster. Amazing.