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

#include <Note.h>

Public Member Functions

bool operator== (const Note &other) const
 
bool operator< (const Note &other) const
 
bool operator> (const Note &other) const
 
bool operator<= (const Note &other) const
 
bool operator>= (const Note &other) const
 
 Note ()
 
 Note (const std::string &name)
 
 Note (PitchClass pitchClass, int octave)
 
std::string toString (Accidental accidental) const
 
Note shift (int inc) const
 
Note shiftOctave (int inc) const
 
Note copy () const
 
Note setOctaveNearest (Note fromNote)
 
int delta (const Note &target) const
 
bool isAtonal () const
 
Note nextUp (PitchClass target) const
 
Note nextDown (PitchClass target) const
 
Note next (PitchClass target, int delta) const
 

Static Public Member Functions

static Note of (const std::string &name)
 
static Note of (PitchClass pitchClass, int octave)
 
static Note atonal ()
 
static std::optional< NoteifValid (const std::string &name)
 
static std::optional< NoteifTonal (const std::string &name)
 
static bool isValid (const std::string &name)
 
static bool containsAnyValidNotes (const std::string &noteCsv)
 
static std::optional< Notemedian (std::optional< Note > n1, std::optional< Note > n2)
 

Public Attributes

int octave
 
PitchClass pitchClass
 

Static Public Attributes

static std::string ATONAL = "X"
 

Detailed Description

A Note is used to represent the relative duration and pitch of a sound.

https://en.wikipedia.org/wiki/Musical_note

Constructor & Destructor Documentation

◆ Note() [1/3]

Note::Note ( )

Default constructor

◆ Note() [2/3]

Note::Note ( const std::string &  name)
explicit

Construct of note

Parameters
nameof note

◆ Note() [3/3]

Note::Note ( PitchClass  pitchClass,
int  octave 
)

Construct note from pitch class and octave #

Parameters
pitchClassof note
octaveof note

Member Function Documentation

◆ atonal()

Note Note::atonal ( )
static

Instantiate an atonal note

Returns
atonal note

◆ containsAnyValidNotes()

bool Note::containsAnyValidNotes ( const std::string &  noteCsv)
static

Whether the CSV contains any valid noteCsv

Parameters
noteCsvto test
Returns
true if contains any valid noteCsv

◆ copy()

Note Note::copy ( ) const

Copies this object to a new Note

Returns
new note

◆ delta()

int Note::delta ( const Note target) const

Delta +/- semitones from this Note to another Note

Parameters
targetnote to get delta to
Returns
delta +/- semitones

◆ ifTonal()

std::optional< Note > Note::ifTonal ( const std::string &  name)
static

Only stream a valid and tonal note, else empty NC sections should not cache notes from the previous section https://www.pivotaltracker.com/story/show/179409784

Parameters
nameof note to test for validity
Returns
valid note stream, or empty stream (if invalid)

◆ ifValid()

std::optional< Note > Note::ifValid ( const std::string &  name)
static

Only stream a valid note, else empty NC sections should not cache notes from the previous section https://www.pivotaltracker.com/story/show/179409784

Parameters
nameof note to test for validity
Returns
valid note stream, or empty stream (if invalid)

◆ isAtonal()

bool Note::isAtonal ( ) const

Whether this note is atonal

Returns
true if the pitch class is none

◆ isValid()

bool Note::isValid ( const std::string &  name)
static

Whether the current note is valid

Parameters
nameof note to test
Returns
true if valid

◆ median()

std::optional< Note > Note::median ( std::optional< Note n1,
std::optional< Note n2 
)
static

Return the median note between the two given notes, or just one if the other is null

Parameters
n1note 1
n2note 2
Returns
median note between the given two

◆ next()

Note Note::next ( PitchClass  target,
int  delta 
) const

Get the first occurrence of the given pitch class in the given direction from the current note

Parameters
targetpitch class to seek
deltadirection (1 or -1) in which to seek
Returns
first note with given pitch class from this

◆ nextDown()

Note Note::nextDown ( PitchClass  target) const

Get the first occurrence of the given pitch class down from the current note

Parameters
targetpitch class to seek
Returns
first note with given pitch class down from this

◆ nextUp()

Note Note::nextUp ( PitchClass  target) const

Get the first occurrence of the given pitch class up from the current note

Parameters
targetpitch class to seek
Returns
first note with given pitch class up from this

◆ of() [1/2]

Note Note::of ( const std::string &  name)
static

Instantiate a note

Parameters
nameof note
Returns
note

◆ of() [2/2]

Note Note::of ( PitchClass  pitchClass,
int  octave 
)
static

Instantiate a note by pitch class and octave

Parameters
pitchClassof note
octaveof note
Returns
note

◆ operator<()

bool Note::operator< ( const Note other) const

Comparison of two notes: this < other

Parameters
otherto compare
Returns
true if this is less than other

◆ operator<=()

bool Note::operator<= ( const Note other) const

Comparison of two notes: this <= other

Parameters
otherto compare
Returns
true if this is less than other

◆ operator==()

bool Note::operator== ( const Note other) const

Equality of two notes

Parameters
otherto compare
Returns
true if this is equal to other

◆ operator>()

bool Note::operator> ( const Note other) const

Comparison of two notes: this > other

Parameters
otherto compare
Returns
true if this is less than other

◆ operator>=()

bool Note::operator>= ( const Note other) const

Comparison of two notes: this >= other

Parameters
otherto compare
Returns
true if this is less than other

◆ setOctaveNearest()

Note Note::setOctaveNearest ( Note  fromNote)

Set the octave of this note to the one that would result in the target note being at most -6 or +5 semitones from the original note.

Here we guarantee that the target note is no more than -6 or +5 semitones away from the original audio note. Note that we are arbitrarily favoring down-pitching versus up-pitching, and that is an aesthetic decision, because it just sounds good.

[#303] Craft calculates drum audio pitch to conform to the allowable note closest to the original note, slightly favoring down-pitching versus up-pitching.

Parameters
fromNoteto set octave nearest to
Returns
this note for chaining

◆ shift()

Note Note::shift ( int  inc) const

Note stepped +/- semitones to a new Note

Parameters
inc+/- semitones to transpose
Returns
Note

◆ shiftOctave()

Note Note::shiftOctave ( int  inc) const

Note stepped +/- octaves to a new Note

Parameters
inc+/- octaves to transpose
Returns
Note

◆ toString()

std::string Note::toString ( Accidental  accidental) const

Note to std::string

Parameters
accidentalto represent note with
Returns
string representation of Note

Member Data Documentation

◆ ATONAL

std::string Note::ATONAL = "X"
static

Atonal note string representation

◆ octave

int XJ::Note::octave

Octave #

◆ pitchClass

PitchClass XJ::Note::pitchClass

Pitch class of note


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