Skip to content

Commit

Permalink
Merge pull request #1435 from xaviliz/fix-note2midi
Browse files Browse the repository at this point in the history
Fix issue with the octaves left from the reference
  • Loading branch information
dbogdanov committed Jul 26, 2024
2 parents 52d8a35 + 3ee3f76 commit a770d1b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/essentia/essentiamath.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,13 +766,12 @@ inline int note2octave(std::string note) {

inline std::string midi2note(int midiNoteNumber) {
std::string NOTES[] = {ALL_NOTES};
//int nNotes = NOTES.size();
int nNotes = *(&NOTES + 1) - NOTES;
int CIdx = 3;
int diffCIdx = nNotes - CIdx;
int noteIdx = midiNoteNumber - 69;
int idx = abs(noteIdx) % nNotes;
int octave = (CIdx + 1) + floor((noteIdx + diffCIdx) / nNotes);
int octave = (CIdx + 1) + floor(float(noteIdx + diffCIdx) / nNotes);
if (noteIdx < 0) {
idx = abs(idx - nNotes) % nNotes;
}
Expand Down

0 comments on commit a770d1b

Please sign in to comment.