def sum_pair_energy(self, chord): if not type(chord[0]) is int and 'pitch' in chord[0]: norm_chord = normalizer.normalize_sequence(chord) else: norm_chord = chord melody_note = norm_chord[0] total_energy = 0 for i in range(1, len(chord)): total_energy += self.pair_energy(melody_note, norm_chord[i]) return total_energy
def chord_energy(self, chord, normed=False): norm_chord = None if not normed: if not type(chord[0]) is int and 'pitch' in chord[0]: norm_chord = normalizer.normalize_sequence(chord) else: norm_chord = chord else: norm_chord = chord if type(norm_chord[0]) == dict: norm_chord = map(lambda n: n[pitch_key], norm_chord) chord_tuple = tuple(norm_chord) if not chord_tuple in self.chordCounts or self.chordCounts[chord_tuple] == 0: return 999999999 return 1.0/self.chordCounts[chord_tuple]
def chord_energy(self, chord, normed=False): norm_chord = None if not normed: if not type(chord[0]) is int and 'pitch' in chord[0]: norm_chord = normalizer.normalize_sequence(chord) else: norm_chord = chord else: norm_chord = chord if type(norm_chord[0]) == dict: norm_chord = map(lambda n: n[pitch_key], norm_chord) chord_tuple = tuple(norm_chord) if not chord_tuple in self.chordCounts or self.chordCounts[ chord_tuple] == 0: return 999999999 return 1.0 / self.chordCounts[chord_tuple]