Пример #1
0
    def test_play_all_notes():
        # Change me if you need this test to run faster or slower.:
        NOTE_DURATION = 0.05

        # Don't worry if this sounds a little strange.
        # Recall than an A9 is actually a higher pitch than a C9, since the
        # octave counts increment at C.
        for octave in range(OCTAVE_MIN, OCTAVE_MAX + 1):
            for pitch in Note.Pitch:
                for accidental in Note.Accidental:
                    note = Note(NOTE_DURATION, pitch, octave, accidental)
                    note.play()
Пример #2
0
    def test_play_tetris():
        # Change me if you need this test to run faster or slower.
        SPEEDUP_FACTOR = 8

        tetris = 'E52 B41 C51 D52 C51 B41 A42 A41 C51 E52 D51 C51 B42 B41 C51 D52 E52 C52 A42 A42 R14 D51 F51 A52 G51 F51 E53 C51 E52 D51 C51 B42 B41 C51 D52 E52 C52 A42 A42'
        for note_info in tetris.split():
            pitch, octave, duration = note_info
            pitch = Note.Pitch[pitch]
            octave = int(octave)
            duration = int(duration)
            note = Note(duration / 8, pitch, octave, Note.Accidental.NATURAL)
            note.play()
Пример #3
0
 def test_play_single_note():
     note = Note(1, Note.Pitch.C, 4, Note.Accidental.NATURAL)
     note.play()