MIDI Tempo Mastering...

vttom

Senior Member
MIDI seems to be a popular subject for the PIXACE, so I thought I'd post an idea and let people comment on whether or not this is possible and/or how hard it would be to implement.

The idea is this:

I'm in a small band and play drums (a wimpy Yamaha electronic drum kit). I also sing occasionally. But I'm not talented enough to drum and sing at the same time.

On the songs I do sing, what I'd like to do is record a drum part beforehand and play it back using MIDI.

What I don't want is for the rest of the band to have to follow a click track or something to stay in sync with the MIDI drum part. What I'd really like would be some kind of input device, a foot switch for example, that I could tap with my foot while singing. The PIXACE would time the taps and calculate a tempo, and then transmit that to the MIDI drum kit to keep it in sync.

A bonus feature would be a way to make it so I don't have to tap every single beat in the song. For instance, if everything is lined up, I could stop tapping, and the MIDI part would continue on with the current tempo. If our beats start to drift, I start tapping again to get us all back together.

It really breaks down into 2 fairly simple pieces:

1) A timing piece to time the input taps and caculate a tempo in whatever units MIDI requires. Some kind of filter would be nice to reject long intervals between taps (to take into account the scenario where I stop tapping altogether).

2) A MIDI piece that takes the tempo information and relays that to the MIDI instrument (or a MIDI sequencer controlling the instrument).

What do you think? Crazy? Impossible? Or am I on to something? Maybe this has been done before?
 

hippy

Ex-Staff (retired)
It should be possible. I'd split it into a two PICAXE system each doing one part; timing foot taps, the other generating timing codes. You can combine them into a sinle PICAXE later if you wish / if possible.

Timing is done with MIDI command $F8 ( System Realtime Message, Timing Clock ). These are sent at a rate of 24 per quarter note.
 

vttom

Senior Member
Thanks. I just found this: http://www.midi.org/techspecs/midimessages.php

So now I realize I don't send tempo change message, but I have to send actual clock ticks.

Let me do some quick math... Let's say the music is in 4/4 time and we're at 120bpm (pretty fast). That's 2 quarter notes per second = 2 * 24 = 48 MIDI clock ticks per second. Definitely well within the bandwidth of a PICAXE.

I think the hard part will actually be at the slow end of the scale, making sure my counters/timers don't overflow.

I'll also want to create some kind of method for starting off and sending the start (0xFA) command followed by the train of clock tick messages.
 

hippy

Ex-Staff (retired)
If 120bpm is 48 messages every second then 30bpm would be 12 per second which is still fairly fast; ~100ms. It's the human bpm foot-tapping as you note which is on a slower scale, possibly two seconds or slower.

I'd probably not worry about actual bpm; the MIDI message rate is proportional to the foot-tapping rate so simply determine time between taps, scale up and that's it. You'll probably want an averaging routine which is weighted towards the last tap so a rolling average should do -

T_to_use = T_previous + T_current / 2
 

womai

Senior Member
BTW, with a slight change to the formula you can improve the averaging:

T_to_use = ((N - 1) * T_current + T_previous) / N

will cause a longer time constant, i.e. sudden changes in tapping speed will take longer to be fully incorporated. The time constant gets larger with increasing N. That formula is basically a discrete time implementation of a R-C low-pass filter.

In Picaxe math, i.e. formula evaluated from left to right that gives

T_to_use = N - 1 * T_current + T_previous / N

where N is some number, e.g. 5 (you get hippy's formula if you use N=2).

Wolfgang
 

vttom

Senior Member
Womai, I was going to just store the 4 most-recent intervals and average them. But I like your idea better.
 

boriz

Senior Member
Why use foot-tap?

Why not just let the MIDI play at the proper tempo?

Seems like a lot of trouble to go to, just to add innaccuracy to the timing.
 

Jeremy Leach

Senior Member
I expect the foot tap is because it's good to add some tempo changes into the music on the fly. A sequenced track can have inbuilt tempo changes but thats very difficult to follow playing live, whereas the method here puts the singer in control of the tempo. Also having just a fixed tempo throughout a song can be too boring.

I can appreciate this because I'm in a band too and we've been pondering the whole midi-backing idea to enrich the sound a bit - but currently given up and just play all live! I'd really like to have a little box that I could upload sequences to and play them back at the touch of a button - rather than lug a laptop around. It's been done - there are products out there - but a bit pricey. 'Old Joe' on this forum was trying to get a system working a bit like this - but not sure how far he managed to get.

I'd also look at MTC and synchronisation options in your Midi device ... i.e it's usually possible to synchronise your sequencer with an external timing source. You could make your PICAXE tempo box the external source.
 
Last edited:

vttom

Senior Member
I sat down last night and sketched out some pseudo code. I came to realize that measuring the actual beats per minute is not necessary. All I really need is a way to "multiply" the frequency of the incoming beat by 24, since the MIDI spec says that the MIDI clock message should be sent 24 times per quarter note, and typically 1 beat = 1 quarter note (I envision putting a selector switch on the box to indicate the beat to quarter note relationship to make it more universal than just x/4 time signatures).

I should have some actual PICAXE BASIC in another day or 2 to share with the group.
 
Top