«pitch tracker utility» by defaultxr

on 29 Sep'13 01:08 in utilityconveniencepitchpitch tracking

This is a small utility i wrote to make it easy to detect the pitch of incoming audio (i.e. your voice into your mic). I recommend binding the execution of "~pitchTrack.();" to a keyboard shortcut in your editor/IDE. It's incredibly convenient to just input a hotkey and instantly see information about the current frequency and MIDI note number for the incoming audio. Because of how i've written ~pitchTrack, you can use the same hotkey to halt the pitch tracker synth as well. This utility makes it much easier to write melodies if you don't have perfect pitch.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
SynthDef(\pitchTrack, {
	var soundin = SoundIn.ar(0);
	var zc = ZeroCrossing.ar(soundin);
	// var pt = Pitch.kr(soundin);
	// var tt = Tartini.kr(soundin);
	SendReply.kr(Impulse.kr(1), '/pitchTrackUtil', [zc, zc.cpsmidi]);
}).add;

~pitchTrack = {
	if(~pitchTrackSynth.isNil or: { ~pitchTrackSynth.isRunning.not }, {
		~pitchTrackSynth = Synth(\pitchTrack);
		~pitchTrackNW = NodeWatcher.register(~pitchTrackSynth);
	}, {
		~pitchTrackSynth.free;
		~pitchTrackSynth = nil;
		"Pitch tracker stopped.".postln;
	});
};

~pitchTrackOSCFunc = {
	OSCFunc({
		| msg |
		("Pitch:"+msg[3].round.asString.padLeft(5)+msg[4].round.asString.padLeft(3)).postln;
	}, '/pitchTrackUtil');
};

~pitchTrackOSCFunc.();

CmdPeriod.add({~pitchTrackOSCFunc.();});
raw 768 chars (focus & ctrl+a+c to copy)
reception
comments