CodeBase - WAV sound loop functions and functions to read a WAV file's channels, sample rate, and length
Return to the CodeBase listing
Category: Sound
Version: 1.0
Information
Uploaded: 30th Jan 2013 01:50
Modified: 31st Jan 2013 23:51
Author: Naphier
Summary
BEWARE! If meta data such as artist's name, track title, etc. is stored in the beginning of the file these functions will not work. LoopWav(filename$,iNum_loops,iOffset,iVolume,iDecay_rate) GetWavChannels(filename$) GetWavSampleRate(filename$) GetWavLength(filename$)
Full Description
// Sound Function Library Test Driver<br /> // Last revision: 2013-01-29<br /> //<br /> //-----------------------------------------------------------------------------<br /> <br /> #include "SoundLibrary.agc"<br /> <br /> // globals require for LoopWav()<br /> global LoopsPlayed = 0<br /> global LoopTimer = GetMilliseconds()<br /> global sound_ID<br /> <br /> // parameters<br /> iNum_loops = 0<br /> iOffset = -100<br /> iVolume = 100<br /> iDecay_rate = 5<br /> filename$ = "sound3.wav"<br /> <br /> repeat<br /> <br /> Print("Channels: " + Str(GetWavChannels(filename$)))<br /> Print("Sample Rate: " + Str(GetWavSampleRate(filename$)))<br /> Print("Wav length: " + Str(GetWavLength(filename$)))<br /> <br /> LoopsPlayed = LoopWav(filename$,iNum_loops,iOffset,iVolume,iDecay_rate)<br /> <br /> Sync()<br /> <br /> until GetSoundExists(sound_ID) = 0<br /> <br /> Escape()<br /> <br /> END<br /> <br /> <br /> function Escape() // Pauses the termination of the program until ESC is pressed<br /> escape_text = CreateText("Press ESC or Back to exit...")<br /> SetTextColor(escape_text,255,255,255,255)<br /> SetTextDepth(escape_text,10000)<br /> SetTextMaxWidth(escape_text,100)<br /> SetTextPosition(escape_text,0,(98-GetTextSize(escape_text)))<br /> Sync()<br /> <br /> repeat<br /> until GetRawKeyPressed(27) = 1<br /> <br /> DeleteText(escape_text)<br /> endfunction<br />
Comments
No comments yet.