7#include "maiacore/constants.h"
8#include "maiacore/duration.h"
9#include "maiacore/key.h"
10#include "maiacore/time-signature.h"
21 std::string _writtenPitchClass;
24 std::string _soundingPitchClass;
30 int _transposeDiatonic;
31 int _transposeChromatic;
41 std::pair<std::string, std::string> _slur;
42 std::string _alterSymbol;
43 std::vector<std::string> _tie;
44 std::vector<std::string> _articulation;
45 std::vector<std::string> _beam;
63 explicit Note(
const std::string& pitch,
const RhythmFigure rhythmFigure = RhythmFigure::QUARTER,
64 bool isNoteOn =
true,
bool inChord =
false,
const int transposeDiatonic = 0,
65 const int transposeChromatic = 0,
const int divisionsPerQuarterNote = 256);
78 explicit Note(
const int midiNumber,
const std::string& accType =
"",
79 const RhythmFigure rhythmFigure = RhythmFigure::QUARTER,
bool isNoteOn =
true,
80 bool inChord =
false,
const int transposeDiatonic = 0,
81 const int transposeChromatic = 0,
const int divisionsPerQuarterNote = 256);
113 void setDuration(
const float quarterDuration,
const int divisionsPerQuarterNote = 256);
120 void setDuration(
const int durationTicks,
const int divisionsPerQuarterNote);
184 const std::string& normalType =
"eighth");
224 void addSlur(
const std::string& slurType,
const std::string& slurOrientation);
441 std::pair<std::string, std::string>
getSlur()
const;
560 const int numPartials = 6,
561 const std::function<std::vector<float>(std::vector<float>)> amplCallback =
nullptr,
562 const float partialsDecayExpRate = 0.88f,
563 const float freqA4 = 440.0f)
const;
570 void transpose(
const int semitones,
const std::string& accType = MUSIC_XML::ACCIDENT::NONE);
578 const std::string
toXML(
const size_t instrumentId = 1,
const int identSize = 2)
const;
Represents the duration of a musical note, supporting multiple temporal representations.
Definition: duration.h:15
Represents a musical key signature (tonality), including circle of fifths and mode (major/minor).
Definition: key.h:11
Represents a musical note, including pitch, duration, articulation, and MusicXML-related attributes.
Definition: note.h:19
void transpose(const int semitones, const std::string &accType=MUSIC_XML::ACCIDENT::NONE)
Transposes the note by a number of semitones and optional accidental type.
void setVoice(const int voice)
Sets the voice number for the note.
const std::string getWrittenPitch() const
Returns the full written pitch (as notated).
void setDuration(const int durationTicks, const int divisionsPerQuarterNote)
Sets the duration for the note using tick values.
Note()
Default constructor. Initializes a note as "A4" (MIDI 69).
std::vector< std::string > getTie() const
Returns the tie types for the note.
std::string getSoundingPitchStep() const
Returns the sounding pitch step (e.g., "C", "D").
std::vector< std::string > getEnharmonicPitches(const bool includeCurrentPitch=false) const
Returns all enharmonic pitch strings for the note.
void setTransposingInterval(const int diatonicInterval, const int chromaticInterval)
Sets the transposing interval for the note.
float getFrequency(const float freqA4=440.0f) const
Returns the frequency of the note in Hz.
bool inChord() const
Returns true if the note is part of a chord.
std::vector< std::string > getBeam() const
Returns the beam types for the note.
bool isGraceNote() const
Returns true if the note is a grace note.
void setStaff(const int staff)
Sets the staff number for the note.
std::pair< std::string, std::string > getSlur() const
Returns the slur information (type and orientation).
bool operator>(const Note &otherNote) const
Greater-than operator for comparing notes by MIDI number.
int getScaleDegree(const Key &key) const
Returns the scale degree of the note in a given key.
std::vector< std::string > getArticulation() const
Returns the articulation marks for the note.
int getMidiNumber() const
Returns the MIDI note number.
bool isTransposed() const
Returns true if the note is transposed.
void setTieStopStart()
Sets the note as tied at both start and stop.
bool operator<=(const Note &otherNote) const
Less-than-or-equal operator for comparing notes by MIDI number.
bool operator==(const Note &otherNote) const
Equality operator for comparing notes by pitch.
void setStem(const std::string &stem)
Sets the stem direction for the note.
Note(const std::string &pitch, const RhythmFigure rhythmFigure=RhythmFigure::QUARTER, bool isNoteOn=true, bool inChord=false, const int transposeDiatonic=0, const int transposeChromatic=0, const int divisionsPerQuarterNote=256)
Constructs a Note from a pitch string and rhythm figure.
std::string getShortType() const
Returns the short note type string (e.g., "quarter").
bool isNoteOff() const
Returns true if the note is a rest (note off).
void setOctave(int octave)
Sets the octave for the note.
bool isPitched() const
Returns true if the note is pitched.
std::string getPitchClass() const
Returns the pitch class (sounding).
std::vector< Note > getEnharmonicNotes(const bool includeCurrentPitch=false) const
Returns all enharmonic Note objects for the note.
void setPitch(const std::string &pitch)
Sets the pitch (e.g., "C4", "G#3") for the note.
int getUnpitchedIndex() const
Returns the unpitched index for percussion notes.
std::string getAlterSymbol() const
Returns the accidental symbol for the note (e.g., "#", "b").
void setDuration(const Duration &duration)
Sets the duration for the note.
void setIsGraceNote(const bool isGraceNote=false)
Sets whether the note is a grace note.
void addTie(const std::string &tieType)
Adds a tie type to the note.
void setIsNoteOn(bool isNoteOn)
Sets whether the note is sounding (note on) or a rest (note off).
void setIsPitched(const bool isPitched=true)
Sets whether the note is pitched (true) or unpitched (false).
const Duration & getDuration() const
Returns the Duration object for the note.
void setIsTuplet(const bool isTuplet=false)
Sets the note as part of a tuplet.
int getSoundingOctave() const
Returns the sounding octave (after transposition).
void setUnpitchedIndex(const int unpitchedIndex)
Sets the unpitched index for percussion notes.
int getNumDots() const
Returns the number of dots for the note.
bool isTuplet() const
Returns true if the note is part of a tuplet.
std::string getStem() const
Returns the stem direction.
void setIsInChord(bool inChord)
Sets whether the note is part of a chord.
void setTieStart()
Sets the note as tied at the start.
int getStaff() const
Returns the staff number.
bool operator<(const Note &otherNote) const
Less-than operator for comparing notes by MIDI number.
std::string getPitchStep() const
Returns the pitch step (sounding).
const std::string getDiatonicWrittenPitchClass() const
Returns the diatonic written pitch class (e.g., "C", "D").
Note(const int midiNumber, const std::string &accType="", const RhythmFigure rhythmFigure=RhythmFigure::QUARTER, bool isNoteOn=true, bool inChord=false, const int transposeDiatonic=0, const int transposeChromatic=0, const int divisionsPerQuarterNote=256)
Constructs a Note from a MIDI number, accidental type, and rhythm figure.
float getQuarterDuration() const
Returns the duration in quarter notes as a float.
int getDurationTicks() const
Returns the duration in ticks.
const std::string getWrittenPitchClass() const
Returns the written pitch class (as notated).
void addBeam(const std::string &beam)
Adds a beam type to the note.
const std::string toXML(const size_t instrumentId=1, const int identSize=2) const
Serializes the note to MusicXML format.
std::pair< std::vector< float >, std::vector< float > > getHarmonicSpectrum(const int numPartials=6, const std::function< std::vector< float >(std::vector< float >)> amplCallback=nullptr, const float partialsDecayExpRate=0.88f, const float freqA4=440.0f) const
Returns the harmonic spectrum of the note (partials and amplitudes).
int getDivisionsPerQuarterNote() const
Returns the divisions per quarter note for the note.
bool isDoubleDotted() const
Returns true if the note is double-dotted.
bool operator!=(const Note &otherNote) const
Inequality operator for comparing notes by pitch.
bool isNoteOn() const
Returns true if the note is a sounding note (note on).
std::string getType() const
Returns the note type as a string (e.g., "quarter", "eighth-dot").
bool isDotted() const
Returns true if the note is dotted.
void addArticulation(const std::string &articulation)
Adds an articulation mark to the note.
int getVoice() const
Returns the voice number.
std::string getWrittenPitchStep() const
Returns the written pitch step (e.g., "C", "D").
void toEnharmonicPitch(const bool alternativeEnhamonicPitch=false)
Converts the note to its enharmonic equivalent.
int getWrittenOctave() const
Returns the written octave (as notated).
void removeTies()
Removes all ties from the note.
Note getEnharmonicNote(const bool alternativeEnhamonicPitch=false) const
Returns an enharmonic equivalent Note object.
void setPitchClass(const std::string &pitchClass)
Sets the pitch class (e.g., "C", "D#", "Bb") for the note.
void setTieStop()
Sets the note as tied at the stop.
std::string getPitch() const
Returns the full pitch string (sounding).
int getTransposeChromatic() const
Returns the chromatic transposition interval.
int getTransposeDiatonic() const
Returns the diatonic transposition interval.
std::string getLongType() const
Returns the long note type string (e.g., "quarter-dot").
const std::string getSoundingPitchClass() const
Returns the sounding pitch class (after transposition).
void setTupleValues(const int actualNotes, const int normalNotes, const std::string &normalType="eighth")
Sets the tuplet values for the note.
const std::string getDiatonicSoundingPitchClass() const
Returns the diatonic sounding pitch class (e.g., "C", "D").
void info() const
Prints detailed information about the note to the log.
void setDuration(const float quarterDuration, const int divisionsPerQuarterNote=256)
Sets the duration for the note using quarter note value.
std::string getEnharmonicPitch(const bool alternativeEnhamonicPitch=false) const
Returns an enharmonic equivalent pitch string.
void addSlur(const std::string &slurType, const std::string &slurOrientation)
Adds a slur to the note.
bool operator>=(const Note &otherNote) const
Greater-than-or-equal operator for comparing notes by MIDI number.
int getOctave() const
Returns the octave (sounding).
const std::string getSoundingPitch() const
Returns the full sounding pitch (after transposition).