Csound and CsoundAC API  5.17
Public Types | Public Member Functions
csound::Chord Class Reference

Chords represent simultaneously sounding pitches. More...

#include <ChordSpace.hpp>

Public Types

enum  {
  PITCH = 0, DURATION = 1, LOUDNESS = 2, INSTRUMENT = 3,
  PAN = 4, COUNT = 5
}

Public Member Functions

virtual Chord ceiling () const
 Returns a new chord whose pitches are the ceilings of this chord's pitches.
 Chord ()
virtual bool contains (double pitch_) const
 Returns whether or not the chord contains the pitch.
virtual size_t count (double pitch) const
virtual Chord cycle (int stride=1) const
 Returns a copy of the chord cyclically permuted by a stride, by default 1.
virtual double distanceToOrigin () const
 Returns the Euclidean distance of this chord from its space's origin.
virtual double distanceToUnisonDiagonal () const
 Returns the distance of this chord from its space's unison diagonal.
virtual Chord eI () const
 Returns the equivalent of the chord within the representative fundamental domain of inversional equivalence.
virtual Chord eO () const
 Returns the equivalent of the chord within the representative fundamental domain of octave equivalence.
virtual Chord eOP () const
 Returns the equivalent of the chord within the representative fundamental domain of octave and permutational equivalence.
virtual Chord eOPI () const
 Returns the equivalent of the chord within the representative fundamental domain of octave, permutational, and inversional equivalence.
virtual Chord eOPT () const
 Returns the equivalent of the chord within the representative fundamental domain of octave, permutational, and transpositional equivalence.
virtual Chord eOPTT (double g=1.0) const
virtual Chord eP () const
 Returns the equivalent of the chord within the representative fundamental domain of permutational equivalence.
virtual Chord epcs () const
 Returns the equivalent of the chord under pitch-class equivalence, i.e.
virtual Chord eR (double range) const
 Returns the equivalent of the chord within the representative fundamental domain of a range equivalence.
virtual Chord eRP (double range) const
 Returns the equivalent of the chord within the representative fundamental domain of range and permutational equivalence.
virtual Chord eRPI (double range) const
 Returns the equivalent of the chord within the representative fundamental domain of range, permutational, and inversional equivalence.
virtual Chord eRPT (double range) const
 Returns the equivalent of the chord within the representative fundamental domain of range, permutational, and transpositional equivalence; the same as set-class type, or chord type.
virtual Chord eRPTT (double range, double g=1.0) const
virtual Chord et () const
 Returns the equivalent of the chord within the fundamental domain of transposition to 0.
virtual Chord eT () const
 Returns the equivalent of the chord within the representative fundamental domain of transpositonal equivalence.
virtual Chord eTT (double g=1.0) const
 Returns the equivalent of the chord within the representative fundamental domain of transpositonal equivalence and the equal temperament generated by g.
virtual Chord eV () const
 Returns the equivalent of the chord within the representative fundamental domain of voicing equivalence.
virtual Chord floor () const
 Returns a new chord whose pitches are the floors of this chord's pitches.
virtual double getDuration (int voice=0) const
virtual double getInstrument (int voice=0) const
virtual double getLoudness (int voice=0) const
virtual double getPan (int voice=0) const
virtual double getPitch (int voice) const
virtual Chord I (double center=0.0) const
 Inverts the chord by another chord that is on the unison diagonal, by default the origin.
virtual bool iseI (Chord *inverse=0) const
 Returns whether the chord is within the representative fundamental domain of inversional equivalence.
virtual bool iseO () const
 Returns whether the chord is within the representative fundamental domain of octave equivalence.
virtual bool iseOP () const
 Returns whether the chord is within the representative fundamental domain of octave and permutational equivalence.
virtual bool iseOPI () const
 Returns whether the chord is within the representative fundamental domain of octave, permutational, and inversional equivalence.
virtual bool iseOPT () const
 Returns whether the chord is within the representative fundamental domain of octave, permutational, and transpositional equivalence.
virtual bool iseOPTT (double g=1.0) const
virtual bool iseP () const
 Returns whether the chord is within the representative fundamental domain of permutational equivalence.
virtual bool isepcs () const
 Returns whether the chord is within the fundamental domain of pitch-class equivalence, i.e.
virtual bool iseR (double range) const
 Returns whether the chord is within the representative fundamental domain of the indicated range equivalence.
virtual bool iseRP (double range) const
 Returns whether the chord is within the representative fundamental domain of range and permutational equivalence.
virtual bool iseRPI (double range) const
 Returns whether the chord is within the representative fundamental domain of range, permutational, and inversional equivalence.
virtual bool iseRPT (double range) const
 Returns whether the chord is within the representative fundamental domain of range, permutational, and transpositional equivalence.
virtual bool iseRPTT (double range, double g=1.0) const
virtual bool iset () const
 Returns whether the chord is within the fundamental domain of transposition to 0.
virtual bool iseT () const
 Returns whether the chord is within the representative fundamental domain of transpositional equivalence.
virtual bool iseTT (double g=1.0) const
 Returns whether the chord is within the representative fundamental domain of translational equivalence and the equal temperament generated by g.
virtual bool iseV () const
 Returns whether the chord is within the representative fundamental domain of voicing equivalence.
virtual double layer () const
 Returns the sum of the pitches in the chord.
virtual std::vector< double > max () const
 Returns the highest pitch in the chord, and also its voice index.
virtual Chord maximallyEven () const
 Returns the maximally even chord in the chord's space, e.g.
virtual double maximumInterval () const
virtual std::vector< double > min () const
 Returns the lowest pitch in the chord, and also its voice index.
virtual double minimumInterval () const
virtual bool operator< (const Chord &other) const
virtual bool operator<= (const Chord &other) const
virtual bool operator== (const Chord &other) const
virtual bool operator> (const Chord &other) const
virtual bool operator>= (const Chord &other) const
virtual Chord origin () const
 Returns the origin of the chord's space.
virtual std::vector< Chordpermutations () const
 Returns the permutations of the pitches in a chord.
virtual void resize (size_t voices)
virtual void setDuration (double value, int voice=-1)
virtual void setInstrument (double value, int voice=-1)
virtual void setLoudness (double value, int voice=-1)
virtual void setPan (double value, int voice=-1)
virtual void setPitch (int voice, double value)
virtual Chord T (double interval) const
 Transposes the chord by the indicated interval (may be a fraction).
virtual std::string toString () const
 Returns a string representation of the chord.
virtual Chord v (int direction=1) const
 Returns a copy of the chord 'inverted' in the musician's sense, i.e.
virtual size_t voices () const
virtual std::vector< Chordvoicings () const
 Returns all the 'inversions' (in the musician's sense) or octavewise revoicings of the chord.
virtual ~Chord ()

Detailed Description

Chords represent simultaneously sounding pitches.

The pitches are represented as semitones with 0 at the origin and middle C as 60. Each voice also has a duration, velocity, channel, and pan. Eigen matrices are accessed (row, column) and stored as columns vectors, so a Chord is accessed (voice, attribute).

Member Enumeration Documentation

anonymous enum
Enumerator:
PITCH 
DURATION 
LOUDNESS 
INSTRUMENT 
PAN 
COUNT 

Constructor & Destructor Documentation

csound::Chord::Chord ( )
inline
virtual csound::Chord::~Chord ( )
inlinevirtual

Member Function Documentation

virtual Chord csound::Chord::ceiling ( ) const
inlinevirtual

Returns a new chord whose pitches are the ceilings of this chord's pitches.

References setPitch().

virtual bool csound::Chord::contains ( double  pitch_) const
inlinevirtual

Returns whether or not the chord contains the pitch.

References csound::eq_epsilon().

virtual size_t csound::Chord::count ( double  pitch) const
inlinevirtual

References csound::eq_epsilon().

virtual Chord csound::Chord::cycle ( int  stride = 1) const
inlinevirtual

Returns a copy of the chord cyclically permuted by a stride, by default 1.

The direction of rotation is by default the same as musicians' first inversion, second inversion, and so on; but negative sign will reverse the direction of rotation.

  • 1 is pop the front and push it on the back, shifting the middle down. 0 1 2 3 4 => 1 2 3 4 0
  • 1 is pop the back and push it on the front, shifting the middle up. 0 1 2 3 4 => 4 0 1 2 3

Referenced by permutations(), and v().

virtual double csound::Chord::distanceToOrigin ( ) const
inlinevirtual

Returns the Euclidean distance of this chord from its space's origin.

References csound::euclidean().

virtual double csound::Chord::distanceToUnisonDiagonal ( ) const
inlinevirtual

Returns the distance of this chord from its space's unison diagonal.

References csound::euclidean(), and setPitch().

virtual Chord csound::Chord::eI ( ) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of inversional equivalence.

References csound::I().

virtual Chord csound::Chord::eO ( ) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of octave equivalence.

References csound::OCTAVE().

virtual Chord csound::Chord::eOP ( ) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of octave and permutational equivalence.

References csound::OCTAVE().

virtual Chord csound::Chord::eOPI ( ) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of octave, permutational, and inversional equivalence.

References csound::OCTAVE().

virtual Chord csound::Chord::eOPT ( ) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of octave, permutational, and transpositional equivalence.

References csound::OCTAVE().

virtual Chord csound::Chord::eOPTT ( double  g = 1.0) const
inlinevirtual

References csound::OCTAVE().

virtual Chord csound::Chord::eP ( ) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of permutational equivalence.

The implementation

uses a bubble sort to swap out of order voices in the Eigen matrix.

References getPitch(), and csound::gt_epsilon().

Referenced by eRP().

virtual Chord csound::Chord::epcs ( ) const
inlinevirtual

Returns the equivalent of the chord under pitch-class equivalence, i.e.

the pitch-class set of the chord.

References csound::epc(), and setPitch().

virtual Chord csound::Chord::eR ( double  range) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of a range equivalence.

References csound::gt_epsilon(), iseR(), layer(), max(), csound::OCTAVE(), and setPitch().

virtual Chord csound::Chord::eRP ( double  range) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of range and permutational equivalence.

References eP().

Referenced by eRPI().

virtual Chord csound::Chord::eRPI ( double  range) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of range, permutational, and inversional equivalence.

References eRP(), I(), and iseRPI().

virtual Chord csound::Chord::eRPT ( double  range) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of range, permutational, and transpositional equivalence; the same as set-class type, or chord type.

References eT(), iseV(), voices(), and voicings().

virtual Chord csound::Chord::eRPTT ( double  range,
double  g = 1.0 
) const
inlinevirtual

References iseV(), voices(), and voicings().

virtual Chord csound::Chord::et ( ) const
inlinevirtual

Returns the equivalent of the chord within the fundamental domain of transposition to 0.

References csound::T().

virtual Chord csound::Chord::eT ( ) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of transpositonal equivalence.

References csound::T().

Referenced by eRPT().

virtual Chord csound::Chord::eTT ( double  g = 1.0) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of transpositonal equivalence and the equal temperament generated by g.

I.e., returns the chord transposed such that its layer is 0 or, under transposition, the positive layer closest to 0. NOTE: Does NOT return the result under any other equivalence class.

References getPitch(), and T().

Referenced by iseTT().

virtual Chord csound::Chord::eV ( ) const
inlinevirtual

Returns the equivalent of the chord within the representative fundamental domain of voicing equivalence.

References csound::ge_epsilon(), getPitch(), csound::OCTAVE(), and voices().

virtual Chord csound::Chord::floor ( ) const
inlinevirtual

Returns a new chord whose pitches are the floors of this chord's pitches.

References setPitch().

virtual double csound::Chord::getDuration ( int  voice = 0) const
inlinevirtual
virtual double csound::Chord::getInstrument ( int  voice = 0) const
inlinevirtual
virtual double csound::Chord::getLoudness ( int  voice = 0) const
inlinevirtual
virtual double csound::Chord::getPan ( int  voice = 0) const
inlinevirtual
virtual double csound::Chord::getPitch ( int  voice) const
inlinevirtual
virtual Chord csound::Chord::I ( double  center = 0.0) const
inlinevirtual

Inverts the chord by another chord that is on the unison diagonal, by default the origin.

NOTE: Does NOT return the result under any equivalence class.

References csound::I(), and setPitch().

Referenced by eRPI().

virtual bool csound::Chord::iseI ( Chord inverse = 0) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of inversional equivalence.

References csound::I().

virtual bool csound::Chord::iseO ( ) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of octave equivalence.

References csound::OCTAVE().

virtual bool csound::Chord::iseOP ( ) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of octave and permutational equivalence.

References csound::OCTAVE().

virtual bool csound::Chord::iseOPI ( ) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of octave, permutational, and inversional equivalence.

References csound::OCTAVE().

virtual bool csound::Chord::iseOPT ( ) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of octave, permutational, and transpositional equivalence.

References csound::OCTAVE().

virtual bool csound::Chord::iseOPTT ( double  g = 1.0) const
inlinevirtual

References csound::OCTAVE().

virtual bool csound::Chord::iseP ( ) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of permutational equivalence.

References csound::le_epsilon().

virtual bool csound::Chord::isepcs ( ) const
inlinevirtual

Returns whether the chord is within the fundamental domain of pitch-class equivalence, i.e.

is a pitch-class set.

References csound::epc(), and csound::eq_epsilon().

virtual bool csound::Chord::iseR ( double  range) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of the indicated range equivalence.

References csound::le_epsilon().

Referenced by eR().

virtual bool csound::Chord::iseRP ( double  range) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of range and permutational equivalence.

virtual bool csound::Chord::iseRPI ( double  range) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of range, permutational, and inversional equivalence.

References csound::I().

Referenced by eRPI().

virtual bool csound::Chord::iseRPT ( double  range) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of range, permutational, and transpositional equivalence.

virtual bool csound::Chord::iseRPTT ( double  range,
double  g = 1.0 
) const
inlinevirtual
virtual bool csound::Chord::iset ( ) const
inlinevirtual

Returns whether the chord is within the fundamental domain of transposition to 0.

virtual bool csound::Chord::iseT ( ) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of transpositional equivalence.

References csound::eq_epsilon().

virtual bool csound::Chord::iseTT ( double  g = 1.0) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of translational equivalence and the equal temperament generated by g.

References eTT().

virtual bool csound::Chord::iseV ( ) const
inlinevirtual

Returns whether the chord is within the representative fundamental domain of voicing equivalence.

Referenced by eRPT(), and eRPTT().

virtual double csound::Chord::layer ( ) const
inlinevirtual

Returns the sum of the pitches in the chord.

References sum().

Referenced by eR().

virtual std::vector<double> csound::Chord::max ( ) const
inlinevirtual

Returns the highest pitch in the chord, and also its voice index.

References csound::gt_epsilon().

Referenced by eR().

virtual Chord csound::Chord::maximallyEven ( ) const
inlinevirtual

Returns the maximally even chord in the chord's space, e.g.

the augmented triad for 3 dimensions.

References csound::OCTAVE(), and setPitch().

virtual double csound::Chord::maximumInterval ( ) const
inlinevirtual

References csound::gt_epsilon().

virtual std::vector<double> csound::Chord::min ( ) const
inlinevirtual

Returns the lowest pitch in the chord, and also its voice index.

References csound::lt_epsilon().

virtual double csound::Chord::minimumInterval ( ) const
inlinevirtual

References csound::lt_epsilon().

virtual bool csound::Chord::operator< ( const Chord other) const
inlinevirtual
virtual bool csound::Chord::operator<= ( const Chord other) const
inlinevirtual
virtual bool csound::Chord::operator== ( const Chord other) const
inlinevirtual
virtual bool csound::Chord::operator> ( const Chord other) const
inlinevirtual
virtual bool csound::Chord::operator>= ( const Chord other) const
inlinevirtual
virtual Chord csound::Chord::origin ( ) const
inlinevirtual

Returns the origin of the chord's space.

References resize().

virtual std::vector<Chord> csound::Chord::permutations ( ) const
inlinevirtual

Returns the permutations of the pitches in a chord.

The permutations starting from any particular permutation are always returned in the same order.

References cycle().

virtual void csound::Chord::resize ( size_t  voices)
inlinevirtual

Referenced by origin().

virtual void csound::Chord::setDuration ( double  value,
int  voice = -1 
)
inlinevirtual
virtual void csound::Chord::setInstrument ( double  value,
int  voice = -1 
)
inlinevirtual
virtual void csound::Chord::setLoudness ( double  value,
int  voice = -1 
)
inlinevirtual
virtual void csound::Chord::setPan ( double  value,
int  voice = -1 
)
inlinevirtual
virtual void csound::Chord::setPitch ( int  voice,
double  value 
)
inlinevirtual
virtual Chord csound::Chord::T ( double  interval) const
inlinevirtual

Transposes the chord by the indicated interval (may be a fraction).

NOTE: Does NOT return the result under any equivalence class.

References setPitch(), and csound::T().

Referenced by eTT().

virtual std::string csound::Chord::toString ( ) const
inlinevirtual

Returns a string representation of the chord.

Quadratic complexity, but short enough not to matter.

virtual Chord csound::Chord::v ( int  direction = 1) const
inlinevirtual

Returns a copy of the chord 'inverted' in the musician's sense, i.e.

revoiced by cyclically permuting the chord and adding (or subtracting) an octave to the highest (or lowest) voice. The revoicing will move the chord up or down in pitch. A positive direction is the same as a musician's first inversion, second inversion, etc.

References cycle(), getPitch(), csound::OCTAVE(), and setPitch().

Referenced by voicings().

virtual size_t csound::Chord::voices ( ) const
inlinevirtual
virtual std::vector<Chord> csound::Chord::voicings ( ) const
inlinevirtual

Returns all the 'inversions' (in the musician's sense) or octavewise revoicings of the chord.

References v().

Referenced by eRPT(), and eRPTT().