-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scale-Aware-Accidentals #3243
base: community
Are you sure you want to change the base?
Scale-Aware-Accidentals #3243
Conversation
todd-gochenour
commented
Jan 8, 2025
•
edited
Loading
edited
- Key scales can display either sharps or flats. The major keys of G, D, A, E, B and F# all display sharps and C, F, Db, Ab, Eb and Bb all display flats. Scale modes and exotic minor scales will use the accidental of its relative major key. Accidentals only apply to black keys on a piano. Db, Eb, F#, Ab and Bb are the five black keys with their accidentals. In the key of E the third degree will display G#. In the key of Eb the fourth degree will display Ab. The are enharmonically equivalent.
- With the 7SEG display, where before a sharp was represented with the decimal point now a sharp is represented using the upper left vertical segment and a flat is represented using the lower left vertical segment.
- A refactor of the function noteCodeToString() will consolidate logic and lookup tables into preset_scales.cpp where it can utilize scale information to determine if the relative major key of the current song is sharp or flat. The function signature takes parameters currentSong->key.rootNote and currentSong->getCurrentScale() when making this decision.
- Areas affected by this change include InstrumentClipMinder, AutomationView, ChordLibrary, ChordKeyboard, KeyboardScreen, MultiRange and KeyRange.
- Notes are shown as a popup when pressing the audition pad of a synth instrument clip and in the KeyboardScreen when pressing any note pad. Press a pad within the ChordKeyboard and ChordLibrary views and the chord name will popup with the appropriate accidental based on key. Notes are shown in the OLED screen layout when scrolling vertically in AutomationView>Velocity and when scrolling horizontally defining a default key range in Settings>Defaults>Key. Create a multisample synth and the SYNTH-BROWSE shortcut will show a Note Range list for each sample loaded.
Test Script:
|
Why not use "b", since that is very much what the flat sign looks like, e.g. "Db3"? |
Test runthrough video: https://www.youtube.com/watch?v=fTYfCT8OS74 |
There are no lower case letters on the Deluge. Only upper case. '&' is the closest shape and is temporary until a new glyph is generated. |
Nevermind, this is smarter naming of notes in the scale/chromatic mode and not accidental support |
It was a surprise to me when I first picked D# (from key of E) as the new key and it popped up 'E& Major' for a second and then every altered note (black key) was displayed in flats. I picked A# (from the key of B) for the new key and it popped up 'B& Major'. When I went chromatic and picked G& it changed to F#. I got this key signature behavior for free. |
Isn't it a convention for parameter changes to first show the current value before changing to the next? SHIFT-SCALE is not doing this. |
It depends. It's applied on some things but not all things (eg note probability, iteration shows current value before changing it). |
Can I apply it to SHIFT-SCALE ? |
Sure, we can see how it feels |
Tested C Lydian for augmented 4th F# in relative major of G. Not sure yet how to handle the mixture of sharps and flats in the Hungarian Minor and Marva scales. There are also the cases E#, F&, B# and C& which show the natural enharmonic note because accidentals in this code only apply to the black keys of a piano. |
…henour/DelugeFirmware into Scale-Aware-Accidentals
Tested D& Major with B, C#, D#, E, F#, G#, A# The Deluge strategy did not handle displaying E# before this change either. Tested D& Major with D&, E&, F, G&, A&, B&, C The Deluge strategy did not handle displaying B# before this change either. There are cases where double accidentals like F## or E&& may be technically correct, but the enharmonic equivalent of G and D are easier to comprehend. There will be cases where a scale contains two of the same note letter, one with an accidental and one without. |
before cycling scales on subsequent presses.
Added logic so that SHIFT-SCALE shows current scale on first press before cycling scales on subsequent presses. This logic applied to instrument clip view and to keyboard screen. Release of the SHIFT key resets the test for first press. |
Instead of creating a new function "shift has changed" I think you should leverage the logic that is used for other "previews" which basically shows a pop up of a "type" And then before changing scale you check if the popup of that type is present. If yes, change scale. Look for the code "display->hasPopupOfType" For examples of this behaviour |
To create new fonts, check fonts.c With that file open if you do a control + f and search for "1" and then turn your head sideways you'll see how the fonts are created. Re 7seg im not the best person for that, id ask @m-m-adams what they think as they have a 7seg |
Character \x81 represents the flat glpyh. |
You could add it in the "high bit" ASCII range (i.e. chars >127) -- these should never appear in filenames that we support today. You'd need to add logic in If you want to test 7seg behavior on an OLED, you can press SHIFT+LEARN+AFFECT ENTIRE with 7seg emulation mode set to Toggle (see community_features.md, search for "Emulated Display"). |
* 'FLAT' found in chordName is converted to char 129 for display.
Flat glyph now represented by uint8_t value of 129. Glyph added after tilde in fonts.cpp and index will convert char 129 to ('~' + 1). In testing this on 7SEG I'm seeing unusual behavior in the Chord Library where sometimes it reads 'Cant', other times it says 'Soon' and other times it acts like a shortcut to a parameter modifier with the pad flashing. |
and flat as lower left vertical segment.
7SEG Displays sharp as upper left vertical segment (segment 2) and flat as lower left vertical segment (segment 3). They appear as ticks next to the note name. The decimal dot is no longer used to signify an accidental. |
Do we have any performance testing tools to see if adding this calculation to each key press has a performance impact? 1.2 already has some performance issues on the isometric keyboard view: #3168 |
The calculations added here are near trivial, I doubt they will have performance impact. We don't have great tools for that though, if you have ideas please join us on Discord or leave something in the discussions tab. #3168 doesn't look like a performance bug, it seems like something is going wrong in the keyboard state reconciliation logic. |
to DEF_SCALE data structure
Test Settings>Defaults>Key
* rootNote set to given noteCode when not provided as parameter * Tested MultiRange menu option * Adjusted KeyRange highlight of right side to line up with note display *
|
no other code uses the internals of this function.
My development and testing are complete. This PR is ready for review. |
I started testing this change tonight. So far it is working great both with new and old songs. One item / observation- some scales are not possible with this change, right? If someone wanted put something together in D#, they would just use Eb? |
Yes, as both keys are enharmonically equivalent. Eb has 3 flats, Bb, Eb and Ab. D# has 9 sharps, and as there are only 7 notes in a scale, 2 of these sharps are double sharps, D#, E#, F##, G#, A#, B#, C##. The scale with the least number of accidentals is favored. If you pick D# as your new key, the display converts to Eb automatically. |