Blitz Toolbox/Other libs/Imphenzia Audio System
Imphenzia Audio System by Imphenziahttp://soundtrack.imphenzia.com/audiosystem.php |
About
Imphenzia Audio System is an include library that can be used to play music and sound effects. The audio system has built in features for crossfading, volume handling, pause/resume, playlist management, channel management and priority etc.Music Features * Load raw/Mod/s3m/xm/it/Mid/rmi/wav/mp2/mp3/ogg/wma/asf files * Simple creation of playlists * Load mp3u lists into playlist * Clear / Remove songs from playlist * Play next song with option crossfade * Play previous song with optional crossfade * Pause / Resume music * Stop music (with optional fadeout) * Set / Get music volume * Get current song name * Randomize playlist * Playlist repeat mode * Autoplay next song Sound Effect Features * Load raw/mp3/ogg/wav sound effects * Group sound effects (easy to unload for game levelts etc.) * Play sound effects with individual volume, priority, panning, fade in, duration, fade out * Set / Get global sound effect volume * Set / Get maximum number of simultaneous sound effect channels * Pause / Resume sound effect system
List of functions:
; ## SOUND EFFECT MAIN FUNCTIONS ############################################## ; ----------------------------------------------------------------------------- ; SFX_Handler() ; IMPORTANT - Sound effect system handler - Call this Function in main loops ; ----------------------------------------------------------------------------- ; SFX_Load(FileName$, Group$="", Loop%=False) ; Load a sound effect into the sound effect system, specify FileName and ; optionally a group and looping status. The 'group' will enable you to ; free (unload) several sound effects with one command which is useful ; when you have associated a number of sounds with for example a game level. ; Compatible formats: raw, wav, mp3, ogg ; ----------------------------------------------------------------------------- ; SFX_Free(SFXHandle) ; Clear (unload) a particular sound effect out of memory and system ; ----------------------------------------------------------------------------- ; SFX_FreeGroup(Group$) ; Clear (unload) group of sound effects (see grouping in SFX_Load function) ; ----------------------------------------------------------------------------- ; SFX_FreeAll() ; Clear (unload) all sound effects out of memory and system ; ----------------------------------------------------------------------------- ; SFX_Play(SFXHandle, Volume#=1.0, Priority%=False, Pan#=0, FadeIn%=0, Duration%=0, FadeOut%=0) ; Play a particular sound effect ; Volume# = Volume of sound effect to be played (also affected by global) ; Priority% = If true max number of active channels are ignored for effect ; Pan# = (-1.0 = all left) --> (0.0 = center) <-- (1.0 = all right) ; FadeIn% = Duration in ms it should take to fade in (0 = none) ; Duration% = Duration in ms of effect once faded in (0 = no duration) ; FadeOut% = Duration in ms of fade out after fade in and duration (0=none) ; (if FadeIn, Duration and FadeOut are all set to 0 sample is played in full) ; ----------------------------------------------------------------------------- ; SFX_Stop(ChannelHandle, FadeOut%=0) ; Stop a particular sound effect channel (optionally fade out in milliseconds) ; ----------------------------------------------------------------------------- ; SFX_StopAll(FadeOut%=0) ; Stop all sound effect channels (optionally fade out in milliseconds) ; ----------------------------------------------------------------------------- ; SFX_SetGlobalVolume(Volume#) ; Set global volume of sound effect system (0.0 = min) --> (1.0 = max) ; ----------------------------------------------------------------------------- ; SFX_GetGlobalVolume#() ; Get the global volume of sound effect sustem (0.0 = min) --> (1.0 = max) ; ----------------------------------------------------------------------------- ; SFX_IsChannelPlaying(ChannelHandle) ; Return true or false if a channel is playing or not ; ------------------------------------------------------------------------------ ; SFX_Pause() ; Pause sound effect system ; ----------------------------------------------------------------------------- ; SFX_Resume() ; Resume sound effect system from paused state ; ----------------------------------------------------------------------------- ; SFX_GetPause() ; Return true or false if sound effect system is paused or not ; ----------------------------------------------------------------------------- ; SFX_SetMaxChannels(NumberOfChannels%) ; Set number of maximum active sound effect system channels (default is 10) ; ----------------------------------------------------------------------------- ; SFX_GetMaxChannels%() ; Get number of maximum active sound effects system channels ; ----------------------------------------------------------------------------- ; ## SOUND EFFECT SYSTEM HELPER FUNCTIONS ##################################### ; ----------------------------------------------------------------------------- ; SFX_GetActiveChannels%() ; Gets number of active sound effect channels ; ----------------------------------------------------------------------------- ; SFX_GetActivePrioritizedChannels%() ; Gets number of active prioritized sound effect channels ; ----------------------------------------------------------------------------- ; SFX_GetActualVolume#(ChannelHandle) ; Gets actual volume of specific sound effect channel (0.0 --> 1.0) ; ----------------------------------------------------------------------------- ; SFX_ChannelTrim() ; Limits number of active sound effect channels to maximum number allowed ; ----------------------------------------------------------------------------- ; ## MUSIC SYSTEM MAIN FUNCTIONS ############################################## ; ----------------------------------------------------------------------------- ; Music_Handler() ; IMPORTANT - Music system handler - Call this Function in main loops ; ----------------------------------------------------------------------------- ; Music_LoadSong(Name$, File$) ; Load Song into playlist - note that this function clears current playlist ; Name$ = Name of song (own name, automatically set if loaded from playlist) ; File$ = File name (optionally including a path) of song ; Compatible formats: raw/Mod/s3m/xm/it/Mid/rmi/wav/mp2/mp3/ogg/wma/asf ; ----------------------------------------------------------------------------- ; Music_AddSong(Name$, File$) ; Add Song into current playlist ; Name$ = Name of song (own name, automatically set if loaded from playlist) ; File$ = File name (optionally including a path) of song ; Compatible formats: raw/Mod/s3m/xm/it/Mid/rmi/wav/mp2/mp3/ogg/wma/asf ; ----------------------------------------------------------------------------- ; Music_LoadPlayList(FileName$) ; Load a M3U playlist - clears any currently loaded songs and playlists ; ----------------------------------------------------------------------------- ; Music_AddPlayList(FileName$) ; Add a M3U playlist to current playlist ; ----------------------------------------------------------------------------- ; Music_FreePlayList() ; Free entire playlist out of memory (also stops music if any is playing) ; ----------------------------------------------------------------------------- ; Music_RemoveSong(Name$) ; Remove song from playlist out of memory (also stops song if playing) ; ----------------------------------------------------------------------------- ; Music_PlaySong(SongName$, CrossFade%=0, Loop%=False) ; Play a particular song from playlist, optionally crossfade it for a number ; of milliseconds. Song names are case insensitive. ; Loop%=True will force song to be looped regardless if there is playlis which ; is useful if you have short repetitive level music for example. NOTE: Due to ; BlitzBasic not caching the track there may be a moment of silence at moment ; of repeat - optionally use SFX_Play with looping for short repeating tracks. ; ----------------------------------------------------------------------------- ; Music_NextSong$(CrossFade%=0) ; Play Next Song, optionally crossfade it for a number of milliseconds ; ----------------------------------------------------------------------------- ; Music_PreviousSong$(CrossFade%=0) ; Play Previous Song, optionally crossfade it for a number of milliseconds ; ----------------------------------------------------------------------------- ; Music_StopChannel(ChannelHandle, FadeOut%=0) ; Stop a particular music channel, optionally fade out in milliseconds ; ----------------------------------------------------------------------------- ; Music_Stop(FadeOut%=0) ; Stop all music channels, optionally fade them out in milliseconds ; ----------------------------------------------------------------------------- ; Music_Pause() ; Pause music system ; ----------------------------------------------------------------------------- ; Music_Resume() ; Resume music system from a paused state ; ----------------------------------------------------------------------------- ; Music_GetPause() ; Return true or false if music system is paused or not ; ------------------------------------------------------------------------------ ; Music_GetGlobalVolume#() ; Get global volume of music system (0.0 = min) --> (1.0 = max) ; ----------------------------------------------------------------------------- ; Music_SetGlobalVolume#(Volume#) ; Set global volume of music system (0.0 = min) --> (1.0 = max) ; ----------------------------------------------------------------------------- ; Music_GetCurrentSong$() ; Get name of current song playing ; ----------------------------------------------------------------------------- ; Music_GetCurrentTimer#() ; Get length of time in milliseconds current song has been playing ; ----------------------------------------------------------------------------- ; Music_GetCurrentChannel() ; Get currently active channel handle ; ----------------------------------------------------------------------------- ; Music_CountSongs() ; Return number of songs in playlist ; ----------------------------------------------------------------------------- ; Music_Crossfade(TrueOrFalse%=True) ; Set crossfade ability to True (enabled) or False (disabled) ; ----------------------------------------------------------------------------- ; Music_GetCrossfade() ; Get if Crossfade is enabled or disabled Returns (true or false) ; ----------------------------------------------------------------------------- ; Music_Randomize(TrueOrFalse%=False) ; Set randomize playlist to True or False ; ----------------------------------------------------------------------------- ; Music_GetRandomize() ; Get is Randomized playlist is enabled or disabled ; ----------------------------------------------------------------------------- ; Music_SetAutoPlayNext(TrueOrFalse%=True) ; Set Auto Play Next song to True or False ; ----------------------------------------------------------------------------- ; Music_GetAutoPlayNext() ; Get if Auto Play Next Song is enabled or disabled (returns true or false) ; ----------------------------------------------------------------------------- ; Music_SetRepeat(TrueOrFalse%=True) ; Set Repeat to True or False (repeats playlists automatically if end reached) ; ----------------------------------------------------------------------------- ; Music_GetRepeat() ; Get if Repeat is enabled or disabled ; ----------------------------------------------------------------------------- ; ## MUSIC SYSTEM HELPER FUNCTIONS ############################################ ; ----------------------------------------------------------------------------- ; Music_GetSongFile$(Name$) ; Get file name of a specific song in the play list ; ----------------------------------------------------------------------------- ; Music_ChannelTrim() ; Limits number of active music channels to allowed ammount ; ----------------------------------------------------------------------------- ; Music_IsLastSong() ; Is current song last in playlist? (returns True / False) ; ----------------------------------------------------------------------------- ; Music_DebugPlaylist() ; Debug playlist into Blitz Debuger