Csound and CsoundAC API  5.17
Public Member Functions | Data Fields | Protected Attributes
csound::ChordLindenmayer Class Reference

This class implements a Lindenmayer system that generates a score by moving a turtle around in various implicit music spaces. More...

#include <ChordLindenmayer.hpp>

+ Inheritance diagram for csound::ChordLindenmayer:

Public Member Functions

virtual void addChild (Node *node)
virtual void addRule (std::string command, std::string replacement)
virtual void apply (Score &score, const VoiceleadingOperation &priorOperation, const VoiceleadingOperation &currentOperation)
 Apply the current voice-leading operation to the score, within the specified range of notes.
virtual void applyVoiceleadingOperations ()
virtual void C (double time, double C_)
 Beginning at the specified time and continuing to the beginning of the next operation or the end of the score, whichever comes first, conform notes produced by this node or its children to the specified prime chord and transposition.
virtual void C (double time, std::string C_)
 Same as PT, except that a single number is used in place of the P and T numbers.
 ChordLindenmayer ()
virtual void CL (double time, double C_, bool avoidParallels=true)
 Same as CV, except the chord is specified by jazz-type name (e.g.
virtual void CL (double time, std::string C_, bool avoidParallels=true)
 Same as PTL, except the chord is specified by a single number instead of P and T numbers.
virtual void clear ()
virtual Eigen::MatrixXd createRotation (int dimension1, int dimension2, double angle) const
virtual Eigen::MatrixXd createTransform ()
virtual void CV (double time, double C_, double V_)
 Same as C, except the chord can be specified by jazz-type name (e.g.
virtual void CV (double time, std::string C_, double V_)
 Same as PTV, except the chord is specified by a single number instead of the P and T numbers.
virtual double & element (size_t row, size_t column)
 Returns a reference to the indicated element of the local transformation of coordinate system.
virtual double equivalence (double &value, char equivalenceClass) const
 Returns the result of applying the equivalence class to the value, both in the argument and as the return value; there may be no effect.
virtual void fixStatus ()
virtual void generate ()
 Scores are generated as follows:
virtual void generateLindenmayerSystem ()
virtual double getAngle () const
virtual std::string getAxiom () const
virtual int getDimension (char dimension) const
virtual int getIterationCount () const
virtual Eigen::MatrixXd getLocalCoordinates () const
 Returns the local transformation of coordinate system.
virtual std::vector< double > getModality () const
virtual std::string getReplacement (std::string command)
virtual void initialize ()
virtual void interpret (std::string command)
virtual void K (double time)
 Find the C of the previous segment, and contextually invert it; apply the resulting C to the current segment.
virtual void KL (double time, bool avoidParallels=true)
 Find the C of the previous segment, and contextually invert it; apply the resulting C to the current segment, using the closest voiceleading from the pitches of the previous segment.
virtual void KV (double time, double V_)
 Find the C of the previous segment, and contextually invert it; apply the resulting C to the current segment with voicing V.
virtual void L (double time, bool avoidParallels=true)
 Beginning at the specified time and continuing to the beginning of the next operation or the end of the score, whichever comes first, conform notes produced by this node or its children to the smoothest voice-leading from the pitches of the previous segment.
virtual char parseCommand (const std::string &command, std::string &operation, char &target, char &equivalenceClass, size_t &dimension, size_t &dimension1, double &scalar, std::vector< double > &vector)
virtual void produceOrTransform (Score &score, size_t beginAt, size_t endAt, const Eigen::MatrixXd &compositeCordinates)
 Applies all of the stored voice-leading operations to the specified range of notes in the score.
virtual void PT (double time, double P_, double T)
 Beginning at the specified time and continuing to the beginning of the next operation or the end of the score, whichever comes first, conform notes produced by this node or its children to the specified prime chord and transposition.
virtual void PTL (double time, double P_, double T, bool avoidParallels=true)
 Beginning at the specified time and continuing to the beginning of the next operation or the end of the score, whichever comes first, conform notes produced by this node or its children to the specified chord; the voicing of the chord will be the smoothest voice-leading from the pitches of the previous chord.
virtual void PTV (double time, double P_, double T, double V_)
 Beginning at the specified time and continuing to the beginning of the next operation or the end of the score, whichever comes first, conform notes produced by this node or its children to the specified prime chord, transposition, and voicing.
virtual void Q (double time, double Q_)
 Find the C of the previous segment, and contextually transpose it; apply the resulting C to the current segment.
virtual void QL (double time, double Q_, bool avoidParallels=true)
 Find the C of the previous segment, and contextually transpose it; apply the resulting C to the current segment, using the closest voiceleading from the pitches of the previous segment.
virtual void QV (double time, double Q_, double V_)
 Find the C of the previous segment, and contextually transpose it; apply the resulting C to the current segment with voicing V.
virtual void setAngle (double angle)
virtual void setAxiom (std::string axiom)
virtual void setElement (size_t row, size_t column, double value)
 Sets the indicated element of the local transformation of coordinate system.
virtual void setIterationCount (int count)
virtual void setModality (const std::vector< double > &pcs)
virtual void tieOverlappingNotes ()
virtual void transform (Score &score, bool rescaleTime=false)
 Apply all of the voice-leading operations stored within this node to the score.
virtual Eigen::MatrixXd traverse (const Eigen::MatrixXd &globalCoordinates, Score &score)
 The default implementation postconcatenates its own local coordinate system with the global coordinates, then passes the score and the product of coordinate systems to each child, thus performing a depth-first traversal of the music graph.
virtual void V (double time, double V_)
 Beginning at the specified time and continuing to the beginning of the next operation or the end of the score, whichever comes first, conform notes produced by this node or its children to the specified voicing of the chord.
virtual void writeScore ()
virtual ~ChordLindenmayer ()

Data Fields

double angle
bool avoidParallels
 If true (the default), voice-leadings will avoid parallel fifths.
std::string axiom
double base
 The lowest pitch of the range of voicings, as a MIDI key number (default = 36).
clock_t beganAt
std::vector< Node * > children
 Child Nodes, if any.
size_t divisionsPerOctave
 The number of equally tempered divisions of the octave (default = 12).
clock_t elapsed
clock_t endedAt
int iterationCount
std::vector< double > modality
 Context for the K and Q operations; must have the same cardinality as the pitch-classes in use.
std::map< double,
VoiceleadingOperation
operations
 Voice-leading operations stored in order of starting time.
std::string production
double range
 The range of voicings, from the lowest to the highest pitch, as a MIDI key number (default = 60).
bool rescaleTimes
 If true (the default), rescale times of voice-leading operations in proportion to the duration of the notes produced by this and its child nodes.
std::map< std::string,
std::string > 
rules
Score score
Turtle turtle
std::stack< TurtleturtleStack

Protected Attributes

Eigen::MatrixXd localCoordinates

Detailed Description

This class implements a Lindenmayer system that generates a score by moving a turtle around in various implicit music spaces.

The turtle consists of:

In accordance with both mathematical music theory and the practice of composers, operations on elements of music take place in spaces whose geometry changes fluidly depending upon the musical context. A paradigmatic example is transposition, which may apply to individual notes, or to chords, or to larger parts of scores; as an even more indicative example, transposition may apply to pitch under octave equivalence (pitch-classes), to pitch under range equivalence (transposition on a staff), or simply to pitch as a real number.

Consequently, the independent parts of an operation in this Lindenmayer system are specified by commands in the format OTEDX, where:

Of course, some operations apply in all ranks, dimensions, and equivalence classes; other operations, only to one dimension or one class.

Commands are as follows (x is a real scalar; for chords, v is a real vector "(x1,..,xn)" or a jazz-style chord name ("F#7b9")):

Dimensions of notes:

  1. i = instrument.
  2. t = time.
  3. d = duration.
  4. k = MIDI key number.
  5. v = MIDI velocity number.
  6. p = phase.
  7. x = pan.
  8. y = height.
  9. z = depth.
  10. s = pitch-class set as Mason number (deprecated here).

Algebraic operations:

Equivalence classes:

Constructor & Destructor Documentation

csound::ChordLindenmayer::ChordLindenmayer ( )
virtual csound::ChordLindenmayer::~ChordLindenmayer ( )
virtual

Member Function Documentation

virtual void csound::Node::addChild ( Node node)
virtualinherited
virtual void csound::ChordLindenmayer::addRule ( std::string  command,
std::string  replacement 
)
virtual
virtual void csound::VoiceleadingNode::apply ( Score score,
const VoiceleadingOperation priorOperation,
const VoiceleadingOperation currentOperation 
)
virtualinherited

Apply the current voice-leading operation to the score, within the specified range of notes.

If voice-leading proper is to be performed, the prior voice-leading operation is used to determine how to lead the voices.

virtual void csound::ChordLindenmayer::applyVoiceleadingOperations ( )
virtual
virtual void csound::VoiceleadingNode::C ( double  time,
double  C_ 
)
virtualinherited

Beginning at the specified time and continuing to the beginning of the next operation or the end of the score, whichever comes first, conform notes produced by this node or its children to the specified prime chord and transposition.

Note that C (equivalent to PT) specifies what musicians normally call a chord.

virtual void csound::VoiceleadingNode::C ( double  time,
std::string  C_ 
)
virtualinherited

Same as PT, except that a single number is used in place of the P and T numbers.

virtual void csound::VoiceleadingNode::CL ( double  time,
double  C_,
bool  avoidParallels = true 
)
virtualinherited

Same as CV, except the chord is specified by jazz-type name (e.g.

EbM7) instead of C number.

virtual void csound::VoiceleadingNode::CL ( double  time,
std::string  C_,
bool  avoidParallels = true 
)
virtualinherited

Same as PTL, except the chord is specified by a single number instead of P and T numbers.

virtual void csound::ChordLindenmayer::clear ( )
virtual

Reimplemented from csound::Node.

virtual Eigen::MatrixXd csound::ChordLindenmayer::createRotation ( int  dimension1,
int  dimension2,
double  angle 
) const
virtual
virtual Eigen::MatrixXd csound::Node::createTransform ( )
virtualinherited
virtual void csound::VoiceleadingNode::CV ( double  time,
double  C_,
double  V_ 
)
virtualinherited

Same as C, except the chord can be specified by jazz-type name (e.g.

EbM7) instead of C number.

virtual void csound::VoiceleadingNode::CV ( double  time,
std::string  C_,
double  V_ 
)
virtualinherited

Same as PTV, except the chord is specified by a single number instead of the P and T numbers.

virtual double& csound::Node::element ( size_t  row,
size_t  column 
)
virtualinherited

Returns a reference to the indicated element of the local transformation of coordinate system.

virtual double csound::ChordLindenmayer::equivalence ( double &  value,
char  equivalenceClass 
) const
virtual

Returns the result of applying the equivalence class to the value, both in the argument and as the return value; there may be no effect.

virtual void csound::ChordLindenmayer::fixStatus ( )
virtual
virtual void csound::ChordLindenmayer::generate ( )
virtual

Scores are generated as follows:

  1. The initial value of the turtle is set by the Lindenmayer system.<
    • >
    • The Lindenmayer system is rewritten by taking the axiom, parsing it into words, and replacing each word with the product of a rewriting rule, if one exists, or itself, if there is no rule. This procedure is iterated for a specified number of times.
    • The finished, rewritten Lindenmayer system is interpreted as a series of commands for moving a turtle around in various music spaces to write a score.
      1. Notes (N operations) are written directly into the score.
      2. Chords (C operations) are written into the score as notes.
      3. L and A operations are written into the score as voice-leading operations, to be applied after all notes have been generated.
    • Overlapping and directly abutting notes in the score are joined.
    • The L and A operations are actually applied to the score.
    • Overlapping and abutting notes in the score are again joined.
virtual void csound::ChordLindenmayer::generateLindenmayerSystem ( )
virtual
virtual double csound::ChordLindenmayer::getAngle ( ) const
virtual
virtual std::string csound::ChordLindenmayer::getAxiom ( ) const
virtual
virtual int csound::ChordLindenmayer::getDimension ( char  dimension) const
virtual
virtual int csound::ChordLindenmayer::getIterationCount ( ) const
virtual
virtual Eigen::MatrixXd csound::Node::getLocalCoordinates ( ) const
virtualinherited

Returns the local transformation of coordinate system.

virtual std::vector<double> csound::VoiceleadingNode::getModality ( ) const
virtualinherited
virtual std::string csound::ChordLindenmayer::getReplacement ( std::string  command)
virtual
virtual void csound::ChordLindenmayer::initialize ( )
virtual
virtual void csound::ChordLindenmayer::interpret ( std::string  command)
virtual
virtual void csound::VoiceleadingNode::K ( double  time)
virtualinherited

Find the C of the previous segment, and contextually invert it; apply the resulting C to the current segment.

Contextual inversion is that inversion of C in which the first two pitch-classes are exchanged.

virtual void csound::VoiceleadingNode::KL ( double  time,
bool  avoidParallels = true 
)
virtualinherited

Find the C of the previous segment, and contextually invert it; apply the resulting C to the current segment, using the closest voiceleading from the pitches of the previous segment.

Contextual inversion is that inversion of C in which the first two pitch-classes are exchanged.

virtual void csound::VoiceleadingNode::KV ( double  time,
double  V_ 
)
virtualinherited

Find the C of the previous segment, and contextually invert it; apply the resulting C to the current segment with voicing V.

Contextual inversion is that inversion of C in which the first two pitch-classes are exchanged.

virtual void csound::VoiceleadingNode::L ( double  time,
bool  avoidParallels = true 
)
virtualinherited

Beginning at the specified time and continuing to the beginning of the next operation or the end of the score, whichever comes first, conform notes produced by this node or its children to the smoothest voice-leading from the pitches of the previous segment.

Optionally, parallel fifths can be avoided. Note that L specifies what musicians normally call voice-leading.

virtual char csound::ChordLindenmayer::parseCommand ( const std::string &  command,
std::string &  operation,
char &  target,
char &  equivalenceClass,
size_t &  dimension,
size_t &  dimension1,
double &  scalar,
std::vector< double > &  vector 
)
virtual
virtual void csound::ChordLindenmayer::produceOrTransform ( Score collectingNode,
size_t  beginAt,
size_t  endAt,
const Eigen::MatrixXd &  coordinates 
)
virtual

Applies all of the stored voice-leading operations to the specified range of notes in the score.

if rescaleTimes is true, the times of the operations will be rescaled to fit the times in the range of notes.

Reimplemented from csound::VoiceleadingNode.

virtual void csound::VoiceleadingNode::PT ( double  time,
double  P_,
double  T 
)
virtualinherited

Beginning at the specified time and continuing to the beginning of the next operation or the end of the score, whichever comes first, conform notes produced by this node or its children to the specified prime chord and transposition.

Note that PT specifies what musicians normally call a chord, e.g. "E flat major ninth." However, chords do not have to be in twelve tone equal temperament.

virtual void csound::VoiceleadingNode::PTL ( double  time,
double  P_,
double  T,
bool  avoidParallels = true 
)
virtualinherited

Beginning at the specified time and continuing to the beginning of the next operation or the end of the score, whichever comes first, conform notes produced by this node or its children to the specified chord; the voicing of the chord will be the smoothest voice-leading from the pitches of the previous chord.

Optionally, parallel fifths can be avoided. Note that PTL specifies what musicians normally call the voice-leading of a chord.

virtual void csound::VoiceleadingNode::PTV ( double  time,
double  P_,
double  T,
double  V_ 
)
virtualinherited

Beginning at the specified time and continuing to the beginning of the next operation or the end of the score, whichever comes first, conform notes produced by this node or its children to the specified prime chord, transposition, and voicing.

Note that PTV specifies what musicians normally call the voicing, or inversion, of a chord.

virtual void csound::VoiceleadingNode::Q ( double  time,
double  Q_ 
)
virtualinherited

Find the C of the previous segment, and contextually transpose it; apply the resulting C to the current segment.

Contextual transposition transposes C up by Q if C is an I-form, and down by Q if C is a T-form.

virtual void csound::VoiceleadingNode::QL ( double  time,
double  Q_,
bool  avoidParallels = true 
)
virtualinherited

Find the C of the previous segment, and contextually transpose it; apply the resulting C to the current segment, using the closest voiceleading from the pitches of the previous segment.

Contextual transposition transposes C up by Q if C is an I-form, and down by Q if C is a T-form.

virtual void csound::VoiceleadingNode::QV ( double  time,
double  Q_,
double  V_ 
)
virtualinherited

Find the C of the previous segment, and contextually transpose it; apply the resulting C to the current segment with voicing V.

Contextual transposition transposes C up by Q if C is an I-form, and down by Q if C is a T-form.

virtual void csound::ChordLindenmayer::setAngle ( double  angle)
virtual
virtual void csound::ChordLindenmayer::setAxiom ( std::string  axiom)
virtual
virtual void csound::Node::setElement ( size_t  row,
size_t  column,
double  value 
)
virtualinherited

Sets the indicated element of the local transformation of coordinate system.

virtual void csound::ChordLindenmayer::setIterationCount ( int  count)
virtual
virtual void csound::VoiceleadingNode::setModality ( const std::vector< double > &  pcs)
virtualinherited
virtual void csound::ChordLindenmayer::tieOverlappingNotes ( )
virtual
virtual void csound::VoiceleadingNode::transform ( Score score,
bool  rescaleTime = false 
)
virtualinherited

Apply all of the voice-leading operations stored within this node to the score.

Enables voice-leading operations to be used outside the context of a music graph.

virtual Eigen::MatrixXd csound::Node::traverse ( const Eigen::MatrixXd &  globalCoordinates,
Score score 
)
virtualinherited

The default implementation postconcatenates its own local coordinate system with the global coordinates, then passes the score and the product of coordinate systems to each child, thus performing a depth-first traversal of the music graph.

Reimplemented in csound::Koch, csound::Stack, csound::Intercut, csound::Hocket, and csound::Sequence.

virtual void csound::VoiceleadingNode::V ( double  time,
double  V_ 
)
virtualinherited

Beginning at the specified time and continuing to the beginning of the next operation or the end of the score, whichever comes first, conform notes produced by this node or its children to the specified voicing of the chord.

Note that V specifies what musicians normally call the voicing or inversion of the chord.

virtual void csound::ChordLindenmayer::writeScore ( )
virtual

Field Documentation

double csound::ChordLindenmayer::angle
bool csound::VoiceleadingNode::avoidParallels
inherited

If true (the default), voice-leadings will avoid parallel fifths.

std::string csound::ChordLindenmayer::axiom
double csound::VoiceleadingNode::base
inherited

The lowest pitch of the range of voicings, as a MIDI key number (default = 36).

clock_t csound::ChordLindenmayer::beganAt
std::vector<Node *> csound::Node::children
inherited

Child Nodes, if any.

size_t csound::VoiceleadingNode::divisionsPerOctave
inherited

The number of equally tempered divisions of the octave (default = 12).

Note that the octave is always size 12. The size of a division of the octave is then 1 in 12-tone equal temperament, 0.5 in 24-tone equal temperament, 1.33333 in 9-tone equal temperament, and so on.

clock_t csound::ChordLindenmayer::elapsed
clock_t csound::ChordLindenmayer::endedAt
int csound::ChordLindenmayer::iterationCount
Eigen::MatrixXd csound::Node::localCoordinates
protectedinherited
std::vector<double> csound::VoiceleadingNode::modality
inherited

Context for the K and Q operations; must have the same cardinality as the pitch-classes in use.

std::map<double, VoiceleadingOperation> csound::VoiceleadingNode::operations
inherited

Voice-leading operations stored in order of starting time.

std::string csound::ChordLindenmayer::production
double csound::VoiceleadingNode::range
inherited

The range of voicings, from the lowest to the highest pitch, as a MIDI key number (default = 60).

bool csound::VoiceleadingNode::rescaleTimes
inherited

If true (the default), rescale times of voice-leading operations in proportion to the duration of the notes produced by this and its child nodes.

std::map<std::string, std::string> csound::ChordLindenmayer::rules
Score csound::ChordLindenmayer::score
Turtle csound::ChordLindenmayer::turtle
std::stack<Turtle> csound::ChordLindenmayer::turtleStack