Request time (again!)
I've successfully implemented MOD music into a project. Having had a play, I noticed that the FMOD.DLL wrapper has no volume controls in it. I don't have the necessary experience to add to the wrapper. Would some kind soul add a volume command to the wrapper? (see Samples/_Projects_/FMOD_Player) and either post it or a link here?
This will allow much more control over .MOD music :)
// --------------------------------- //
// Project: fmod player
// Start: Tuesday, May 09, 2006
// IDE Version: 3.118
INLINE
DECLARE_ALIAS(FMUSIC_LoadSong, "fmod.dll", "_FMUSIC_LoadSong@4", (const char* name), void*);
DECLARE_ALIAS(FMUSIC_PlaySong, "fmod.dll", "_FMUSIC_PlaySong@4", (void* pMod), char);
DECLARE_ALIAS(FMUSIC_FreeSong, "fmod.dll", "_FMUSIC_FreeSong@4", (void* pMod), char);
DECLARE_ALIAS(FSOUND_Init, "fmod.dll", "_FSOUND_Init@12", (int, int, unsigned int), char);
DECLARE_ALIAS(FSOUND_Close, "fmod.dll", "_FSOUND_Close@0", (void), void);
DECLARE_ALIAS(FMUSIC_IsFinished, "fmod.dll", "_FMUSIC_IsFinished@4", (void* pMod), char);
DECLARE_ALIAS(FMUSIC_SetMasterVolume, "fmod.dll", "_FMUSIC_SetMasterVolume@8", (void*, int), char);
void* g_pFMod = 0;
// need this for ESC-exits
struct FMOD_killer {~FMOD_killer() {if (g_pFMod) FMod_Stop();} } g_Fmod_killa;
ENDINLINE
FUNCTION FMod_Load: fname$
GLOBAL fmod_init
LOCAL good
IF fmod_init = FALSE
fmod_init=TRUE
ENDIF
FMod_Stop()
INLINE
if(FSOUND_Init) FSOUND_Init(44100,64,0);
if(FMUSIC_LoadSong)
g_pFMod = FMUSIC_LoadSong(fname_Str.c_str());
if(g_pFMod) good = true;
ENDINLINE
RETURN good
ENDFUNCTION
FUNCTION FMod_Play:
INLINE
if(FMUSIC_PlaySong && g_pFMod)
FMUSIC_PlaySong(g_pFMod);
ENDINLINE
ENDFUNCTION
FUNCTION FMod_Stop:
INLINE
if(FMUSIC_FreeSong && g_pFMod)
FMUSIC_FreeSong(g_pFMod);
g_pFMod = 0;
if(FSOUND_Close)
FSOUND_Close();
fmod_init=FALSE;
ENDINLINE
ENDFUNCTION
FUNCTION FMod_IsFinished:
INLINE
char ok=1;
if(FMUSIC_IsFinished && g_pFMod)
ok = FMUSIC_IsFinished(g_pFMod);
return ok ? TRUE : FALSE;
ENDINLINE
RETURN TRUE
ENDFUNCTION
FUNCTION FMod_SetMasterVolume: vol
INLINE
if(FMUSIC_SetMasterVolume && g_pFMod)
{
return FMUSIC_SetMasterVolume(g_pFMod, (int)(vol * 256.0)) ? TRUE:FALSE;
}
ENDINLINE
RETURN FALSE
ENDFUNCTION
Then use:
FMod_SetMasterVolume(1.0) // full volume / Volle Lautstärke
I'll include the fix in the next update, too.
Cheers Gernot :D
That worked a treat, however...
I'm not sure if you'll be able to do anything about this next bit, but it would appear that you can't shoebox MOD music files. .MP3 and .WAV files work well, but not .MOD music - there's no error reports, just no sound :(
It's not that important for my current project, as I plan to distribute it with full source and media, however in future I may wish to keep everything out of prying eyes ;)
uh-oh. Here's a problem. You can't access shoeboxed media from inside GLBasic, since you could write an un-boxer easily else. However, I see your need to be able to load protected/packed mod files.
Hard problem. Anyone an idea?
You could think about doing that the Terabit DataPak systems does, which is encrypt all the data with a 32 bit key and header mask. That way, the chances of someone taking the effort to try and decrypt your shoeboxed media are remote to none.
I see your point there. Maybe I insert shoeboxing in the build process, generate a random key for both and link the shoebox to the .exe (if wanted). That way you have one file, only.
I love it when a plan comes together! :D
How about a strong name key (eg: the .NET sn.exe utility) stored in a file. The EXE could use this (again, eg: .NET stored this in the properties to strong name assemblies etc) and the shoebox program could use this. The developer would be in control of the key and you won't get into a problem of a shoebox or exe being 'out of sync' and the shoebox being locked out.
Either way, an encryption function to access from the GLB code would be handy too, to allow the developer to make their own encrypted files.