![]() |
Deluge Firmware 1.3.0
Build date: 2025.04.16
|
#include <note_set.h>
Public Member Functions | |
NoteSet () | |
NoteSet (uint16_t bits_) | |
NoteSet (std::initializer_list< uint8_t > notes) | |
void | add (int8_t note) |
void | remove (int8_t note) |
bool | has (int8_t note) const |
void | addUntrusted (uint8_t note) |
int8_t | operator[] (uint8_t index) const |
int8_t | degreeOf (uint8_t note) const |
void | fill () |
void | clear () |
bool | isEmpty () const |
uint8_t | highest () const |
int8_t | highestNotIn (NoteSet used) const |
int | count () const |
int | scaleSize () const |
bool | operator== (const NoteSet &other) const |
int8_t | majorness () const |
bool | isSubsetOf (NoteSet other) const |
NoteSet | operator| (const NoteSet &other) |
void | addMajorDependentModeNotes (uint8_t i, bool preferHigher, const NoteSet notesWithinOctavePresent) |
NoteSet | modulateByOffset (uint8_t offset) |
NoteSet | toImpliedScale () const |
uint16_t | toBits () const |
Static Public Attributes | |
static const int8_t | size = 12 |
Private Attributes | |
uint16_t | bits |
Set of chromatic notes.
NoteSet represents a set of chromatic notes within an octave.
0 is root, 1 is minor second, 2 is major second, etc.
NoteSet::size is always 12, provided for convenience of iteration. NoteSet::count() is number of notes in the set.
The class is just a thin wrapper around a integer bitfield. First 12 bits represent semitones. Last 4 bits curretly are unused, but there is no range checking.
|
inline |
Default constructor for an empty NoteSet.
|
inline |
NoteSet::NoteSet | ( | std::initializer_list< uint8_t > | notes | ) |
Constructs a NoteSet from notes.
|
inline |
Add a note to NoteSet.
void NoteSet::addMajorDependentModeNotes | ( | uint8_t | i, |
bool | preferHigher, | ||
const NoteSet | notesWithinOctavePresent ) |
Adds a mode-note to NoteSet, optionally specifying that we prefer it a semitone higher, although this may be overridden by what actual note is present
void NoteSet::addUntrusted | ( | uint8_t | note | ) |
Like add(), but ensures note is in range and higher than previous notes.
|
inline |
Removes all semitones from the NoteSet.
|
inline |
Returns number of notes in the NoteSet.
int8_t NoteSet::degreeOf | ( | uint8_t | note | ) | const |
Returns number of notes lower than the note given, or -1 if the note is not present.
This is the scale degree of the note if the NoteSet represents a scale and has a root.
|
inline |
Marks all semitones as being part of the NoteSet.
|
inline |
Returns true if note is part of the NoteSet.
|
inline |
Returns the highest note that has been added to the NoteSet.
int8_t NoteSet::highestNotIn | ( | NoteSet | used | ) | const |
|
inline |
Returns true if the NoteSet is empty
|
inline |
True if this is a subset of the other NoteSet.
int8_t NoteSet::majorness | ( | ) | const |
Determines the majorness of the NoteSet. Positive is major, negative is minor.
NoteSet NoteSet::modulateByOffset | ( | uint8_t | offset | ) |
Function to modulate NoteSet up offset semitones
|
inline |
True if two NoteSets are identical.
int8_t NoteSet::operator[] | ( | uint8_t | index | ) | const |
|
inline |
Remove a note to NoteSet.
int NoteSet::scaleSize | ( | ) | const |
Returns the size of the scale needed for this NoteSet.
|
inline |
Returns NoteSet content as a uint16_t bitfield for serialization.
NoteSet NoteSet::toImpliedScale | ( | ) | const |
Size of NoteSet, ie. the maximum number of notes it can hold.