My Daily Gist | Ferdinand Silva


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
view raw test.ttk hosted with ❤ by GitHub