Last active
August 29, 2015 14:20
-
-
Save G4MR/be15c27ac1afed4dcf3e to your computer and use it in GitHub Desktop.
Audio test code for SDL2_Mixer in nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#test audio | |
var sound : Mix_ChunkPtr | |
var channel : cint | |
var audio_rate : cint | |
var audio_format : uint16 | |
var audio_buffers : cint = 4096 | |
var audio_channels : cint = 2 | |
if Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0: | |
quit("There was a problem") | |
sound = Mix_LoadWAV("SDL_PlaySound/sound.wav") | |
if isNil(sound): | |
quit("Unable to load wav") | |
channel = Mix_PlayChannel(-1, sound, 0); | |
if channel == -1: | |
quit("Unable to play WAV sound") | |
while Mix_Playing(channel) != 0: | |
discard | |
Mix_FreeChunk(sound) | |
Mix_CloseAudio(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment