This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#11752 - pitch_detector: Mixed accidentals and Key Transposition
Attached to Project:
Rockbox
Opened by Robert Horn (eastcheap) - Friday, 12 November 2010, 17:33 GMT+2
Opened by Robert Horn (eastcheap) - Friday, 12 November 2010, 17:33 GMT+2
|
DetailsPatch against r28560.
Adds options for displaying pitches according to key (for transposing instruments) and "mixed" accidentals a la Korg (C#, Eb, F#, G#, Bb). I'd also like to add some kind of support for alternate temperaments (perhaps even just intonation), however this isn't trivial and I probably won't undertake the project unless some interest is expressed. |
This task depends upon
1. I think the two features should be separated into two patches
2. Why did you choose to display only A# and D# as Bb and Eb? Because Korg does this? I'd do it in a different way: introduce a setting for the key signature (C-Dur by default) and then display the notes according to that signature (with e.g. F# or Gb chosen automatically).
3. I don't quite understand what the key transposition is for. I understand it now as follows: I'd use the feature if I play a transposed (differently tuned) instrument (say, guitar). The ideal tuning is C. If I know that it's tuned a tone higher than it should be, I'd set this setting to "D". And then, if the detector detects a D, it would display it as C, so that I'd play the same string at the same position as I would do it if the guitar was tuned in the ideal way. He-he, try to describe it in the manual! :-)
2. I chose to emulate Korg because it seems like a reasonable compromise and because the TM-40 is so wildly popular. Why they chose G# is a head-scratcher. Ab makes more sense, at least in a harmonic context. I had considered accidentals according to key, but was just too lazy to work it out. :-) I'll go ahead and see what I can come up with for the 13 common keys, at least.
3. It makes sense if you play a transposing instrument (trumpet, horn, sax, etc.). How useful it is is another question. And, no doubt about it, anything involving transposition will be a beast to document.
2. I don't use TM-40 and hence can't know how it works. I'm not sure how many people do. But we could have four possible values for accidentals: "sharps only", "flats only", "like Korg TM-40" (or "Bb and Eb only") and "Based on the key". The latter will require another setting with some popular keys. (Dur or Moll only or both?) What do you think about this?
3. OK, I've read up about transposing instruments and see that my intuition was correct. A nice feature!
"R.L. Horn" is my preference, but "Robert Horn" is fine too. If you use the latter, I'll change my profile to match.
I've attached a revised and tested transposition patch (against r28972) which can use, if you like. The only differences are a comment in display_frequency() to explain what's happening and some (mostly decorative) #defines.
Once it's committed, I believe it would be best to close this task -- anything to do with accidentals can be submitted separately. However, as regards (2) above, after some thought, I'm now inclined to think that the Korg approach is a bad idea. Try as I might, I just can't make any sense out of that G# (maybe someone at Korg really likes the Dorian mode?). The harmonic chromatic scale adds three flats to arrive at accidentals, which neatly encompasses the major and natural minor scales, and is probably the way to go (with some cheating to avoid double sharps and flats) for key-based accidentals.
After committing the transposition part, I will leave this task open since the other part can still be tracked here.
I've tweaked your patch a bit (no functional changes). Basically, I did the following:
- eliminated the constants for the transpositions since they are really not needed and, as a sequence, not used anywhere in the code
- renamed the "transposition" setting from ..._idx to key_... thus making it semantical rather than purely technical. This is OK IMO since the setting is exactly that: the number of semitones between the concert C and the instrument key
- added a comment to the setting
I attach the modified patch. If you find it OK, I'll commit it.