For all those who want to play a musical instrument and a) have a copy of matlab, but b) have no ability to keep a beat (surely these must go together often enough) here is some useful code.

function metronome(persec)
blip = sin(1:82 * 2 * pi * 1000 / 8192);
while (1)
soundsc(blip);
pause(60/persec);
end

And in stereo!

function metronome2(persec)
len = 500;
blip = sin((1:len) * 2 * pi * 1000 / 8192)';
blip1 = [blip zeros(len,1)];
blip2 = [zeros(len,1) blip];
while (1)
sound(blip1);
pause(60/persec);
sound(blip2);
pause(60/persec);
end

Matlab is good for tuning too - all you need to know is that a violin's A is 440Hz and a fifth (interval between violin strings) is seven half-steps, so the frequencies are separated by 2^(7/12).

## 4 comments:

you and ilya should start using matlab to build effects.

can the signal be processed by matlab quickly enough to be real-time? (i guess that depennds on how you process it, but you know what i mean)

i've delved into the hardware side of effects a tiny bit and have a box of electronic components-- we could actually build effects boxes if we ever came up with something new and cool.

also, i saw a band play, where the chick played electric violin-- you need one of those.

yeah, i definitely need to do electric violin sometime.

realtime effects processing is tricky. jeff did a realtime quantizer, which you can read about at

http://bea.st/text/iq/

(he says that he'd like to know if you use it for anything - follow links on that page for his contact info.)

also, ben made a hardware DSP box and put some descriptions of it at

http://www.dsperado.com/chiclet.

a musical fifth is not actually defined as 2^(7/12) even though that makes an even temperment. a 'real' fifth is defined as 3/2, which you'll notice is amazingly close to 2^(7/12).. the fact is, a perfect fifth sounds better, but if you use fifths to tune instead of 2^(1/12) half steps, you can only tune to one key at a time - that's the original tuning people used before the time when they invented 'equal temperment' which is what led bach to the 'well tempered clavier', basically a study in using the 'new keyboard tuning that could be used in any key'.. the difference in half notes is called the pythagorean comma. anyway, totally useless, but interesting.. if you ever tune a violin by matching harmonics etc, you are tuning perfect fifths, not 12th roots of 2.

i have a quantizer on my drum machine, which can be useful for making loops, though its smallest "basket" is 1/32, which doesn't quite do it for me, since i like to use the tablas and bongos and make a bunch of really quick successive strikes that straddle around the primary downbeat...

... a further problem i have is that i run my drum machine through my pedal controlled looper, then to the amp, so if i have a drum loop and a loop on the pedal, and want to line them up, it's hard to do it perfectly, because i'm hitting 2 buttons at once (twice), and with a small margin for error i'm bound to miss by enough to make it noticable more often than i'd like.

it seems like a quantizer could somehow be used to reconcile the difference between the 2 devices, and get rid of the error caused by the stupid human.

Post a Comment