Csound and CsoundAC API  5.17
Data Structures | Typedefs | Functions | Variables
csound Namespace Reference

The csound namespace contains classes for doing algorithmic composition, and for rendering audio from algorithmically generated scores, especially using Csound. More...

Data Structures

class  Cell
 Score node that simplifies building up repetitive and overlapping motivic cells, such as used in Minimalism. More...
class  Chord
 Chords represent simultaneously sounding pitches. More...
class  ChordLindenmayer
 This class implements a Lindenmayer system that generates a score by moving a turtle around in various implicit music spaces. More...
class  Chunk
struct  Command
class  Composition
 Base class for user-defined musical compositions. More...
class  Conversions
 Conversions to and from various music and signal processing units. More...
class  CounterpointNode
 Uses Bill Schottstaedt's species counterpoint generator code to either (a) generate a counterpoint in species 1, 2, or 3 for a cantus firmus selected from notes generated by child nodes, or (b) attempt to correct the voice leading for species 1, 2, or 3 counterpoint in notes generated by child nodes. More...
class  Event
 Represents an event in music space, such as a note of definite duration, a MIDI-like "note on" or "note off" event, or a MIDI-like control event. More...
class  Exception
 Base class for C++ exceptions in the Silence system. More...
class  Hocket
 Simplifies constructing complex hocketted scores. More...
class  ImageToScore
 Translates images in various RGB formats to scores. More...
class  Intercut
 The notes produced by each child node are intercut to produce the notes produced by this; e.g. More...
class  Koch
 All notes produced by child[N - 1] are rescaled and stacked on top of each note produced by child[N - 2], and so on. More...
class  Lindenmayer
 This class implements a Lindenmayer system in music space for a turtle that writes either notes into a score, or Jones-Parks grains into a memory soundfile. More...
class  Logger
class  MCRM
class  MidiEvent
 This class is used to store ALL Midi messages. More...
struct  MidiEventComparator
class  MidiFile
 Reads and writes format 0 and format 1 standard MIDI files. More...
class  MidiHeader
class  MidiTrack
class  MusicModel
 A ScoreModel that uses Csound to render generated scores, via the CppSound class. More...
class  Node
 Base class for all music graph nodes in the Silence system. More...
class  Random
 A random value will be sampled from the specified distribution, translated and scaled as specified, and set in the specified row and column of the local coordinates. More...
class  RemoveDuplicates
 Removes all duplicate events produced by the child nodes of this. More...
class  Rescale
 Rescales all child events to fit a bounding hypercube in music space. More...
class  Score
 Base class for collections of events in music space. More...
class  ScoreModel
 Base class for compositions that use the principle of a music graph to generate a score. More...
class  ScoreNode
 Node class that produces events from the contained score, which can be built up programmatically or imported from a standard MIDI file. More...
class  Sequence
 Node that creates a temporal sequence of child nodes. More...
class  Shell
 Provide a shell in which Python scripts can be loaded, saved, and executed. More...
class  Soundfile
 Simple, basic read/write access, in sample frames, to PCM soundfiles. More...
class  Stack
 The notes produced by each (not all) child node, are rescaled to all start at the same time, and last for the same duration; that of the 0th child, or a specified duration. More...
class  StrangeAttractor
 Generates notes by searching for a chaotic dynamical system defined by a polynomial equation or partial differential equation using Julien C. More...
class  System
 Abstraction layer for a minimal set of system services. More...
class  TempoMap
class  ThreadLock
 Encapsulates a thread monitor, such as a Windows event handle. More...
struct  Turtle
class  Voicelead
 This class contains facilities for voiceleading, harmonic progression, and identifying chord types. More...
class  VoiceleadingNode
 This node class imposes a sequence of one or more "voice-leading" operations upon the pitches of notes produced by children of this node, within a segment of the notes. More...
class  VoiceleadingOperation
 Utility class for storing voice-leading operations within a VoiceleadNode for future application. More...

Typedefs

typedef unsigned char csound_u_char
typedef void(* MessageCallbackType )(CSOUND *csound, int attribute, const char *format, va_list marker)
typedef NodeNodePtr
typedef void PyObject_

Functions

double C4 ()
double epc (double pitch)
 Returns the equivalent of the pitch under pitch-class equivalence, i.e.
double EPSILON ()
double & epsilonFactor ()
bool eq_epsilon (double a, double b)
double euclidean (const Chord &a, const Chord &b)
 Returns the Euclidean distance between chords a and b, which must have the same number of voices.
double factorial (double n)
 This class, part of CsoundAC, implements a geometric approach to some common operations on chords in neo-Riemannian music theory for use in score generating procedures:
double ge_epsilon (double a, double b)
double gt_epsilon (double a, double b)
double I (double pitch, double center=0.0)
 Returns the pitch reflected in the center, which may be any pitch.
double le_epsilon (double a, double b)
double lt_epsilon (double a, double b)
double MIDDLE_C ()
double OCTAVE ()
 The size of the octave, defined to be consistent with 12 tone equal temperament and MIDI.
bool SILENCE_PUBLIC operator< (const Event &a, const Event &b)
bool SILENCE_PUBLIC operator< (const MidiEvent &a, const MidiEvent &b)
std::ostream SILENCE_PUBLICoperator<< (std::ostream &stream, const VoiceleadingOperation &operation)
void SILENCE_PUBLIC printChord (std::ostream &stream, std::string label, const std::vector< double > &chord)
double T (double pitch, double semitones)
 Returns the pitch transposed by semitones, which may be any scalar.

Variables

class SILENCE_PUBLIC Chord
class SILENCE_PUBLIC MidiFile
void(* Py_Finalize_ )(void)
void(* Py_Initialize_ )(void)
void(* PyErr_Print_ )(void)
PyObject_ *(* PyImport_ImportModule_ )(char *)
long(* PyLong_AsLong_ )(PyObject_ *)
PyObject_ *(* PyObject_CallMethod_ )(PyObject_ *, char *, char *,...)
PyObject_ *(* PyObject_GetAttrString_ )(PyObject_ *, char *)
int(* PyRun_SimpleFileEx_ )(FILE *, const char *, int)
int(* PyRun_SimpleString_ )(const char *)
void(* PySys_SetArgv_ )(int, char **)

Detailed Description

The csound namespace contains classes for doing algorithmic composition, and for rendering audio from algorithmically generated scores, especially using Csound.

There should be one header file for each class declared in CsoundAC, and that header file should be #included in Silence.hpp.

SWIG is run on Silence.hpp to generate wrappers for all CsoundAC classes in other languages, especially scripting languages such as Python, Therefore, all framework headers must be included in this header, and all framework headers must use #ifdef SWIG to declare the module and make other SWIG declarations (see Node.h for an extensive example). The order of declaration is important to SWIG!

It is also expected that doxygen will be used to generate documentation from comments in the framework header files.

Typedef Documentation

typedef unsigned char csound::csound_u_char
typedef void(* csound::MessageCallbackType)(CSOUND *csound, int attribute, const char *format, va_list marker)
typedef void csound::PyObject_

Function Documentation

double csound::C4 ( )

References MIDDLE_C().

double csound::epc ( double  pitch)

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

the pitch is in the interval [0, OCTAVE).

References ge_epsilon(), lt_epsilon(), and OCTAVE().

Referenced by csound::Chord::epcs(), and csound::Chord::isepcs().

double csound::EPSILON ( )

Referenced by eq_epsilon().

double& csound::epsilonFactor ( )

Referenced by eq_epsilon().

bool csound::eq_epsilon ( double  a,
double  b 
)
double csound::euclidean ( const csound::Chord a,
const csound::Chord b 
)

Returns the Euclidean distance between chords a and b, which must have the same number of voices.

References csound::Chord::getPitch(), and csound::Chord::voices().

Referenced by csound::Chord::distanceToOrigin(), and csound::Chord::distanceToUnisonDiagonal().

double csound::factorial ( double  n)

This class, part of CsoundAC, implements a geometric approach to some common operations on chords in neo-Riemannian music theory for use in score generating procedures:

– Identifying whether a chord belongs to some equivalence class of music theory, or sending a chord to its equivalent within a representative fundamental domain of some equivalence class. The equivalence classes are octave (O), permutational (P), transpositional, (T), inversional (I), and their compounds OP, OPT (set-class or chord type), and OPTI (prime form).

– Causing chord progressions to move strictly within an orbifold that generates some equivalence class.

– Implementing chord progressions based on the L, P, R, D, K, and Q operations of neo-Riemannian theory (thus implementing some aspects of "harmony").

– Implementing chord progressions performed within a more abstract equivalence class by means of the best-formed voice-leading within a less abstract equivalence class (thus implementing some fundamentals of "counterpoint").

The associated ChordSpaceView package can display these chord spaces and operations for trichords in an interactive 3-dimensional view.

DEFINITIONS

Pitch is the perception of a distinct sound frequency. It is a logarithmic perception; octaves, which sound 'equivalent' in some sense, represent doublings or halvings of frequency.

Pitches and intervals are represented as real numbers. Middle C is 60 and the octave is 12. Our usual system of 12-tone equal temperament, as well as MIDI key numbers, are completely represented by the whole numbers; any and all other pitches can be represented simply by using fractions.

A voice is a distinct sound that is heard as having a pitch.

A chord is simply a set of voices heard at the same time, represented here as a point in a chord space having one dimension of pitch for each voice in the chord.

For the purposes of algorithmic composition in CsoundAC, a score is considered as a sequence of more or less fleeting chords.

EQUIVALENCE CLASSES

An equivalence class identifies elements of a set. Operations that send one equivalent point to another induce quotient spaces or orbifolds, where the equivalence operation identifies points on one face of the orbifold with points on an opposing face. The fundamental domain of the equivalence class is the space "within" the orbifold.

Plain chord space has no equivalence classes. Ordered chords are represented as vectors in parentheses (p1, ..., pN). Unordered chords are represented as sorted vectors in braces {p1, ..., pN}. Unordering is itself an equivalence class.

The following equivalence classes apply to pitches and chords, and exist in different orbifolds. Equivalence classes can be combined (Callendar, Quinn, and Tymoczko, "Generalized Voice-Leading Spaces," Science 320, 2008), and the more equivalence classes are combined, the more abstract is the resulting orbifold compared to the parent space.

In most cases, a chord space can be divided into a number, possibly infinite, of geometrically equivalent fundamental domains for the same equivalence class. Therefore, here we use the notion of 'representative' fundamental domain. For example, the representative fundamental domain of unordered sequences, out of all possible orderings, consists of all sequences in their ordinary sorted order. It is important, in the following, to identify representative fundamental domains that combine properly, e.g. such that the representative fundamental domain of OP / the representative fundamental domain of PI equals the representative fundamental domain of OPI. And this in turn may require accounting for duplicate elements of the representative fundamental domain caused by reflections or singularities in the orbifold.

C Cardinality equivalence, e.g. {1, 1, 2} == {1, 2}. Not assuming cardinality equivalence ensures that there is a proto-metric in plain chord space that is inherited by all child chord spaces. Cardinality equivalence is never assumed here, because we are working in chord spaces of fixed dimensionality; e.g. we represent the note middle C not as {60}, but as {60, 60, ..., 60}.

O Octave equivalence. The fundamental domain is defined by the pitches in a chord spanning the range of an octave or less, and summing to an octave or less.

P Permutational equivalence. The fundamental domain is defined by a "wedge" of plain chord space in which the voices of a chord are always sorted by pitch.

T Transpositional equivalence, e.g. {1, 2} == {7, 8}. The fundamental domain is defined as a plane in chord space at right angles to the diagonal of unison chords. Represented by the chord always having a sum of pitches equal to 0.

I Inversional equivalence. Care is needed to distinguish the mathematician's sense of 'invert', which means 'pitch-space inversion' or 'reflect in a point', from the musician's sense of 'invert', which varies according to context but in practice often means 'registral inversion' or 'revoice by adding an octave to the lowest tone of a chord.' Here, we use 'invert' and 'inversion' in the mathematician's sense, and we use the terms 'revoice' and 'voicing' for the musician's 'invert' and 'inversion'. The inversion point for any inversion lies on the unison diagonal. A fundamental domain is defined as any half of chord space that is bounded by a plane containing the inversion point. Represented as the chord having the first interval between voices be smaller than or equal to the final interval (recursing for chords of more than 3 voices).

PI Inversional equivalence with permutational equivalence. The 'inversion flat' of unordered chord space is a hyperplane consisting of all those unordered chords that are invariant under inversion. A fundamental domain is defined by any half space bounded by a hyperplane containing the inversion flat. It is represented as that half of the space on or lower than the hyperplane defined by the inversion flat and the unison diagonal.

OP Octave equivalence with permutational equivalence. Tymoczko's orbifold for chords; i.e. chords with a fixed number of voices in a harmonic context. The fundamental domain is defined as a hyperprism one octave long with as many sides as voices and the ends identified by octave equivalence and one cyclical permutation of voices, modulo the unordering. In OP for trichords in 12TET, the augmented triads run up the middle of the prism, the major and minor triads are in 6 alternating columns around the augmented triads, the two-pitch chords form the 3 sides, and the one-pitch chords form the 3 edges that join the sides.

OPT The layer of the OP prism as close as possible to the origin, modulo the number of voices. Chord type. Note that CM and Cm are different OPT. Because the OP prism is canted down from the origin, at least one pitch in each OPT chord (excepting the origin itself) is negative.

OPI The OP prism modulo inversion, i.e. 1/2 of the OP prism. The representative fundamental consits of those chords less than or equal to their inversions modulo OP.

OPTI The OPT layer modulo inversion, i.e. 1/2 of the OPT layer. Set-class. Note that CM and Cm are the same OPTI.

OPERATIONS

Each of the above equivalence classes is, of course, an operation that sends chords outside the fundamental domain to chords inside the fundamental domain. And we define the following additional operations:

T(p, x) Translate p by x.

I(p [, x]) Reflect p in x, by default the origin.

P Send a major triad to the minor triad with the same root, or vice versa (Riemann's parallel transformation).

L Send a major triad to the minor triad one major third higher, or vice versa (Riemann's Leittonwechsel or leading-tone exchange transformation).

R Send a major triad to the minor triad one minor third lower, or vice versa (Riemann's relative transformation).

D Send a triad to the next triad a perfect fifth lower (dominant transformation).

P, L, and R have been extended as follows, see Fiore and Satyendra, "Generalized Contextual Groups", Music Theory Online 11, August 2008:

K(c) Interchange by inversion; K(c) := I(c, c[1] + c[2]). This is a generalized form of P; for major and minor triads, it is exactly the same as P, but it also works with other chord types.

Q(c, n, m) Contexual transposition; Q(c, n, m) := T(c, n) if c is a T-form of m, or T(c, -n) if c is an I-form of M. Not a generalized form of L or R; but, like them, K and Q generate the T-I group. Returns n!

double csound::ge_epsilon ( double  a,
double  b 
)

References eq_epsilon().

Referenced by epc(), and csound::Chord::eV().

double csound::gt_epsilon ( double  a,
double  b 
)
double csound::I ( double  pitch,
double  center = 0.0 
)

Returns the pitch reflected in the center, which may be any pitch.

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

Referenced by csound::Chord::eI(), csound::Chord::I(), csound::Chord::iseI(), and csound::Chord::iseRPI().

double csound::le_epsilon ( double  a,
double  b 
)

References eq_epsilon().

Referenced by csound::Chord::iseP(), and csound::Chord::iseR().

double csound::lt_epsilon ( double  a,
double  b 
)
double csound::MIDDLE_C ( )

Referenced by C4().

double csound::OCTAVE ( )
bool SILENCE_PUBLIC csound::operator< ( const Event &  a,
const Event &  b 
)
bool SILENCE_PUBLIC csound::operator< ( const MidiEvent &  a,
const MidiEvent &  b 
)
std::ostream SILENCE_PUBLIC& csound::operator<< ( std::ostream &  stream,
const VoiceleadingOperation &  operation 
)
void SILENCE_PUBLIC csound::printChord ( std::ostream &  stream,
std::string  label,
const std::vector< double > &  chord 
)

Referenced by csound::Turtle::__str__().

double csound::T ( double  pitch,
double  semitones 
)

Variable Documentation

void(* csound::Py_Finalize_)(void)
void(* csound::Py_Initialize_)(void)
void(* csound::PyErr_Print_)(void)
PyObject_*(* csound::PyImport_ImportModule_)(char *)
long(* csound::PyLong_AsLong_)(PyObject_ *)
PyObject_*(* csound::PyObject_CallMethod_)(PyObject_ *, char *, char *,...)
PyObject_*(* csound::PyObject_GetAttrString_)(PyObject_ *, char *)
int(* csound::PyRun_SimpleFileEx_)(FILE *, const char *, int)
int(* csound::PyRun_SimpleString_)(const char *)
void(* csound::PySys_SetArgv_)(int, char **)