Making music on a computer, from a programmers perspective

I spent most of yesterday’s evening setting up Cubase SE after my harddrive crash. I went through all free CD’s that I got with the issues of swedish computer music magazine Studio and discovered a bunch of interesting virtual effects and instruments.

A little background in how modern versions of Cubase (or indeed most any sequencer program works): The program mimics a analog multi-track recorder, to which you can record analouge sound sources (in my cases an electric guitar and an electric bass — soon, vocals as well). There’s nothing magical about the way the audio is recorded — basically they just end up as high-resolution WAV files on your harddrive.

In addition, you can record or program MIDI as well. A midi file is essentially a bunch of messages arranged on a time scale, the most important being Note on (that has some parameters, like pitch and velocity) and Note off. MIDI is about 20 years old as a standard now, but it’s surprisingly versatile in a computer recording environment.

In the old way of doing things (like 5 or 10 years ago), these MIDI messages were sent to an external unit of some kind — a synthesized/sampler/workstation/sound module or some other box outside of the computer that made some kind of sound, that was then recorded more or less like an analouge source (like a electric guitar). Nowadays, it’s feasible to simulate all kinds of sound-generating boxes inside of the sequencer program in form of plugins. In Cubase lingo, such a plugin is called a Virtual instrument, or VSTi (Virtual Studio Technology instrument), and it’s essentially a multithreaded win32 dynamically loaded library, compatible with C++ calling conventions. When writing a VSTi, you inherit from a base C++ class and override a bunch of methods. Basically, one method that the host application calls to notify you that there is a incoming MIDI message, and another that the host application calls to find out how the instrument sounds. Your plugin renders the sound, based on incoming MIDI data, in the form of an array of doubles that represent the sound (typically 44100 doubles each second) — essentially PCM samples.

Now, MIDI messages can be more than just Note on and note off. There’s a whole class of messages that are used for parametrizing various aspects of a electronic instruments sound generation — things like changing the cutoff frequency or the resonance. If you’ve ever twiddled on a Roland TR303 or it’s virtual cousin Rebirth you know the kind of things that can be tweaked, and what kind of sounds can come as a result. Each VSTi can choose if and how to map these messages to some form of internal state.

There are some additional methods that are used for the host application to query and set the state of the instrument (for things like changing the sound preset, or manipulating parameters that can’t be changed by MIDI messages), but essentially that’s the entire interface — it’s less than 10 methods, most with very very simple signatures. But that’s enough for building an amazing amount of virtual instruments — every known technique for generating sound (playing samples, frequency modulation, simulating analog circuits, and so on) has been encapsulated in the form of VSTi’s. I used to play with hardware synthesizers and ”music workstations” back in the day, and it’s so much more flexible and downright fun to work with virtual instruments.

There is a similar (and older) API for writing effect plugins, like reverb and delay — override some methods, recieve a bunch of floats and tweak them to produce the sound you want — enabling you to virtualize a bunch of effect boxes, and even simulate complex things like the sound of a Marshall tube amplifier playing through a 4×12 speaker.

My favorites so far:

  • sfz – a soundfont player. A soundfont is basically a bunch of audio samples with some metadata that tells which samples that corresponds to what notes and velocity ranges. This is a common format for free sample collections.
  • crystal – a polyphonic synthesizer with really good presets
  • creakbox – sounds like a Roland TR303, including all the knobs to tweak.
  • Lallapallooza lite – great for more noisy sounds
  • Little green amp II – a guitar amplifier simulator

4 reaktioner till “Making music on a computer, from a programmers perspective”

  1. Hi Staffan,

    I’ve been trying to get hold of a copy of Little Green Amp II – I can’t find it anywhere on the Web. I’ve even contacted its designer, Patrick Wurr, but he told me that it’s no longer available. Is there some way that you could let me have a copy? I would be very grateful.

    All the best,

    Graham Foster (Valencia, Spain)

  2. Sorry I can’t comment on ”Making Music on a computer from a programmer’s perspective” – it’s way out of my reach. If you’d like to talk about it from a musician’s perspective then maybe I could contribute a little …

    One thing that intrigues me: there are a lot of excellent free vst plugins out there (for example the Simulanalog Guitar Suite) that don’t have a dedicated GUI – they use the Cubase default one. How difficult is it to design a GUI for these plugins? If I wanted to try where would I begin?

    One of the FREE Simulanalog plugins, the JCM900, is by far the best Marshall Amplifier simulator available anywhere at any price, and someone has lovingly come up with a version with a wonderful GUI and called it the JVM900. Simulanalog also has a great-sounding Fender Twin Amp simulator (called the Rednef Twin) – It’d be great to see it with a decent GUI.

    It may seem strange to talk about the visual side of things when obviously it’s the sound that’s important but if you visit some of the Cubase forums you’ll see that a lot of people’s opinions are based on what a plugin looks like. I suppose it’s a bit like having a meal laid out perfectly – I’m told it tastes better! We must be eating with our eyes – maybe the same is true with plugins – are we listening with our eyes too?

    Anyway enough of this rambling,

    All the best (and I’d love to hear and of course see the Little Green Amp II plugin..),

    Graham Foster (Valencia, Spain)

  3. Many developers release free vst’s which rely on the host sequencers default gui’s because the gui part is the hardest part to tie in with the code and can cause many bugs if not done properly. I’m still very much starting out learning dsp but some people say that mathematics does tie in with music,they say there are some strong similarities.

Kommentarer kan inte lämnas på detta inlägg.