Logo Search packages:      
Sourcecode: csound version File versions

VoiceleadingNode.hpp

/*
 * C S O U N D
 *
 * L I C E N S E
 *
 * This software is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#ifndef VOICELEADNODE_H
#define VOICELEADNODE_H

#include "Platform.hpp"
#include "Voicelead.hpp"
#ifdef SWIG
%module CsoundAC
%{
#include "Node.hpp"
#include "Score.hpp"
  %}
#else
#include "Node.hpp"
#include "Score.hpp"
#include "Voicelead.hpp"
using namespace boost::numeric;
#endif

namespace csound
{
  /**
   * Utility class for storing voice-leading operations
   * within a VoiceleadNode for future application.
   */
00044   class VoiceleadingOperation
  {
  public:
    VoiceleadingOperation();
    virtual ~VoiceleadingOperation();
    /**
     * The operation begins at this time,
     * and continues until just before the beginning
     * of the next operation, or the end of the score,
     * whichever comes first.
     */
00055     double beginTime;
    /**
     * Times may need to be rescaled to
     * match the duration of the score.
     */
00060     double rescaledBeginTime;
    /**
     * The operation ends before this time.
     */
00064     double endTime;
    /**
     * Times may need to be rescaled
     * to match the duration of the score.
     */
00069     double rescaledEndTime;
    double P;
    /**
     * Prime chord, or NAN if no operation.
     */
00074     double T;
    /**
     * Transposition, or NAN if no operation.
     */
00078     double C;
    /**
     * Voicing, or NAN if no operation.
     */
00082     double V;
    /**
     * If true, perform the closest voice-leading from the prior operation.
     */
00086     bool L;
    /**
     * The index of the first event to which the operation is applied.
     */
00090     size_t begin;
    /**
     * One past the index of the last event to which the operation is applied.
     */
00094     size_t end;
    bool avoidParallels;
  };

  std::ostream &operator << (std::ostream &stream, const VoiceleadingOperation &operation);

  /**
   * This node class imposes
   * a sequence of one or more
   * "voice-leading" operations upon
   * the pitches of notes produced by children of this node.
   * These operations comprise:
   * prime chord (P),
   * transpose (T),
   * unordered pitch-class set (C, equivalent to PT),
   * voicing (V) within a specified range of pitches,
   * and voice-lead (L).
   * The values of P, T, C, and V
   * each form an additive cyclic group
   * whose elements are defined
   * by counting through all possible values in order.
   * Note that C is not the same as "pitch-class set number"
   * in the sense of M = sum over pitch-classes of (2 ^ pitch-class);
   * it is rather one less than M.
   * Not all combinations of operations are consistent.
   * P requires T.
   * PT cannot be used with C.
   * V cannot be used with L.
   * If neither PT nor C is specified, the existing C of the notes is used.
   * The consistent combinations of operations are thus:
   * PT, PTV, PTL, C, CV, CL, V, and L.
   */
00126   class VoiceleadingNode :
    public Node
  {
  public:
    /**
     * Voice-leading operations stored in order
     * of starting time.
     */
00134     std::map<double, VoiceleadingOperation> operations;
    /**
     * The lowest pitch of the range of voicings,
     * as a MIDI key number (default = 36).
     */
00139     double base;
    /**
     * The range of voicings, from the lowest to the highest
     * pitch, as a MIDI key number (default = 60).
     */
00144     double range;
    /**
     * 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.
     */
00150     bool rescaleTimes;
    /**
     * If true (the default), voice-leadings will avoid
     * parallel fifths.
     */
00155     bool avoidParallels;
    /**
     * 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.
     */
00162     size_t divisionsPerOctave;
    VoiceleadingNode();
    virtual ~VoiceleadingNode();
    /**
     * 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 apply(Score &score, const VoiceleadingOperation &priorOperation, const VoiceleadingOperation &currentOperation);
    /**
     * 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.
     */
    virtual void produceOrTransform(Score &score, size_t beginAt, size_t endAt, const ublas::matrix<double> &coordinates);
    /**
     * 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 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, transposition, and voicing.
     * Note that PTV specifies what musicians normally call
     * the voicing, or inversion, of a 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 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 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 prime chord and transposition.
     * Note that PT specifies what musicians normally call a chord.
     */
    virtual void C(double time, double C_);
    /**
     * Same as PT, except that a single number
     * is used in place of the P and T numbers.
     */
    virtual void C(double time, std::string C_);
    /**
     * Same as PT, except the chord can be specified by
     * jazz-type name (e.g. EbM7) instead of P and T numbers.
     */
    virtual void CV(double time, double C_, double V_);
    /**
     * Same as PTV, except the chord is specified by
     * a single number instead of the P and T numbers.
     */
    virtual void CV(double time, std::string C_, double V_);
    /**
     * Same as PTV, except the chord is specified by
     * jazz-type name (e.g. EbM7) instead of P and T numbers.
     */
    virtual void CL(double time, double C_, bool avoidParallels = true);
    /**
     * Same as PTL, except the chord is specified by
     * a single number instead of P and T numbers.
     */
    virtual void CL(double time, std::string C_, bool avoidParallels = true);
    /**
     * Same as PTL, except the chord is specified by
     * jazz-type name (e.g. EbM7) instead of P and T numbers.
     */
    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.
     * Note that V specifies what musicians normally call
     * the voicing or inversion of the chord.
     */
    virtual void L(double time, bool avoidParallels = true);
    /**
     * 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 void transform(Score &score, bool rescaleTime = false);
  };
}
#endif


Generated by  Doxygen 1.6.0   Back to index