adding practice tones

main
Michael Winter 7 years ago
parent 9c02fd80ce
commit 915634a1c4

@ -0,0 +1,28 @@
(
var dir, stringFreqRatios, fund, stringFreqs, noteNames, primes, denoms, file, fileName, sig;
var freq, noteName, cents, centDev, baseName, plusminus;
dir = thisProcess.nowExecutingPath.dirname;
fund = 50.midicps;
stringFreqRatios = [1, 7/4, 5/4, 1, 3/2, 1];
stringFreqs = [fund, fund * 7/4, fund * 5/4, fund, fund * 3/2, fund, 60.midicps, 59.midicps, 58.midicps, 53.midicps, 52.midicps, 50.midicps];
noteNames = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
primes = [1, 3, 5, 7, 11, 13];
denoms = [1, 2, 4, 4, 8, 8];
stringFreqs.do({ arg sFreq, i;
primes.do({ arg p, j;
freq = sFreq * p / denoms[j];
freq.postln;
noteName = noteNames[(freq.cpsmidi.round - 60) % 12];
cents = (1200 * log2(p / denoms[j] * if(i < 6, {stringFreqRatios[i]}, {1}))).round;
centDev = cents - cents.round(100);
plusminus = if(centDev >= 0, {"_plus_"}, {"_minus_"});
baseName = if(i < 6, {"part_" ++ (i + 1).asString ++ "_"}, {"ostinato_note_" ++ (i + 1 - 6).asString ++ "_"});
fileName = dir +/+ baseName ++ "harmonic_" ++ p.asString ++ "_" ++ noteName ++ plusminus ++ centDev.abs.asString ++ "_cents.wav";
file = SoundFile.new.headerFormat_("WAV").sampleFormat_("int16").numChannels_(1);
file.openWrite(fileName);
sig = Signal.newClear(44100 * 10);
sig.waveFill({ arg x, old, i; sin(x)}, 0, 2pi * freq * 10);
file.writeData(sig * 0.5);
file.close;
})})
)
Loading…
Cancel
Save