Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
NoteSet Class Reference

#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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ NoteSet() [1/3]

NoteSet::NoteSet ( )
inline

Default constructor for an empty NoteSet.

◆ NoteSet() [2/3]

NoteSet::NoteSet ( uint16_t bits_)
inline

Construct NoteSet from uint16_t bitfield returned by toBits().

◆ NoteSet() [3/3]

NoteSet::NoteSet ( std::initializer_list< uint8_t > notes)

Constructs a NoteSet from notes.

Member Function Documentation

◆ add()

void NoteSet::add ( int8_t note)
inline

Add a note to NoteSet.

◆ addMajorDependentModeNotes()

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

◆ addUntrusted()

void NoteSet::addUntrusted ( uint8_t note)

Like add(), but ensures note is in range and higher than previous notes.

◆ clear()

void NoteSet::clear ( )
inline

Removes all semitones from the NoteSet.

◆ count()

int NoteSet::count ( ) const
inline

Returns number of notes in the NoteSet.

◆ degreeOf()

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.

◆ fill()

void NoteSet::fill ( )
inline

Marks all semitones as being part of the NoteSet.

◆ has()

bool NoteSet::has ( int8_t note) const
inline

Returns true if note is part of the NoteSet.

◆ highest()

uint8_t NoteSet::highest ( ) const
inline

Returns the highest note that has been added to the NoteSet.

◆ highestNotIn()

int8_t NoteSet::highestNotIn ( NoteSet used) const

Returns the highest note present in this NoteSet not present in the other.

Returns -1 if there are no notes present unused in the other NoteSet..

◆ isEmpty()

bool NoteSet::isEmpty ( ) const
inline

Returns true if the NoteSet is empty

◆ isSubsetOf()

bool NoteSet::isSubsetOf ( NoteSet other) const
inline

True if this is a subset of the other NoteSet.

◆ majorness()

int8_t NoteSet::majorness ( ) const

Determines the majorness of the NoteSet. Positive is major, negative is minor.

◆ modulateByOffset()

NoteSet NoteSet::modulateByOffset ( uint8_t offset)

Function to modulate NoteSet up offset semitones

◆ operator==()

bool NoteSet::operator== ( const NoteSet & other) const
inline

True if two NoteSets are identical.

◆ operator[]()

int8_t NoteSet::operator[] ( uint8_t index) const

Return the index'th note, or -1 if there aren't that many notes present.

If the NoteSet has a 0 and represents a scale, then is a scale degree as semitone offset from root.

Ie. if a NoteSet has add(0), add(1), add(4), and optionally higher notes added, notesSet[2] will return 4.

◆ operator|()

NoteSet NoteSet::operator| ( const NoteSet & other)

Union of two NoteSets

◆ remove()

void NoteSet::remove ( int8_t note)
inline

Remove a note to NoteSet.

◆ scaleSize()

int NoteSet::scaleSize ( ) const

Returns the size of the scale needed for this NoteSet.

◆ toBits()

uint16_t NoteSet::toBits ( ) const
inline

Returns NoteSet content as a uint16_t bitfield for serialization.

◆ toImpliedScale()

NoteSet NoteSet::toImpliedScale ( ) const

Size of NoteSet, ie. the maximum number of notes it can hold.


The documentation for this class was generated from the following files: