Logo Search packages:      
Sourcecode: csound version File versions  Download package

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

Definition at line 816 of file Score.cpp.

References csound::System::getMessageLevel(), getPitches(), getVoicing(), csound::System::inform(), csound::Voicelead::nonBijectiveVoicelead(), csound::Voicelead::pcs(), setPitchClassSet(), setPitches(), and csound::Voicelead::uniquePcs().

  {
    if ( (System::getMessageLevel() & System::INFORMATION_LEVEL) == System::INFORMATION_LEVEL ) {
      std::stringstream stream;
      stream << "BEGAN Score::voicelead:..." << std::endl;
      stream << "  beginSource:         " << beginSource << std::endl;
      stream << "  endSource:           " << endSource << std::endl;
      stream << "  beginTarget:         " << beginTarget << std::endl;
      stream << "  endTarget:           " << endTarget << std::endl;
      printChord(stream, "  target:              ", target);
      stream << "  lowest:              " << lowest << std::endl;
      stream << "  range:               " << range << std::endl;
      stream << "  avoidParallelFifths: " << avoidParallelFifths << std::endl;
      stream << "  divisionsPerOctave:  " << divisionsPerOctave_ << std::endl;
      stream << std::endl;
      stream.flush();
      System::inform(stream.str().c_str());
    }
    if (beginSource < 0) {
      beginSource = 0;
    }
    if (endSource > size()) {
      endSource = size();
    }
    if (beginSource == endSource) {
      return;
    }
    if (beginTarget < 0) {
      beginTarget = 0;
    }
    if (endTarget > size()) {
      endTarget = size();
    }
    if (beginTarget == endTarget) {
      return;
    }
    if ((beginSource == beginTarget) && (endSource == endTarget)) {
      setPitchClassSet(beginTarget, endTarget, target, divisionsPerOctave_);
      std::vector<double> result = getPitches(beginTarget, endTarget, divisionsPerOctave_);
      printChord("  result:              ", result);
      std::vector<double> resultTones = Voicelead::uniquePcs(result, divisionsPerOctave_);
      printChord("  as pitch-class set:  ", resultTones);  
      return;
    }
    std::vector<double> source = getVoicing(beginSource, endSource, divisionsPerOctave_);
    printChord("  source voicing:      ", source);
     if (source.size() == 0) {
      return;
    }
    if (target.size() == 0) {
      return;
    }
    std::vector<double> tones = Voicelead::pcs(target, divisionsPerOctave_);
    printChord("  target tones:        ", target);
    // Double voices in the source if necessary.
    if (tones.size() > source.size()) {
      size_t k = source.size();
      size_t n = tones.size() - k;
      for (size_t i = 0, j = 0; i < n; i++, j++) {
        if (j >= k) {
        j = 0;
      }
        source.push_back(source[j]);
      }
      printChord("  doubled source:      ", source);
    }
    // Double voices in the target if necessary.
    if (source.size() > tones.size()) {
      size_t k = tones.size();
      size_t n = source.size() - k;
      for (size_t i = 0, j = 0; i < n; i++, j++) {
        if (j >= k) {
        j = 0;
      }
        tones.push_back(tones[j]);
      }
      std::sort(tones.begin(), tones.end());
      printChord("  doubled tones:       ", tones);
    }
    //std::vector<double> voicing = Voicelead::recursiveVoicelead(source, tones, lowest, range, avoidParallelFifths, divisionsPerOctave_);
    std::vector< std::vector<double> > result3 = Voicelead::nonBijectiveVoicelead(source, tones, divisionsPerOctave_);
    const std::vector<double> voicing = result3[2];
    printChord("  target voicing:      ", voicing);
    //setVoicing(beginTarget, endTarget, voicing, range, divisionsPerOctave_);
    setPitches(beginTarget, endTarget, voicing);
    std::vector<double> result = getPitches(beginTarget, endTarget, divisionsPerOctave_);
    printChord("  result:              ", result);
    std::vector<double> resultTones = Voicelead::uniquePcs(result, divisionsPerOctave_);
    printChord("  as pitch-class set:  ", resultTones);  
    System::inform("ENDED Score::voicelead.\n");
  }


Generated by  Doxygen 1.6.0   Back to index