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

std::vector< double > csound::Voicelead::chordToPTV ( const std::vector< double > &  chord,
size_t  lowestPitch,
size_t  highestPitch,
size_t  divisionsPerOctave = 12 
) [static]

Return the voiced chord for the prime chord index P, transposition T, and voicing index V within the specified range for the indicated number of tones per octave. The algorithm finds the zero voicing (the lowest octave transposition of the normal chord of the chord that is no lower than the lowest pitch, which has voicing index V = 0) and the zero iterator (the lowest (in all voices) unordered voicing of the chord that is no lower (in all voices) than the lowest pitch, which has enumeration index = 0). Thus, the V of a voicing equals the enumeration index of that voicing minus the enumeration index of the zero voicing. The algorithm enumerates the voicings until the chord is matched.

Definition at line 847 of file Voicelead.cpp.

References addOctave(), normalChord(), pcs(), and pitchClassSetToPandT().

Referenced by csound::Score::getPTV().

  {
    std::vector<double> ptv;
    std::vector<double> sortedChord = sort(chord_);
    std::vector<double> zeroVoicing = normalChord(chord_);
    while (zeroVoicing[0] < lowestPitch) {
      for (size_t i = 0, n = zeroVoicing.size(); i < n; i++) {
      zeroVoicing[i] += double(divisionsPerOctave);
      }
    }    
    while (zeroVoicing[0] >= (lowestPitch + double(divisionsPerOctave))) {
      for (size_t i = 0, n = zeroVoicing.size(); i < n; i++) {
      zeroVoicing[i] -= double(divisionsPerOctave);
      }
    }    
    std::vector<double> zeroVoicing_ = sort(zeroVoicing);
    std::vector<double> zeroIterator = pcs(zeroVoicing, divisionsPerOctave);
    for(size_t i = 0, n = zeroIterator.size(); i < n; i++) {
      while (zeroIterator[i] < lowestPitch) {
      zeroIterator[i] += double(divisionsPerOctave);
      }
      while (zeroIterator[i] >= (lowestPitch + double(divisionsPerOctave))) {
      zeroIterator[i] -= double(divisionsPerOctave);
      }
    }
    size_t zeroVoicingEnumeration = 0;    
    bool zeroVoicingEnumerationFound = false;
    size_t modulus = 0;
    bool modulusFound = false;
  found:                                  \
    std::vector<double> iterator = sort(zeroIterator);
    for(size_t V = 0; ; V++) {
      if (!zeroVoicingEnumerationFound) {
      if (zeroVoicing_ == sort(iterator)) {
        zeroVoicingEnumerationFound = true;
        zeroVoicingEnumeration = V;
        goto found;
      }
      } else {
      size_t actualV = V - zeroVoicingEnumeration;
      if (sortedChord == sort(iterator)) {
        ptv = pitchClassSetToPandT(chord_, divisionsPerOctave);
        ptv.push_back(actualV);
        return ptv;
      }
      }
      if (!addOctave(zeroIterator, iterator, highestPitch, divisionsPerOctave)) {
      break;
      }
    }
    return ptv;
  }


Generated by  Doxygen 1.6.0   Back to index