Skip to content

Commit

Permalink
REmove all notes vector as input.
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviliz committed May 22, 2024
1 parent 287915b commit e50ed5e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/essentia/essentiamath.h
Original file line number Diff line number Diff line change
Expand Up @@ -755,14 +755,17 @@ inline int hz2midi(Real hz, Real tuningFrequency) {

// TODO: check MIDI standard conventions

inline std::string midi2note(int midiNoteNumber, std::vector<std::string> allNotes) {
inline std::string midi2note(int midiNoteNumber) {
// considering ALL_NOTES in A scale
// { "A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#" };
const std::vector<std::string> ALL_NOTES { "A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#" };
int noteIdx = midiNoteNumber - 69;
int idx = abs(noteIdx) % 12;
int octave = 4 + floor((noteIdx + 9) / 12.0);
if (noteIdx < 0) {
idx = abs(idx - 12) % 12;
}
std::string closest_note = allNotes[idx] + std::to_string(octave);
std::string closest_note = ALL_NOTES[idx] + std::to_string(octave);
return closest_note;
}

Expand Down

0 comments on commit e50ed5e

Please sign in to comment.