Blitz PLus module player?

Miscellaneous Forums/General Discussion/Blitz PLus module player?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Okay, for B3D the following is pretty much everything:

modplug.decls
.lib "npmod32.dll"

ModPlug_CreateEx%(lpszArgs$)
ModPlug_SetWindow%(pPlugin%, hwnd%)
ModPlug_Destroy%(pPlugin%)
ModPlug_Load%(pPlugin%, lpszFileName$)
ModPlug_Play%(pPlugin%)
ModPlug_SetCurrentPosition%(pPlugin%, nPos%)
ModPlug_Stop%(pPlugin%)
ModPlug_IsPlaying%(plugin%)
ModPlug_GetCurrentPosition%(plugin%)
ModPlug_GetMaxPosition%(plugin%)
ModPlug_GetVolume%(plugin%)
ModPlug_SetVolume%(plugin%,vol%)
ModPlug_GetVersion%()
ModPlug_IsReady%(plugin%)



And an example of usage (dependent on npmod32.dll, modplug.decls & user32.decls remember):
Graphics 800,600,0,2
SetBuffer BackBuffer()

AppTitle "test" 

Global ModPlug

ModPlug = ModPlug_CreateEx("loop|true|hidden|true")
TheWindow =  api_FindWindow("Blitz Runtime Class", "test")
ChildWindow=api_CreateMDIWindow% ("Blitz Runtime Class", "ModPlug Output", WS_MINIMIZE, 10, 10, 100, 100, TheWindow,0,0)
ModPlug_SetWindow(ModPlug,ChildWindow)		
sp$ = "whatever.xm"		
ModPlug_Load(ModPlug, sp)
If Not ModPlug_IsReady(ModPlug) Then ModPlug_Destroy(ModPlug) : RuntimeError "Unable to initialise ModPlug :("
maxPos%=ModPlug_GetMaxPosition(ModPlug)
ModPlug_SetCurrentPosition(ModPlug, 0)				
ModPlug_Play(ModPlug)
ver%=ModPlug_GetVersion()

While Not KeyHit(1)
	If KeyHit(57)
		If ModPlug_IsPlaying(ModPlug)
			ModPlug_Stop(ModPlug)
		Else
			ModPlug_Play(ModPlug)
		EndIf 
	EndIf
	vol%=ModPlug_GetVolume(ModPlug)
	If KeyDown(12) And vol>0 Then ModPlug_SetVolume(ModPlug,vol-1)
	If KeyDown(13) And vol<100 Then ModPlug_SetVolume(ModPlug,vol+1)
	
	Text 10,10,"Using ModPlug Plugin Version "+ver
	Text 10,50,"ESC to quit,  SPACE to pause,  +/- to alter volume."
	Text 10,70,"Current Position: "+ModPlug_GetCurrentPosition(ModPlug)+"/"+maxPos
	Text 10,90,"Volume: "+vol
	Flip
	Cls
	Delay 1	
Wend
ModPlug_Destroy(ModPlug)


So hurrah, we can play mod music in Blitz again without having to use one of the commercial* API's - yay us!


EDIT: By way of notes, it's still a minor concern that the player seems to stay resident after an application quits, though as long as there's only one instance allowed I suppose it's *okaaaay*. Also, the version number returned seems way out (bleh!). Oh, and there's a twenty channel limit on the player so don't ask too much of it.

* The plug-in is only intended for non-commercial use so I guess you'd have to email the author, Olivier Lapicque (olivierl@...), if you wanted it for professional work. As the SDK is available for any purpose and we're essentially using the plugin in its place the response might be favourable - I should ask him, really. :D