Skip to content

Instantly share code, notes, and snippets.

@six519
Created November 14, 2022 10:27
Show Gist options
  • Save six519/9f4956be56f53bc72bd03778cca0d34c to your computer and use it in GitHub Desktop.
Save six519/9f4956be56f53bc72bd03778cca0d34c to your computer and use it in GitHub Desktop.
Titik Programming Language/Interpreter SDL2 Play Sounds
if(!(s_i(S_E))) # init sdl
abt('Unable to initialize SDL...')
fi
if(!(s_mi(SM_MP))) # init mix
abt('Unable to initialize SDL Mix...')
fi
if(!(s_moa(SM_D_FR, SM_D_FO, SM_D_CHA, SM_D_CHU))) # open audio
abt('Unable to open audio...')
fi
wav = s_mlw('test.wav')
if(wav == Nil)
abt('Cannot load wav file...')
fi
music = s_mlm('test.mp3')
if(music == Nil)
abt('Cannot load mp3 file...')
fi
s_mpc(wav, -1, 0) #play the wav file once
s_mpm(music, -1) #play the music forever
fl(0, 0)
#nothing to do
lf
s_mfc(wav) #free chunk
s_mfm(music) #free music
s_mca() #close audio
s_mq() #quit mix
s_q() #quit sdl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment