Skip to content

Commit d3419a5

Browse files
committed
Fix synchronous audio example.
1 parent 3eb49df commit d3419a5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tcod/sdl/audio.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@
1111
Example::
1212
1313
# Synchronous audio example using SDL's low-level API.
14+
import time
15+
1416
import soundfile # pip install soundfile
1517
import tcod.sdl.audio
1618
1719
device = tcod.sdl.audio.open() # Open the default output device.
18-
sound, samplerate = soundfile.read("example_sound.wav") # Load an audio sample using SoundFile.
20+
sound, samplerate = soundfile.read("example_sound.wav", dtype="float32") # Load an audio sample using SoundFile.
1921
converted = device.convert(sound, samplerate) # Convert this sample to the format expected by the device.
2022
device.queue_audio(converted) # Play audio syncroniously by appending it to the device buffer.
2123
24+
while device.queued_samples: # Wait until device is done playing.
25+
time.sleep(0.001)
26+
2227
Example::
2328
2429
# Asynchronous audio example using BasicMixer.

0 commit comments

Comments
 (0)