SID sound patches and vibrato

Having established that I could turn voices on or off according to the MIDI information coming in, the next step is to shape those notes beyond just beeps.

This isn't going to be a Roland SC55, but we can get quite a bit of the way there while retaining the characteristics of the SID chips.

General MIDI specifies 128 sounds / sound effects and our MIDI input may instruct us to use any of those for a given channel.  Building some of those sounds will be fun - reverse cymbal, or synth drum for example. Some are going to sound very similar to each other.

Automagic!

Which sound is played for each channel will be automatic, at least in this 'MIDI' mode.  My program for C64 allows the user to map instrument to MIDI channel, but that's a pain to configure each time you use it, and a MIDI file usually contains the 'program' information. If you're using a DAW or scoring tool like Musescore, it's very easy to make sure that information is there. (the 'program change' event, Cx).

The SID chip is very flexible. Each voice has an envelope and waveform and each chip has a very flexible filter which can be applied to any of the voices. It has advanced features like sync, ring modulation and resonance.

Vibrato

As a brass player, a musical characteristic that's important to me is vibrato.  This varies the pitch of the note very slightly. It makes the difference between a straight beep and a note that sounds like it's coming from a human player. A further enhancement is to hold the note straight for a short period before starting the vib. 

Another term is tremelo which may be the same or slightly different. Players of different instruments will argue about exactly what these terms mean but really we're just talking about adding expression.

A brass player generally varies the pitch of the note, so that's what seems natural and 'correct' to me. More recently I have learned to use 'breath vibrato' with woodwind instruments which varies the intensity of the note just a little rather than the pitch.  It happens that wobbling the pitch is the easiest thing to do with our SID voices, and so that's what we're doing here.

Implementing this in code

Like pulse width modulation (one for another day) vibrato isn't a setting on the chip, it's something you need to code. 

The easiest way to do this would be to count up to a preset value, count down, repeat. However, I feel that the 'shape' of vibrato should be a sine rather than a triangle. So I've always used a sine table. 

I've done this before in 6502 and Z80 assembly but it's way easier in C on a machine with floating point! You can see that I've generated a sine table consisting of floats, ranging from 1 to -1 and in 50 steps, meaning that a full sinewave at one step per 'frame' (or 50th second) makes one cycle per second. 

For fellow coders, yes I started with an array of structures containing the various parameters, one per voice. But I've settled on each parameter as an array. I find the resulting code more readable. 

So instead of vibrato[sidvoice]->vib_step  it's  vib_step[sid_voice]. 

Our handle_vib() is called every 1/50s, and for each voice it first counts down the delay variable (set to the delay value each time the note is started). Once that's down to zero, we do a sine lookup based on our vib table pointer. The value is multiplied by the multiplier (ie how subtle or extreme the effect). Because the frequency of the note isn't linear, we can't vary the frequency by an amount, it must be a percentage of the starting frequency of that note. (Otherwise a higher note won't seem to change, while lower notes will swing around wildly.)

Here's the result, Not my finished 'cello sound but I think it's very pleasing and adds realism and expression to certain instruments. 

What about applying this automatically in response to control changes in the MIDI?

Yes, the MIDI may contain control information. There is a fairly standard control change message used for the amount of vibrato and common for keyboards to have a control wheel for this purpose. Just how often this appears in MIDI files / streams, I'm not sure. It'll be good to respond to information in the MIDI where it's present.

Comments

Popular posts from this blog

e-ther 2 - Announcement and full rundown of features

Enclosures for MIDISID

MIDISID - second batch and giveaway