Get Root Note
-
@DanH I think it would be sensible if it used the loading callback that we already have.
-
It works like this in both directions now.
- when changing the sample, the RootNote of the sample is displayed.
- if I change the value of the knob, it is played with a new root note.
Wonderful
inline function onknb_RootControl(component, value) { if(value) AudioLoopPlayer1.setAttribute(AudioLoopPlayer1.RootNote, value); }; Content.getComponent("knb_Root").setControlCallback(onknb_RootControl);
-
@MikeB You don't the
if (value)
part. -
Next challenge in this topic!
Is there already a snippet (or 2 lines of code) with the definition or the conversion of the note numbers into notes e.g. 60 = C3 or C4 as the case may be?
So that the root note number is no longer displayed here (60) but the actual note C3.
-
Engine.getMidiNoteName(midinotenumber);
-
@ulrik That's simple - isn't there something more complicated?
-
@MikeB said in Get Root Note:
isn't there something more complicated?
inline function midiNumberToName(n) { local notes = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']; return notes[n % 12] + Math.round((n / 12) - 2); }
-
@d-healey :beaming_face_with_smiling_eyes: :beaming_face_with_smiling_eyes: :beaming_face_with_smiling_eyes:
-
@MikeBDo You Have A Snippet For Study On This Usage?
-
Actually I think my solution is better than HISE's :p This is the JUCE function that HISE is calling. Mine doesn't have as many options though.
String MidiMessage::getMidiNoteName (int note, bool useSharps, bool includeOctaveNumber, int octaveNumForMiddleC) { static const char* const sharpNoteNames[] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; static const char* const flatNoteNames[] = { "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B" }; if (isPositiveAndBelow (note, 128)) { String s (useSharps ? sharpNoteNames[note % 12] : flatNoteNames [note % 12]); if (includeOctaveNumber) s << (note / 12 + (octaveNumForMiddleC - 5)); return s; } return {}; }
-
@d-healey Haha...yes your's is shorter at least, but you don't get flatmates
-
@ulrik "aint got no use for no stinkin flats!"