def generate_chord_sequence(self, length=20): """ Just for a laugh, use the trained n-gram to generate a chord sequence and output it in a playable form. Returns a tuple: (chords, tags) @todo: this isn't implemented yet for n-grams. It's not a high priority, but would be fun. """ # Easily done, because the NgramModel already implements it itself raise NotImplementedError, "not yet done generation for n-grams" # This is what the other tagger did: from jazzparser.utils.chords import int_to_chord_numeral # Use the model to generate randomly rand_seq = self.model.random_sample(random.Random(), length) pitch = 0 chords = [] prochords,tags = zip(*rand_seq) # Convert the generated observations into readable chords for chord in prochords: interval,__,ctype = chord.partition("-") chords.append("%s%s" % (int_to_chord_numeral(pitch),ctype)) pitch = (pitch + int(interval)) % 12 return (chords, tags)
def generate_chord_sequence(self, length=20): """ Just for a laugh, use the trained n-gram to generate a chord sequence and output it in a playable form. Returns a tuple: (chords, tags) @todo: this isn't implemented yet for n-grams. It's not a high priority, but would be fun. """ # Easily done, because the NgramModel already implements it itself raise NotImplementedError, "not yet done generation for n-grams" # This is what the other tagger did: from jazzparser.utils.chords import int_to_chord_numeral # Use the model to generate randomly rand_seq = self.model.random_sample(random.Random(), length) pitch = 0 chords = [] prochords, tags = zip(*rand_seq) # Convert the generated observations into readable chords for chord in prochords: interval, __, ctype = chord.partition("-") chords.append("%s%s" % (int_to_chord_numeral(pitch), ctype)) pitch = (pitch + int(interval)) % 12 return (chords, tags)
def __unicode__(self): return unicode('%s%s' % (int_to_chord_numeral(self.root), self.type))
def _get_jp_input(self): """ A string format suitable for input to the Jazz Parser. """ return "%s%s" % (int_to_chord_numeral(self.root), self.type.symbol)
def _get_root_numeral(self): if self.roman: return int_to_chord_numeral(self._root) else: return int_to_pitch_class(self._root)