Logo Search packages:      
Sourcecode: csound version File versions

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

Definition at line 719 of file Score.cpp.

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

Referenced by csound::VoiceleadingNode::apply().

  {
    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;
      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)) {
      System::inform("First segment, returning without doing anything.\n");
      return;
    }
    std::vector<double> source = getVoicing(beginSource, endSource, divisionsPerOctave_);
    printChord("  source voicing:      ", source);
    if (source.size() == 0) {
      return;
    }
    std::vector<double> target = getVoicing(beginTarget, endTarget, divisionsPerOctave_);
    if (target.size() == 0) {
      return;
    }
    printChord("  target voicing:      ", target);
    std::vector<double> tones = Voicelead::pcs(target, divisionsPerOctave_);
    printChord("  target voicing tones:", tones);
    // 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("  source doubled:      ", 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]);
      }
    }
    printChord("  tones doubled:       ", 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("  final 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