From 13225d5da86c6efd2f925a31e33fc7121c503a23 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 6 Sep 2018 09:17:57 -0400 Subject: [PATCH] cleanup --- pytheory/play.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytheory/play.py b/pytheory/play.py index 6074506..2c884c7 100644 --- a/pytheory/play.py +++ b/pytheory/play.py @@ -11,9 +11,6 @@ from .tones import Tone SAMPLE_RATE = 44_100 SAMPLE_PEAK = 4_096 -pygame.mixer.pre_init(SAMPLE_RATE, -16, 1) -pygame.mixer.init() - def sine_wave(hz, peak=SAMPLE_PEAK, n_samples=SAMPLE_RATE): """Compute N samples of a sine wave with given frequency and peak amplitude. Defaults to one second. @@ -51,6 +48,9 @@ class Synth(Enum): def play(tone_or_chord, temperament='equal', synth=Synth.SINE, t=1_000): + pygame.mixer.pre_init(SAMPLE_RATE, -16, 1) + pygame.mixer.init() + if isinstance(tone_or_chord, Tone): chord = [synth(tone_or_chord.pitch(temperament=temperament, symbolic=True))] else: