Hi folks,
I was wondering if there is an option to retune the entire midicps system, meaning that instead of a4 = 440 → a4 = 443 or 419?
I only found an entry from 4 years ago (Convert .midicps to 432hz base - #3 by Davon666)
In the source code I found the line:
SC_InlineUnaryOp.h:
line 77-85
/// Convert MIDI note to cycles per second
inline float32 sc_midicps(float32 note) {
return (float32)440. * std::pow((float32)2., (note - (float32)69.) * (float32)0.083333333333);
}
/// Convert cycles per second to MIDI note.
inline float32 sc_cpsmidi(float32 freq) {
return sc_log2(freq * (float32)0.0022727272727) * (float32)12. + (float32)69.;
}
would it be possible to make this somehow accessible from the outside?
Because the reality in working with classical musicians (at least in central europe) is that nobody tunes in 440 for decades any more…
Thanks ans all the best
Sem
I think this is definitely doable. First step would be to propose this as an improvement in SC’s GitHub. Then hopefully someone would raise the hand, and see if it is indeed possible.
As a quick solution, something that I try to implement to every software I write:
(
var diapason = 442;
var getMidiFreq = { |midiNote|
midiNote.midicps / 440 * diapason
};
// Is our new A tuned?
getMidiFreq.value(69).postln;
)
With proper setDiapason
function, etc.
1 Like
You can add an offset to the MIDI note numbers. The numbers given to midicps may have a fractional component for microtuning. So, strictly speaking, a software change isn’t necessary.
In the Event system, you can use ctranspose (by a fractional amount).
E.g. 442 Hz is about .65 cents higher than 440 Hz, so if you ask for MIDI note number 69.0065, you’d get just about 442.
Basically two different philosophies in the two replies: One is, push for a change in the software so that you can do it someday; the other (here) is, what can you do in the software today to get what you want? If it’s me, I’d take the “today” solution.
hjh
1 Like
Thanks for this, I didn’t know it was possible! Even better, it also works with .cpsmidi
!
I’m not comfortable with cents, but I think your example is wrong because we’re comparing a linear scale with an exponential scale (or is it just because you meant 69.065 ?):
69.0065.midicps → 440.16523109449
442.cpsmidi → 69.078514150401
The ‘midi increment’ ratio is inconsistent:
442.cpsmidi / 440.cpsmidi → 1.0011378862377
884.cpsmidi / 880.cpsmidi → 1.0009693104988
I think this implies there’s no way to rescale the linear midi scale in one step (i.e. midiNote.midicps / 440 * diapason
equivalent is always needed). Sorry I don’t know how to express this idea clearly.
Ah, I forgot to multiply by 12.
I had done ln(442/440) / ln(2), which is 0.0065428458667 – but that’s the proportion of the octave, not of the semitone. Sorry about that – I wasn’t at the computer, so I was doing it on the phone’s calculator.
hjh
1 Like
thanks for all your feedback, in the end thanks to you and thorough in person discussion with @Luc_Doebereiner I came up with the following solution:
+ SimpleNumber {
midicps443 {
^(443*2.pow((this-69)/12))
}
midicps442 {
^(442*2.pow((this-69)/12))
}
cpsmidi443 {
^((this/443).log2 * 12 + 69)
}
cpsmidi442 {
^((this/442).log2 * 12 + 69)
}
}
best
Sem
2 Likes