site : ICI
La version pour purebasic (faite à la va vite) LA

Code : Tout sélectionner
XIncludeFile "ufmod.pbi"
#THEFILE = 0
Global theFile.s
Global sizeXM.l, hWave.l
Global playing.s
theFile = OpenFileRequester("Open XM file", "", "XM Files (*.xm)|*.xm", 0)
playing = "Playing : "+Chr(34)+GetFilePart(theFile)+Chr(34)+" !!!"
sizeXM = FileSize(theFile)
OpenFile(#THEFILE,theFile)
*buffer = AllocateMemory(sizeXM)
If *buffer
ReadData(#THEFILE, *buffer, sizeXM)
Else
MessageRequester("*** ERROR ***","Unable to allocate memory")
End
EndIf
CloseFile(#THEFILE)
hWave = uFMOD_PlaySong(*buffer, sizeXM, #XM_MEMORY)
If hWave <> 0
; Pop-up a message box to let uFMOD play the XM till user input
MessageRequester(".:PureBasic:.",Playing,#PB_MessageRequester_Ok)
; Stop playback
uFMOD_PlaySong(0, 0, 0)
Else
MessageRequester("*** ERROR ***","Unable to play "+Chr(34)+theFile+Chr(34)+Chr(10)+"Returned result = "+Str(hWave))
EndIf
FreeMemory(*buffer)
End
Code : Tout sélectionner
Import "winmm.lib"
waveOutOpen(lphWaveOut.l, uDeviceID.l, lpFormat.l, dwCallback.l, dwInstance.l, dwFlags.l)
waveOutPrepareHeader(hWaveOut.l, lpWaveOutHdr.l, uSize.l)
waveOutWrite(hWaveOut.l, lpWaveOutHdr.l, uSize.l)
waveOutReset(hWaveOut.l)
waveOutUnprepareHeader(hWaveOut.l, lpWaveOutHdr.l, uSize.l)
waveOutClose(hWaveOut.l)
waveOutGetPosition(hwo.l, pmmt.l, cbmmt.l)
EndImport
Import "ufmod.lib"
; The uFMOD_PlaySong function starts playing an XM song
; --------------
; HWAVEOUT* uFMOD_PlaySong(
; LPVOID lpXM,
; DWORD param,
; DWORD fdwSong
; );
; Parameters:
; lpXM
; Specifies the song to play. If this parameter is NULL,
; any currently playing song is stopped. In such a case, function
; does not return a meaningful value
; fdwSong parameter determines whether this value is interpreted
; as a filename, as a resource identifier or a pointer to an image
; of the song in memory
; param
; Handle to the executable file that contains the resource to be
; loaded or size of the image of the song in memory. This parameter
; is ignored unless XM_RESOURCE or XM_MEMORY is specified in fdwSong
; fdwSong
; Flags for playing the song. The following values are defined
; Value Meaning
; XM_FILE lpXM points to filename
; param is ignored
; XM_MEMORY lpXM points to an image of a song in memory
; param is the image size
; XM_RESOURCE lpXM Specifies the name of the resource
; param identifies the module whose executable file
; contains the resource
; The resource type must be RT_RCDATA
; Return Values:
; Returns a pointer to HWAVEOUT on success or NULL otherwise
uFMOD_PlaySong(lpXM.l, param.l, fdwSong.l) ;As "_uFMOD_PlaySong@12"
; The uFMOD_GetRowOrder function returns the song's current row And order
; --------------
; unsigned short uFMOD_GetRowOrder();
; Return Values:
; Returns the song's current row in high-order byte And order
; in low-order byte
uFMOD_GetRowOrder() ;As "_uFMOD_GetRowOrder@0"
; The uFMOD_GetTime function returns the time in milliseconds since the
; song was started. This is useful for synchronizing purposes.
; --------------
; unsigned int uFMOD_GetTime();
; Return Values:
; Returns the time in milliseconds since the song was started
uFMOD_GetTime() ;As "_uFMOD_GetTime@0"
EndImport
#XM_RESOURCE = 0
#XM_MEMORY = 1
#XM_FILE = 2