File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 1111Example::
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+
2227Example::
2328
2429 # Asynchronous audio example using BasicMixer.
You can’t perform that action at this time.
0 commit comments