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

Base class for collections of events in music space. More...

#include <Score.hpp>

+ Inheritance diagram for csound::Score:

Public Member Functions

virtual void append (Event event)
virtual void append (double time, double duration, double status, double channel, double key, double velocity, double phase=0, double pan=0, double depth=0, double height=0, double pitches=4095)
virtual void arrange (int oldInstrumentNumber, int newInstrumentNumber)
 Re-assign instrument number for export to Csound score.
virtual void arrange (int oldInstrumentNumber, int newInstrumentNumber, double gain)
 Re-assign instrument number and adjust gain for export to Csound score.
virtual void arrange (int oldInstrumentNumber, int newInstrumentNumber, double gain, double pan)
 Re-assign instrument number, adjust gain, and change pan for export to Csound score.
virtual void dump (std::ostream &stream)
virtual void findScale ()
virtual std::string getCsoundScore (double tonesPerOctave=12.0, bool conformPitches=false)
 Translate the Silence events in this to a Csound score, that is, to a list of i statements.
virtual double getDuration ()
virtual std::vector< double > getPitches (size_t begin, size_t end, size_t divisionsPerOctave=12) const
 Return a vector containing the MIDI key numbers in the specified segment of the score.
virtual std::vector< double > getPT (size_t begin, size_t end, double lowest, double range, size_t divisionsPerOctave=12) const
 For the specified segment of the score, return the indexes for the prime chord and its transposition, within the specified range.
virtual std::vector< double > getPTV (size_t begin, size_t end, double lowest, double range, size_t divisionsPerOctave=12) const
 For the specified segment of the score, return the indexes for the prime chord, its transposition, and their voicing within the specified range.
virtual std::vector< double > getVoicing (size_t begin, size_t end, size_t divisionsPerOctave=12) const
 Iterate over each note from the beginning to end of the segment; sort the unique pitches; return those unique pitches which also have unique pitch-class sets, in order from lowest to highest in pitch; this has the effect of returning the "inversion" or "voicing", in the musician's informal sense, of the pitches in that segment of the score.
virtual int indexAfterTime (double time)
 Return the index of the first event after the specified time, that is return "end" for the time; if the time is not found, return the size of the score.
virtual int indexAtTime (double time)
 Return the index of the first event at or after the specified time, that is, return "begin" for the time; if the time is not found, return the size of the score.
virtual double indexToTime (size_t index)
 Return the time of the first event at or after the specified index; if the index is not found, return DBL_MAX.
virtual void initialize ()
virtual void load (std::string filename)
 Loads score data from a MIDI (.mid) file, or a MusicXML (.xml) file.
virtual void load (std::istream &stream)
virtual void remove (size_t index)
virtual void removeArrangement ()
 Remove instrument number, gain, and pan assignments.
virtual void rescale ()
virtual void rescale (Event &event)
virtual void rescale (int dimension, bool rescaleMinimum, double minimum, bool rescaleRange=false, double range=0.0)
virtual void save (std::string filename)
 Save as a MIDI file, format 1 (.mid) file, or as a partwise MusicXML (.xml) file, or as a Fomus music notation (.fms) file.
virtual void save (std::ostream &stream)
 Save as a MIDI file, format 1.
 Score ()
virtual void setDuration (double targetDuration)
 Multiply existing times and durations by (targetDuration / getDuration()), i.e.
virtual void setK (size_t priorBegin, size_t begin, size_t end, double base, double range)
 Find the non-unique pitch-class set of the prior segment; invert the set such that the inversion's first two pitch-classes are exchanged from the origina; conform the pitches of the current segment to that inversion.
virtual void setKL (size_t priorBegin, size_t begin, size_t end, double base, double range, bool avoidParallels=true)
 Find the non-unique pitch-class set of the prior segment; invert the set such that the inversion's first two pitch-classes are exchanged from the original; conform the pitches of the current segment to that inversion, using the closest voice-leading from the pitches of the prior segment, optionally avoiding parallel fifths.
virtual void setKV (size_t priorBegin, size_t begin, size_t end, double V, double base, double range)
 Find the non-unique pitch-class set of the prior segment; invert the set such that the inversion's first two pitch-classes are exchanged from the original; conform the pitches of the current segment to that inversion, with voicing V.
virtual void setPitchClassSet (size_t begin, size_t end, const std::vector< double > &pcs, size_t divisionsPerOctave=12)
 Set the pitches of the specified segment of the score to the specified pitch-class set.
virtual void setPitches (size_t begin, size_t end, const std::vector< double > &pitches)
 Set the pitches of the specified segment of the score to the specified pitches.
virtual void setPT (size_t begin, size_t end, double prime, double transposition, double lowest, double range, size_t divisionsPerOctave=12)
 For the specified segment of the score, adjust the pitches to match the specified indexes for the prime chord and its transposition within the specified range.
virtual void setPTV (size_t begin, size_t end, double prime, double transposition, double voicing, double lowest, double range, size_t divisionsPerOctave=12)
 For the specified segment of the score, adjust the pitches to match the specified indexes for the prime chord, its transposition, and their voicing within the specified range.
virtual void setQ (size_t priorBegin, size_t begin, size_t end, double Q, const std::vector< double > &context, double base, double range)
 Find the non-unique pitch-class set of the prior segment; transpose the set up by Q if the set is a T-form of the context, or down by Q if the set is an I-form of the context; then conform the pitches of the current segment to that set.
virtual void setQL (size_t priorBegin, size_t begin, size_t end, double Q, const std::vector< double > &context, double base, double range, bool avoidParallels=true)
 Find the non-unique pitch-class set of the prior segment; transpose the set up by Q if the set is a T-form of the context, or down by Q if the set is an I-form of the context; then conform the pitches of the segment to that set, using the closest voice-leading from the pitches of the prior segment, optionally avoiding parallel fifths.
virtual void setQV (size_t priorBegin, size_t begin, size_t end, double Q, const std::vector< double > &context, double V, double base, double range)
 Find the non-unique pitch-class set of the prior segment; transpose the set up by Q if the set is a T-form of the context, or down by Q if the set is an I-form of the context; then conform the pitches of the current segment to that set, with the voicing V.
virtual void setVoicing (size_t begin, size_t end, const std::vector< double > &voicing, double range, size_t divisionsPerOctave=12)
 Move the pitches in the segment as little as possible to make them have the same ordering of pitch-class sets as the voicing, from the bottom to the top of the range.
virtual void sort ()
 Sort all events in the score by time, instrument number, pitch, duration, loudness, and other dimensions as given by Event::SORT_ORDER.
virtual void temper (double tonesPerOctave=12.0)
 Confirm pitches in this score to the closest pitch in the indicated system of equal temperament.
virtual void tieOverlappingNotes (bool considerInstrumentNumber=false)
 If the score contains two notes of the same pitch and loudness greater than 0 that overlap in time, extend the earlier note and discard the later note.
virtual std::string toString ()
virtual void voicelead (size_t beginSource, size_t endSource, size_t beginTarget, size_t endTarget, double lowest, double range, bool avoidParallelFifths, size_t divisionsPerOctave=12)
 Performs voice-leading between the specified segments of the score within the specified range.
virtual void voicelead (size_t beginSource, size_t endSource, size_t beginTarget, size_t endTarget, const std::vector< double > &targetPitches, double lowest, double range, bool avoidParallelFifths, size_t divisionsPerOctave=12)
 Performs voice-leading between the specified segments of the score within the specified range, using the specified target pitches.
virtual ~Score ()

Static Public Member Functions

static void getScale (std::vector< Event > &score, int dimension, size_t beginAt, size_t endAt, double &minimum, double &range)
 Save as a MIDI file, format 1.
static void setScale (std::vector< Event > &score, int dimension, bool rescaleMinimum, bool rescaleRange, size_t beginAt, size_t endAt, double targetMinimum, double targetRange)

Data Fields

T elements
 STL member.
std::map< int, double > gains
MidiFile midifile
std::map< int, double > pans
std::map< int, double > reassignments
std::vector< bool > rescaleMinima
std::vector< bool > rescaleRanges
Event scaleActualMinima
Event scaleActualRanges
Event scaleTargetMinima
Event scaleTargetRanges

Protected Member Functions

void createMusicModel ()

Detailed Description

Base class for collections of events in music space.

Can order events by time.

The implementation is a std::vector of Events. The elements of the vector are value objects, not references.

Constructor & Destructor Documentation

csound::Score::Score ( )
virtual csound::Score::~Score ( )
virtual

Member Function Documentation

virtual void csound::Score::append ( Event  event)
virtual
virtual void csound::Score::append ( double  time,
double  duration,
double  status,
double  channel,
double  key,
double  velocity,
double  phase = 0,
double  pan = 0,
double  depth = 0,
double  height = 0,
double  pitches = 4095 
)
virtual
virtual void csound::Score::arrange ( int  oldInstrumentNumber,
int  newInstrumentNumber 
)
virtual

Re-assign instrument number for export to Csound score.

virtual void csound::Score::arrange ( int  oldInstrumentNumber,
int  newInstrumentNumber,
double  gain 
)
virtual

Re-assign instrument number and adjust gain for export to Csound score.

virtual void csound::Score::arrange ( int  oldInstrumentNumber,
int  newInstrumentNumber,
double  gain,
double  pan 
)
virtual

Re-assign instrument number, adjust gain, and change pan for export to Csound score.

void csound::Score::createMusicModel ( )
protected
virtual void csound::Score::dump ( std::ostream &  stream)
virtual
virtual void csound::Score::findScale ( )
virtual
virtual std::string csound::Score::getCsoundScore ( double  tonesPerOctave = 12.0,
bool  conformPitches = false 
)
virtual

Translate the Silence events in this to a Csound score, that is, to a list of i statements.

The Silence events are rounded off to the nearest equally tempered pitch by the specified number of tones per octave; if this argument is zero, the pitch is not tempered. The Silence events are conformed to the nearest pitch-class set in the pitch-class set dimension of the event, if the conform pitches argument is true; otherwise, the pitches are not conformed.

virtual double csound::Score::getDuration ( )
virtual
virtual std::vector<double> csound::Score::getPitches ( size_t  begin,
size_t  end,
size_t  divisionsPerOctave = 12 
) const
virtual

Return a vector containing the MIDI key numbers in the specified segment of the score.

virtual std::vector<double> csound::Score::getPT ( size_t  begin,
size_t  end,
double  lowest,
double  range,
size_t  divisionsPerOctave = 12 
) const
virtual

For the specified segment of the score, return the indexes for the prime chord and its transposition, within the specified range.

See: http://ruccas.org/pub/Gogins/music_atoms.pdf

virtual std::vector<double> csound::Score::getPTV ( size_t  begin,
size_t  end,
double  lowest,
double  range,
size_t  divisionsPerOctave = 12 
) const
virtual

For the specified segment of the score, return the indexes for the prime chord, its transposition, and their voicing within the specified range.

Each of these indexes forms an additive cyclic group.

See: http://ruccas.org/pub/Gogins/music_atoms.pdf

static void csound::Score::getScale ( std::vector< Event > &  score,
int  dimension,
size_t  beginAt,
size_t  endAt,
double &  minimum,
double &  range 
)
static

Save as a MIDI file, format 1.

virtual std::vector<double> csound::Score::getVoicing ( size_t  begin,
size_t  end,
size_t  divisionsPerOctave = 12 
) const
virtual

Iterate over each note from the beginning to end of the segment; sort the unique pitches; return those unique pitches which also have unique pitch-class sets, in order from lowest to highest in pitch; this has the effect of returning the "inversion" or "voicing", in the musician's informal sense, of the pitches in that segment of the score.

virtual int csound::Score::indexAfterTime ( double  time)
virtual

Return the index of the first event after the specified time, that is return "end" for the time; if the time is not found, return the size of the score.

Iterating from indexAtTime(t1) to indexAfterTime(t2) is guaranteed to iterate over all and only those events included from and including t1 and up to but not including t2.

virtual int csound::Score::indexAtTime ( double  time)
virtual

Return the index of the first event at or after the specified time, that is, return "begin" for the time; if the time is not found, return the size of the score.

Iterating from indexAtTime(t1) to indexAfterTime(t2) is guaranteed to iterate over all and only those events included between t1 and t2.

virtual double csound::Score::indexToTime ( size_t  index)
virtual

Return the time of the first event at or after the specified index; if the index is not found, return DBL_MAX.

virtual void csound::Score::initialize ( )
virtual
virtual void csound::Score::load ( std::string  filename)
virtual

Loads score data from a MIDI (.mid) file, or a MusicXML (.xml) file.

Non-sounding data is ignored.

virtual void csound::Score::load ( std::istream &  stream)
virtual
virtual void csound::Score::remove ( size_t  index)
virtual
virtual void csound::Score::removeArrangement ( )
virtual

Remove instrument number, gain, and pan assignments.

virtual void csound::Score::rescale ( )
virtual
virtual void csound::Score::rescale ( Event event)
virtual
virtual void csound::Score::rescale ( int  dimension,
bool  rescaleMinimum,
double  minimum,
bool  rescaleRange = false,
double  range = 0.0 
)
virtual
virtual void csound::Score::save ( std::string  filename)
virtual

Save as a MIDI file, format 1 (.mid) file, or as a partwise MusicXML (.xml) file, or as a Fomus music notation (.fms) file.

Only sounding data is saved.

virtual void csound::Score::save ( std::ostream &  stream)
virtual

Save as a MIDI file, format 1.

virtual void csound::Score::setDuration ( double  targetDuration)
virtual

Multiply existing times and durations by (targetDuration / getDuration()), i.e.

stretch or shrink musical time.

virtual void csound::Score::setK ( size_t  priorBegin,
size_t  begin,
size_t  end,
double  base,
double  range 
)
virtual

Find the non-unique pitch-class set of the prior segment; invert the set such that the inversion's first two pitch-classes are exchanged from the origina; conform the pitches of the current segment to that inversion.

virtual void csound::Score::setKL ( size_t  priorBegin,
size_t  begin,
size_t  end,
double  base,
double  range,
bool  avoidParallels = true 
)
virtual

Find the non-unique pitch-class set of the prior segment; invert the set such that the inversion's first two pitch-classes are exchanged from the original; conform the pitches of the current segment to that inversion, using the closest voice-leading from the pitches of the prior segment, optionally avoiding parallel fifths.

virtual void csound::Score::setKV ( size_t  priorBegin,
size_t  begin,
size_t  end,
double  V,
double  base,
double  range 
)
virtual

Find the non-unique pitch-class set of the prior segment; invert the set such that the inversion's first two pitch-classes are exchanged from the original; conform the pitches of the current segment to that inversion, with voicing V.

virtual void csound::Score::setPitchClassSet ( size_t  begin,
size_t  end,
const std::vector< double > &  pcs,
size_t  divisionsPerOctave = 12 
)
virtual

Set the pitches of the specified segment of the score to the specified pitch-class set.

Each pitch in the score is moved to the closest pitch-class in the specified set.

virtual void csound::Score::setPitches ( size_t  begin,
size_t  end,
const std::vector< double > &  pitches 
)
virtual

Set the pitches of the specified segment of the score to the specified pitches.

Each pitch in the score is moved to the closest pitch in the specified pitches.

virtual void csound::Score::setPT ( size_t  begin,
size_t  end,
double  prime,
double  transposition,
double  lowest,
double  range,
size_t  divisionsPerOctave = 12 
)
virtual

For the specified segment of the score, adjust the pitches to match the specified indexes for the prime chord and its transposition within the specified range.

See: http://ruccas.org/pub/Gogins/music_atoms.pdf

virtual void csound::Score::setPTV ( size_t  begin,
size_t  end,
double  prime,
double  transposition,
double  voicing,
double  lowest,
double  range,
size_t  divisionsPerOctave = 12 
)
virtual

For the specified segment of the score, adjust the pitches to match the specified indexes for the prime chord, its transposition, and their voicing within the specified range.

Each of these indexes forms an additive cyclic group.

See: http://ruccas.org/pub/Gogins/music_atoms.pdf

virtual void csound::Score::setQ ( size_t  priorBegin,
size_t  begin,
size_t  end,
double  Q,
const std::vector< double > &  context,
double  base,
double  range 
)
virtual

Find the non-unique pitch-class set of the prior segment; transpose the set up by Q if the set is a T-form of the context, or down by Q if the set is an I-form of the context; then conform the pitches of the current segment to that set.

The context will be reduced or doubled as required to match the cardinality of the set.

virtual void csound::Score::setQL ( size_t  priorBegin,
size_t  begin,
size_t  end,
double  Q,
const std::vector< double > &  context,
double  base,
double  range,
bool  avoidParallels = true 
)
virtual

Find the non-unique pitch-class set of the prior segment; transpose the set up by Q if the set is a T-form of the context, or down by Q if the set is an I-form of the context; then conform the pitches of the segment to that set, using the closest voice-leading from the pitches of the prior segment, optionally avoiding parallel fifths.

The context will be reduced or doubled as required to match the cardinality of the set.

virtual void csound::Score::setQV ( size_t  priorBegin,
size_t  begin,
size_t  end,
double  Q,
const std::vector< double > &  context,
double  V,
double  base,
double  range 
)
virtual

Find the non-unique pitch-class set of the prior segment; transpose the set up by Q if the set is a T-form of the context, or down by Q if the set is an I-form of the context; then conform the pitches of the current segment to that set, with the voicing V.

The context will be reduced or doubled as required to match the cardinality of the set.

static void csound::Score::setScale ( std::vector< Event > &  score,
int  dimension,
bool  rescaleMinimum,
bool  rescaleRange,
size_t  beginAt,
size_t  endAt,
double  targetMinimum,
double  targetRange 
)
static
virtual void csound::Score::setVoicing ( size_t  begin,
size_t  end,
const std::vector< double > &  voicing,
double  range,
size_t  divisionsPerOctave = 12 
)
virtual

Move the pitches in the segment as little as possible to make them have the same ordering of pitch-class sets as the voicing, from the bottom to the top of the range.

This has the effect of "inverting" or "re-voicing", in the musician's informal sense, the pitches in that segment of the score.

virtual void csound::Score::sort ( )
virtual

Sort all events in the score by time, instrument number, pitch, duration, loudness, and other dimensions as given by Event::SORT_ORDER.

virtual void csound::Score::temper ( double  tonesPerOctave = 12.0)
virtual

Confirm pitches in this score to the closest pitch in the indicated system of equal temperament.

virtual void csound::Score::tieOverlappingNotes ( bool  considerInstrumentNumber = false)
virtual

If the score contains two notes of the same pitch and loudness greater than 0 that overlap in time, extend the earlier note and discard the later note.

virtual std::string csound::Score::toString ( )
virtual
virtual void csound::Score::voicelead ( size_t  beginSource,
size_t  endSource,
size_t  beginTarget,
size_t  endTarget,
double  lowest,
double  range,
bool  avoidParallelFifths,
size_t  divisionsPerOctave = 12 
)
virtual

Performs voice-leading between the specified segments of the score within the specified range.

The voice-leading is first the closest by taxicab norm, and then the simplest in motion, optionally avoiding parallel fifths. Only the pitches of the target notes are affected. If necessary, the number of pitches in the target chord is adjusted to match the source.

See: http://ruccas.org/pub/Gogins/music_atoms.pdf

virtual void csound::Score::voicelead ( size_t  beginSource,
size_t  endSource,
size_t  beginTarget,
size_t  endTarget,
const std::vector< double > &  targetPitches,
double  lowest,
double  range,
bool  avoidParallelFifths,
size_t  divisionsPerOctave = 12 
)
virtual

Performs voice-leading between the specified segments of the score within the specified range, using the specified target pitches.

The voice-leading is first the closest by taxicab norm, and then the simplest in motion, optionally avoiding parallel fifths. Only the pitches of the target notes are affected. If necessary, the number of pitches in the target chord is adjusted to match the source.

See: http://ruccas.org/pub/Gogins/music_atoms.pdf

Field Documentation

template<typename T>
T std::vector< T >::elements
inherited

STL member.

std::map<int, double> csound::Score::gains
MidiFile csound::Score::midifile
std::map<int, double> csound::Score::pans
std::map<int, double> csound::Score::reassignments
std::vector<bool> csound::Score::rescaleMinima
std::vector<bool> csound::Score::rescaleRanges
Event csound::Score::scaleActualMinima
Event csound::Score::scaleActualRanges
Event csound::Score::scaleTargetMinima
Event csound::Score::scaleTargetRanges