Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; -------------------------------------------------------------------------------------
- ; SCAL v2.00 x86-64 DLL - Play-Library for multiple formats [1060 (x86) / 424 (x64)]
- ; -------------------------------------------------------------------------------------
- ; Peace/TST - 05.10.2020 / Purebasic 5.70
- ; https://testaware.wordpress.com
- ; -------------------------------------------------------------------------------------
- ; Note: - x64: Doesn't support #C2D_MUSIC_[AMP,BAS,BMF,FCP,MED,S68,SID,TSR,V2M,YMP]
- ; - x86: Install the AmpMaster_x86.dll to playback +626 rare formats
- ; -------------------------------------------------------------------------------------
- EnableExplicit
- #SCAL_VERSION = 200 ; * 0.01 -> 2.00
- XIncludeFile "Include\i_scal.pbi"
- Global RS_SCAL.RS_SCAL
- ;************************
- ;{ *** LIB-INCLUDES *** }
- IncludePath "Include\"
- XIncludeFile "minizip_include.pbi"
- IncludePath "Include\MusicLibs\"
- CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
- ;Import "winmm_x86.lib" : EndImport ; not needed coz #C2D_MUSIC_MOD
- Import "dsound_x86.lib" : EndImport
- CompilerIf #IsSID
- Import "masm32_x86.lib" : EndImport
- CompilerEndIf
- ;CompilerElse
- ;Import "winmm.lib" : EndImport ; not needed coz #C2D_MUSIC_MOD
- CompilerEndIf
- UseOGGSoundDecoder()
- UseFLACSoundDecoder()
- ;{ #C2D_MUSIC_MOD * Native PureBasic ModPlug Library * }
- ; *.669;*.ABC;*.AMF;*.AMS;*.DBM;*.DMF;*.FAR;*.IT;*.J2B;*.MDL;*.MED;*.MID;*.MOD;*.MT2;*.MTM;*.OKT;*.PAT;*.PSM;*.PTM;*.S3M;*.STM;*.ULT;*.UMX;*.WAV;*.XM;*.MMCMP;*.PP
- ;InitSound()
- ;}
- ;{ #C2D_MUSIC_MOV * Native PureBasic Movie Library * }
- ; *.MP3;*.WAV;*.WMA...
- ;InitMovie()
- ;}
- ;{ #C2D_MUSIC_FT2 * Thanx to Olav "8bitbubsy" for the opensource FT2PLAY v1.04 * }
- ; Copyright (c) 2016-2020, Olav "8bitbubsy" Sørensen
- ; https://16-bits.org
- ; https://pastebin.com/0TLkMm0A
- ; *.FT;*.MOD;*.STK;*.XM
- ;Import "winmm.lib" : EndImport
- CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
- Import "playFT2_x64.lib"
- ft2play_Close()
- ft2play_GetAmp() ; 1..32
- ft2play_GetMasterVol() ; 0..256
- ft2play_GetMixerTicks() ; returns the amount of milliseconds of mixed audio (not realtime)
- ft2play_GetSongName() ; max 20 chars (21 with '\0'), string is in code page 437
- ft2play_PauseSong(flag)
- ft2play_PlaySong(*moduleData, length, interpolation, volumeramping, freq) ; returns 1 = playing or 0 = error
- ft2play_SetAmp(factor) ; 1..32
- ft2play_SetInterpolation(flag) ; true/false
- ft2play_SetMasterVol(vol) ; 0..256
- ft2play_SetVolumeRamping(flag) ; true/false
- ft2play_TogglePause()
- EndImport
- CompilerElse
- ImportC "playFT2_x86.lib"
- ft2play_Close() As "_ft2play_Close"
- ft2play_GetAmp() As "_ft2play_GetAmp"
- ft2play_GetMasterVol() As "_ft2play_GetMasterVol"
- ft2play_GetMixerTicks() As "_ft2play_GetMixerTicks"
- ft2play_GetSongName() As "_ft2play_GetSongName"
- ft2play_PauseSong(flag) As "_ft2play_PauseSong"
- ft2play_PlaySong(*moduleData, length, interpolation, volumeramping, freq) As "_ft2play_PlaySong"
- ft2play_SetAmp(factor) As "_ft2play_SetAmp"
- ft2play_SetInterpolation(flag) As "_ft2play_SetInterpolation"
- ft2play_SetMasterVol(vol) As "_ft2play_SetMasterVol"
- ft2play_SetVolumeRamping(flag) As "_ft2play_SetVolumeRamping"
- ft2play_TogglePause() As "_ft2play_TogglePause"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_PT2 * Thanx to Olav "8bitbubsy" for the opensource PT2PLAY v1.60 * }
- ; https://16-bits.org
- ; https://pastebin.com/pg95YduC
- ; *.MOD
- #CIA_TEMPO_MODE = 0
- #VBLANK_TEMPO_MODE = 1
- ;Import "winmm.lib" : EndImport
- CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
- Import "playPT2_x64.lib"
- pt2play_Close()
- pt2play_GetMasterVol() ; 0..256
- pt2play_GetMixerTicks() ; returns the amount of milliseconds of mixed audio (not realtime)
- pt2play_GetSongName() ; max 20 chars (21 with '\0'), string is in code page 437
- pt2play_PauseSong(flag) ; true/false
- pt2play_PlaySong(*moduleData, length, tempoMode, freq) ; returns 1 = playing or 0 = error
- pt2play_SetMasterVol(vol) ; 0..256
- pt2play_SetStereoSep(percent) ; 0..100
- pt2play_TogglePause()
- EndImport
- CompilerElse
- ImportC "playPT2_x86.lib"
- pt2play_Close() As "_pt2play_Close"
- pt2play_GetMasterVol() As "_pt2play_GetMasterVol"
- pt2play_GetMixerTicks() As "_pt2play_GetMixerTicks"
- pt2play_GetSongName() As "_pt2play_GetSongName"
- pt2play_PauseSong(flag) As "_pt2play_PauseSong"
- pt2play_PlaySong(*moduleData, length, tempoMode, freq) As "_pt2play_PlaySong"
- pt2play_SetMasterVol(vol) As "_pt2play_SetMasterVol"
- pt2play_SetStereoSep(percent) As "_pt2play_SetStereoSep"
- pt2play_TogglePause() As "_pt2play_TogglePause"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_FC4 * Thanx to Olav "8bitbubsy" for the opensource FC14PLAY v1.29 * }
- ; https://16-bits.org
- ; https://pastebin.com/VHxZ58UC
- ; *.FC;*.FC13;*.FC14;*.FC3;*.FC4;*.FCM;*.SMOD
- ;Import "winmm.lib" : EndImport
- CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
- Import "playFC4_x64.lib"
- fc14play_Close()
- fc14play_GetMasterVol()
- fc14play_GetMixerTicks() ; returns the amount of milliseconds of mixed audio (not realtime)
- fc14play_PauseSong(flag) ; true/false
- fc14play_PlaySong(*moduleData, length, freq) ; returns 1 = playing or 0 = error
- fc14play_SetMasterVol(vol) ; 0..256
- fc14play_SetStereoSep(percent) ; 0..100
- fc14play_TogglePause()
- EndImport
- CompilerElse
- ImportC "playFC4_x86.lib"
- fc14play_Close() As "_fc14play_Close"
- fc14play_GetMasterVol() As "_fc14play_GetMasterVol"
- fc14play_GetMixerTicks() As "_fc14play_GetMixerTicks"
- fc14play_PauseSong(flag) As "_fc14play_PauseSong"
- fc14play_PlaySong(*moduleData, length, freq) As "_fc14play_PlaySong"
- fc14play_SetMasterVol(vol) As "_fc14play_SetMasterVol"
- fc14play_SetStereoSep(percent) As "_fc14play_SetStereoSep"
- fc14play_TogglePause() As "_fc14play_TogglePause"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_AHX * Thanx to Olav "8bitbubsy" for the opensource AHX1PLAY v0.27 * }
- ; https://16-bits.org
- ; https://pastebin.com/fqwadbj7
- ; *.AHX;*.THX
- ;Import "winmm.lib" : EndImport
- CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
- Import "playAHX_x64.lib"
- ahx1play_PlaySong(*moduleData, length, subsong, freq) ; returns 1 = playing or 0 = error
- ahx1play_GetSongName() ; max 64 chars (65 with '\0'), string is in latin1
- ahx1play_Close()
- ahx1play_PauseSong(flag) ; true/false
- ahx1play_TogglePause()
- ahx1play_GetMixerTicks() ; returns the amount of milliseconds of mixed audio (not realtime)
- ahx1play_SetStereoSep(percent) ; 0..100
- EndImport
- CompilerElse
- ImportC "playAHX_x86.lib"
- ahx1play_PlaySong(*moduleData, length, subsong, freq) As "_ahx1play_PlaySong"
- ahx1play_GetSongName() As "_ahx1play_GetSongName"
- ahx1play_Close() As "_ahx1play_Close"
- ahx1play_PauseSong(flag) As "_ahx1play_PauseSong"
- ahx1play_TogglePause() As "_ahx1play_TogglePause"
- ahx1play_GetMixerTicks() As "_ahx1play_GetMixerTicks"
- ahx1play_SetStereoSep(percent) As "_ahx1play_SetStereoSep"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_STM * Thanx to Olav "8bitbubsy" for the opensource STMPLAY v0.33 * }
- ; https://16-bits.org
- ; https://pastebin.com/ifXSCZ71
- ; *.STM
- ;Import "winmm.lib" : EndImport
- CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
- Import "playST2_x64.lib"
- st23play_Close()
- st23play_GetMasterVol() ; 0..256
- st23play_GetMixerTicks() ; returns the amount of milliseconds of mixed audio (not realtime)
- st23play_GetSongName() ; max 20 chars (21 with '\0'), string is in code page 437
- st23play_PauseSong(flag) ; true/false
- st23play_PlaySong(*moduleData, dataLength, useInterpolationFlag, audioFreq) ; returns 1 = playing or 0 = error
- st23play_SetInterpolation(flag) ; true/false
- st23play_SetMasterVol(vol) ; 0..256
- st23play_TogglePause()
- EndImport
- CompilerElse
- ImportC "playST2_x86.lib"
- st23play_Close() As "_st23play_Close"
- st23play_GetMasterVol() As "_st23play_GetMasterVol"
- st23play_GetMixerTicks() As "_st23play_GetMixerTicks"
- st23play_GetSongName() As "_st23play_GetSongName"
- st23play_PauseSong(flag) As "_st23play_PauseSong"
- st23play_PlaySong(*moduleData, dataLength, useInterpolationFlag, audioFreq) As "_st23play_PlaySong"
- st23play_SetInterpolation(flag) As "_st23play_SetInterpolation"
- st23play_SetMasterVol(vol) As "_st23play_SetMasterVol"
- st23play_TogglePause() As "_st23play_TogglePause"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_S3M * Thanx to Olav "8bitbubsy" for the opensource ST3PLAY v0.91+ (x86) / v0.99 (x64) * }
- ; https://16-bits.org
- ; https://pastebin.com/AwRXZAw7
- ; *.S3M
- #SOUNDCARD_GUS = 0 ;/* Default */
- #SOUNDCARD_SBPRO = 1
- ;Import "winmm.lib" : EndImport
- CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
- Import "playST3_x64.lib"
- st3play_Close()
- st3play_GetMasterVol() ; 0..256
- st3play_GetMixerTicks() ; returns the amount of milliseconds of mixed audio (not realtime)
- st3play_GetSongName()
- st3play_PauseSong(flag) ; true/false
- st3play_PlaySong(*moduleData, length, flag, type, freq) ; returns 1 = playing or 0 = error
- st3play_SetInterpolation(flag) ; true/false
- st3play_SetMasterVol(vol) ; 0..256
- st3play_TogglePause()
- EndImport
- CompilerElse
- ImportC "playST3_x86.lib" ; ST3PLAY v0.91 last working for x86
- st3play_Close() As "_st3play_Close"
- st3play_GetMixerTicks() As "_st3play_GetMixerTicks"
- st3play_GetSongName() As "_st3play_GetSongName"
- st3play_PauseSong(flag) As "_st3play_PauseSong"
- st3play_PlaySong(*moduleData, length, flag, type, freq) As "_st3play_PlaySong"
- st3play_SetInterpolation(flag) As "_st3play_SetInterpolation"
- st3play_SetMasterVol(vol) As "_st3play_SetMasterVol"
- st3play_TogglePause() As "_st3play_TogglePause"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_V1M * Thanx to kb^farbrausch for the static libv2.lib v1.0 / Error * }
- ; *.V2M 1.0
- CompilerIf #IsV1M
- ;Import "winmm.lib" : EndImport
- ;Import "dsound.lib" : EndImport
- Import "libv2_x86.lib"
- ssClose() As "_ssClose@0"
- ssDoTick() As "_ssDoTick@0"
- ssFadeOut(milliseconds) As "_ssFadeOut@4"
- ssGetTime() As "_ssGetTime@0"
- ssInit(*module, *hWnd) As "_ssInit@8"
- ssPlay() As "_ssPlay@0"
- ssStop() As "_ssStop@0"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_V2M * Thanx to kb^farbrausch for the static libv2simple.lib v1.5 * }
- ; *.V2M 1.5
- CompilerIf #IsV2M
- Prototype DSIOCALLBACK(*param, *buf.FLOAT, length.l)
- Prototype PERCENTCALLBACK(percent.f)
- ;Import "dsound.lib" : EndImport
- Import "libv2simple_x86.lib"
- V2MClose() As "_V2MClose@0"
- V2MGetChannelVU(channel, *left, *right) As "_V2MGetChannelVU@12"
- V2MGetCurrentTime() As "_V2MGetCurrentTime@0"
- V2MGetTotalTime() As "_V2MGetTotalTime@0"
- V2MInit(*tune, samplerate, *hWnd) As "_V2MInit@12"
- V2MIsPlaying() As "_V2MIsPlaying@0"
- V2MPlay(start=0) As "_V2MPlay@4"
- V2MSaveAsWave(a.s, *b.PERCENTCALLBACK) As "_V2MSaveAsWave@8"
- V2MSetRepeat(status.b) As "_V2MSetRepeat@4"
- V2MSetVUMode(mode) As "_V2MSetVUMode@4"
- V2MStop(fade=0) As "_V2MStop@4"
- ;initializes DirectSound output.
- ;callback: your render callback function
- ;parm: a pointer that'll be supplied to the function on every call
- ;hWnd: window handle of your application (GetForegroundWindow() works quite well :)
- dsInit(*callback.DSIOCALLBACK, *parm, *hWnd) As "_dsInit@12"
- dsClose() As "_dsClose@0" ;shuts down DirectSound output
- dsGetCurSmp() As "_dsGetCurSmp@0" ;gets sample-exact and latency compensated current play position
- dsSetVolume(vol.f=1.0) As "_dsSetVolume@4" ;sets player volume (Default is 1.0)
- ;forces rendering thread to update. On single-core CPUs it's a good idea to
- ;call this once per frame (improves A/V sync And reduces any stuttering),
- ;with more than one CPU it's pretty much useless.
- dsTick() As "_dsTick@0"
- ;lock And unlock the sound thread's thread sync lock. If you want to modify
- ;any of your sound variables outside the render thread, encapsulate that part
- ;of code in between these two functions.
- dsLock() As "_dsLock@0"
- dsUnlock() As "_dsUnlock@0"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_XM2 * Thanx to Quantum for the FastTracker2 uFMOD static lib * }
- ; *.XM
- CompilerIf #IsXM2
- #XM_RESOURCE = 0
- #XM_MEMORY = 1
- #XM_FILE = 2
- #XM_NOLOOP = 8
- #XM_SUSPENDED = 16
- #uFMOD_MIN_VOL = 0
- #uFMOD_MAX_VOL = 25
- #uFMOD_DEFAULT_VOL = 25
- ;Import "winmm.lib" : EndImport
- Import "ufmod_x86.lib"
- uFMOD_GetRowOrder() As "_uFMOD_GetRowOrder@0" ;Returns the current order in hi-order word and row in low-order word
- uFMOD_GetStats() As "_uFMOD_GetStats@0" ;Returns the L RMS volume in hi-order word and R RMS in low-order word
- uFMOD_GetTime() As "_uFMOD_GetTime@0" ;Returns the time in milliseconds since the song was started
- uFMOD_GetTitle() As "_uFMOD_GetTitle@0" ;Returns the track's title
- uFMOD_Jump2Pattern(pat) As "_uFMOD_Jump2Pattern@4" ;Jumps to the specified zero based pattern index
- uFMOD_Pause() As "_uFMOD_Pause@0" ;Pauses the currently playing song, if any
- uFMOD_PlaySong(*lpXM, param=0, fdwSong=0) As "_uFMOD_PlaySong@12" ;Starts playing an XM song, *lpXM -> 0 = Stopp song
- uFMOD_Resume() As "_uFMOD_Resume@0" ;Resumes the currently paused song, if any
- uFMOD_SetVolume(vol) As "_uFMOD_SetVolume@4" ;Sets global volume: 0 - 25
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_SID * Thanx to statmat for the titchysid_extras.lib * }
- ; *.SID
- CompilerIf #IsSID
- #SID_RESOURCE = 0 ;Load SID file from a resource
- #SID_MEMORY = 1 ;Load SID file from provided memory
- ;Options used in SIDOpen()
- #SID_DEFAULT = 1 ;Play Default subsong, as found in the PSID header
- #SID_NON_DEFAULT = 2 ;Play specified subsong
- ;Import "winmm.lib" : EndImport ; Not really needed!
- ;Import "masm32_x86.lib" : EndImport
- Import "titchysid_extras_x86.lib"
- SIDOpen(*mem, len, mode, options, subsong) As "_SIDOpen@20" ;Returns non-zero on success
- SIDClose() As "_SIDClose@0" ;Close the SID library
- SIDChangeSong(song) As "_SIDChangeSong@4";Change to another sub song in the currently playing SID file
- SIDPause() As "_SIDPause@0" ;Pause the currently playing SID song
- SIDPlay() As "_SIDPlay@0" ;Start the SID playback
- SIDResume() As "_SIDResume@0" ;Resume playing the SID song after a pause
- SIDStop() As "_SIDStop@0" ;Stop the SID playback
- EndImport
- ; Import "titchysid_x86.lib"
- ; SIDOpen(*mem, len, mode, options, subsong) As "_SIDOpen@20" ;Returns non-zero on success
- ; SIDClose() As "_SIDClose@0" ;Close the SID library
- ; EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_TPT * Not official TINY PT2PLAY v1.60 * }
- CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
- Import "tinyPT2_x64.lib"
- tinypt2play_Close() As "pt2play_Close"
- tinypt2play_PlaySong(*moduleData, length) As "pt2play_PlaySong"; returns 1 = playing or 0 = error
- EndImport
- CompilerElse
- ImportC "tinyPT2_x86.lib"
- tinypt2play_Close() As "_pt2play_Close"
- tinypt2play_PlaySong(*moduleData, length) As "_pt2play_PlaySong"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_TFC * Not official TINY FC14PLAY v1.29 * }
- ; https://16-bits.org
- ; https://pastebin.com/VHxZ58UC
- ; *.FC;*.FC13;*.FC14;*.FC3;*.FC4;*.FCM;*.SMOD
- ;Import "winmm.lib" : EndImport
- CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
- Import "tinyFC4_x64.lib"
- tinyfc14play_Close() As "fc14play_Close"
- tinyfc14play_PlaySong(*moduleData, length) As "fc14play_PlaySong" ; returns 1 = playing or 0 = error
- EndImport
- CompilerElse
- ImportC "tinyFC4_x86.lib"
- tinyfc14play_Close() As "_fc14play_Close"
- tinyfc14play_PlaySong(*moduleData, length) As "_fc14play_PlaySong"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_THX * Not official TINY AHX1PLAY v0.27 * }
- ; https://16-bits.org
- ; https://pastebin.com/fqwadbj7
- ; *.AHX;*.THX
- ;Import "winmm.lib" : EndImport
- CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
- Import "tinyAHX_x64.lib"
- tinyahx1play_PlaySong(*moduleData, length, subsong) As "ahx1play_PlaySong" ; returns 1 = playing or 0 = error
- tinyahx1play_Close() As "ahx1play_Close"
- EndImport
- CompilerElse
- ImportC "tinyAHX_x86.lib"
- tinyahx1play_PlaySong(*moduleData, length, subsong) As "_ahx1play_PlaySong"
- tinyahx1play_Close() As "_ahx1play_Close"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_TSR * Thanx to unknown? for the tsidreplay.lib * }
- ; *.SID
- CompilerIf #IsTSR
- ImportC "tsidreplay_x86.lib"
- sid_sound_server_replay_init(*mem, len, subsong) As "_sid_sound_server_replay_init"
- sid_sound_server_replay_play() As "_sid_sound_server_replay_play"
- sid_sound_server_replay_stop() As "_sid_sound_server_replay_stop"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_FCP * Thanx to SiRioKD for the tFCLIB.lib (FutureComposer 1.4) * }
- ; *.FC;*.FC4;*.FC14
- CompilerIf #IsFCP
- ;Import "winmm.lib" : EndImport ; Not really needed?
- ;Import "dsound.lib" : EndImport
- Import "tFCLIB_x86.lib"
- FCp_Open(*hWnd) As "_FCp_Open@4"
- FCp_InitModule(*Ptr) As "_FCp_InitModule@4"
- FCp_Start() As "_FCp_Start@0"
- FCp_Close() As "_FCp_Close@0"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_BAS * Thanx to Ghandi for the ripped bassmod.lib * }
- ; *.XM;*.IT;*.S3M;*.MOD;*.MTM;*.UMX
- CompilerIf #IsBAS
- #BASS_OK = 0 ; all is OK
- #BASS_ERROR_MEM = 1 ; memory error
- #BASS_ERROR_FILEOPEN = 2 ; can't open the file
- #BASS_ERROR_DRIVER = 3 ; can't find a free/valid driver
- #BASS_ERROR_HANDLE = 5 ; invalid handle
- #BASS_ERROR_FORMAT = 6 ; unsupported format
- #BASS_ERROR_POSITION = 7 ; invalid playback position
- #BASS_ERROR_INIT = 8 ; BASS_Init has not been successfully called
- #BASS_ERROR_ALREADY = 14 ; already initialized/loaded
- #BASS_ERROR_ILLTYPE = 19 ; an illegal type was specified
- #BASS_ERROR_ILLPARAM = 20 ; an illegal parameter was specified
- #BASS_ERROR_DEVICE = 23 ; illegal device number
- #BASS_ERROR_NOPLAY = 24 ; not playing
- #BASS_ERROR_NOMUSIC = 28 ; no MOD music has been loaded
- #BASS_ERROR_NOSYNC = 30 ; synchronizers have been disabled
- #BASS_ERROR_NOTAVAIL = 37 ; requested data is not available
- #BASS_ERROR_DECODE = 38 ; the channel is a "decoding channel"
- #BASS_ERROR_FILEFORM = 41 ; unsupported file format
- #BASS_ERROR_UNKNOWN = -1 ; some other mystery error
- ; Device setup flags
- #BASS_DEVICE_8BITS = 1 ; use 8 bit resolution, else 16 bit
- #BASS_DEVICE_MONO = 2 ; use mono, else stereo
- #BASS_DEVICE_NOSYNC = 16 ; disable synchronizers
- #BASS_MUSIC_RAMP = 1 ; normal ramping
- #BASS_MUSIC_RAMPS = 2 ; sensitive ramping
- #BASS_MUSIC_LOOP = 4 ; loop music
- #BASS_MUSIC_FT2MOD = 16 ; play .MOD as FastTracker 2 does
- #BASS_MUSIC_PT1MOD = 32 ; play .MOD as ProTracker 1 does
- #BASS_MUSIC_POSRESET = 256 ; stop all notes when moving position
- #BASS_MUSIC_SURROUND = 512 ; surround sound
- #BASS_MUSIC_SURROUND2 = 1024 ; surround sound (mode 2)
- #BASS_MUSIC_STOPBACK = 2048 ; stop the music on a backwards jump effect
- #BASS_MUSIC_CALCLEN = 8192 ; calculate playback length
- #BASS_MUSIC_NONINTER = 16384 ; non-interpolated mixing
- #BASS_MUSIC_NOSAMPLE = $400000 ; don't load the samples
- #BASS_UNICODE = $80000000
- #BASS_SYNC_MUSICPOS = 0
- #BASS_SYNC_POS = 0
- #BASS_SYNC_MUSICINST = 1
- #BASS_SYNC_END = 2
- #BASS_SYNC_MUSICFX = 3
- #BASS_SYNC_ONETIME = $80000000 ; FLAG: sync only once, else continuously
- ; BASSMOD_ChannelIsActive return values
- #BASS_ACTIVE_STOPPED = 0
- #BASS_ACTIVE_PLAYING = 1
- #BASS_ACTIVE_PAUSED = 3
- ;Import "winmm.lib" : EndImport
- Import "bassmod_x86.lib"
- BASSMOD_DllMain(*hInstance, fdwReason, lpvReserved)
- BASSMOD_Free()
- BASSMOD_GetVolume()
- BASSMOD_Init(device=-1, freq=44100, flags=0)
- BASSMOD_MusicFree()
- BASSMOD_MusicGetLength(playlen)
- BASSMOD_MusicGetName()
- BASSMOD_MusicLoad(mem, *file, offset=#Null, length=#Null, flags=#BASS_MUSIC_LOOP|#BASS_MUSIC_POSRESET|#BASS_MUSIC_NONINTER|#BASS_MUSIC_CALCLEN) ;mem=#true -> Load from *memory
- BASSMOD_MusicPause()
- BASSMOD_MusicPlay()
- BASSMOD_MusicSetPosition(pos) ; $FFFF0000 | Seconds (max. $0000FFFF)
- BASSMOD_MusicSetVolume(chanins, volume)
- BASSMOD_MusicStop()
- BASSMOD_SetVolume(volume)
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_S68 * Thanx to benjihan for the MC68000 Amiga/Atari SC68 libsc68replay.lib * }
- ; http://sc68.atari.org/index.html
- ; *.SC68
- CompilerIf #IsS68
- #SC68Replay_MEMORY = 0
- #SC68Replay_FILE = 1
- ;Import "winmm.lib" : EndImport
- ImportC "libsc68replay_x86.lib"
- sc68replay_Init(*Ptr, Size, Mode) As "_sc68replay_Init"
- sc68replay_Play() As "_sc68replay_Play"
- sc68replay_Stop() As "_sc68replay_Stop"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_BMF * Thanx to BeRo^farbraush for the BR404 Software Synthesizer libbr404.lib * }
- ; *.BRO
- CompilerIf #IsBMF
- Import "libbr404_x86.lib"
- SynthCreate(SampleRate, BufferSize, ThreadPlay, SoundOutput) As "_SynthCreate@16" ; = int Track
- SynthReadBMFSampleRate(*Ptr, Size) As "_SynthReadBMFSampleRate@8"
- SynthReadBMF(Track, *Ptr, Size) As "_SynthReadBMF@12"
- SynthPlay(Track) As "_SynthPlay@4"
- SynthSetLooping(Track, Looping) As "_SynthSetLooping@8"
- SynthEnter(Track) As "_SynthEnter@4"
- SynthStop(Track) As "_SynthStop@4"
- SynthLeave(Track) As "_SynthLeave@4"
- SynthDestroy(Track) As "_SynthDestroy@4"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_MED * MEDPDLL static lib ripped by Peace^TST * }
- ; *.MED;*.MMD0;*.MMD1;*.MMD2;*.MMD3 (PP20)
- ;Import "winmm.lib" : EndImport
- ;Import "dsound.lib": EndImport
- CompilerIf #IsMED
- Import "medpdll_x86.lib"
- MEDPDLL_DllMain(*hinstDLL, fdwReason, lpvReserved) As "_MEDPDLL_DllMain@12"
- MEDP_Initialize(*instance, *mainwindow) As "__MEDP_Initialize@8"
- MEDP_ChangeOption(option, newvalue) As "__MEDP_ChangeOption@8"
- MEDP_Load(*filename) As "__MEDP_Load@4"
- MEDP_IsLoaded() As "__MEDP_IsLoaded@0"
- MEDP_Play() As "__MEDP_Play@0"
- MEDP_Stop() As "__MEDP_Stop@0"
- MEDP_Unload() As "__MEDP_Unload@0"
- MEDP_ModuleLength() As "__MEDP_ModuleLength@0"
- MEDP_ModuleTime() As "__MEDP_ModuleTime@0"
- MEDP_PlayPosition() As "__MEDP_PlayPosition@0"
- MEDP_SetPlayPosition(pos) As "__MEDP_SetPlayPosition@4"
- MEDP_IsPlaying() As "__MEDP_IsPlaying@0"
- MEDP_ModuleName(*buffer, max) As "__MEDP_ModuleName@8"
- MEDP_Release() As "__MEDP_Release@0"
- EndImport
- CompilerEndIf
- ;}
- ;{ #C2D_MUSIC_YMP * YmPluginDLL static lib ripped by Peace^TST * }
- ; *.YM
- CompilerIf #IsYMP
- Structure RS_ymMusicInfo_t
- *pSongName
- *pSongAuthor
- *pSongComment
- *pSongType
- *pSongPlayer
- musicTimeInSec.l
- musicTimeInMs.l
- EndStructure
- ;Import "winmm.lib" : EndImport
- Import "YmPlugin_x86.lib"
- YMPLUGIN_DllMain(*hinstDLL, fdwReason, lpvReserved) As "_YMPLUGIN_DllMain@12"
- YM_Close() As "__YM_Close@0"
- YM_FFT() As "__YM_FFT@0"
- YM_Get_Info(struct) As "__YM_Get_Info@4" ; RS_ymMusicInfo_t
- YM_Init() As "__YM_Init@0"
- YM_Open(*file, *memory, size) As "__YM_Open@12" ; file (size=0) or memory (size <>0)
- YM_Pause() As "__YM_Pause@0"
- YM_Play() As "__YM_Play@0"
- YM_Seek(seconds) As "__YM_Seek@4"
- YM_SetVolume(vol) As "__YM_SetVolume@4" ; 0..255
- YM_Stop() As "__YM_Stop@0"
- EndImport
- CompilerEndIf
- ;}
- ;#C2D_MUSIC_WAV ; *.WAV
- ;#C2D_MUSIC_API ; *.WAV
- ;#C2D_MUSIC_OGG ; *.OGG
- ;#C2D_MUSIC_FLA ; *.FLAC
- ;#C2D_MUSIC_MCI ; *.MID;*.MP3;*.OGG;*.WMA...
- ;}
- ;************************
- Procedure StrSize(Value.q, Flags=1)
- Protected nSize.d
- Static t$ ; return param MUST! global or static in dll
- If Value >= 1099511627776
- nSize = Value / 1099511627776 : t$ = "TB" ;Pow(1024,4)
- ElseIf Value >= 1073741824
- nSize = Value / 1073741824 : t$ = "GB" ;Pow(1024,3)
- ElseIf Value >= 1048576
- nSize = Value / 1048576 : t$ = "MB" ;Pow(1024,2)
- ElseIf Value >= 1024
- nSize = Value / 1024 : t$ = "KB"
- Else ; also negative size / no NbDecimals
- t$ = FormatNumber(Value, 0) + " Bytes"
- ProcedureReturn @t$
- EndIf
- t$ = FormatNumber(nSize, 2) + " " + t$
- If Flags
- t$ + " (" + FormatNumber(Value, 0) + " Bytes)"
- EndIf
- ProcedureReturn @t$
- ; *** Not working in PB x86 ***
- ; Static *Memory
- ; If *Memory = #Null : *Memory = AllocateMemory(128) : EndIf
- ; StrFormatByteSize_(Value, *Memory, 128)
- ; ProcedureReturn PeekS(*Memory)
- EndProcedure
- Procedure StrAsc(*Memory)
- ; correct ascii or unicode strings
- Static *Buffer
- If *Buffer
- FreeMemory(*Buffer)
- *Buffer = #Null
- EndIf
- If *Memory
- If RS_SCAL\StrFormat = #PB_Ascii
- ProcedureReturn *Memory
- Else
- *Buffer = Ascii(PeekS(*Memory, -1, RS_SCAL\StrFormat))
- EndIf
- EndIf
- ProcedureReturn *Buffer
- EndProcedure
- Procedure$ StrTime(Time)
- ; Milliseconds to String: HH:MM:SS,TTT
- ; Flags <> 0 => show rest ms
- Static t$
- t$ = RSet(StrU(Time / 3600000), 2, "0") + ":" + ; HH:
- RSet(StrU((Time / 60000) % 60), 2, "0") + ":" + ; MM:
- RSet(StrU((Time / 1000) % 60), 2, "0") ; SS
- t$ + "," + LSet(StrU(Time % 1000), 3, "0") ; ,TTT
- ProcedureReturn t$
- ; Protected t$=Space(64)
- ; StrFromTimeInterval_(@t$, 64, Time, 1000)
- ; ProcedureReturn t$
- EndProcedure
- ;*******************************
- ;- *** NetWork ? ***************
- CompilerIf Defined(HTTP_QUERY_CONTENT_LENGTH, #PB_Constant) = 0
- #HTTP_QUERY_CONTENT_LENGTH = $5
- CompilerEndIf
- CompilerIf Defined(INTERNET_FLAG_RELOAD, #PB_Constant) = 0
- #INTERNET_FLAG_RELOAD = $80000000
- CompilerEndIf
- CompilerIf Defined(INTERNET_FLAG_NO_CACHE_WRITE, #PB_Constant) = 0
- #INTERNET_FLAG_NO_CACHE_WRITE = $4000000
- CompilerEndIf
- Structure RS_NetWork
- *CallBack ; @Procedure(Param)
- *hInternet ; iNetConnection
- *hURL ; iNetURL
- BytesRead.i ; Buffered bytes
- BytesSkip.i ; Skip bytes of "header"!
- Length.i ; Bytesize of url
- EndStructure
- Global RS_NetWork.RS_NetWork
- Procedure NetWorkCallBack(*CallBack=0)
- ; *CallBack = @Procedure(Param)
- RS_NetWork\CallBack = *CallBack
- EndProcedure
- Procedure NetWorkFree() ; private
- With RS_NetWork
- If \hInternet
- InternetCloseHandle_(\hInternet)
- EndIf
- ClearStructure(@RS_NetWork, RS_NetWork)
- EndWith
- EndProcedure
- Procedure$ NetWorkUrl(Url$) ; private
- ; Encode unsave characters (canonicalize)
- ; https://www.ietf.org/rfc/rfc1738.txt
- Protected *Memory.Character=@Url$, i
- Static t$
- t$ = #Null$
- While *Memory\c
- Select *Memory\c
- Case ',',' ','!','"','#','$','&','+',';','<','=','>','@','[','\',']','^','_','`','{','|','}','~',$27 ; not '-','%'
- t$ + "%" + Hex(*Memory\c)
- Default
- If *Memory\c <> '\' ; no "\/"
- t$ + Chr(*Memory\c)
- EndIf
- EndSelect
- *Memory + SizeOf(Character)
- Wend
- ; Canonicalize filename - else error when char + %
- If StrStrI_(@t$, @"%")
- For i = $20 To $FF
- Select i
- Case $20 To $2F, $40 To $FF ; no numbers
- t$ = ReplaceString(t$, "%" + Chr(i), "%25" + Chr(i), #PB_String_CaseSensitive)
- EndSelect
- Next
- EndIf
- ProcedureReturn t$
- EndProcedure
- Procedure NetWorkBytes(Length=4096)
- ; Length (BytesToRead) = Number of bytes preloaded from Url$
- If Length > #Null
- RS_NetWork\BytesRead = Length
- EndIf
- EndProcedure
- Procedure NetWorkInit(Url$) ; private
- ; Return: Filesize(Url$) or #NULL -> Error
- If StrStrI_(@Url$, @"://") = #Null : ProcedureReturn #Null : EndIf
- Protected *Memory, Length
- With RS_NetWork
- NetWorkCallBack(RS_SCAL\CallBack) ; always set callback!
- If \hInternet <= #Null
- \hInternet = InternetOpen_(@"SCAL/1.0", #INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0)
- EndIf
- \Length = #Null
- If \hInternet
- If \BytesRead <= #Null
- NetWorkBytes()
- EndIf
- ; Encode unsave URL-Characters (canonicalize)
- Url$ = NetWorkUrl(Url$)
- Length = 1024 + Len(Url$) + \BytesSkip ; + space for query content
- *Memory = AllocateMemory(Length * SizeOf(Character))
- PokeS(*Memory, Url$)
- \hURL = InternetOpenUrl_(\hInternet, *Memory, 0, 0, #INTERNET_FLAG_RELOAD|#INTERNET_FLAG_NO_CACHE_WRITE|#INTERNET_FLAG_NO_COOKIES, 0)
- If \hURL
- If HttpQueryInfo_(\hURL, #HTTP_QUERY_CONTENT_LENGTH, *Memory, @Length, 0)
- \Length = StrToInt_(*Memory)
- If GetLastError_() Or \Length <= 0 ; Error?
- \Length = #Null
- ElseIf \BytesSkip ; <- skip pseudoheader for deceive hoster?
- InternetReadFile_(\hURL, *Memory, \BytesSkip, @Length)
- \Length - Length
- EndIf
- EndIf
- EndIf
- FreeMemory(*Memory)
- EndIf
- RS_SCAL\NetLength = \Length ; global length for SCAL_Struct()
- ProcedureReturn \Length
- EndWith
- EndProcedure
- Procedure NetWorkLoad(Url$)
- ; Download Netfile to *Memory
- ; Return: Ptr to *Memory
- Protected *Buffer, Length
- Static *Memory
- *Memory = #Null
- If NetWorkInit(Url$)
- With RS_NetWork
- If \Length > #Null
- *Memory = AllocateMemory(\Length)
- *Buffer = *Memory
- While InternetReadFile_(\hURL, *Buffer, \BytesRead, @Length)
- *Buffer + Length
- ;// If *CallBack And CallFunctionFast(*CallBack, Percent) : Break : EndIf
- If \CallBack
- If CallFunctionFast(\CallBack, (100.0 / \Length) * (*Buffer - *Memory)) ; Abort?
- FreeMemory(*Memory)
- *Memory = #Null
- Break
- EndIf
- Else
- Delay(1)
- EndIf
- If (Length <= #Null) Or (*Buffer >= *Memory + \Length)
- Break
- EndIf
- Wend
- EndIf
- InternetCloseHandle_(\hURL)
- EndWith
- EndIf
- If RS_NetWork\CallBack
- CallFunctionFast(RS_NetWork\CallBack, 100)
- EndIf
- ProcedureReturn *Memory
- EndProcedure
- Procedure NetWorkSize(Url$)
- ; = size of url$
- If NetWorkInit(Url$)
- InternetCloseHandle_(RS_NetWork\hURL)
- ProcedureReturn RS_NetWork\Length
- EndIf
- EndProcedure
- Procedure NetWorkSkip(Length=0)
- ; Length (skip bytes) of decive header chars
- If Length >= #Null
- RS_NetWork\BytesSkip = Length
- EndIf
- EndProcedure
- Procedure NetWorkDownload(Url$, File$)
- ; Return: Size of saved file, Error = #NULL
- If NetWorkInit(Url$) = #Null : ProcedureReturn #Null : EndIf
- Protected *Memory, Length, hF
- Protected nSizeLoad, IsAbort
- Static nSizeSave
- nSizeSave = #Null
- With RS_NetWork
- If \Length > #Null
- *Memory = AllocateMemory(\BytesRead)
- hF = CreateFile(#PB_Any, File$)
- If hF
- While InternetReadFile_(\hURL, *Memory, \BytesRead, @nSizeLoad)
- Length = WriteData(hF, *Memory, nSizeLoad)
- nSizeSave + Length
- ;// If *CallBack And CallFunctionFast(*CallBack, Percent) : Break : EndIf
- If \CallBack
- If CallFunctionFast(\CallBack, (100.0 / \Length) * nSizeSave) ; %Percent (Abort?)
- IsAbort = #True
- Break
- EndIf
- Else
- Delay(1)
- EndIf
- If nSizeSave >= \Length Or Length < nSizeLoad ; Length -> WriteError?
- Break
- EndIf
- Wend
- FlushFileBuffers(hF)
- CloseFile(hF)
- EndIf
- FreeMemory(*Memory)
- EndIf
- InternetCloseHandle_(\hURL)
- EndWith
- If IsAbort ; aborted?
- nSizeSave = #Null
- DeleteFile_(@File$)
- EndIf
- If RS_NetWork\CallBack
- CallFunctionFast(RS_NetWork\CallBack, 100)
- EndIf
- ProcedureReturn nSizeSave
- EndProcedure
- ;*******************************
- Declare SCAL_IsFormat(Mode, *Memory.Long, Length)
- Declare SCAL_SetVolume(Percent)
- Procedure scal_Init()
- Static IsInit
- If IsInit : ProcedureReturn : EndIf
- IsInit = 1
- InitSound()
- CompilerIf #IsMOV
- InitMovie()
- CompilerEndIf
- EndProcedure
- Procedure scal_Temp(Name$)
- ; Creates %TEMP%\Name$
- Protected t$, Path$, i
- Static IsError
- If RS_SCAL\Temp$ : ProcedureReturn #True : EndIf
- Path$ = GetTemporaryDirectory()
- IsError = #Null
- Repeat
- i + 1
- t$ = Trim(StringField(Name$, i, #PS$))
- If Len(t$)
- Path$ + t$ + #PS$
- If FileSize(Path$) = -1
- If CreateDirectory(Path$) = #Null
- IsError = 1 : Break ; ERROR - Can't create directory
- EndIf
- EndIf
- EndIf
- Until Len(t$) = 0
- If IsError
- RS_SCAL\Temp$ = GetTemporaryDirectory()
- Else
- RS_SCAL\Temp$ = Path$
- EndIf
- IsError ! 1
- ProcedureReturn IsError ; true if ok
- EndProcedure
- Procedure scal_Size(File$)
- Static Length
- If StrStrI_(@File$, @"://") ; Netfile?
- Length = NetWorkSize(File$)
- If Length < #Null : Length = #Null : EndIf
- ProcedureReturn Length
- EndIf
- Length = FileSize(File$)
- If Length < #Null : Length = #Null : EndIf
- ProcedureReturn Length
- EndProcedure
- Procedure$ scal_Case(a$, b$)
- ; canonicalize a$ like b$
- ; some server allows real upper/lower chars only.
- ; so we have to adapt the upper/lower chars!
- ; use it align char-cases of "MDAT.?" / "SMPL.?" files
- Protected *a.Character = @a$
- Protected *b.Character = @b$
- While *a\c And *b\c
- If *b\c & %0100000
- *a\c | %0100000
- Else
- *a\c & %1011111
- EndIf
- *a + SizeOf(Character)
- *b + SizeOf(Character)
- Wend
- ProcedureReturn a$
- EndProcedure
- Procedure scal_Copy(File$, Save$)
- ; Return: #True = OK, #False = Error
- Static IsError
- If StrStrI_(@File$, @"://") ; Netfile?
- IsError = NetWorkDownload(File$, Save$)
- ProcedureReturn IsError
- EndIf
- IsError = CopyFile_(@File$, @Save$, #False)
- ProcedureReturn IsError
- EndProcedure
- Procedure scal_Sufx(*Memory, Flags)
- ; Checks filename first for "*.mod" & second for "mod.*"
- ; Do NOT check with GetExtensionPart()
- ; Extension doesn't accept spaces, that's why we must use the stringfield-trick!
- ; Return: ptr to semi-quoted extension ";MOD;" etc.
- Static t$
- Protected File$ = GetFilePart(PeekS(*Memory, -1, RS_SCAL\StrFormat))
- If Flags ; MOD.* (like MDAT.*)
- t$ = StringField(File$, 1, ".")
- Else ; *.MOD (default)
- t$ = Trim(PeekS(PathFindExtension_(@File$), -1), ".") ;StringField(File$, CountString(File$, ".") + 1, ".")
- EndIf
- If Len(t$) = #Null Or Len(t$) > 16 Or StrStrI_(@t$, @" ") ; spaces in extension are NOT allowed!
- ProcedureReturn #Null
- EndIf
- CharUpper_(@t$)
- t$ = ";" + t$ + ";"
- ProcedureReturn @t$
- EndProcedure
- Procedure scal_Down(URL$)
- ;- Download file + sfx-libs to temporary path
- ; Return: <> 0 = OK
- Protected File$, t$, i
- If StrStrI_(@URL$, @"://") = #Null : ProcedureReturn #Null : EndIf
- scal_Temp(#SCAL_TempPath$)
- File$ = GetFilePart(URL$)
- For i = $20 To $FF
- If StrStrI_(@File$, @"%") = #Null : Break : EndIf
- File$ = ReplaceString(File$, "%" + Hex(i), Chr(i), #PB_String_NoCase)
- Next
- File$ = RS_SCAL\Temp$ + File$
- RS_SCAL\File$ = File$
- ; *** Already downloaded?
- If scal_Size(URL$) = scal_Size(File$)
- ProcedureReturn #True
- EndIf
- ; *** Download file to #SCAL_TempPath$
- If scal_Copy(URL$, File$) = 0
- ProcedureReturn #Null
- EndIf
- ; =======================================================
- ;{ *** Check for needed sfx-lib files on server (x86) ***
- CompilerIf #IsAMP
- If StrStrI_(@File$, @"MDAT.")
- ; MDAT.* = Amiga TFMX? - Needs the SMPL.* sfx-file! Download always with adapted chars
- t$ = GetFilePart(URL$, #PB_FileSystem_NoExtension)
- t$ = scal_Case("SMPL", t$) ; adapt upper / lower chars
- PokeS(StrStrI_(@URL$, @"MDAT."), t$, -1, #PB_String_NoZero)
- PokeS(StrStrI_(@File$,@"MDAT."), t$, -1, #PB_String_NoZero)
- scal_Copy(URL$, File$)
- ElseIf StrStrI_(PathFindExtension_(@File$), @".TFX")
- ; *.TFX = Amiga TFMX Clone? - Needs the *.SAM sfx-file! Download always with adapted chars
- t$ = GetExtensionPart(URL$)
- t$ = "." + scal_Case("SAM", t$)
- PathRenameExtension_(@URL$, @t$)
- PathRenameExtension_(@File$, @t$)
- scal_Copy(URL$, File$)
- ElseIf StrStrI_(PathFindExtension_(@File$), @".KDM")
- ; *.KDM = Ken's Digital Music? - Needs the waves.kwv sfx-file!
- URL$ = GetPathPart(URL$) + "waves.kwv"
- File$ = RS_SCAL\Temp$ + "waves.kwv"
- If scal_Size(URL$) <> scal_Size(File$)
- scal_Copy(URL$, File$)
- EndIf
- ElseIf StrStrI_(@File$, @".MINI2SF") Or ; = Nintendo DS Sound? - Needs a tagged *.lib sfx-file
- StrStrI_(@File$, @".MINIDSF") Or ; = Dreamcast Sound? - Needs a tagged *.lib sfx-file
- StrStrI_(@File$, @".MINIGSF") Or ; = Gameboy Sound? - Needs a tagged *.lib sfx-file
- StrStrI_(@File$, @".MINIPSF") Or ; = Playstation Sound? - Needs almost a couple of tagged *.lib sfx-files
- StrStrI_(@File$, @".PSF") Or ; = Playstation Sound? - Courious yes/no tagged *.lib sfx-files
- StrStrI_(@File$, @".MINIPSF2") Or ; = Playstation2 Sound? - Needs a tagged *.lib sfx-file
- StrStrI_(@File$, @".MINIQSF") Or ; = Capcom Q-Sound? - Needs a tagged *.lib sfx-file
- StrStrI_(@File$, @".MINISNSF") Or ; = Super Nintendo Sound? - Needs a tagged *.lib sfx-file
- StrStrI_(@File$, @".MINISSF") Or ; = Saturn Sound? - Needs almost a couple of tagged *.lib sfx-files
- StrStrI_(@File$, @".SSF") Or ; = Saturn Sound? - Courious yes/no tagged *.lib sfx-files
- StrStrI_(@File$, @".MINIUSF") ; = Ultra64 Sound? - Needs a tagged *.lib sfx-file
- ; *** Hardcoded [TAG] check for all needed *.lib sfx-files ***
- ; (too bad, unfortunately there are occasionally incorrect named *.lib's on modland server)
- If ReadFile(0, File$)
- While Eof(0) = 0
- t$ = ReadString(0, #PB_Ascii)
- If StrStrI_(@t$, @"_lib") And StrStrI_(@t$, @"=") ; [Tag] & _lib=, _lib1=, _lib2=..
- t$ = PeekS(CharLower_(StrStrI_(@t$, @"=") + SizeOf(Character))) ; LCase(StringField(t$, 2, "="))
- If scal_Size(GetPathPart(URL$) + t$) <> scal_Size(RS_SCAL\Temp$ + t$) ; Bad solution, but works for now
- scal_Copy(GetPathPart(URL$) + t$, RS_SCAL\Temp$ + t$)
- EndIf
- EndIf
- Wend
- CloseFile(0)
- EndIf
- EndIf
- CompilerEndIf ;}
- ; =======================================================
- ProcedureReturn #True
- EndProcedure
- CompilerIf #IsAMP ; C:\Users\Public\Documents\AmpMaster\
- PrototypeC pAmp_Close()
- PrototypeC pAmp_CountAmpFormatsAll()
- PrototypeC pAmp_CountAmpPlayersAll()
- PrototypeC pAmp_CountSubSongs(*File.p-Ascii)
- PrototypeC pAmp_Free()
- PrototypeC pAmp_GetAmpFormatsStrAll()
- PrototypeC pAmp_GetAmpInDllsStrAll(*File.p-Ascii)
- PrototypeC pAmp_GetAmpInDllStr(*File.p-Ascii)
- PrototypeC pAmp_GetAmpInFormatStr(*InLib.p-Ascii)
- PrototypeC pAmp_GetError()
- PrototypeC pAmp_GetErrorStr(Error.i)
- PrototypeC pAmp_GetFileInfo(*File.p-Ascii, *Title, *Length)
- PrototypeC pAmp_GetInFlags(*InLib.p-Ascii)
- PrototypeC pAmp_GetInFormatStr()
- PrototypeC pAmp_GetInInfoStr()
- PrototypeC pAmp_GetOutInfoStr()
- PrototypeC pAmp_GetPercent()
- PrototypeC pAmp_GetPlayTime()
- PrototypeC pAmp_GetStopTime()
- PrototypeC pAmp_GetSubSong(*File.p-Ascii)
- PrototypeC pAmp_InAbout()
- PrototypeC pAmp_InConfig()
- PrototypeC pAmp_InfoBox(*File.p-Ascii)
- PrototypeC pAmp_Init()
- PrototypeC pAmp_MusicBox(*File.p-Ascii, Flags.i=1)
- PrototypeC pAmp_MusicGetLength(Flags.i=0)
- PrototypeC pAmp_MusicGetOutPosition()
- PrototypeC pAmp_MusicGetPosition()
- PrototypeC pAmp_MusicGetTitleStr()
- PrototypeC pAmp_MusicIsPlaying()
- PrototypeC pAmp_MusicIsSeekable()
- PrototypeC pAmp_MusicPause(Pause.i)
- PrototypeC pAmp_MusicPlay(*File.p-Ascii)
- PrototypeC pAmp_MusicSetPan(Pan.i)
- PrototypeC pAmp_MusicSetPosition(Milliseconds.i)
- PrototypeC pAmp_MusicSetVolume(Volume.i)
- PrototypeC pAmp_MusicStop()
- PrototypeC pAmp_Open()
- PrototypeC pAmp_OutAbout()
- PrototypeC pAmp_OutConfig()
- PrototypeC pAmp_Play(*File.p-Ascii, Volume.i=255)
- PrototypeC pAmp_QuickPlay(*File.p-Ascii, *Path.p-Ascii)
- PrototypeC pAmp_SetAmpPath(*Path.p-Ascii)
- PrototypeC pAmp_SetDefaultLength(Milliseconds.i=0)
- PrototypeC pAmp_SetInDll(*InLib.p-Ascii)
- PrototypeC pAmp_SetInPath(*Path.p-Ascii)
- PrototypeC pAmp_SetLength(Milliseconds.i)
- PrototypeC pAmp_SetOutDll(*OutLib.p-Ascii)
- PrototypeC pAmp_SetOutPath(*Path.p-Ascii)
- PrototypeC pAmp_SetSubSong(*File.p-Ascii, SubSong.i)
- PrototypeC pAmp_SetWindow(*Window)
- PrototypeC pAmp_VersionStr(Flags.i=0)
- Structure RS_Amp
- DLL.i
- IsPlay.i
- TimeLength.i
- TimeLoop.i
- File$
- CountSubSongs .pAmp_CountSubSongs
- Play .pAmp_Play
- Free .pAmp_Free
- GetPlayTime .pAmp_GetPlayTime
- GetInInfoStr .pAmp_GetInInfoStr
- GetSubSong .pAmp_GetSubSong
- MusicGetLength .pAmp_MusicGetLength
- MusicGetTitle .pAmp_MusicGetTitleStr
- MusicIsSeekable .pAmp_MusicIsSeekable
- MusicPause .pAmp_MusicPause
- MusicSetPosition .pAmp_MusicSetPosition
- MusicSetVolume .pAmp_MusicSetVolume
- SetAmpPath .pAmp_SetAmpPath
- SetSubSong .pAmp_SetSubSong
- EndStructure
- Global RS_Amp.RS_Amp
- ProcedureC AmpMusicFree()
- With RS_Amp
- If \DLL
- \Free()
- FreeLibrary_(\DLL)
- \DLL = #Null
- \IsPlay = #Null
- EndIf
- EndWith
- EndProcedure
- ProcedureC AmpMusicInit(Path$=#Null$)
- ; Default path to AmpMaster -> "C:\Users\Public\Documents\AmpMaster\"
- If RS_Amp\DLL : ProcedureReturn RS_Amp\DLL : EndIf
- Protected t${#MAX_PATH}
- With RS_Amp
- If Path$
- t$ = Path$
- Else ; C:\Users\Public\Documents\ + "AmpMaster\"
- SHGetFolderPath_(#Null, #CSIDL_COMMON_DOCUMENTS, #Null, #Null, @t$)
- PathAddBackslash_(@t$)
- t$ + "AmpMaster\"
- EndIf
- t$ + "AmpMaster_x86.dll"
- \DLL = LoadLibrary_(@t$)
- If \DLL
- \CountSubSongs = GetProcAddress_(\DLL, StrAsc(@"Amp_CountSubSongs"))
- \Play = GetProcAddress_(\DLL, StrAsc(@"Amp_Play"))
- \Free = GetProcAddress_(\DLL, StrAsc(@"Amp_Free"))
- \MusicGetLength = GetProcAddress_(\DLL, StrAsc(@"Amp_MusicGetLength"))
- \MusicGetTitle = GetProcAddress_(\DLL, StrAsc(@"Amp_MusicGetTitleStr"))
- \MusicPause = GetProcAddress_(\DLL, StrAsc(@"Amp_MusicPause"))
- \MusicIsSeekable = GetProcAddress_(\DLL, StrAsc(@"Amp_MusicIsSeekable"))
- \MusicSetPosition = GetProcAddress_(\DLL, StrAsc(@"Amp_MusicSetPosition"))
- \MusicSetVolume = GetProcAddress_(\DLL, StrAsc(@"Amp_MusicSetVolume"))
- \GetPlayTime = GetProcAddress_(\DLL, StrAsc(@"Amp_GetPlayTime"))
- \GetInInfoStr = GetProcAddress_(\DLL, StrAsc(@"Amp_GetInInfoStr"))
- \GetSubSong = GetProcAddress_(\DLL, StrAsc(@"Amp_GetSubSong"))
- \SetAmpPath = GetProcAddress_(\DLL, StrAsc(@"Amp_SetAmpPath"))
- \SetSubSong = GetProcAddress_(\DLL, StrAsc(@"Amp_SetSubSong"))
- If Path$
- Path$ + "AmpLibs\" : \SetAmpPath(StrAsc(@Path$)) ; set path of amplibs
- EndIf
- EndIf
- ProcedureReturn \DLL
- EndWith
- EndProcedure
- ProcedureC AmpMusicPlay(*Memory, SubSong=0)
- ; *Memory = Ptr to @Filename$ only!
- ; SubSong = Number of subsong to play (eg. SID)
- ; Return: #True = Music is playing or #False = Error!
- With RS_Amp
- \IsPlay = #False
- \TimeLength = #Null
- \TimeLoop = #Null
- \File$ = PeekS(*Memory, -1, RS_SCAL\StrFormat)
- If AmpMusicInit()
- \Free()
- If SubSong > 0
- \SetSubSong(StrAsc(@\File$), SubSong)
- EndIf
- If \Play(StrAsc(@\File$)) = 0
- \TimeLength = \MusicGetLength()
- If \TimeLength <= 100 Or StrStrI_(@\File$, @".SID") Or StrStrI_(@\File$, @".PSID") Or StrStrI_(@\File$, @".RSID")
- \TimeLength = 600000
- EndIf
- \TimeLoop = \TimeLength + ElapsedMilliseconds() + 50 ; <- Time to reset
- \IsPlay = #True
- EndIf
- ProcedureReturn \IsPlay
- EndIf
- EndWith
- EndProcedure
- ProcedureC AmpMusicStop()
- RS_Amp\Free() : RS_Amp\IsPlay = #False
- EndProcedure
- ProcedureC AmpMusicLoop()
- If RS_Amp\IsPlay And ElapsedMilliseconds() > RS_Amp\TimeLoop
- ProcedureReturn AmpMusicPlay(@RS_Amp\File$)
- EndIf
- EndProcedure
- ProcedureC AmpMusicPosition()
- If RS_Amp\IsPlay
- ProcedureReturn RS_Amp\GetPlayTime()
- EndIf
- EndProcedure
- ProcedureC AmpMusicVolume(Volume)
- If RS_Amp\IsPlay
- ProcedureReturn RS_Amp\MusicSetVolume(Volume)
- EndIf
- EndProcedure
- ProcedureC AmpMusicTitle()
- If RS_Amp\IsPlay
- ProcedureReturn RS_Amp\MusicGetTitle()
- EndIf
- EndProcedure
- ProcedureC AmpCountSubSongs(*Memory)
- ProcedureReturn RS_Amp\CountSubSongs(StrAsc(*Memory))
- EndProcedure
- ProcedureC AmpMusicInfo()
- If RS_Amp\IsPlay
- ProcedureReturn RS_Amp\GetInInfoStr()
- EndIf
- EndProcedure
- ProcedureC AmpMusicLength()
- ProcedureReturn RS_Amp\TimeLength
- EndProcedure
- ProcedureC AmpMusicPause(Flags)
- If RS_Amp\IsPlay
- ProcedureReturn RS_Amp\MusicPause(Flags)
- EndIf
- EndProcedure
- ProcedureC AmpMusicIsSeekable()
- With RS_Amp
- ProcedureReturn \MusicIsSeekable()
- EndWith
- EndProcedure
- ProcedureC AmpMusicSetPosition(Milliseconds)
- With RS_Amp
- If \IsPlay And AmpMusicIsSeekable() And ; no PSID/SID/RSID
- StrStrI_(@\File$, @".SID") = 0 And
- StrStrI_(@\File$, @".PSID") = 0 And
- StrStrI_(@\File$, @".RSID") = 0
- ProcedureReturn \MusicSetPosition(Milliseconds)
- EndIf
- EndWith
- EndProcedure
- CompilerEndIf
- CompilerIf #IsS68
- ProcedureC sc68_Play(*Memory, Length)
- With RS_SCAL
- If Length
- \ID = sc68replay_Init(*Memory, Length, #SC68Replay_MEMORY)
- \Title$ = PeekS(*Memory + $48, -1, #PB_Ascii)
- Else
- \ID = sc68replay_Init(StrAsc(*Memory), #Null, #SC68Replay_FILE)
- EndIf
- If \ID
- sc68replay_Play()
- EndIf
- ProcedureReturn \ID
- EndWith
- EndProcedure
- ProcedureC sc68_Free()
- If RS_SCAL\ID
- sc68replay_Stop()
- EndIf
- EndProcedure
- CompilerEndIf
- Procedure IsAmpMaster()
- CompilerIf #IsAMP
- Static t${#MAX_PATH}
- If Len(t$) = #Null
- SHGetFolderPath_(#Null, #CSIDL_COMMON_DOCUMENTS, #Null, #Null, @t$)
- PathAddBackslash_(@t$)
- t$ + "AmpMaster"
- EndIf
- ProcedureReturn Bool(FileSize(t$) = -2)
- CompilerElse
- ProcedureReturn #False
- CompilerEndIf
- EndProcedure
- Procedure Default_Mode(*Memory.Long, Length)
- ; Autodetect #C2D_MUSIC_[mode]
- ; *Memory = Pointer to @Filename if Length = 0
- ; Checks file.extension ?.* and *.?
- ; Return: Default playback-mode or 0 = Error!
- Static Mode
- Mode = #Null
- If Length > #Null ; *** Check memory for default mode (not to be confused with supported mode!) ***
- If SCAL_IsFormat(#C2D_MUSIC_FT2, *Memory, Length) : Mode = #C2D_MUSIC_FT2 ; stabile Sound/Pro/Mod/FastTracker-Replay
- ElseIf SCAL_IsFormat(#C2D_MUSIC_PT2, *Memory, Length) : Mode = #C2D_MUSIC_PT2 ; only Protracker 2.3d
- ElseIf SCAL_IsFormat(#C2D_MUSIC_AHX, *Memory, Length) : Mode = #C2D_MUSIC_AHX
- ElseIf SCAL_IsFormat(#C2D_MUSIC_FC4, *Memory, Length) : Mode = #C2D_MUSIC_FC4
- ElseIf SCAL_IsFormat(#C2D_MUSIC_S3M, *Memory, Length) : Mode = #C2D_MUSIC_S3M
- ElseIf SCAL_IsFormat(#C2D_MUSIC_STM, *Memory, Length) : Mode = #C2D_MUSIC_STM
- ElseIf SCAL_IsFormat(#C2D_MUSIC_OGG, *Memory, Length) : Mode = #C2D_MUSIC_OGG
- ElseIf SCAL_IsFormat(#C2D_MUSIC_FLA, *Memory, Length) : Mode = #C2D_MUSIC_FLA
- ElseIf SCAL_IsFormat(#C2D_MUSIC_WAV, *Memory, Length) : Mode = #C2D_MUSIC_WAV
- CompilerIf (#IsSID + #IsTSR)
- ElseIf SCAL_IsFormat(#C2D_MUSIC_SID, *Memory, Length) : Mode = #C2D_MUSIC_SID
- CompilerEndIf
- CompilerIf #IsYMP
- ElseIf SCAL_IsFormat(#C2D_MUSIC_YMP, *Memory, Length) : Mode = #C2D_MUSIC_YMP
- CompilerEndIf
- CompilerIf #IsBAS
- ElseIf SCAL_IsFormat(#C2D_MUSIC_BAS, *Memory, Length) : Mode = #C2D_MUSIC_BAS
- CompilerEndIf
- CompilerIf #IsBMF
- ElseIf SCAL_IsFormat(#C2D_MUSIC_BMF, *Memory, Length) : Mode = #C2D_MUSIC_BMF
- CompilerEndIf
- CompilerIf #IsS68
- ElseIf SCAL_IsFormat(#C2D_MUSIC_S68, *Memory, Length) : Mode = #C2D_MUSIC_S68
- CompilerEndIf
- CompilerIf (#IsV2M + #IsV1M)
- ElseIf SCAL_IsFormat(#C2D_MUSIC_V2M, *Memory, Length) : Mode = #C2D_MUSIC_V2M
- CompilerEndIf
- Else ; default memory mode
- Mode = #C2D_MUSIC_MOD
- EndIf
- Else ; *** Checks file.extension ?.* and *.? ***
- Protected *x, i
- For i = 0 To 1
- *x = scal_Sufx(*Memory, i) : If *x = #Null : Continue : EndIf
- If StrStrI_(?l_FT2, *x) : Mode = #C2D_MUSIC_FT2
- ElseIf StrStrI_(?l_PT2, *x) : Mode = #C2D_MUSIC_PT2
- ElseIf StrStrI_(?l_S3M, *x) : Mode = #C2D_MUSIC_S3M
- ElseIf StrStrI_(?l_STM, *x) : Mode = #C2D_MUSIC_STM
- ElseIf StrStrI_(?l_AHX, *x) : Mode = #C2D_MUSIC_AHX
- ElseIf StrStrI_(?l_FC4, *x) : Mode = #C2D_MUSIC_FC4
- ElseIf StrStrI_(?l_WAV, *x) : Mode = #C2D_MUSIC_WAV
- ElseIf StrStrI_(?l_OGG, *x) : Mode = #C2D_MUSIC_OGG
- ElseIf StrStrI_(?l_FLA, *x) : Mode = #C2D_MUSIC_FLA
- CompilerIf #IsBAS
- ElseIf StrStrI_(?l_BAS, *x) : Mode = #C2D_MUSIC_BAS
- CompilerEndIf
- CompilerIf #IsMED
- ElseIf StrStrI_(?l_MED, *x) : Mode = #C2D_MUSIC_MED
- CompilerEndIf
- CompilerIf #IsSID
- ElseIf StrStrI_(?l_SID, *x) : Mode = #C2D_MUSIC_SID
- CompilerEndIf
- CompilerIf #IsTSR
- ElseIf StrStrI_(?l_SID, *x) : Mode = #C2D_MUSIC_TSR
- CompilerEndIf
- CompilerIf #IsYMP
- ElseIf StrStrI_(?l_YMP, *x) : Mode = #C2D_MUSIC_YMP
- CompilerEndIf
- CompilerIf #IsS68
- ElseIf StrStrI_(?l_SC68, *x): Mode = #C2D_MUSIC_S68
- CompilerEndIf
- CompilerIf #IsV2M
- ElseIf StrStrI_(?l_V2M, *x)
- If IsAmpMaster()
- Mode = #C2D_MUSIC_AMP ; stabile v1.0/1.5 playback
- Else
- Mode = #C2D_MUSIC_V2M
- EndIf
- CompilerEndIf
- CompilerIf #IsBMF
- ElseIf StrStrI_(?l_BMF, *x) : Mode = #C2D_MUSIC_BMF
- CompilerEndIf
- ElseIf StrStrI_(?l_MCI, *x) : Mode = #C2D_MUSIC_MCI
- ElseIf StrStrI_(?l_MOD, *x) : Mode = #C2D_MUSIC_MOD
- CompilerIf #IsAMP ; check at last, coz we don't know if ampmaster is installed?
- ElseIf StrStrI_(?l_AMP, *x) : Mode = #C2D_MUSIC_AMP
- CompilerEndIf
- EndIf
- If Mode : Break : EndIf
- ;Mode = #C2D_MUSIC_MCI ; pre-set as default
- Next
- EndIf
- ProcedureReturn Mode
- EndProcedure
- ;- *** Functions ***************
- ProcedureDLL SCAL_AmpInstall(*URL)
- ; Only for Windows x86!
- ; *** ZIP ***
- ; https://testaware.files.wordpress.com/2020/08/ampmaster200824
- CompilerIf #IsAMP
- scal_Temp(#SCAL_TempPath$) ; create temporary directory for all files
- Static IsError
- Protected URL$, File$, i, Count
- ; 2.5KB smaller than -> Install_Path$ = GetUserDirectory(#PB_Directory_Public)
- Protected Install_Path${#MAX_PATH}
- SHGetFolderPath_(#Null, #CSIDL_COMMON_DOCUMENTS, #Null, #Null, @Install_Path$)
- PathAddBackslash_(@Install_Path$)
- If *URL
- URL$ = PeekS(*URL, -1, RS_SCAL\StrFormat)
- Else
- URL$ = #SCAL_AmpMaster$ + ".gif"
- EndIf
- If StrStrI_(@URL$, @"://")
- File$ = RS_SCAL\Temp$ + GetFilePart(URL$, #PB_FileSystem_NoExtension) + ".zip"
- If StrStrI_(@URL$, @".GIF")
- NetWorkSkip(6) ; "GIF89a" -> ; skip to real Arc-Header (6 bytes)
- Else
- NetWorkSkip(#Null)
- EndIf
- IsError = Bool(NetWorkDownload(URL$, File$)=0)
- Else ; unpack file-archive
- File$ = URL$
- IsError = Bool(FileSize(File$)<=0) ; file error?
- EndIf
- If IsError = 0
- Count = ZIP_GetFilesCount(File$)
- If Count
- For i = 1 To Count
- If ZIP_ExtractFile(File$, i, Install_Path$)
- If RS_SCAL\CallBack ; user proc?
- If CallFunctionFast(RS_SCAL\CallBack, (100.0 / Count) * (i + 1)) ; 126 Files + 3 Folders
- IsError = #True
- Break
- EndIf
- EndIf
- Else
- IsError = #True
- Break
- EndIf
- Next
- Else
- IsError = #True
- EndIf
- Else
- IsError = #True
- EndIf
- If RS_SCAL\CallBack : CallFunctionFast(RS_SCAL\CallBack, 100) : EndIf ; user proc?
- ; *** #True = ALL correct unpacked, #False = ERROR!
- ProcedureReturn Bool(IsError=0)
- CompilerElse
- If RS_SCAL\CallBack : CallFunctionFast(RS_SCAL\CallBack, 100) : EndIf ; user proc?
- ProcedureReturn #False
- CompilerEndIf
- EndProcedure
- ProcedureDLL SCAL_CallBack(*Proc)
- ; *proc = @Procedurename(Param)
- ; Param -> downloadstatus 0-100%
- RS_SCAL\CallBack = *Proc ; NetWorkCallBack()
- EndProcedure
- ProcedureDLL SCAL_Download(*URL, *File, Skip, Flags)
- ; Return: Bytesize of download or number of unpacked files
- Static Count
- Protected i, File$, Path$, URL$
- If *URL = #Null : ProcedureReturn #Null : EndIf
- URL$ = PeekS(*URL, -1, RS_SCAL\StrFormat)
- If StrStrI_(@URL$, @"://") = #Null : ProcedureReturn #Null : EndIf
- If *File = #Null
- scal_Temp(#SCAL_TempPath$)
- File$ = RS_SCAL\Temp$ + GetFilePart(URL$)
- Else
- File$ = PeekS(*File, -1, RS_SCAL\StrFormat)
- EndIf
- ; *** already downloaded?
- Count = scal_Size(File$)
- If scal_Size(URL$) = Count
- ProcedureReturn Count
- EndIf
- NetWorkSkip(Skip)
- i = NetWorkDownload(URL$, File$)
- ; *** Unzip archive?
- If Flags And i > #Null
- Count = ZIP_GetFilesCount(File$)
- If Count
- Path$ = GetPathPart(File$)
- For i = 1 To Count
- If ZIP_ExtractFile(File$, i, Path$)
- If RS_SCAL\CallBack ; user proc?
- If CallFunctionFast(RS_SCAL\CallBack, (100.0 / Count) * (i + 1))
- Count = i
- Break
- EndIf
- EndIf
- Else
- Count = i
- Break
- EndIf
- Next
- Else
- Count = i ; bytesize if not packed
- EndIf
- Else
- Count = i ; bytesize
- EndIf
- If RS_SCAL\CallBack : CallFunctionFast(RS_SCAL\CallBack, 100) : EndIf ; user proc?
- ProcedureReturn Count
- EndProcedure
- ProcedureDLL SCAL_DownMemory(*URL, *Length.Integer)
- Static *Memory
- If *Memory > #Null
- FreeMemory(*Memory)
- *Memory = #Null
- EndIf
- If *URL <= #Null Or *Length <= #Null : ProcedureReturn #Null : EndIf
- *Memory = NetWorkLoad(PeekS(*URL, -1, RS_SCAL\StrFormat))
- If *Memory
- *Length\i = RS_NetWork\Length
- Else
- *Length\i = #Null
- EndIf
- ProcedureReturn *Memory
- EndProcedure
- ProcedureDLL SCAL_Formats(Mode, Flags)
- ; Mode: #C2D_MUSIC_[MODE] = Get info of supported formats by Mode
- ; < min or > max = Get info of all supported formats by SCAL
- ; Flags: 0 = Get number of supported formats
- ; 1 = Get ptr to unicode formatstrings "AHX;MOD;MP3..."
- Static Count
- Static TotalMode$, TotalCount
- Protected t$, *Memory.Character
- Select Mode
- Case #SCAL_MIN To #SCAL_MAX
- ;{ Mode = #C2D_MUSIC_[MODE] - Calculate supported formats by Engine }
- Select Mode
- Case #C2D_MUSIC_AHX : *Memory = ?l_AHX
- CompilerIf #IsAMP
- Case #C2D_MUSIC_AMP : *Memory = ?l_AMP
- CompilerEndIf
- Case #C2D_MUSIC_API : *Memory = ?l_WAV
- CompilerIf #IsBAS
- Case #C2D_MUSIC_BAS : *Memory = ?l_BAS
- CompilerEndIf
- CompilerIf #IsBMF
- Case #C2D_MUSIC_BMF : *Memory = ?l_BMF
- CompilerEndIf
- Case #C2D_MUSIC_FC4 : *Memory = ?l_FC4
- CompilerIf #IsFCP
- Case #C2D_MUSIC_FCP : *Memory = ?l_FCP
- CompilerEndIf
- Case #C2D_MUSIC_FLA : *Memory = ?l_FLA
- Case #C2D_MUSIC_FT2 : *Memory = ?l_FT2
- Case #C2D_MUSIC_MCI : *Memory = ?l_MCI
- CompilerIf #IsMED
- Case #C2D_MUSIC_MED : *Memory = ?l_MED
- CompilerEndIf
- Case #C2D_MUSIC_MOD : *Memory = ?l_MOD
- CompilerIf #IsMOV
- Case #C2D_MUSIC_MOV : *Memory = ?l_MCI
- CompilerEndIf
- Case #C2D_MUSIC_OGG : *Memory = ?l_OGG
- Case #C2D_MUSIC_PT2 : *Memory = ?l_PT2
- CompilerIf #IsS68
- Case #C2D_MUSIC_S68 : *Memory = ?l_SC68
- CompilerEndIf
- CompilerIf #IsSID
- Case #C2D_MUSIC_SID : *Memory = ?l_SID
- CompilerEndIf
- Case #C2D_MUSIC_STM : *Memory = ?l_STM
- Case #C2D_MUSIC_S3M : *Memory = ?l_S3M
- Case #C2D_MUSIC_TFC : *Memory = ?l_FC4
- Case #C2D_MUSIC_THX : *Memory = ?l_AHX
- Case #C2D_MUSIC_TPT : *Memory = ?l_PT2
- CompilerIf #IsTSR
- Case #C2D_MUSIC_TSR : *Memory = ?l_SID
- CompilerEndIf
- CompilerIf #IsV1M
- Case #C2D_MUSIC_V1M : *Memory = ?l_V2M
- CompilerEndIf
- CompilerIf #IsV2M
- Case #C2D_MUSIC_V2M : *Memory = ?l_V2M
- CompilerEndIf
- Case #C2D_MUSIC_WAV : *Memory = ?l_WAV
- CompilerIf #IsXM2
- Case #C2D_MUSIC_XM2 : *Memory = ?l_XM2
- CompilerEndIf
- CompilerIf #IsYMP
- Case #C2D_MUSIC_YMP : *Memory = ?l_YMP
- CompilerEndIf
- EndSelect
- If Flags And *Memory
- ProcedureReturn *Memory ; ptr to ;MOD;...
- EndIf
- If *Memory ; count extensions?
- Count = -2 ; first ";" + last ";" + #null
- While *Memory > SizeOf(Character)
- *Memory = StrStrI_(*Memory, @";") + SizeOf(Character)
- Count + 1
- Wend
- Else
- Count = #Null
- EndIf
- ProcedureReturn Count
- ;}
- Default ; -1
- ;{ Mode <= #Null - Calculate ALL supported formats once }
- If TotalCount
- If Flags ; String?
- ProcedureReturn @TotalMode$
- EndIf
- ProcedureReturn TotalCount
- EndIf
- Protected NewMap ExtMap.s()
- Protected NewList ExtList.s()
- *Memory = ?l_Start
- While *Memory < ?l_Finish
- If *Memory\c
- t$ = PeekS(*Memory)
- TotalMode$ + Trim(t$, ";") + ";" : *Memory + Len(t$) * SizeOf(Character)
- EndIf
- *Memory + SizeOf(Character) ; Null$
- Wend
- Repeat
- TotalCount + 1 : t$ = StringField(TotalMode$, TotalCount, ";") : ExtMap(t$)
- Until Len(t$) = #Null
- ForEach ExtMap()
- If MapKey(ExtMap())
- AddElement(ExtList()) : ExtList() = MapKey(ExtMap())
- EndIf
- Next
- SortList(ExtList(), #PB_Sort_Ascending)
- TotalCount = ListSize(ExtList())
- TotalMode$ = ";" ; ";Format;"
- ForEach ExtList()
- TotalMode$ + ExtList() + ";"
- Next
- FreeMap(ExtMap())
- FreeList(ExtList())
- If Flags
- ProcedureReturn @TotalMode$
- EndIf
- ProcedureReturn TotalCount
- ;}
- EndSelect
- EndProcedure
- ProcedureDLL SCAL_Free()
- Protected StrFormat, Freq, *Proc
- Static Volume=-1
- With RS_SCAL
- If \ID ; Is playing active?
- Select \Mode
- Case #C2D_MUSIC_AHX : ahx1play_Close()
- Case #C2D_MUSIC_API : PlaySound_(#Null, #Null, #Null)
- Case #C2D_MUSIC_FC4 : fc14play_Close()
- Case #C2D_MUSIC_FLA : If IsSound(0) : FreeSound(0) : EndIf
- Case #C2D_MUSIC_FT2 : ft2play_Close()
- Case #C2D_MUSIC_MCI : mciSendString_(@"STOP 0", 0, 0, 0) : mciSendString_(@"CLOSE 0", 0, 0, 0)
- Case #C2D_MUSIC_MOD : If IsMusic(0) : FreeMusic(0) : EndIf
- Case #C2D_MUSIC_OGG : If IsSound(0) : FreeSound(0) : EndIf
- Case #C2D_MUSIC_PT2 : pt2play_Close()
- Case #C2D_MUSIC_S3M : st3play_Close()
- Case #C2D_MUSIC_STM : st23play_Close()
- Case #C2D_MUSIC_TFC : tinyfc14play_Close()
- Case #C2D_MUSIC_THX : tinyahx1play_Close()
- Case #C2D_MUSIC_TPT : tinypt2play_Close()
- Case #C2D_MUSIC_WAV : If IsSound(0) : FreeSound(0) : EndIf
- CompilerIf #IsAMP
- Case #C2D_MUSIC_AMP : AmpMusicFree()
- CompilerEndIf
- CompilerIf #IsBAS
- Case #C2D_MUSIC_BAS
- BASSMOD_MusicStop()
- BASSMOD_MusicFree()
- BASSMOD_SetVolume(100) ; restore digital volume!
- BASSMOD_Free()
- CompilerEndIf
- CompilerIf #IsBMF
- Case #C2D_MUSIC_BMF
- SynthEnter(\ID)
- SynthStop(\ID)
- SynthLeave(\ID)
- SynthDestroy(\ID)
- CompilerEndIf
- CompilerIf #IsFCP
- Case #C2D_MUSIC_FCP : FCp_Close()
- CompilerEndIf
- CompilerIf #IsMED
- Case #C2D_MUSIC_MED
- MEDP_Stop()
- MEDP_Unload()
- MEDP_Release()
- CompilerEndIf
- CompilerIf #IsMOV
- Case #C2D_MUSIC_MOV
- If IsMovie(0) : FreeMovie(0) : EndIf
- If \WinID And IsWindow(\WinID)
- CloseWindow(\WinID)
- EndIf
- \WinID = #Null
- CompilerEndIf
- CompilerIf #IsS68
- Case #C2D_MUSIC_S68 : sc68_Free() ;sc68replay_Stop()
- CompilerEndIf
- CompilerIf #IsSID
- Case #C2D_MUSIC_SID : SIDClose()
- CompilerEndIf
- CompilerIf #IsTSR
- Case #C2D_MUSIC_TSR : sid_sound_server_replay_stop()
- CompilerEndIf
- CompilerIf #IsV1M
- Case #C2D_MUSIC_V1M
- ssStop()
- ssClose()
- CompilerEndIf
- CompilerIf #IsV2M
- Case #C2D_MUSIC_V2M
- If \IsPause = 0 ; remember: custom pause!
- V2MStop()
- dsClose()
- EndIf
- CompilerEndIf
- CompilerIf #IsXM2
- Case #C2D_MUSIC_XM2 : uFMOD_PlaySong(#Null)
- CompilerEndIf
- CompilerIf #IsYMP
- Case #C2D_MUSIC_YMP
- YM_Stop()
- YM_Close()
- CompilerEndIf
- EndSelect
- EndIf
- ; Netfile downloaded?
- NetWorkFree()
- ; Intern temporary *buffer?
- If \IsAlloc And \Memory
- FreeMemory(\Memory)
- EndIf
- ; AscII or Unicode?
- If \StrFormat <= #Null
- \StrFormat = #PB_Unicode ; Default PeekS-Mode if *Memory = @File
- EndIf
- ; Set default frequency
- If \Freq <= #Null
- \Freq = 44100
- EndIf
- ; Set default volume (used in SCAL_Play)
- If Volume < #Null And \Volume <= #Null
- \Volume = 100
- EndIf
- StrFormat = \StrFormat
- Freq = \Freq
- Volume = \Volume
- *Proc = \CallBack
- ClearStructure(@RS_SCAL, RS_SCAL)
- \Freq = Freq
- \StrFormat = StrFormat
- \Volume = Volume ; -1
- \CallBack = *Proc
- \NetLength = #Null
- ; Generate *pointers (avoid *ptr=0 error)
- \File$ = #Null$
- \Path$ = #Null$
- \Time$ = #Null$
- \Title$ = #Null$
- \Tracker$ = #Null$
- EndWith
- EndProcedure
- ProcedureDLL SCAL_GetLength(Flags)
- ; Flags: 0 = Get timelength in ms
- ; 1 = Get ptr to unicode timestring "hh:mm:ss.ttt"
- ; RETURN: Time in ms or ptr to timestring - #NULL not playing or time not calcuable
- With RS_SCAL
- If Flags
- If \Time
- \Time$ = StrTime(\Time)
- \Time$ = RTrim(\Time$, "0")
- \Time$ = RTrim(\Time$, ",")
- Else
- \Time$ = PeekS(?s_unknown) ; "?"
- EndIf
- ProcedureReturn @\Time$
- EndIf
- ProcedureReturn \Time
- EndWith
- EndProcedure
- ProcedureDLL SCAL_GetMode(Flags)
- ; Flags: 0 = Get #ID of playengine
- ; 1 = Get *ptr to string char[3] of playengine
- Static t$
- With RS_SCAL
- If \ID = #Null ; do not check with <= 0
- If Flags
- ProcedureReturn ?s_unknown
- EndIf
- ProcedureReturn #Null
- EndIf
- If Flags
- t$ = PeekS(PeekI(?mode + \Mode * SizeOf(Integer)))
- t$ = StringField(t$, 1, "|")
- ProcedureReturn @t$
- ;ProcedureReturn (?s_Mode + (\Mode - 1) * 4 * SizeOf(Character)) ; 4 = AHX + 0
- EndIf
- ProcedureReturn \Mode
- EndWith
- EndProcedure
- ProcedureDLL SCAL_GetPosition(Flags)
- ; Flags: 0 = Get current playposition in ms
- ; 1 = Get ptr to timestring (hh:mm:ss.ttt) of current playposition
- ; RETURN: Playtime in ms or *ptr to timestring
- ; - remarked engines calculate a timeline not the real pos of mixerticks!
- ; - call GetPosition() also to loop song on end
- Static Time, t${#MAX_PATH}
- With RS_SCAL
- If \ID = #Null ; do not check with <= 0
- If Flags
- ProcedureReturn ?s_unknown
- EndIf
- ProcedureReturn #Null
- EndIf
- Select \Mode
- ;Case #C2D_MUSIC_AHX : Time = ahx1play_GetMixerTicks()
- ;Case #C2D_MUSIC_FC4 : Time = fc14play_GetMixerTicks()
- ;Case #C2D_MUSIC_FT2 : Time = ft2play_GetMixerTicks()
- ;Case #C2D_MUSIC_PT2 : Time = pt2play_GetMixerTicks()
- ;Case #C2D_MUSIC_STM : Time = st23play_GetMixerTicks()
- ;Case #C2D_MUSIC_S3M : Time = st3play_GetMixerTicks()
- Case #C2D_MUSIC_OGG, #C2D_MUSIC_FLA, #C2D_MUSIC_WAV
- Time = GetSoundPosition(0, #PB_Sound_Millisecond)
- Case #C2D_MUSIC_MCI
- mciSendString_(@"STATUS 0 POSITION", @t$, #MAX_PATH, 0)
- StrToInt64Ex_(@t$, #Null, @Time)
- CompilerIf #IsV2M
- Case #C2D_MUSIC_V2M
- Time = V2MGetCurrentTime()
- CompilerEndIf
- CompilerIf #IsXM2
- Case #C2D_MUSIC_XM2
- Time = uFMOD_GetTime()
- CompilerEndIf
- CompilerIf #IsAMP
- Case #C2D_MUSIC_AMP
- Time = AmpMusicPosition()
- If Time >= RS_Amp\TimeLength
- RS_Amp\TimeLoop = #Null
- AmpMusicLoop() ; reload file
- AmpMusicVolume(2.55 * RS_SCAL\Volume)
- EndIf
- CompilerEndIf
- Default
- Time = ElapsedMilliseconds() - \TimePlay
- ; reset time-position & loop media?
- If \Time And Time >= \Time
- Select \Mode
- Case #C2D_MUSIC_YMP
- CompilerIf #IsYMP
- ; time is -200 ms coz no loop on (real) end
- ; some songs work, some not...
- YM_Seek(0)
- CompilerEndIf
- Case #C2D_MUSIC_MOV
- CompilerIf #IsMOV
- MovieSeek(0, 0)
- CompilerEndIf
- EndSelect
- Time = #Null
- \TimePlay = ElapsedMilliseconds()
- EndIf
- EndSelect
- If Time < #Null : Time = #Null : EndIf
- If Flags ; TimeString?
- \Time$ = StrTime(Time)
- ProcedureReturn @\Time$
- EndIf
- ProcedureReturn Time
- EndWith
- EndProcedure
- ProcedureDLL SCAL_GetSize(Flags)
- ; Flags: 0 = Integer, 1 = *StrSize
- With RS_SCAL
- If \Length <= #Null
- \Length = FileSize(\File$)
- EndIf
- If \Length < #Null
- \Length = #Null
- EndIf
- If Flags
- ProcedureReturn StrSize(\Length)
- EndIf
- ProcedureReturn \Length
- EndWith
- EndProcedure
- ProcedureDLL SCAL_GetSubsongs()
- With RS_SCAL
- ProcedureReturn \Songs
- EndWith
- EndProcedure
- ProcedureDLL SCAL_GetTitle()
- With RS_SCAL
- ProcedureReturn @\Title$
- EndWith
- EndProcedure
- ProcedureDLL SCAL_GetTracker()
- With RS_SCAL
- ProcedureReturn @\Tracker$
- EndWith
- EndProcedure
- ProcedureDLL SCAL_Info(Flags)
- Protected t$, Title$="SCAL DLL v" + StrF(#SCAL_VERSION * 0.01, 2)
- CompilerIf #IsX86
- Title$ + " (x86)"
- CompilerElse
- Title$ + " (x64)"
- CompilerEndIf
- With RS_SCAL
- ; Sound playing?
- If \ID <= #Null : ProcedureReturn #Null : EndIf
- If \Length <= #Null
- \Length = SCAL_GetSize(0)
- EndIf
- If \File$
- \File$ = ReplaceString(\File$, "%20", " ")
- t$ + "File:" + #TAB$ + GetFilePart(\File$) + #LF$
- t$ + "Path:" + #TAB$ + GetPathPart(\File$) + #LF$
- EndIf
- If \Length : t$ + "Size:" + #TAB$ + PeekS(SCAL_GetSize(1)) + #LF$ : EndIf
- If t$ : t$ + #LF$ : EndIf ; kosmetische Freizeile
- If \Title$ : t$ + "Title:" + #TAB$ + \Title$ + #LF$ : EndIf ; PeekS(SCAL_GetTitle())
- If \Time > #Null : t$ + "Time:" + #TAB$ + PeekS(SCAL_GetLength(1)) + #LF$ : EndIf
- If \Songs > 1
- t$ + "Song:" + #TAB$ + Str(\SubSong + \ZipSong) + "/" + Str(\Songs) + #LF$ ; Str(SCAL_GetSubsongs())
- EndIf
- t$ + #LF$ ; kosmetische Freizeile
- If \Tracker$ : t$ + "Type:" + #TAB$ + \Tracker$ + #LF$ : EndIf ; PeekS(SCAL_GetTracker())
- t$ + #LF$ + "Mode:" + #TAB$ + "#C2D_MUSIC_" + PeekS(SCAL_GetMode(1)) + #LF$
- ProcedureReturn MessageBox_(GetForegroundWindow_(), @t$, @Title$, Flags)
- EndWith
- EndProcedure
- ProcedureDLL SCAL_IsFormat(Mode, *Memory.Long, Length)
- ; Tiny check file.extension ?.* and *.? or *Memoryblock
- ; *Memory = Pointer to @File or *Memory
- ; Length = Size of *Memory or 0 if *Memory = @File
- ; Return: Mode or #NULL if not supported
- Static Typ
- Typ = #Null
- If Length <= #Null
- ;{ *File? }
- Protected *x, i
- For i = 0 To 1
- *x = scal_Sufx(*Memory, i) : If *x = #Null : Continue : EndIf
- Select Mode
- Case #C2D_MUSIC_AHX, #C2D_MUSIC_THX : Typ = StrStrI_(?l_AHX, *x)
- Case #C2D_MUSIC_FC4, #C2D_MUSIC_TFC : Typ = StrStrI_(?l_FC4, *x)
- Case #C2D_MUSIC_PT2, #C2D_MUSIC_TPT : Typ = StrStrI_(?l_PT2, *x)
- Case #C2D_MUSIC_API, #C2D_MUSIC_WAV : Typ = StrStrI_(?l_WAV, *x)
- Case #C2D_MUSIC_MCI, #C2D_MUSIC_MOV : Typ = StrStrI_(?l_MCI, *x)
- Case #C2D_MUSIC_FT2 : Typ = StrStrI_(?l_FT2, *x)
- Case #C2D_MUSIC_S3M : Typ = StrStrI_(?l_S3M, *x)
- Case #C2D_MUSIC_STM : Typ = StrStrI_(?l_STM, *x)
- Case #C2D_MUSIC_FLA : Typ = StrStrI_(?l_FLA, *x)
- Case #C2D_MUSIC_OGG : Typ = StrStrI_(?l_OGG, *x)
- Case #C2D_MUSIC_MOD : Typ = StrStrI_(?l_MOD, *x)
- CompilerIf #IsAMP
- Case #C2D_MUSIC_AMP
- Typ = StrStrI_(?l_AMP, *x)
- CompilerEndIf
- CompilerIf #IsBAS
- Case #C2D_MUSIC_BAS
- Typ = StrStrI_(?l_BAS, *x)
- CompilerEndIf
- CompilerIf #IsBMF
- Case #C2D_MUSIC_BMF
- Typ = StrStrI_(?l_BMF, *x)
- CompilerEndIf
- CompilerIf #IsMED
- Case #C2D_MUSIC_MED
- Typ = StrStrI_(?l_MED, *x)
- CompilerEndIf
- CompilerIf #IsFCP
- Case #C2D_MUSIC_FCP
- Typ = StrStrI_(?l_FCP, *x)
- CompilerEndIf
- CompilerIf #IsS68
- Case #C2D_MUSIC_S68
- Typ = StrStrI_(?l_SC68, *x)
- CompilerEndIf
- CompilerIf (#IsSID + #IsTSR)
- Case #C2D_MUSIC_SID, #C2D_MUSIC_TSR
- Typ = StrStrI_(?l_SID, *x)
- CompilerEndIf
- CompilerIf (#IsV1M + #IsV2M)
- Case #C2D_MUSIC_V1M, #C2D_MUSIC_V2M
- Typ = StrStrI_(?l_V2M, *x)
- CompilerEndIf
- CompilerIf #IsXM2
- Case #C2D_MUSIC_XM2
- Typ = StrStrI_(?l_XM2, *x)
- CompilerEndIf
- CompilerIf #IsYMP
- Case #C2D_MUSIC_YMP
- Typ = StrStrI_(?l_YMP, *x)
- CompilerEndIf
- Default ; < Min or > Max -> search through all extensions (SCAL Mode)
- Typ = StrStrI_(SCAL_Formats(#Null, 1), *x) ; fastest check on 2. call!
- EndSelect
- If Typ > 0 : Break : EndIf
- Next
- ;}
- Else
- ;{ *Memory? }
- Protected *ID_MOD.Long = *Memory + $438
- Protected *ID_STM.Long = *Memory + $14
- Protected *ID_S3M.Long = *Memory + $2C
- Protected *ID_WAV.Long = *Memory + $8
- CompilerIf #IsYMP
- Protected *ID_YMP.Long = *Memory + $2
- CompilerEndIf
- Select Mode
- Case #C2D_MUSIC_PT2, #C2D_MUSIC_TPT
- Typ = Bool(*ID_MOD\l = #ID_M_K_ Or
- *ID_MOD\l = #ID_MIKI Or
- *ID_MOD\l = #ID_MAKI Or
- *ID_MOD\l = #ID_N_T_)
- Case #C2D_MUSIC_FT2
- Typ = Bool(*Memory\l = #ID_XM) +
- Bool(*ID_MOD\l = #ID_6CHN Or
- *ID_MOD\l = #ID_8CHN Or
- *ID_MOD\l = #ID_FLT4 Or
- *ID_MOD\l = #ID_FLT8 Or
- *ID_MOD\l = #ID_M_K_ Or
- *ID_MOD\l = #ID_MIKI Or
- *ID_MOD\l = #ID_MAKI Or
- *ID_MOD\l = #ID_N_T_)
- Case #C2D_MUSIC_AHX, #C2D_MUSIC_THX
- Typ = Bool(*Memory\l = #ID_AHX Or
- *Memory\l = #ID_THX)
- Case #C2D_MUSIC_FC4, #C2D_MUSIC_TFC
- Typ = Bool(*Memory\l = #ID_SMOD Or
- *Memory\l = #ID_FC14)
- Case #C2D_MUSIC_S3M
- Typ = Bool(*ID_S3M\l = #ID_S3M)
- Case #C2D_MUSIC_STM
- Typ = Bool(*ID_STM\l = #ID_STM)
- Case #C2D_MUSIC_OGG
- Typ = Bool(*Memory\l = #ID_OGG)
- Case #C2D_MUSIC_FLA
- Typ = Bool(*Memory\l = #ID_FLAC)
- Case #C2D_MUSIC_API, #C2D_MUSIC_WAV
- Typ = Bool(*Memory\l = #ID_RIFF And
- *ID_WAV\l = #ID_WAVE)
- Case #C2D_MUSIC_MOD
- Typ = Bool(*ID_MOD\l = #ID_M_K_ Or
- *ID_MOD\l = #ID_MIKI Or
- *ID_MOD\l = #ID_MAKI Or
- *ID_MOD\l = #ID_N_T_ Or
- *ID_MOD\l = #ID_6CHN Or
- *ID_MOD\l = #ID_8CHN Or
- *ID_MOD\l = #ID_FLT4 Or
- *ID_MOD\l = #ID_FLT8) +
- Bool(*ID_S3M\l = #ID_S3M) +
- Bool(*ID_STM\l = #ID_STM) +
- Bool(*Memory\l = #ID_XM Or
- *Memory\l = #ID_IT Or
- *Memory\l = #ID_UMX Or
- *Memory\l = #ID_MTM Or
- *Memory\l = #ID_MT20 Or
- *Memory\l = #ID_MMD0 Or
- *Memory\l = #ID_MMD1 Or
- *Memory\l = #ID_MMD2 Or
- *Memory\l = #ID_MMD3 Or
- *Memory\l = #ID_OKTA) +
- Bool(*Memory\l = #ID_RIFF And
- *ID_WAV\l = #ID_WAVE)
- CompilerIf #IsBAS
- Case #C2D_MUSIC_BAS
- Typ = Bool(*Memory\l = #ID_IT Or
- *Memory\l = #ID_UMX Or
- *Memory\l = #ID_MTM) +
- Bool(*Memory\l = #ID_XM Or
- *ID_MOD\l = #ID_6CHN Or
- *ID_MOD\l = #ID_8CHN Or
- *ID_MOD\l = #ID_FLT4 Or
- *ID_MOD\l = #ID_FLT8) +
- Bool(*ID_MOD\l = #ID_M_K_ Or
- *ID_MOD\l = #ID_MIKI Or
- *ID_MOD\l = #ID_MAKI Or
- *ID_MOD\l = #ID_N_T_) +
- Bool(*ID_S3M\l = #ID_S3M)
- CompilerEndIf
- CompilerIf #IsBMF
- Case #C2D_MUSIC_BMF
- Typ = Bool(*Memory\l = #ID_BMF4)
- CompilerEndIf
- CompilerIf #IsFCP
- Case #C2D_MUSIC_FCP
- Typ = Bool(*Memory\l = #ID_FC14)
- CompilerEndIf
- CompilerIf #IsS68
- Case #C2D_MUSIC_S68
- Typ = Bool(*Memory\l = #ID_SC68)
- CompilerEndIf
- CompilerIf (#IsSID + #IsTSR)
- Case #C2D_MUSIC_SID, #C2D_MUSIC_TSR
- Typ = Bool(*Memory\l = #ID_SID)
- CompilerEndIf
- CompilerIf (#IsV2M + #IsV1M)
- Case #C2D_MUSIC_V1M, #C2D_MUSIC_V2M
- Typ = Bool(*Memory\l = #ID_V2M Or
- *Memory\l = #ID_V2M6 Or
- *Memory\l = #ID_V2ME)
- ; Loosy but important v1.5 sanity check or... crash
- If Mode = #C2D_MUSIC_V2M And PeekL(*Memory + Length - SizeOf(Long)) <> #Null
- Typ = #Null
- EndIf
- CompilerEndIf
- CompilerIf #IsXM2
- Case #C2D_MUSIC_XM2 : Typ = Bool(*Memory\l = #ID_XM)
- CompilerEndIf
- CompilerIf #IsYMP
- Case #C2D_MUSIC_YMP
- Typ = Bool(*ID_YMP\l = #ID_LH5 Or
- *Memory\l = #ID_YM6I)
- CompilerEndIf
- EndSelect
- ;}
- EndIf
- ProcedureReturn Bool(Typ > #Null)
- EndProcedure
- ProcedureDLL SCAL_Pause(Flags)
- ; Flags: 1 = Pause, 0 = Resume
- ; Return: 1 = paused, 0 = unpaused or no pause possible by engine
- Static Time
- With RS_SCAL
- If \ID = #Null : ProcedureReturn #Null : EndIf
- Flags = Bool(Flags<>0)
- If \IsPause = Flags : ProcedureReturn \IsPause : EndIf
- \IsPause = Flags
- Select \Mode
- Case #C2D_MUSIC_AHX
- ahx1play_PauseSong(\IsPause)
- CompilerIf #IsAMP
- Case #C2D_MUSIC_AMP
- AmpMusicPause(\IsPause)
- CompilerEndIf
- CompilerIf #IsBAS
- Case #C2D_MUSIC_BAS
- If \IsPause
- BASSMOD_MusicPause()
- Else
- BASSMOD_MusicPlay()
- EndIf
- CompilerEndIf
- CompilerIf #IsBMF
- Case #C2D_MUSIC_BMF
- If \IsPause
- SynthStop(\ID)
- Else
- SynthPlay(\ID)
- EndIf
- CompilerEndIf
- Case #C2D_MUSIC_FC4
- fc14play_PauseSong(\IsPause)
- Case #C2D_MUSIC_FLA, #C2D_MUSIC_OGG, #C2D_MUSIC_WAV
- If IsSound(0)
- If \IsPause
- PauseSound(0)
- Else
- ResumeSound(0)
- EndIf
- EndIf
- Case #C2D_MUSIC_FT2
- ft2play_PauseSong(\IsPause)
- Case #C2D_MUSIC_MCI
- If \IsPause
- mciSendString_(@"PAUSE 0", 0, 0, 0)
- Else
- mciSendString_(@"RESUME 0", 0, 0, 0)
- EndIf
- CompilerIf #IsMED
- Case #C2D_MUSIC_MED
- If \IsPause
- MEDP_Stop()
- Else
- MEDP_Play()
- EndIf
- CompilerEndIf
- Case #C2D_MUSIC_MOD
- If \IsPause
- StopMusic(0)
- Else
- PlayMusic(0)
- EndIf
- CompilerIf #IsMOV
- Case #C2D_MUSIC_MOV
- If \IsPause
- PauseMovie(0)
- Else
- ResumeMovie(0)
- EndIf
- CompilerEndIf
- Case #C2D_MUSIC_PT2
- pt2play_PauseSong(\IsPause)
- Case #C2D_MUSIC_S3M
- st3play_PauseSong(\IsPause)
- CompilerIf #IsSID
- Case #C2D_MUSIC_SID
- If \IsPause
- SIDPause()
- Else
- SIDResume()
- EndIf
- CompilerEndIf
- Case #C2D_MUSIC_STM
- st23play_PauseSong(\IsPause)
- CompilerIf #IsV2M ; Custom Pause
- Case #C2D_MUSIC_V2M
- If \IsPause
- Time = V2MGetCurrentTime()
- V2MStop()
- dsClose()
- Else
- V2MInit(\Memory, \Freq, GetForegroundWindow_())
- V2MSetRepeat(1)
- dsSetVolume(0.01 * \Volume)
- V2MPlay(Time)
- EndIf
- CompilerEndIf
- CompilerIf #IsXM2
- Case #C2D_MUSIC_XM2
- If \IsPause
- uFMOD_Pause()
- Else
- uFMOD_Resume()
- EndIf
- CompilerEndIf
- CompilerIf #IsYMP
- Case #C2D_MUSIC_YMP
- If \IsPause
- YM_Pause()
- Else
- YM_Play()
- EndIf
- CompilerEndIf
- Default
- ; #C2D_MUSIC_API, #C2D_MUSIC_FCP, #C2D_MUSIC_S68
- ; #C2D_MUSIC_SCA, #C2D_MUSIC_TFC, #C2D_MUSIC_THX
- ; #C2D_MUSIC_TPT, #C2D_MUSIC_TSR, #C2D_MUSIC_V1M
- \IsPause = #Null
- ProcedureReturn #Null
- EndSelect
- ; Timecorrection, coz some mixerticks do a simple timeline
- Select \Mode
- Case #C2D_MUSIC_AHX,
- #C2D_MUSIC_BAS,
- #C2D_MUSIC_BMF,
- #C2D_MUSIC_FC4,
- #C2D_MUSIC_FT2,
- #C2D_MUSIC_PT2,
- #C2D_MUSIC_MED,
- #C2D_MUSIC_MOD,
- #C2D_MUSIC_MOV,
- #C2D_MUSIC_S3M,
- #C2D_MUSIC_SID,
- #C2D_MUSIC_STM,
- #C2D_MUSIC_YMP
- If \IsPause
- Time = ElapsedMilliseconds()
- Else
- \TimePlay + ElapsedMilliseconds() - Time
- EndIf
- EndSelect
- ProcedureReturn \IsPause
- EndWith
- EndProcedure
- ProcedureDLL SCAL_Play(Mode, *Memory, Length, SubSong)
- ; Mode = -1 (autoset) or #C2D_MUSIC_[Mode]
- ; *Memory = Ptr to data or @Filename$
- ; Length = Size(End) of data or #Null (*Memory = @Filename$)
- ; SubSong = #Subsong to play (#AMP, #SID, #TSR)
- ; Return: #True = Music is playing or #False = Error!
- Protected IsOK, IsAmp, i, t$, Path$, *x, MDAT$, SMPL$
- Static File$ ; *Memory = temporary @File$
- SCAL_Free() ; always stop if playing
- With RS_SCAL
- ; Check for not-supported engines (*)do NOT check with [SCA] here!
- If Mode = #C2D_MUSIC_V1M Or Mode = #C2D_MUSIC_S68
- ProcedureReturn #Null
- EndIf
- ; Check if *Memory is a ptr to a @Filename
- If Length <= #Null
- \File$ = PeekS(*Memory, -1, \StrFormat)
- EndIf
- ; ==========================================================================
- ;{ Network file? ("http://...") *** also download all needed sfx-libs ***
- If Length <= 0 And StrStrI_(@\File$, @"://")
- If scal_Down(\File$)
- *Memory = @\File$
- Length = #Null
- Else
- SCAL_Free() : ProcedureReturn #Null
- EndIf
- EndIf
- ;}
- ; ==========================================================================
- ; ==========================================================================
- ;{ Check for zipped @File (Extension)
- If Length <= #Null
- *x = scal_Sufx(@\File$, 0) ; ";ZIP;" etc.
- If *x And StrStrI_(?l_ZIP, *x)
- scal_Temp(#SCAL_TempPath$)
- \ZipCount = ZIP_GetFilesCount(\File$)
- If \ZipCount <= 2 ; Single zipped or TFMX (MDAT+SMPL)?
- i = 1 ; First file in archive
- Else
- \IsZip = 1 ; Playing subsongs from zip-archive (flag)
- ;\Songs = \ZipCount;
- \ZipSong = SubSong ; SongNumber of archive-file (for Info)
- i = SubSong ; SongNumber of archive-file to unpack
- SubSong = #Null ; No individual subsong when zipped archive
- If i <= #Null : i = 1 : EndIf
- EndIf
- t$ = GetFilePart(ZIP_GetFileInfo(\File$, i))
- If Len(t$) = #Null : SCAL_Free() : ProcedureReturn #Null : EndIf
- CompilerIf #IsAMP
- ; UnZIP always TFMX (almost same names for different songs/sample-banks (MDAT.ingame1...)
- *x = PathFindExtension_(@t$)
- If StrStrI_(@t$, @"MDAT.") Or StrStrI_(@t$, @"SMPL.") Or ; TFMX
- StrStrI_(*x, @".TFX") Or StrStrI_(*x, @".SAM") Or ; TFMX Custom
- StrStrI_(*x, @".KDM") ; Ken's Digital Music (waves.kwv sfx-bank)
- IsAMP = #True
- If ZIP_ExtractFile(\File$, i, \Temp$) = #False ; Error?
- SCAL_Free() : ProcedureReturn #Null
- EndIf
- If StrStrI_(@t$, @"MDAT.") = @t$ : PokeS(@t$, "SMPL", -1, #PB_String_NoZero)
- ElseIf StrStrI_(@t$, @"SMPL.") = @t$ : PokeS(@t$, "MDAT", -1, #PB_String_NoZero)
- ElseIf StrStrI_(*x, @".SAM") : PathRenameExtension_(@t$, @".TFX") ; need the song.tfx
- ElseIf StrStrI_(*x, @".TFX") : PathRenameExtension_(@t$, @".SAM") ; need the sfx-file.sam
- ElseIf StrStrI_(*x, @".KDM") : File$ = t$ : t$ = "waves.kwv" ; need kwv sfx-bank
- EndIf
- i = ZIP_GetFileNumber(\File$, t$)
- If i <= #Null Or ZIP_ExtractFile(\File$, i, \Temp$) = #False ; Error?
- SCAL_Free() : ProcedureReturn #Null
- EndIf
- ; Restore songname!
- If StrStrI_(@t$, @"SMPL.") = @t$ : PokeS(@t$, "MDAT", -1, #PB_String_NoZero)
- ElseIf StrStrI_(PathFindExtension_(@t$), @".SAM") : PathRenameExtension_(@t$, @".TFX")
- ElseIf StrStrI_(PathFindExtension_(@t$), @".KWV") : t$ = File$
- EndIf
- EndIf
- CompilerEndIf
- ; No AMP & Do not UnZip if already unzipped
- If IsAMP = #Null And FileSize(\Temp$ + t$) <= #Null
- If ZIP_ExtractFile(\File$, i, \Temp$) = #False ; Error?
- SCAL_Free() : ProcedureReturn #Null
- EndIf
- EndIf
- ; Update to temporary unzipped filename
- \File$ = \Temp$ + t$
- \Title$ = t$
- *Memory = @\File$
- EndIf
- EndIf
- ;}
- ; ==========================================================================
- ; ==========================================================================
- ;{ Check mode-flag (when own-call (*) [SCA] - change to default mode
- If Bool(Mode = #C2D_MUSIC_SCA Or Mode < #SCAL_MIN Or Mode > #SCAL_MAX) ; (-1,0) .. Clamp(1 upto 29)
- If Length > #Null
- Mode = Default_Mode(*Memory, Length)
- Else
- Mode = Default_Mode(@\File$, #Null)
- EndIf
- If Mode <= #Null
- SCAL_Free() : ProcedureReturn #Null
- EndIf
- EndIf
- ;}
- ; ==========================================================================
- ; ================================================================================
- ; Play from memory? Check if file-only mode -> reset to its default support-engine
- ; ================================================================================
- If Length > #Null
- Select Mode ; this can't play from memory
- Case #C2D_MUSIC_AMP,
- #C2D_MUSIC_MCI,
- #C2D_MUSIC_MED,
- #C2D_MUSIC_MOV
- Mode = Default_Mode(*Memory, Length)
- EndSelect
- EndIf
- \Mode = Mode
- ; *** @File or *Memory?
- Select \Mode
- Case #C2D_MUSIC_AMP ; *Memory = @File (ascii)
- Case #C2D_MUSIC_API ; *Memory & @File (ascii & utf8)
- Case #C2D_MUSIC_BAS ; *Memory & @File (ascii)
- Case #C2D_MUSIC_FLA ; *Memory & @File (ascii & utf8)
- Case #C2D_MUSIC_MCI ; *Memory = @File (ascii & utf8)
- Case #C2D_MUSIC_MED ; *Memory = @File (ascii)
- Case #C2D_MUSIC_MOD ; *Memory & @File (ascii & utf8)
- Case #C2D_MUSIC_MOV ; *Memory = @File (ascii & utf8)
- Case #C2D_MUSIC_OGG ; *Memory & @File (ascii & utf8)
- Case #C2D_MUSIC_S68 ; *Memory & @File (ascii)
- Case #C2D_MUSIC_WAV ; *Memory & @File (ascii & utf8)
- Case #C2D_MUSIC_XM2 ; *Memory & @File (ascii)
- Case #C2D_MUSIC_YMP ; *Memory & @File (ascii)
- Default ;{ Engines who supports *Memory only? }
- If Length <= #Null
- If ReadFile(0, \File$)
- Length = Lof(0)
- If Length > 0
- \Memory = AllocateMemory(Length)
- \IsAlloc = Bool(\Memory>0) ; flag to free temp *memory
- If \IsAlloc
- Length = ReadData(0, \Memory, Length)
- Else
- Length = #Null
- EndIf
- EndIf
- CloseFile(0)
- EndIf
- If Length <= #Null
- SCAL_Free() : ProcedureReturn #Null
- EndIf
- *Memory = \Memory
- EndIf
- ;}
- EndSelect
- If Length > *Memory : Length - *Memory : EndIf
- ; *** DEFAULTS ***
- \ID = #True ; ok by default
- \Memory = *Memory
- \Length = Length
- \SubSong = SubSong
- ; *** Default name of Tracker- / Decoder ***
- If \Mode >= #SCAL_MIN And Mode <= #SCAL_MAX
- \Tracker$ = StringField(PeekS(PeekI(?mode + \Mode * SizeOf(Integer))), 3, "|")
- EndIf
- ; =========================================================================
- ; Playback the music (na endlich...)
- ; =========================================================================
- Select \Mode
- Case #C2D_MUSIC_AHX ;{ *** Play AHX/THX (no HVL) (*Memory)
- ; http://lclevy.free.fr/exotica/ahx/ahxformat.txt
- \ID = ahx1play_PlaySong(\Memory, \Length, \SubSong - 1, \Freq)
- If \ID
- \Title$ = PeekS(ahx1play_GetSongName(), -1, #PB_Ascii)
- If \Songs = #Null ; no zip archive?
- \Songs = PeekB(\Memory + $D) + 1
- EndIf
- EndIf
- ;}
- Case #C2D_MUSIC_API ;{ *** Play API-Wave (*.WAV) (@File / *Memory)
- If \Length
- \ID = PlaySound_(\Memory, #Null, #SND_MEMORY|#SND_ASYNC|#SND_LOOP|#SND_NODEFAULT) ; play from *Memory
- Else
- \ID = PlaySound_(\Memory, #Null, #SND_FILENAME|#SND_ASYNC|#SND_LOOP|#SND_NODEFAULT) ; play from file -> *Memory = @Filename$
- EndIf
- ;}
- Case #C2D_MUSIC_FC4 ;{ *** Play FutureComposer 1..4 (FC) (*Memory)
- \ID = fc14play_PlaySong(\Memory, \Length, \Freq)
- If \ID And PeekL(\Memory) = #ID_SMOD
- \Tracker$ + " / SMOD" ; 1.3
- EndIf
- ;}
- Case #C2D_MUSIC_FLA ;{ *** Play native FLAC-decoder (*.FLAC) (@File / *Memory)
- scal_Init()
- If \Length
- \ID = CatchSound(0, \Memory, \Length)
- Else
- \ID = LoadSound(0, PeekS(\Memory))
- EndIf
- If \ID
- PlaySound(0, #PB_Sound_Loop)
- \Time = SoundLength(0, #PB_Sound_Millisecond)
- EndIf
- ;}
- Case #C2D_MUSIC_FT2 ;{ *** Play FastTracker I/II (FT/XM) & Amiga Tracker (MOD) (*Memory)
- \ID = ft2play_PlaySong(\Memory, \Length, 0, 1, \Freq)
- If \ID
- ft2play_SetAmp(18)
- If PeekL(\Memory) = #ID_XM
- \Title$ = PeekS(\Memory + $11, 20, #PB_Ascii)
- Else
- \Tracker$ + " / Amiga Tracker"
- \Title$ = PeekS(\Memory, 20, #PB_Ascii)
- EndIf
- EndIf
- ;}
- Case #C2D_MUSIC_MCI ;{ *** Play Systemfile (*.MP3;*.OGG;*.WAV;*.WMA...) (@File)
- ; https://www.vbarchiv.net/tipps/tipp_856-alles-ueber-das-multimedia-control-interface-mci-api.html
- t$ = "OPEN " + #DQUOTE$ + PeekS(\Memory) + #DQUOTE$ + " TYPE MPEGVIDEO ALIAS 0"
- If mciSendString_(@t$, 0, 0, 0) = #S_OK
- t$ = Space(#MAX_PATH)
- mciSendString_(@"SET 0 TIME FORMAT MILLISECONDS", 0, 0, 0)
- mciSendString_(@"PLAY 0 REPEAT", 0, 0, 0)
- mciSendString_(@"STATUS 0 LENGTH", @t$, #MAX_PATH, 0)
- \Time = Val(t$)
- Else
- \ID = #False
- EndIf
- ;}
- Case #C2D_MUSIC_MOD ;{ *** Play native Tracker (*.XM;*.IT;*.S3M;*.MOD;*.MTM;*.UMX;*.OKT;*.MED + PP20) (@File / *Memory)
- scal_Init()
- If \Length
- \ID = CatchMusic(0, \Memory, \Length)
- Else
- \ID = LoadMusic(0, PeekS(\Memory))
- EndIf
- If \ID
- PlayMusic(0)
- EndIf
- ;}
- Case #C2D_MUSIC_MOV ;{ *** Play native Movie / Audio (same as MCI) (@File)
- CompilerIf #IsMOV
- scal_Init()
- If LoadMovie(0, \File$)
- *Memory = GetForegroundWindow_()
- If MovieWidth(0) > 0 ; 99 if portable
- \WinID = OpenWindow(#PB_Any, 40, 40, MovieWidth(0), MovieHeight(0), GetFilePart(\File$), #PB_Window_Tool|#PB_Window_NoGadgets)
- *Memory = WindowID(\WinID)
- EndIf
- If PlayMovie(0, *Memory)
- \Time = (MovieLength(0) / (MovieInfo(0, 0) + 1)) * 1000
- Else
- \ID = #False
- EndIf
- Else
- \ID = #False
- EndIf
- CompilerElse
- \ID = #False
- CompilerEndIf
- ;}
- Case #C2D_MUSIC_OGG ;{ *** Play native ogg-decoder (*.OGG) (@File / *Memory)
- scal_Init()
- If \Length
- \ID = CatchSound(0, \Memory, \Length)
- Else
- \ID = LoadSound(0, PeekS(\Memory))
- EndIf
- If \ID
- PlaySound(0, #PB_Sound_Loop)
- \Time = SoundLength(0, #PB_Sound_Millisecond)
- EndIf
- ;}
- Case #C2D_MUSIC_PT2 ;{ *** Play ProTracker 2.3D (MOD) (*Memory)
- If SCAL_IsFormat(#C2D_MUSIC_PT2, \Memory, \Length) ; check, coz pt2 crashes if an error;Default_Mode(\Memory, \Length) = #C2D_MUSIC_PT2
- \ID = pt2play_PlaySong(\Memory, \Length, #CIA_TEMPO_MODE, \Freq)
- Else
- \ID = #False
- EndIf
- If \ID
- \Title$ = PeekS(pt2play_GetSongName(), -1, #PB_Ascii)
- EndIf
- ;}
- Case #C2D_MUSIC_S3M ;{ *** Play ScreamTracker III (S3M) (*Memory)
- \ID = st3play_PlaySong(\Memory, \Length, 0, #SOUNDCARD_GUS, \Freq)
- If \ID
- \Title$ = PeekS(st3play_GetSongName(), -1, #PB_Ascii)
- EndIf
- ;}
- Case #C2D_MUSIC_STM ;{ *** Play Scream Tracker 2.3 (STM) (*Memory)
- \ID = st23play_PlaySong(\Memory, \Length, 0, \Freq)
- If \ID
- \Title$ = PeekS(st23play_GetSongName(), -1, #PB_Ascii)
- EndIf
- ;}
- Case #C2D_MUSIC_TPT ;{ +++ Tiny ProTracker 2.3D (MOD) (*Memory)
- If SCAL_IsFormat(#C2D_MUSIC_TPT, \Memory, \Length)
- \ID = tinypt2play_PlaySong(\Memory, \Length)
- EndIf
- If \ID
- \Title$ = PeekS(\Memory, -1, #PB_Ascii)
- EndIf
- ;}
- Case #C2D_MUSIC_TFC ;{ +++ Tiny FutureComposer 1..4 (FC) (*Memory)
- \ID = tinyfc14play_PlaySong(\Memory, \Length)
- If \ID And PeekL(\Memory) = #ID_SMOD
- \Tracker$ + " / SMOD" ; 1.3
- EndIf
- ;}
- Case #C2D_MUSIC_THX ;{ +++ Tiny AHX (no HVL) (*Memory)
- \ID = tinyahx1play_PlaySong(\Memory, \Length, \SubSong)
- ;}
- Case #C2D_MUSIC_WAV ;{ *** Play native Wave-Decoder (*.WAV) (@File / *Memory)
- scal_Init()
- If \Length
- \ID = CatchSound(0, \Memory, \Length)
- Else
- \ID = LoadSound(0, PeekS(\Memory))
- EndIf
- If \ID
- PlaySound(0, #PB_Sound_Loop)
- \Time = SoundLength(0, #PB_Sound_Millisecond)
- EndIf
- ;}
- CompilerIf #IsAMP ;{ *** x86 - Play AmpMaster Plugin (933+ formats) (@File)
- Case #C2D_MUSIC_AMP
- If AmpMusicInit()
- ; Clone to temp & set Subsong - coz we will NOT change the original one by AmpMaster!
- scal_Temp(#SCAL_TempPath$) ; create temporary directory for all files
- Path$ = GetPathPart(\File$)
- File$ = GetFilePart(\File$)
- If StrStrI_(@File$, @"MDAT.") ; *** MDAT.file ***
- MDAT$ = StringField(File$, 1, ".")
- SMPL$ = scal_Case("SMPL", MDAT$) ; adapt upper/lower case
- File$ = StringField(File$, 2, ".") ; Filename (no extension)
- ; path-check coz don't download again to temp if already downloaded
- If (Path$ <> \Temp$) And scal_Size(\File$) <> scal_Size(\Temp$ + MDAT$ + File$)
- scal_Copy(\File$, \Temp$ + MDAT$ + "." + File$)
- scal_Copy(Path$ + SMPL$ + "." + File$, \Temp$ + SMPL$ + "." + File$)
- EndIf
- File$ = \Temp$ + MDAT$ + "." + File$
- \Memory = @File$
- \Songs = AmpCountSubSongs(\Memory)
- ElseIf StrStrI_(@File$, @".MDAT") ; *** file.MDAT (rare) ***
- MDAT$ = GetExtensionPart(File$)
- SMPL$ = scal_Case("SMPL", MDAT$)
- PathRemoveExtension_(@File$) ; no extension (MDAT)
- If (Path$ <> \Temp$) And scal_Size(\File$) <> scal_Size(\Temp$ + MDAT$ + "." + File$)
- scal_Copy(\File$, \Temp$ + MDAT$ + "." + File$)
- scal_Copy(Path$ + File$ + "." + SMPL$, \Temp$ + SMPL$ + "." + File$)
- EndIf
- File$ = \Temp$ + MDAT$ + "." + File$
- \Memory = @File$
- \Songs = AmpCountSubSongs(\Memory)
- ElseIf StrStrI_(@File$, @".TFX") ; *** file.TFX (MDAT Clone) ***
- MDAT$ = GetExtensionPart(File$)
- SMPL$ = scal_Case("SAM", MDAT$)
- PathRemoveExtension_(@File$) ; no extension (TFX)
- If (Path$ <> \Temp$) And scal_Size(\File$) <> scal_Size(\Temp$ + File$ + "." + MDAT$)
- scal_Copy(\File$, \Temp$ + File$ + "." + MDAT$)
- scal_Copy(Path$ + File$ + "." + SMPL$, \Temp$ + File$ + "." + SMPL$)
- EndIf
- File$ = \Temp$ + File$ + "." + MDAT$
- \Memory = @File$
- \Songs = AmpCountSubSongs(\Memory)
- ElseIf StrStrI_(@File$, @".SID") Or
- StrStrI_(@File$, @".PSID") Or
- StrStrI_(@File$, @".RSID") Or
- StrStrI_(@File$, @".TFM") Or
- StrStrI_(@File$, @".TFMX") Or
- StrStrI_(@File$, @".GBS") Or
- StrStrI_(@File$, @".NSF") Or
- StrStrI_(@File$, @".FRED") Or StrStrI_(@File$, @"FRED.")
- File$ = \Temp$ + File$
- \Memory = @File$
- If (Path$ <> \Temp$) And scal_Size(File$) <= #Null
- scal_Copy(\File$, File$)
- EndIf
- \Songs = AmpCountSubSongs(\Memory)
- Else
- \SubSong = 0
- EndIf
- \ID = AmpMusicPlay(\Memory, \SubSong)
- If \ID
- \File$ = PeekS(\Memory, -1, \StrFormat)
- \Time = AmpMusicLength()
- \Title$ = PeekS(AmpMusicTitle(), -1, #PB_Ascii)
- \Tracker$ = PeekS(AmpMusicInfo(), -1, #PB_Ascii)
- EndIf
- Else
- \ID = #False ; Error!
- EndIf
- CompilerEndIf
- ;}
- CompilerIf #IsBAS ;{ *** x86 - Play Modules (*.XM;*.IT;*.S3M;*.MOD;*.MTM;*.UMX) (@File / *Memory)
- Case #C2D_MUSIC_BAS
- ; http://www.users.on.net/~jtlim/ImpulseTracker/
- BASSMOD_DllMain(GetModuleHandle_(#Null), #DLL_PROCESS_ATTACH, #Null)
- \ID = BASSMOD_Init(-1, \Freq, #Null)
- If \ID
- If \Length ; play from *memory?
- IsOK = BASSMOD_MusicLoad(#True, \Memory, 0, \Length)
- Select PeekL(\Memory)
- Case #ID_IT
- \Tracker$ + " / Impulse Tracker 2.14"
- Case #ID_UMX
- \Tracker$ + " / UMX Container"
- Case #ID_MTM
- \Tracker$ + " / Multi Tracker"
- Case #ID_XM
- \Tracker$ + " / Fast Tracker II"
- EndSelect
- Else ; play from file
- \File$ = PeekS(\Memory, -1, \StrFormat)
- IsOK = BASSMOD_MusicLoad(#False, StrAsc(\Memory))
- EndIf
- If IsOK And BASSMOD_MusicPlay()
- ;\Time = BASSMOD_MusicGetLength(1) / 176.4 ; = 44100
- \Time = BASSMOD_MusicGetLength(1) / (\Freq / 250.0) ; / 2 * 125 BPM
- *Memory = BASSMOD_MusicGetName()
- If *Memory
- \Title$ = PeekS(*Memory, -1, #PB_Ascii)
- EndIf
- Else
- \ID = #Null ; Error!
- EndIf
- EndIf
- CompilerEndIf
- ;}
- CompilerIf #IsBMF ;{ *** x86 - Play BeroTracker04 (*.BMF) (*Memory)
- Case #C2D_MUSIC_BMF
- \ID = SynthCreate(SynthReadBMFSampleRate(\Memory, \Length), 2048, 1, 1)
- If \ID
- SynthReadBMF(\ID, \Memory, \Length)
- SynthPlay(\ID)
- SynthSetLooping(\ID, 1)
- EndIf
- CompilerEndIf
- ;}
- CompilerIf #IsFCP ;{ *** x86 - Play FutureComposer 1.4 (*.FC;*.FC14;*.FC4) (*Memory)
- Case #C2D_MUSIC_FCP
- FCp_Open(GetForegroundWindow_())
- FCp_InitModule(\Memory)
- FCp_Start()
- CompilerEndIf
- ;}
- CompilerIf #IsMED ;{ *** x86 - Play OctaMED (*.MED;*.MMD0;*.MMD1;*.MMD2;*.MMD3;*.MOD + PP20) (@File)
- Case #C2D_MUSIC_MED
- MEDPDLL_DllMain(GetModuleHandle_(#Null), #DLL_PROCESS_ATTACH, #Null)
- MEDP_Initialize(#Null, GetForegroundWindow_())
- If MEDP_Load(StrAsc(\Memory)) ; *Memory = always @Filename$
- If MEDP_IsLoaded()
- t$ = Space(100)
- MEDP_Play()
- MEDP_ModuleName(@t$, 100)
- \Title$ = PeekS(@t$, -1, #PB_Ascii)
- \Time = Abs(MEDP_ModuleTime()) * 0.001 ; micro- to milliseconds (dear Andreas - it's buggy)
- Else
- \ID = #False
- EndIf
- Else
- \ID = #False
- EndIf
- CompilerEndIf
- ;}
- CompilerIf #IsS68 ;{ *** x86 - Play SC68 MC68000 Amiga/Atari (*.SC68;*.SNDH + GZIP) (@File / *Memory)
- Case #C2D_MUSIC_S68
- \ID = sc68_Play(\Memory, \Length)
- CompilerEndIf
- ;}
- CompilerIf #IsSID ;{ *** x86 - Play C64 (*.SID) (*Memory) (need masm32.lib)
- Case #C2D_MUSIC_SID
- If \SubSong
- \ID = SIDOpen(\Memory, \Length, #SID_MEMORY, #SID_NON_DEFAULT, \SubSong)
- Else
- \ID = SIDOpen(\Memory, \Length, #SID_MEMORY, #SID_DEFAULT, #Null)
- EndIf
- If \ID
- \Title$ = PeekS(\Memory + $16, -1, #PB_Ascii)
- If \Songs = #Null
- \Songs = PeekW(\Memory + $E)
- \Songs = UINT16(\Songs)
- EndIf
- EndIf
- CompilerEndIf
- ;}
- CompilerIf #IsTSR ;{ *** x86 - Play C64 (*.SID) (*Memory) (no masm32.lib)
- Case #C2D_MUSIC_TSR
- \Title$ = PeekS(\Memory + $16, -1, #PB_Ascii)
- If \Songs = #Null
- \Songs = PeekW(\Memory + $E)
- \Songs = UINT16(\Songs)
- EndIf
- sid_sound_server_replay_init(\Memory, \Length, \SubSong)
- sid_sound_server_replay_play()
- CompilerEndIf
- ;}
- CompilerIf #IsV1M ;{ *** x86 - Play LibV2 1.0 (*.V2M) (*Memory)
- Case #C2D_MUSIC_V1M
- \ID = ssInit(\Memory, GetForegroundWindow_())
- If \ID
- ssPlay()
- ssDoTick()
- EndIf
- CompilerEndIf
- ;}
- CompilerIf #IsV2M ;{ *** x86 - Play LibV2 1.5 (*.V2M) (*Memory)
- Case #C2D_MUSIC_V2M
- \ID = V2MInit(\Memory, \Freq, GetForegroundWindow_())
- If \ID
- V2MSetRepeat(1)
- V2MPlay()
- \Time = V2MGetTotalTime()
- EndIf
- CompilerEndIf
- ;}
- CompilerIf #IsXM2 ;{ *** x86 - Play FastTracker II (*.XM) (@File / *Memory)
- Case #C2D_MUSIC_XM2
- If \Length
- uFMOD_PlaySong(\Memory, \Length, #XM_MEMORY) ; *memory
- Else
- uFMOD_PlaySong(StrAsc(\Memory), #Null, #XM_FILE) ; @file
- EndIf
- \Title$ = PeekS(uFMOD_GetTitle(), -1, #PB_Ascii)
- CompilerEndIf
- ;}
- CompilerIf #IsYMP ;{ *** x86 - Play Atari (*.YM) (@File / *Memory)
- Case #C2D_MUSIC_YMP
- Protected *RS_ymMusicInfo_t.RS_ymMusicInfo_t = AllocateStructure(RS_ymMusicInfo_t)
- YMPLUGIN_DllMain(GetModuleHandle_(#Null), #DLL_PROCESS_ATTACH, #Null)
- YM_Init()
- If \Length > 0
- YM_Open(#Null, \Memory, \Length)
- Else
- YM_Open(StrAsc(@\File$), #Null, #Null)
- EndIf
- YM_Play()
- YM_Get_Info(*RS_ymMusicInfo_t)
- \Tracker$ + " / " + Trim(PeekS(*RS_ymMusicInfo_t\pSongPlayer, -1, #PB_Ascii), ".") + " (" + PeekS(*RS_ymMusicInfo_t\pSongType, -1, #PB_Ascii) + ")"
- \Title$ = PeekS(*RS_ymMusicInfo_t\pSongName, -1, #PB_Ascii)
- \Time = *RS_ymMusicInfo_t\musicTimeInSec * 1000 - 200 ; -200 ms coz no loop on (real) end
- FreeStructure(*RS_ymMusicInfo_t)
- CompilerEndIf
- ;}
- Default
- \ID = #False ; unknown or play x86 on x64?
- EndSelect
- If \ID
- SCAL_SetVolume(\Volume)
- If \IsZip ; restore subsongs from zip-archive?
- \Songs = \ZipCount
- \SubSong = \ZipSong
- EndIf
- \TimePlay = ElapsedMilliseconds()
- Else
- SCAL_Free()
- EndIf
- ProcedureReturn \ID
- EndWith
- EndProcedure
- ProcedureDLL SCAL_Seek(Position, Flags)
- ; Position = ms or 0-100%
- ; Flags = 0 -> seek in ms, 1 -> seek in percent
- ; Remember: \TimePlay = ElapsedMilliseconds() - Position
- Protected t$
- With RS_SCAL
- ; Playing?
- If \ID = #Null : ProcedureReturn #Null : EndIf
- If Flags ; Percent?
- If Position < 0 Or Position > 100
- Position = #Null
- EndIf
- ElseIf Position < 0 Or Position > \Time ; Milliseconds!
- Position = #Null
- EndIf
- If Flags ; convert % to ms
- Position = \Time * 0.01 * Position
- EndIf
- Select \Mode
- Case #C2D_MUSIC_OGG, #C2D_MUSIC_FLA, #C2D_MUSIC_WAV
- If IsSound(0)
- SetSoundPosition(0, Position, #PB_Sound_Millisecond)
- EndIf
- Case #C2D_MUSIC_MCI
- t$ = "SEEK 0 TO " + Str(Position)
- mciSendString_(@t$, 0, 0, 0)
- mciSendString_(@"PLAY 0 REPEAT", 0, 0, 0)
- CompilerIf #IsAMP
- Case #C2D_MUSIC_AMP
- AmpMusicSetPosition(Position)
- CompilerEndIf
- CompilerIf #IsBAS
- Case #C2D_MUSIC_BAS
- \TimePlay = ElapsedMilliseconds() - Position
- Position = $FFFF0000 | (Position / 1000)
- BASSMOD_MusicSetPosition(Position)
- CompilerEndIf
- CompilerIf #IsMED ; Error
- ; Case #C2D_MUSIC_MED
- ; If Flags ; only percent (coz unknown / buggy? ticks)
- ; \TimePlay = ElapsedMilliseconds() - Position
- ; Position = Abs(MEDP_ModuleLength()) * 0.01 * Position
- ; MEDP_SetPlayPosition(Position)
- ; EndIf
- CompilerEndIf
- CompilerIf #IsV2M
- Case #C2D_MUSIC_V2M
- V2MStop()
- dsClose()
- V2MInit(\Memory, \Freq, GetForegroundWindow_())
- V2MSetRepeat(1)
- dsSetVolume(0.01 * \Volume)
- V2MPlay(Position)
- CompilerEndIf
- CompilerIf #IsYMP
- Case #C2D_MUSIC_YMP
- \TimePlay = ElapsedMilliseconds() - Position
- Position / 1000
- YM_Seek(Position)
- CompilerEndIf
- EndSelect
- EndWith
- EndProcedure
- ProcedureDLL SCAL_SetFreq(Freq)
- If Freq <= #Null
- Freq = 44100
- EndIf
- RS_SCAL\Freq = Freq
- EndProcedure
- ProcedureDLL SCAL_SetString(Format)
- ; Set stringformat to AscII, UTF8, Unicode
- ; Format: ASCII = 1 or #PB_Ascii (24)
- ; UTF8 = 3
- ; UNICODE = any other number (default)
- ; Tipp = SizeOf(Character))
- With RS_SCAL
- Select Format
- Case 1, #PB_Ascii
- \StrFormat = #PB_Ascii
- Case 3; #PB_UTF8
- \StrFormat = #PB_UTF8
- Default
- \StrFormat = #PB_Unicode
- EndSelect
- EndWith
- EndProcedure
- ProcedureDLL SCAL_SetVolume(Percent)
- Protected t$
- With RS_SCAL
- If Percent < 0
- Percent = 0
- ElseIf Percent > 100
- Percent = 100
- EndIf
- \Volume = Percent
- ; Playing?
- If \ID = #Null : ProcedureReturn : EndIf
- Select \Mode
- Case #C2D_MUSIC_FT2 : ft2play_SetMasterVol(2.56 * \Volume)
- Case #C2D_MUSIC_PT2 : pt2play_SetMasterVol(2.56 * \Volume)
- Case #C2D_MUSIC_FC4 : fc14play_SetMasterVol(2.56 * \Volume)
- Case #C2D_MUSIC_STM : st23play_SetMasterVol(2.56 * \Volume)
- Case #C2D_MUSIC_S3M : st3play_SetMasterVol(2.56 * \Volume)
- Case #C2D_MUSIC_MCI
- t$ = "SETAUDIO 0 VOLUME TO " + Str(10 * \Volume)
- mciSendString_(@t$, 0, 0, 0) ; 0 - 1000
- Case #C2D_MUSIC_MOD : MusicVolume(0, \Volume)
- Case #C2D_MUSIC_MOV : MovieAudio(0, \Volume, 0)
- Case #C2D_MUSIC_FLA, #C2D_MUSIC_OGG, #C2D_MUSIC_WAV
- SoundVolume(0, \Volume)
- CompilerIf #IsAMP
- Case #C2D_MUSIC_AMP
- AmpMusicVolume(2.55 * \Volume)
- CompilerEndIf
- CompilerIf #IsBAS
- Case #C2D_MUSIC_BAS
- BASSMOD_SetVolume(\Volume)
- CompilerEndIf
- CompilerIf #IsV2M
- Case #C2D_MUSIC_V2M
- dsSetVolume(0.01 * \Volume)
- CompilerEndIf
- CompilerIf #IsXM2
- Case #C2D_MUSIC_XM2
- uFMOD_SetVolume(0.25 * \Volume)
- CompilerEndIf
- CompilerIf #IsYMP
- Case #C2D_MUSIC_YMP
- YM_SetVolume(2.55 * \Volume)
- CompilerEndIf
- EndSelect
- EndWith
- EndProcedure
- ProcedureDLL SCAL_Struct()
- ; creates temporary directory for all files
- ; define RS_SCAL\Temp$ even if not exist
- ; Return: private *structure
- scal_Temp(#SCAL_TempPath$)
- ProcedureReturn @RS_SCAL
- EndProcedure
- ProcedureDLL SCAL_Table(Mode)
- ; Mode = #C2D_MUSIC_[ID]
- ; Return: ptr to infostring or table
- Static *Memory.Integer
- *Memory = ?mode
- If Mode >= #Null And Mode <= #SCAL_MAX
- *Memory + Mode * SizeOf(Integer)
- ProcedureReturn *Memory\i
- EndIf
- ProcedureReturn *Memory
- EndProcedure
- ProcedureDLL SCAL_Version()
- ; 100 = 1.00
- ProcedureReturn #SCAL_VERSION
- EndProcedure
- DataSection
- IncludePath "Include\"
- l_Start: ; Compare extensions
- l_AHX: : IncludeFile "i_AHX.pbi"
- l_FC4: : IncludeFile "i_FC4.pbi"
- l_FLA: : IncludeFile "i_FLA.pbi"
- l_FT2: : IncludeFile "i_FT2.pbi"
- l_MOD: : IncludeFile "i_MOD.pbi"
- l_OGG: : IncludeFile "i_OGG.pbi"
- l_PT2: : IncludeFile "i_PT2.pbi"
- l_S3M: : IncludeFile "i_S3M.pbi"
- l_STM: : IncludeFile "i_STM.pbi"
- l_API: ; same as wav
- l_WAV: : IncludeFile "i_WAV.pbi"
- l_MOV: ; same as mci
- l_MCI: : IncludeFile "i_MCI.pbi"
- CompilerIf #IsAMP
- l_AMP: : IncludeFile "i_AMP.pbi"
- CompilerEndIf
- CompilerIf #IsBAS
- l_BAS: : IncludeFile "i_BAS.pbi"
- CompilerEndIf
- CompilerIf #IsBMF
- l_BMF: : IncludeFile "i_BMF.pbi"
- CompilerEndIf
- CompilerIf #IsFCP
- l_FCP: : IncludeFile "i_FCP.pbi"
- CompilerEndIf
- CompilerIf #IsMED
- l_MED: : IncludeFile "i_MED.pbi"
- CompilerEndIf
- CompilerIf #IsS68
- l_SC68: : IncludeFile "i_S68.pbi"
- CompilerEndIf
- CompilerIf (#IsSID + #IsTSR)
- l_TSR: ; same as sid
- l_SID: : IncludeFile "i_SID.pbi"
- CompilerEndIf
- CompilerIf (#IsV1M + #IsV2M)
- l_V1M: ; same as v2m
- l_V2M: : IncludeFile "i_V2M.pbi"
- CompilerEndIf
- CompilerIf #IsXM2
- l_XM2: : IncludeFile "i_XM2.pbi"
- CompilerEndIf
- CompilerIf #IsYMP
- l_YMP: : IncludeFile "i_YMP.pbi"
- CompilerEndIf
- l_ZIP: : IncludeFile "i_ZIP.pbi"
- l_Finish: : Data.l #Null ; End of compare extensions
- ; Playengines: ID | Processor x86-64 | Trackerinfo/name -> never change order (same as #C2D_MUSIC_[ID])!
- mode: : Data.i ?m0,?m1,?m2,?m3,?m4,?m5,?m6,?m7,?m8,?m9,?m10,?m11,?m12,?m13,?m14,?m15,?m16,?m17,?m18,?m19,?m20,?m21,?m22,?m23,?m24,?m25,?m26,?m27,?m28,?m29
- m0: : Data.s "AUTO|x86-64|Autodetect"
- m1: : Data.s "AHX|x86-64|Amiga Abyss' Highest eXperience 1.00-1.27"
- m2: : Data.s "AMP|x86|AmpMaster_x86.dll"
- m3: : Data.s "API|x86-64|PlaySound Wave API"
- m4: : Data.s "BAS|x86|BASSMOD 2.0"
- m5: : Data.s "BMF|x86|BeRo 404 Tracker"
- m6: : Data.s "FC4|x86-64|Amiga Future Composer 1.0-1.4"
- m7: : Data.s "FCP|x86|Amiga Future Composer 1.4"
- m8: : Data.s "FLA|x86-64|Pure Free Lossless Audio Codec"
- m9: : Data.s "FT2|x86-64|FastTracker I / II"
- m10: : Data.s "MCI|x86-64|Media Control Interface"
- m11: : Data.s "MED|x86|Amiga OctaMED / MEDP 1.0"
- m12: : Data.s "MOD|x86-64|Pure ModPlug Module"
- m13: : Data.s "MOV|x86-64|Pure Movie Mediadecoder"
- m14: : Data.s "OGG|x86-64|Pure OGG Vorbis Decoder"
- m15: : Data.s "PT2|x86-64|Amiga ProTracker 2.3d"
- m16: : Data.s "S3M|x86-64|ScreamTracker v3.21"
- m17: : Data.s "S68|x86|SC68 MC68000 Amiga / Atari"
- m18: : Data.s "SCA|x86-64|SCAL DLL"
- m19: : Data.s "SID|x86|C64 TitchySid"
- m20: : Data.s "STM|x86-64|ScreamTracker v2.2-2.3"
- m21: : Data.s "TFC|x86-64|Tiny Future Composer 1.0-1.4"
- m22: : Data.s "THX|x86-64|Tiny Abyss' Highest eXperience 1.00-1.27"
- m23: : Data.s "TPT|x86-64|Tiny ProTracker 2.3d"
- m24: : Data.s "TSR|x86|C64 Sid SoundServer"
- m25: : Data.s "V1M|x86|Farbrausch V2 Synthesizer System v1.0"
- m26: : Data.s "V2M|x86|Farbrausch V2 Synthesizer System v1.5"
- m27: : Data.s "WAV|x86-64|Pure WAV Sound Decoder"
- m28: : Data.s "XM2|x86|uFMOD FastTracker II"
- m29: : Data.s "YMP|x86|Atari ST YM2149 (LZH-h0)"
- s_unknown: : Data.s "?"
- EndDataSection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement