implement MusicalKey::in_key()

Limited to 12 tones per octave for now
This commit is contained in:
Paul Davis 2021-11-08 12:39:15 -07:00
parent fb7dd71c45
commit 7f88c71bd3
1 changed files with 25 additions and 3 deletions

View File

@ -18,15 +18,37 @@
#include "ardour/key.h"
MusicalKey::~MusicalKey ()
{
}
void
MusicalKey::set_root (int r)
{
_root = r;
/* force root into lowest octave. Yes, 12 tone for now */
_root = (r % 12);
}
bool
MusicalKey::in_key (int note) const
{
return true;
}
/* currently 12 tone based */
note = note % 12;
/* we should speed this us. Probably a bitset */
if (note == _root) {
return true;
}
for (std::vector<float>::const_iterator i = steps.begin(); i != steps.end(); ++i) {
int ii = (int) ((*i) * 2.0);
if (note == _root + ii) {
return true;
}
}
return false;
}