I have made some method discussed here and in the following threads:
The method definitions are as follows:
+ Integer {
midispn {
var quarterToneStep, octave;
quarterToneStep = [
\c, 'a quarter-tone raised c', 'c#', 'a quarter-tone raised c#',
\d, 'a quarter-tone raised d', 'd#', 'a quarter-tone raised d#',
\e, 'a quarter-tone raised e',
\f, 'a quarter-tone raised f', 'f#', 'a quarter-tone raised f#',
\g, 'a quarter-tone raised g', 'g#', 'a quarter-tone raised g#',
\a, 'a quarter-tone raised a', 'a#', 'a quarter-tone raised a#',
\b, 'a quarter-tone raised b'
][this * 2 % 24];
octave = (this / 12).floor - 1;
^quarterToneStep ++ octave.asInteger
}
cpsspn {
var quarterToneStep, octave;
quarterToneStep = [
\c, 'a quarter-tone raised c', 'c#', 'a quarter-tone raised c#',
\d, 'a quarter-tone raised d', 'd#', 'a quarter-tone raised d#',
\e, 'a quarter-tone raised e',
\f, 'a quarter-tone raised f', 'f#', 'a quarter-tone raised f#',
\g, 'a quarter-tone raised g', 'g#', 'a quarter-tone raised g#',
\a, 'a quarter-tone raised a', 'a#', 'a quarter-tone raised a#',
\b, 'a quarter-tone raised b'
][this.cpsmidi.round(0.5) * 2 % 24];
octave = (this.cpsmidi / 12).floor - 1;
^quarterToneStep ++ octave.asInteger
}
}
+ Float {
midispn {
var quarterToneStep, octave;
quarterToneStep = [
\c, 'a quarter-tone raised c', 'c#', 'a quarter-tone raised c#',
\d, 'a quarter-tone raised d', 'd#', 'a quarter-tone raised d#',
\e, 'a quarter-tone raised e',
\f, 'a quarter-tone raised f', 'f#', 'a quarter-tone raised f#',
\g, 'a quarter-tone raised g', 'g#', 'a quarter-tone raised g#',
\a, 'a quarter-tone raised a', 'a#', 'a quarter-tone raised a#',
\b, 'a quarter-tone raised b'
][this.round(0.5) * 2 % 24];
octave = (this / 12).floor - 1;
^quarterToneStep ++ octave.asInteger
}
cpsspn {
var quarterToneStep, octave;
quarterToneStep = [
\c, 'a quarter-tone raised c', 'c#', 'a quarter-tone raised c#',
\d, 'a quarter-tone raised d', 'd#', 'a quarter-tone raised d#',
\e, 'a quarter-tone raised e',
\f, 'a quarter-tone raised f', 'f#', 'a quarter-tone raised f#',
\g, 'a quarter-tone raised g', 'g#', 'a quarter-tone raised g#',
\a, 'a quarter-tone raised a', 'a#', 'a quarter-tone raised a#',
\b, 'a quarter-tone raised b'
][this.cpsmidi.round(0.5) * 2 % 24];
octave = (this.cpsmidi / 12).floor - 1;
^quarterToneStep ++ octave.asInteger
}
}
+ Symbol {
midi {
var quarterToneStep, octave;
quarterToneStep = (
[
(-11 .. 12).collect { |octave|
var pitchClasses = [
\c, \cq, \cs, \cQ,
\d, \dq, \ds, \dQ,
\e, \eq,
\f, \fq, \fs, \fQ,
\g, \gq, \gs, \gQ,
\a, \aq, \as, \aQ,
\b, \bq
];
pitchClasses.collect { |pitchclass|
(pitchclass ++ octave).asSymbol
}
}.flat,
(-120, -119.5 .. 156)
].flop
.collect { |item|
item[0] -> item[1]
}.asEvent
);
^quarterToneStep[this]
}
cps {
var quarterToneStep, octave;
quarterToneStep = (
[
(-11 .. 12).collect { |octave|
var pitchClasses = [
\c, \cq, \cs, \cQ,
\d, \dq, \ds, \dQ,
\e, \eq,
\f, \fq, \fs, \fQ,
\g, \gq, \gs, \gQ,
\a, \aq, \as, \aQ,
\b, \bq
];
pitchClasses.collect { |pitchclass|
(pitchclass ++ octave).asSymbol
}
}.flat,
(-120, -119.5 .. 156)
].flop
.collect { |item|
item[0] -> item[1].midicps
}.asEvent
);
^quarterToneStep[this]
}
}
The test results are as follows:
\a2.cps // -> 110.0
110.cpsspn // -> a2
111.cpsspn // -> a2
\aq2.cps // -> 113.22324603078
112.cpsspn // -> a quarter-tone raised a2
113.cpsspn // -> a quarter-tone raised a2
114.cpsspn // -> a quarter-tone raised a2
\as2.cps // -> 116.54094037952
115.cpsspn // -> a#2
116.cpsspn // -> a#2
117.cpsspn // -> a#2
118.cpsspn // -> a#2
\aQ2.cps // -> 119.95585059318
119.cpsspn // -> a quarter-tone raised a#2
120.cpsspn // -> a quarter-tone raised a#2
121.cpsspn // -> a quarter-tone raised a#2
\b2.cps // -> 123.47082531403
122.cpsspn // -> b2
\a4.midi
69.midispn // -> a4
69.1.midispn // -> a4
69.2.midispn // -> a4
69.3.midispn // -> a quarter-tone raised a4
69.4.midispn // -> a quarter-tone raised a4
69.5.midispn // -> a quarter-tone raised a4
69.6.midispn // -> a quarter-tone raised a4
69.7.midispn // -> a quarter-tone raised a4
69.8.midispn // -> a#4
69.9.midispn // -> a#4
70.midispn // -> a#4
70.0.midispn // -> a#4
70.1.midispn // -> a#4
70.2.midispn // -> a#4
70.3.midispn // -> a quarter-tone raised a#4
70.4.midispn // -> a quarter-tone raised a#4
70.5.midispn // -> a quarter-tone raised a#4
70.6.midispn // -> a quarter-tone raised a#4
70.7.midispn // -> a quarter-tone raised a#4
70.8.midispn // -> b4
70.9.midispn // -> b4
71.midispn // -> b4
I think it is not good enough to make a PR because there are duplicate variable definitions in the different methods in a class such as pitchClasses
as well as in the different classes such as quarterToneStep
.