XJ music engine  1.9.6
In-game runtime engine for XJ music.
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
XJ::NoteRange Class Reference

#include <NoteRange.h>

Public Member Functions

 NoteRange ()
 
 NoteRange (std::optional< Note > low, std::optional< Note > high)
 
 NoteRange (const std::string &low, const std::string &high)
 
std::string toString (Accidental accidental)
 
void expand (const std::vector< Note > &notes)
 
void expand (Note note)
 
void expand (const NoteRange *range)
 
int getDeltaSemitones (NoteRange target)
 
std::optional< NotegetMedianNote ()
 
NoteRange shifted (int inc) const
 
bool empty () const
 
std::optional< NotegetNoteNearestMedian (PitchClass root)
 
Note toAvailableOctave (Note note) const
 
bool includes (Note note) const
 

Static Public Member Functions

static NoteRange from (Note low, Note high)
 
static NoteRange from (const std::string &low, const std::string &high)
 
static NoteRange copyOf (const NoteRange &range)
 
static NoteRange ofNotes (std::vector< Note > notes)
 
static NoteRange ofNotes (const std::set< Note > &notes)
 
static NoteRange ofStrings (const std::vector< std::string > &notes)
 
static NoteRange median (const NoteRange &r1, const NoteRange &r2)
 
static int computeMedianOptimalRangeShiftOctaves (const NoteRange *sourceRange, const NoteRange *targetRange)
 

Public Attributes

std::optional< Notelow
 
std::optional< Notehigh
 

Detailed Description

Represent a note range

Constructor & Destructor Documentation

◆ NoteRange() [1/3]

NoteRange::NoteRange ( )

◆ NoteRange() [2/3]

NoteRange::NoteRange ( std::optional< Note low,
std::optional< Note high 
)

◆ NoteRange() [3/3]

NoteRange::NoteRange ( const std::string &  low,
const std::string &  high 
)

Member Function Documentation

◆ computeMedianOptimalRangeShiftOctaves()

int NoteRange::computeMedianOptimalRangeShiftOctaves ( const NoteRange sourceRange,
const NoteRange targetRange 
)
static

Compute the median optimal range shift octaves

Parameters
sourceRangefrom
targetRangeto
Returns
median optimal range shift octaves

◆ copyOf()

NoteRange NoteRange::copyOf ( const NoteRange range)
static

◆ empty()

bool NoteRange::empty ( ) const

Whether this range is empty

Returns
true if empty

◆ expand() [1/3]

void NoteRange::expand ( const NoteRange range)

Expand the note range to include the given range

Parameters
rangeto include

◆ expand() [2/3]

void NoteRange::expand ( const std::vector< Note > &  notes)

◆ expand() [3/3]

void NoteRange::expand ( Note  note)

Expand the note range to include the given note

Parameters
noteto include

◆ from() [1/2]

NoteRange NoteRange::from ( const std::string &  low,
const std::string &  high 
)
static

◆ from() [2/2]

NoteRange NoteRange::from ( Note  low,
Note  high 
)
static

◆ getDeltaSemitones()

int NoteRange::getDeltaSemitones ( NoteRange  target)

Get the delta semitones between this range and the target

Parameters
targetto compare
Returns
delta semitones

◆ getMedianNote()

std::optional< Note > NoteRange::getMedianNote ( )

Get the median note of this range

Returns
median note

◆ getNoteNearestMedian()

std::optional< Note > NoteRange::getNoteNearestMedian ( PitchClass  root)

Get the note nearest the median of the given root

Parameters
rootto find nearest note
Returns
note nearest the median

◆ includes()

bool NoteRange::includes ( Note  note) const

Whether the given note is within this range

Parameters
noteto test
Returns
true if note is within this range

◆ median()

NoteRange NoteRange::median ( const NoteRange r1,
const NoteRange r2 
)
static

◆ ofNotes() [1/2]

NoteRange NoteRange::ofNotes ( const std::set< Note > &  notes)
static

◆ ofNotes() [2/2]

NoteRange NoteRange::ofNotes ( std::vector< Note notes)
static

◆ ofStrings()

NoteRange NoteRange::ofStrings ( const std::vector< std::string > &  notes)
static

◆ shifted()

NoteRange NoteRange::shifted ( int  inc) const

Get this range shifted by the given number of semitones

Parameters
incsemitones to shift
Returns
shifted range

◆ toAvailableOctave()

Note NoteRange::toAvailableOctave ( Note  note) const

Change the octave of a note such that it is within this range

Parameters
notesource
Returns
note moved to available octave

◆ toString()

std::string NoteRange::toString ( Accidental  accidental)

Member Data Documentation

◆ high

std::optional<Note> XJ::NoteRange::high

◆ low

std::optional<Note> XJ::NoteRange::low

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