コード例 #1
0
ファイル: test_score.py プロジェクト: norpol/music-generator
def test_measure_note_generate():
    measure = Measure(Tempo(120), Signature(4, 4))
    measure.add_note(Note('C#', 3), 0, 1)
    measure.add_note(Note('D', 3), 1, 1)
    measure.add_note(Note('E', 3), 2, 1)
    measure.add_note(Note('C#', 3), 3, 1)
    result = measure.generate_notes(Duration(1.5))
    assert result[0].offset.seconds == (measure.notes[0].offset +
                                        Duration(1.5)).seconds
    pass
コード例 #2
0
    def generate(self, start_octave=0, end_octave=8):

        notes = []
        for octave in range(start_octave, end_octave):

            for step in self.steps:
                generator_note = Note(self.root, octave)
                notes.append(generator_note.increment(step))

        return notes
コード例 #3
0
ファイル: test_score.py プロジェクト: norpol/music-generator
def test_measure():

    measure = Measure(Tempo(120), Signature(4, 4))

    measure.add_note(Note('C', 3), 0, 1)
    measure.add_note(Note('D', 3), 1, 1)
    measure.add_note(Note('E', 3), 2, 1)
    measure.add_note(Note('C', 3), 3, 1)

    assert len(measure.notes) == 4
コード例 #4
0
def test_max_duration():
    measure = Measure(Tempo(120), Signature(4, 4))
    measure.add_note(Note('C#', 3), 0, 1)
    measure.add_note(Note('F', 3), 2, 5)
    measure.add_note(Note('D', 3), 1, 1)
    measure.add_note(Note('E', 3), 2, 1)
    measure.add_note(Note('C#', 3), 3, 1)

    max_duration = get_max_duration(measure.generate_notes(Duration(1.5)))

    assert max_duration.seconds == 5.0
コード例 #5
0
def vader_jacob():

    theme1 = Measure(Tempo(120), Signature(4, 4)) \
        .add_note(Note('C', 3), 0, 1) \
        .add_note(Note('D', 3), 1, 1) \
        .add_note(Note('E', 3), 2, 1) \
        .add_note(Note('C', 3), 3, 1)

    theme2 = Measure(Tempo(120), Signature(4, 4)) \
        .add_note(Note('E', 3), 0, 1) \
        .add_note(Note('F', 3), 1, 1) \
        .add_note(Note('G', 3), 2, 2)

    theme3 = Measure(Tempo(120), Signature(4, 4)) \
        .add_note(Note('G', 3), 0, 0.5) \
        .add_note(Note('A', 3), 0.5, 0.5) \
        .add_note(Note('G', 3), 1, 0.5) \
        .add_note(Note('F', 3), 1.5, 0.5) \
        .add_note(Note('E', 3), 2, 1) \
        .add_note(Note('C', 3), 3, 1)

    theme4 = Measure(Tempo(120), Signature(4, 4)) \
        .add_note(Note('C', 3), 0, 1) \
        .add_note(Note('G', 2), 1, 1) \
        .add_note(Note('C', 3), 2, 2)

    track = Track([theme1] * 2 + [theme2] * 2 + [theme3] * 2 + [theme4] * 2)

    return track
コード例 #6
0
def test_semitones():
    a4 = Note('A', 4)
    assert a4.get_semi_from_a4() == 0
コード例 #7
0
def test_frequency():
    a4 = Note('A', 4)
    a3 = Note('A', 3)
    assert a4.frequency() / 2 == a3.frequency()
コード例 #8
0
def test_increment_octave():
    a2 = Note('A#', 2)
    a2.increment(2)

    assert a2.get_symbol() == 'C'
    assert a2.get_octave() == 3
コード例 #9
0
def test_increment():
    a4 = Note('A', 4)
    assert a4.increment(1).get_symbol() == 'A#'