refactor: ccNote delegates to noteFor
This commit is contained in:
@@ -69,16 +69,13 @@
|
||||
};
|
||||
|
||||
// -- harmony state --
|
||||
~ccScales = (
|
||||
minor: [0,2,3,5,7,8,10], dorian: [0,2,3,5,7,9,10],
|
||||
phrygian: [0,1,3,5,7,8,10], penta: [0,2,4,7,9]);
|
||||
// Gammes + resolution degree->note : delegue a palette/note.scd (~noteFor).
|
||||
// ~ccScales reste un alias de ~scales pour les lecteurs externes.
|
||||
~ccScales = ~scales ? ~ccScales;
|
||||
~ccHarmony = ~ccHarmony ? (root: 45, scale: \minor, pad: \dark, phrase: 0, octave: 0);
|
||||
~ccNote = { |degree, oct=0|
|
||||
var sc = ~ccScales[~ccHarmony[\scale]] ? ~ccScales[\minor];
|
||||
var d = degree.asInteger;
|
||||
(~ccHarmony[\root] ? 45)
|
||||
+ (((~ccHarmony[\octave] ? 0) + oct + (d div: sc.size)) * 12)
|
||||
+ sc[d % sc.size];
|
||||
~noteFor.(degree, ~ccHarmony[\scale] ? \minor,
|
||||
~ccHarmony[\root] ? 45, (~ccHarmony[\octave] ? 0) + oct);
|
||||
};
|
||||
|
||||
// -- registre des morceaux --
|
||||
|
||||
@@ -18,6 +18,16 @@ if(~noteFor.(-1, \minor, 60, 0) != 58) { ok = false; "FAIL: neg".postln };
|
||||
// freq matches midicps
|
||||
if(~freqFor.(0, \minorPent, 60, 0) != 60.midicps) { ok = false; "FAIL: freq".postln };
|
||||
|
||||
// ~ccNote parity: wrapper must match the historical formula
|
||||
~ccHarmony = (root: 45, scale: \minor, pad: \dark, phrase: 0, octave: 0);
|
||||
~ccScales = ~scales;
|
||||
~ccNote = { |degree, oct = 0|
|
||||
~noteFor.(degree, ~ccHarmony[\scale] ? \minor,
|
||||
~ccHarmony[\root] ? 45, (~ccHarmony[\octave] ? 0) + oct);
|
||||
};
|
||||
if(~ccNote.(2, 0) != 48) { ok = false; "FAIL: ccNote 48".postln };
|
||||
if(~ccNote.(0, 1) != 57) { ok = false; "FAIL: ccNote oct".postln };
|
||||
|
||||
if(ok) { "PASS test_note".postln } { "TESTS FAILED".postln };
|
||||
0.exit;
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user