Skip to content

Instantly share code, notes, and snippets.

@G4MR
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save G4MR/be15c27ac1afed4dcf3e to your computer and use it in GitHub Desktop.
Save G4MR/be15c27ac1afed4dcf3e to your computer and use it in GitHub Desktop.
Audio test code for SDL2_Mixer in nim
#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