def gen(self, WEIGHTS, chords, key, note_count, note_bar, bars):
        """Generate a random list of symbols for the measure
        that fit in the necessary time signature

        Arguments:
        WEIGHTS -- the default weights
        chords -- the possible chords
        key -- the tune's key
        note_count -- needed for time signature
        note_bar -- needed for time signature
        bars -- needed for time signature
        """
        self.symbols = []
        beats_left = (note_count * 1 / bars) * note_bar
        note_weights = self.set_weights(WEIGHTS, chords)

        while beats_left > 0:
            s = Symbol()
            beats_left -= convert_to_float(
                s.gen(WEIGHTS, note_weights, beats_left))
            self.append(s)
Exemple #2
0
    def add(self, name, value, dataType, environment, references, line, column):
        self._idSymbol += 1

        self._symbols.append(Symbol(self._idSymbol, name, value, dataType, environment,
                                    references, line, column))
                       '"G" c3 B3 A2 B|"F" c3 B2 c d2 G|"C" e2 d c2 B c2 d|'
                       '"Am" e3 ^d3 B2 =d|"G" c3 B3 A2 B|"F" c3 B2 A G2 B|'
                       '"Am" A3 z2 A A2 c|"Am" e3 ^d3 B2 =d|"G" c3 B3 A2 B|'
                       '"F" c3 B2 c d2 G|"C" e2 d c2 B c2 d|"Am" e3 ^d3 B2 =d|'
                       '"G" c3 B3 A2 B|"F" c3 B2 A G2 B|"Am" A3 A,6'))

Ode_to_joy = Tune(
    title="Ode to Joy",
    note_count=4,
    bars=4,
    note_duration=1,
    note_bar=4,
    key='C',
    measures=[
        Measure(chord="C",
                symbols=[Symbol("E"),
                         Symbol("E"),
                         Symbol("F"),
                         Symbol("G")]),
        Measure(chord="C",
                symbols=[Symbol("G"),
                         Symbol("F"),
                         Symbol("E"),
                         Symbol("D")]),
        Measure(chord="C",
                symbols=[Symbol("C"),
                         Symbol("C"),
                         Symbol("D"),
                         Symbol("E")]),
        Measure(
            chord="G",