Notice: A non well formed numeric value encountered in /sites/ on line 96 Notice: A non well formed numeric value encountered in /sites/ on line 96 Notice: A non well formed numeric value encountered in /sites/ on line 96 Deprecated: Function create_function() is deprecated in /sites/ on line 104 Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /sites/ on line 845 Deprecated: Function create_function() is deprecated in /sites/ on line 111 FS#11752 : pitch_detector: Mixed accidentals and Key Transposition



FS#11752 - pitch_detector: Mixed accidentals and Key Transposition

Attached to Project: Rockbox
Opened by Robert Horn (eastcheap) - Friday, 12 November 2010, 16:33 GMT
Task Type Patches
Category Plugins
Status Unconfirmed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No


Patch 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

Comment by Alexander Levin (fml2) - Wednesday, 05 January 2011, 16:10 GMT
A few notes and questions:

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! :-)
Comment by Robert Horn (eastcheap) - Thursday, 06 January 2011, 06:24 GMT
1. Two independent patches are a definite possibility, since only the transposition bit adds a menu item. I'll keep it in mind for the next revision.

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.
Comment by Alexander Levin (fml2) - Thursday, 06 January 2011, 07:41 GMT
1. So we agree on this

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!
Comment by Alexander Levin (fml2) - Thursday, 06 January 2011, 07:42 GMT
Another thing: I'd introduce an enum for possible values of accidental_mode -- for better code readability.
Comment by Alexander Levin (fml2) - Friday, 07 January 2011, 19:44 GMT
Could you please provide your real name (for the credits). I'd like o commit the "transposing instrument" part. Thanks.
Comment by Robert Horn (eastcheap) - Sunday, 09 January 2011, 05:33 GMT
Great, especially since, once I started working on accidentals-by-key, there wasn't enough fuzz in the world to keep two patches compatible.

"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.
Comment by Alexander Levin (fml2) - Sunday, 09 January 2011, 13:48 GMT
OK, I will use "Robert Horn", but that doesn't necessarily mean that you have to update your profile. That would be convenient though so that no questions will have to be asked when committing future patches from you!

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.
Comment by Robert Horn (eastcheap) - Tuesday, 11 January 2011, 03:56 GMT
Looks good to me.
Comment by Alexander Levin (fml2) - Tuesday, 11 January 2011, 06:55 GMT
Good! Another thought: what do you think about renaming the "transposition" setting (and the menu entry) to "instrument key"?
Comment by Alexander Levin (fml2) - Friday, 14 January 2011, 21:42 GMT
The key transposition part has been committed as r29052.
Comment by Robert Horn (eastcheap) - Saturday, 15 January 2011, 08:33 GMT
Terrific. Sorry I've been a bit preoccupied lately, but the "Instrument Key," idea also seems like a good one to me.