kaz Posted June 28 Share Posted June 28 (edited) Hello, i try for a long time to play xm music with ufmod.dll (only 10k). But i don't obtain any sound, i think i don't call function correctly. HotKeySet("{ESC}", "Terminate") $xm = "J:\test.xm" Local $hDLL = DllOpen("ufmod.dll") $return = DllCall($hDLL, "HANDLE", "uFMOD_PlaySong", "STR*", $xm, "INT", 0, "INT", 2) If @error = 0 Then ConsoleWrite("OK" & @CRLF) While True Sleep(100) WEnd Else ConsoleWrite("KO " & @error & @CRLF) EndIf Func Terminate() Exit 0 DllClose($hDLL) EndFunc ;==>Terminate dll and examples can be download from : https://ufmod.sourceforge.io , on top left. Inside 7z file, directory ufmodlib\dll a lot of xm file can be download from : https://github.com/sxiii/keygen-music/tree/master/music How can i make my code works? Edited June 29 by kaz Link to comment Share on other sites More sharing options...
UEZ Posted June 29 Share Posted June 29 (edited) Try $return = DllCall($hDLL, "int", "uFMOD_PlaySong", "str", $xm, "uint", 0, "uint", 2) "STR*" is a string pointer which is wrong here. Before exiting the script I would suggest to stop the player by DllCall($hDLL, "int", "uFMOD_PlaySong", "str", 0, "uint", 0, "uint", 0) Edited June 29 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
kaz Posted June 29 Author Share Posted June 29 (edited) thanks, but i still have no sound. i try to add : DllCall($hDLL, "none", "uFMOD_SetVolume", "uint", 15) to be sure volume is not 0. But still nothing 😞 it seems program not responding, esc key do nothing and program don't exit. After debugging, i think call to waveOutWrite (winmm.dll) get an error. Edited June 29 by kaz Link to comment Share on other sites More sharing options...
Gianni Posted June 29 Share Posted June 29 with the changes suggested by @UEZ it works for me try putting #AutoIt3Wrapper_UseX64=n at the beginning of the script Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
kaz Posted June 29 Author Share Posted June 29 still no sound with this otion. i'm on W10, i will try on another PC. While debugging, i see parameter passed to uFMOD_PlaySong function, but ... Link to comment Share on other sites More sharing options...
UEZ Posted June 29 Share Posted June 29 (edited) You may have a look here: Edited June 29 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
kaz Posted June 29 Author Share Posted June 29 (edited) Thanks UEZ, player on this link works fine. I thought it should be easy tu use this small dll. I tried on a W10 VM, no sound On a W11 desktop, loop on first notes only. with or without the while loop. Edited June 29 by kaz Link to comment Share on other sites More sharing options...
UEZ Posted June 29 Share Posted June 29 This works for me: expandcollapse popup;Coded by UEZ build 2024-06-29 #include <WinAPIConv.au3> #AutoIt3Wrapper_UseX64=n Global Const $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 Global $g_iDLLPath = DllOpen(@ScriptDir & "\ufmod.dll") Func uFMOD_PlaySongFile($sFilename, $param = 0, $fdwSong = $XM_FILE) Local Const $aReturn = DllCall($g_iDLLPath, "ptr", "uFMOD_PlaySong", "str", $sFilename, "ulong", $param, "ulong", $fdwSong) If @error Or Not IsArray($aReturn) Then Return SetError(1, 0, 0) If Not $aReturn[0] Then Return SetError(2, 0, 0) Return $aReturn[0] EndFunc Func uFMOD_PlaySongMem($pMem, $iSize, $fdwSong = $XM_MEMORY) Local Const $aReturn = DllCall($g_iDLLPath, "ptr", "uFMOD_PlaySong", "ptr", $pMem, "ulong", $iSize, "ulong", $fdwSong) If @error Or Not IsArray($aReturn) Then Return SetError(1, 0, 0) If Not $aReturn[0] Then Return SetError(2, 0, 0) Return $aReturn[0] EndFunc Func uFMOD_StopSong() DllCall($g_iDLLPath, "ptr", "uFMOD_PlaySong", "str", "", "long", 0, "long", 0) Return 1 EndFunc Func uFMOD_PauseSong() DllCall($g_iDLLPath, "none", "uFMOD_Pause") Return 1 EndFunc Func uFMOD_ResumeSong() DllCall($g_iDLLPath, "none", "uFMOD_Resume") Return 1 EndFunc Func uFMOD_SetVolume($iVol) DllCall($g_iDLLPath, "none", "uFMOD_SetVolume", "long", $iVol) Return 1 EndFunc Func uFMOD_GetStats() Local Const $aReturn = DllCall($g_iDLLPath, "int", "uFMOD_GetStats") If @error Or Not IsArray($aReturn) Then Return SetError(1, 0, 0) If Not $aReturn[0] Then Return SetError(2, 0, 0) Local $aRMS[] = [_WinAPI_HiWord($aReturn[0]), _WinAPI_LoWord($aReturn[0])] ;L / R channel Return $aRMS EndFunc Func uFMOD_GetRowOrder() Local Const $aReturn = DllCall($g_iDLLPath, "int", "uFMOD_GetRowOrder") If @error Or Not IsArray($aReturn) Then Return SetError(1, 0, 0) If Not $aReturn[0] Then Return SetError(2, 0, 0) Return $aReturn[0] EndFunc Func uFMOD_GetTime() Local Const $aReturn = DllCall($g_iDLLPath, "long", "uFMOD_GetTime") If @error Or Not IsArray($aReturn) Then Return SetError(1, 0, 0) If Not $aReturn[0] Then Return SetError(2, 0, 0) Return $aReturn[0] EndFunc Func uFMOD_GetTitle() Local Const $aReturn = DllCall($g_iDLLPath, "str", "uFMOD_GetTitle") If @error Or Not IsArray($aReturn) Then Return SetError(1, 0, 0) If Not $aReturn[0] Then Return SetError(2, 0, 0) Return $aReturn[0] EndFunc Func uFMOD_Jump2Pattern($iPattern) DllCall($g_iDLLPath, "none", "uFMOD_Jump2Pattern", "long", $iPattern) Return 1 EndFunc uFMOD_PlaySongFile(<YOUR XM FILE>) ;<<<<<<<<<<<<<<<<<<< change it While Sleep(10) If uFMOD_GetTime() > 10000 Then ExitLoop WEnd uFMOD_StopSong() DllClose($g_iDLLPath) Important is to load the DLL via DllOpen() otherwise it will crash. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
kaz Posted June 29 Author Share Posted June 29 thanks UEZ for your works. unfortunatly, it doesn't works on my computers, no sound. If i add uFMOD_StopSong() before uFMOD_PlaySongFile, i obtain a loop on first notes, but nothing more (W10 and W11) Link to comment Share on other sites More sharing options...
UEZ Posted June 29 Share Posted June 29 Works on my Win10 22h2 Notebook properly. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
kaz Posted June 29 Author Share Posted June 29 just try on a Win10 22h2 Notebook, no more luck. Perhaps the problem come from my french settings... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now