Music#

Notes#

namespace YSE

Public API of libYSE — sound playback, mixing, and 3D positional audio.

Entry points: YSE::System (lifecycle and audio device), YSE::Listener (3D origin), YSE::sound (a playable source), YSE::channel (mixing tree), YSE::reverb (positioned reverb zone), YSE::patcher (modular DSP graph), YSE::player (note sequencer). Sub-namespaces group domain-specific types: YSE::DSP for signal processing, YSE::MIDI for MIDI I/O, YSE::MUSIC for note / chord / motif primitives.

Note

Apart from their constructors, the oscillator and vcf classes must only be invoked from inside a DSP callback / process body.

namespace MUSIC#

Music-theory primitives: notes, chords, positioned notes for motifs.

These types feed YSE::scale, YSE::motif, and YSE::player to drive generative composition.

Functions

note operator+(const note &n, Flt pitch)#

Add a pitch value to a note (pitch only).

note operator-(const note &n, Flt pitch)#

Subtract a pitch value from a note (pitch only).

note operator*(const note &n, Flt pitch)#

Multiply a note’s pitch by a value.

note operator/(const note &n, Flt pitch)#

Divide a note’s pitch by a value.

note operator+(Flt pitch, const note &n)#

Add a note’s pitch to a value.

The result carries the note’s velocity.

note operator-(Flt pitch, const note &n)#

Subtract a note’s pitch from a value.

The result carries the note’s velocity.

note operator*(Flt pitch, const note &n)#

Multiply a value by a note’s pitch.

The result carries the note’s velocity.

note operator/(Flt pitch, const note &n)#

Divide a value by a note’s pitch.

The result carries the note’s velocity.

note operator+(const note &n1, const note &n2)#

Add two notes’ pitches (pitch only).

note operator-(const note &n1, const note &n2)#

Subtract two notes’ pitches (pitch only).

note operator*(const note &n1, const note &n2)#

Multiply two notes’ pitches (pitch only).

note operator/(const note &n1, const note &n2)#

Divide two notes’ pitches (pitch only).

class note#

A single musical event — pitch, volume, length, and MIDI channel.

note is the fundamental unit for the music subsystem: chords are collections of notes, motifs are sequences of pitched notes (pNote), and players generate notes within a scale constraint.

The arithmetic operators (+ / - / * / /) operate on pitch only; volume, length, and channel are preserved.

See also

YSE::scale

Subclassed by YSE::MUSIC::pNote

Public Functions

note(Flt pitch = 60.f, Flt volume = 1.f, Flt length = 0.f, Int channel = 1)#

Construct a note.

Parameters:
  • pitch – MIDI pitch (60 = middle C).

  • volume – Velocity in [0.0, 1.0].

  • length – Duration in seconds. 0 means use the default length.

  • channel – MIDI channel (1-16).

note(const note &object)#
note &operator=(const note&) = default#
note &set(Flt pitch, Flt volume = 1.f, Flt length = 0.f, Int channel = 1)#

Replace all four fields in one call.

note &setPitch(Flt value)#

Set the MIDI pitch.

note &setVolume(Flt value)#

Set the velocity.

note &setLength(Flt value)#

Set the duration in seconds.

note &setChannel(Int value)#

Set the MIDI channel.

Flt getPitch() const#

Current pitch.

Flt getVolume() const#

Current velocity.

Flt getLength() const#

Current duration.

Int getChannel() const#

Current MIDI channel.

bool update()#

Advance the note one tick.

Returns false once the note has finished.

bool update(Flt delta)#

More precise variant of update driven by an explicit delta.

Note

Audio-thread only.

note &operator+=(const note &object)#

Add another note’s pitch (pitch only).

note &operator-=(const note &object)#

Subtract another note’s pitch (pitch only).

note &operator*=(const note &object)#

Multiply pitch by another note’s pitch.

note &operator/=(const note &object)#

Divide pitch by another note’s pitch.

void operator=(const pNote &other)#

Copy from a positioned note (drops the position field).

note &operator+=(Flt pitch)#

Add a pitch value.

note &operator-=(Flt pitch)#

Subtract a pitch value.

note &operator*=(Flt pitch)#

Multiply pitch by a value.

note &operator/=(Flt pitch)#

Divide pitch by a value.

Bool operator==(const note &object)#

Equality on pitch.

Bool operator!=(const note &object)#

Inequality on pitch.

Bool operator<(const note &object)#

Order by pitch.

Bool operator>(const note &object)#

Order by pitch.

Bool operator<=(const note &object)#

Order by pitch.

Bool operator>=(const note &object)#

Order by pitch.

Bool operator==(Flt pitch)#

Compare pitch against a value.

Bool operator!=(Flt pitch)#

Compare pitch against a value.

Bool operator<(Flt pitch)#

Compare pitch against a value.

Bool operator>(Flt pitch)#

Compare pitch against a value.

Bool operator<=(Flt pitch)#

Compare pitch against a value.

Bool operator>=(Flt pitch)#

Compare pitch against a value.

Private Members

Flt pitch#
Flt volume#
Flt length#
Int channel#
namespace YSE

Public API of libYSE — sound playback, mixing, and 3D positional audio.

Entry points: YSE::System (lifecycle and audio device), YSE::Listener (3D origin), YSE::sound (a playable source), YSE::channel (mixing tree), YSE::reverb (positioned reverb zone), YSE::patcher (modular DSP graph), YSE::player (note sequencer). Sub-namespaces group domain-specific types: YSE::DSP for signal processing, YSE::MIDI for MIDI I/O, YSE::MUSIC for note / chord / motif primitives.

Note

Apart from their constructors, the oscillator and vcf classes must only be invoked from inside a DSP callback / process body.

namespace MUSIC

Music-theory primitives: notes, chords, positioned notes for motifs.

These types feed YSE::scale, YSE::motif, and YSE::player to drive generative composition.

class pNote : public YSE::MUSIC::note#

A note with a time position — the building block of a motif.

Where a plain note represents a sound event in isolation, pNote fixes it to a moment in a motif’s timeline. Position is measured from the start of the containing motif, in seconds.

Public Functions

pNote(Flt position, Flt pitch, Flt volume, Flt length, Int channel = 1)#

Construct a positioned note.

Parameters:
  • position – Offset from the start of the motif, in seconds.

  • pitch – MIDI pitch (60 = middle C).

  • volume – Velocity in [0.0, 1.0].

  • length – Duration in seconds.

  • channel – MIDI channel.

pNote(const note &object, Flt position = 0.f)#

Construct from an existing note plus a position.

pNote &setPosition(Flt value)#

Set the time position.

Flt getPosition() const#

Current time position.

Private Members

Flt position#
namespace YSE

Public API of libYSE — sound playback, mixing, and 3D positional audio.

Entry points: YSE::System (lifecycle and audio device), YSE::Listener (3D origin), YSE::sound (a playable source), YSE::channel (mixing tree), YSE::reverb (positioned reverb zone), YSE::patcher (modular DSP graph), YSE::player (note sequencer). Sub-namespaces group domain-specific types: YSE::DSP for signal processing, YSE::MIDI for MIDI I/O, YSE::MUSIC for note / chord / motif primitives.

Note

Apart from their constructors, the oscillator and vcf classes must only be invoked from inside a DSP callback / process body.

namespace MUSIC

Music-theory primitives: notes, chords, positioned notes for motifs.

These types feed YSE::scale, YSE::motif, and YSE::player to drive generative composition.

Functions

chord operator+(const chord &c, const note &n)#

Chord with an extra note appended.

chord operator-(const chord &c, const note &n)#

Chord with the given note removed.

chord operator+(const chord &c1, const chord &c2)#

Concatenation of two chords.

chord operator-(const chord &c1, const chord &c2)#

Notes of c1 minus notes of c2.

chord operator+(const note &n, const chord &c)#

Chord built from a single note plus the notes of c.

chord operator-(const note &n, const chord &c)#

Notes of c minus the single note n.

class chord#

An unordered collection of note objects sounding together.

Build a chord additively or pass several notes to the variadic constructor. The arithmetic operators add notes to / remove notes from the chord, and transpose shifts every note’s pitch by a fixed amount.

Public Functions

chord()#
chord(const chord &object)#
chord(UInt count, ...)#

Variadic constructor — pass count followed by count note values.

Example: chord c(3, note(60), note(64), note(67)); builds a C major triad.

UInt elms()#

Number of notes in the chord.

chord &transpose(Flt value)#

Shift every note’s pitch by value.

chord &operator+=(const chord &object)#

Append every note of object to this chord.

chord &operator-=(const chord &object)#

Remove notes that also appear in object.

chord &operator+=(const note &object)#

Append a single note.

chord &operator-=(const note &object)#

Remove a single note.

Bool operator==(const chord &object)#

Whether the two chords hold the same notes.

Bool operator!=(const chord &object)#

Inequality.

Private Members

std::vector<note> notes#

Scales#

namespace YSE

Public API of libYSE — sound playback, mixing, and 3D positional audio.

Entry points: YSE::System (lifecycle and audio device), YSE::Listener (3D origin), YSE::sound (a playable source), YSE::channel (mixing tree), YSE::reverb (positioned reverb zone), YSE::patcher (modular DSP graph), YSE::player (note sequencer). Sub-namespaces group domain-specific types: YSE::DSP for signal processing, YSE::MIDI for MIDI I/O, YSE::MUSIC for note / chord / motif primitives.

Note

Apart from their constructors, the oscillator and vcf classes must only be invoked from inside a DSP callback / process body.

namespace YSE

Public API of libYSE — sound playback, mixing, and 3D positional audio.

Entry points: YSE::System (lifecycle and audio device), YSE::Listener (3D origin), YSE::sound (a playable source), YSE::channel (mixing tree), YSE::reverb (positioned reverb zone), YSE::patcher (modular DSP graph), YSE::player (note sequencer). Sub-namespaces group domain-specific types: YSE::DSP for signal processing, YSE::MIDI for MIDI I/O, YSE::MUSIC for note / chord / motif primitives.

Note

Apart from their constructors, the oscillator and vcf classes must only be invoked from inside a DSP callback / process body.

class scale#

A set of allowed pitches.

Drives the player so its generated notes stay in key, and constrains the transpositions a motif can take. Pitches are added with an optional step that controls automatic octave replication.

See also

YSE::player

See also

YSE::motif

Public Functions

scale()#
~scale()#
scale &add(Flt pitch, Flt step = 12)#

Add a pitch to the scale.

Parameters:
  • pitch – The MIDI pitch to add.

  • step – Octave step. 12 (default) replicates the pitch at every octave. Values <= 0 add only the exact pitch.

scale &remove(Flt pitch, Flt step = 12)#

Remove a pitch from the scale.

Parameters:
  • pitch – The MIDI pitch to remove.

  • step – Octave step — by default the pitch is removed at every octave.

Bool has(Flt pitch)#

Whether pitch is a member of the scale.

Flt getNearest(Flt pitch) const#

Nearest in-scale pitch to pitch.

UInt size() const#

Number of pitches in the scale.

scale &clear()#

Remove every pitch.

scale(const scale &other)#
scale &operator=(const scale &other)#

Private Members

SCALE::implementationObject *pimpl#
std::vector<Flt> pitches#

Friends

friend class player
friend class motif

Motifs#

namespace YSE

Public API of libYSE — sound playback, mixing, and 3D positional audio.

Entry points: YSE::System (lifecycle and audio device), YSE::Listener (3D origin), YSE::sound (a playable source), YSE::channel (mixing tree), YSE::reverb (positioned reverb zone), YSE::patcher (modular DSP graph), YSE::player (note sequencer). Sub-namespaces group domain-specific types: YSE::DSP for signal processing, YSE::MIDI for MIDI I/O, YSE::MUSIC for note / chord / motif primitives.

Note

Apart from their constructors, the oscillator and vcf classes must only be invoked from inside a DSP callback / process body.

namespace YSE

Public API of libYSE — sound playback, mixing, and 3D positional audio.

Entry points: YSE::System (lifecycle and audio device), YSE::Listener (3D origin), YSE::sound (a playable source), YSE::channel (mixing tree), YSE::reverb (positioned reverb zone), YSE::patcher (modular DSP graph), YSE::player (note sequencer). Sub-namespaces group domain-specific types: YSE::DSP for signal processing, YSE::MIDI for MIDI I/O, YSE::MUSIC for note / chord / motif primitives.

Note

Apart from their constructors, the oscillator and vcf classes must only be invoked from inside a DSP callback / process body.

class motif#

A sequence of positioned notes — a re-usable phrase or pattern.

Add notes (with positions) via add, optionally constrain the starting pitch with a scale, and hand the motif to a player which will trigger it at appropriate moments.

See also

YSE::player

Public Functions

motif()#
~motif()#
motif &add(const MUSIC::pNote &note)#

Append a positioned note.

motif &clear()#

Remove every note.

motif &setLength(Flt length)#

Set the motif length explicitly, in seconds.

motif &setLength()#

Set the motif length automatically to the end of the last note.

motif &transpose(Flt pitch)#

Transpose every note by pitch semitones.

motif &setFirstPitch(const scale &validPitches)#

Restrict legal starting pitches.

When a player picks a transposition for this motif it picks one whose starting note belongs to validPitches.

inline Flt getLength()#

Current motif length in seconds.

inline Bool empty()#

Whether the motif contains any notes.

inline UInt size()#

Number of notes.

MUSIC::pNote &operator[](UInt pos)#

Access the note at index pos.

motif(const motif &other)#
motif &operator=(const motif &other)#

Private Functions

void sort()#

Private Members

MOTIF::implementationObject *pimpl#
Flt length#
std::vector<MUSIC::pNote> notes#

Friends

friend class player