flxfxp Posted December 4, 2008 Posted December 4, 2008 As asked earlier by Brett, I've created a topic for my problem.I would like to create a simple program with xm music playing in the background. I got the example working, but it has tons of stuff I dont need. It just needs to have some buttons and the music playing. I tried to strip the example (first time AutoIt user) but that ended with no avail.This is what I made so far:expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 633, 450, 193, 125) $Button1 = GUICtrlCreateButton("Button1", 48, 112, 73, 33, 0) $Button2 = GUICtrlCreateButton("Button2", 136, 120, 97, 33, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Dim $RetValue2[1], $Is_playing[1], $file,$ext $dll = DllOpen("fmod.dll") $buffer = DllCall($dll, "long", "_FSOUND_SetBufferSize@4", "long",200) $RetValue = DllCall($dll, "long", "_FSOUND_Init@12", _ "long", 44100, _ "long", 32, _ "long", 0x0001) ;;;;;;;;;;;;;;;;;;;;;onload, LOAD SONG AND EXECUTE $file = "flx.xm" $ext = StringRight($file, 2) $RetValue2 = DllCall($dll, "long", "_FMUSIC_LoadSong@4", "str", $file) $value = 50 $volume = DllCall($dll, "long", "_FMUSIC_SetMasterVolume@8", _ "long", $RetValue2[0], _ "long",$value) $get = DllCall($dll, "long", "_FMUSIC_GetNumOrders@4", _ "long", $RetValue2[0]) DllCall($dll, "long", "_FMUSIC_SetLooping@8", _ "long", $RetValue2[0], _ "long", "True") DllCall($dll, "long", "_FMUSIC_PlaySong@4", _ "long", $RetValue2[0]) While 1 Sleep(1000) If $RetValue2[0] <> 0 Then getOrder() WEnd Func getOrder() $order = DllCall($dll, "long", "_FMUSIC_GetOrder@4", _ "long", $RetValue2[0]) EndFuncI know its stupid, please don't ridicule me I appreciate the help.Thank you in advance.Regards,Dennis
Zedna Posted December 4, 2008 Posted December 4, 2008 (edited) I don't know what do you want exactly so I have arranged your code little: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $RetValue2[1], $Is_playing[1], $dll #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Music", 633, 450, 193, 125) $Button1 = GUICtrlCreateButton("Load", 48, 120, 73, 33, 0) $Button2 = GUICtrlCreateButton("Stop", 136, 120, 97, 33, 0) GUISetState(@SW_SHOW) #EndRegion ### START Koda GUI section ### Form= MusicInit() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MusicLoad("flx.xm") Case $Button2 MusicStop() EndSwitch If $RetValue2[0] <> 0 Then getOrder() WEnd Func MusicInit() $dll = DllOpen("fmod.dll") $buffer = DllCall($dll, "long", "_FSOUND_SetBufferSize@4", "long", 200) $RetValue = DllCall($dll, "long", "_FSOUND_Init@12", _ "long", 44100, _ "long", 32, _ "long", 0x0001) EndFunc Func MusicLoad($file) $ext = StringRight($file, 2) $RetValue2 = DllCall($dll, "long", "_FMUSIC_LoadSong@4", "str", $file) $value = 50 $volume = DllCall($dll, "long", "_FMUSIC_SetMasterVolume@8", _ "long", $RetValue2[0], _ "long", $value) $get = DllCall($dll, "long", "_FMUSIC_GetNumOrders@4", _ "long", $RetValue2[0]) DllCall($dll, "long", "_FMUSIC_SetLooping@8", _ "long", $RetValue2[0], _ "long", "True") DllCall($dll, "long", "_FMUSIC_PlaySong@4", _ "long", $RetValue2[0]) EndFunc Func MusicStop() ; ... EndFunc Func getOrder() $order = DllCall($dll, "long", "_FMUSIC_GetOrder@4", _ "long", $RetValue2[0]) EndFunc ;==>getOrder Edited December 4, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
BrettF Posted December 4, 2008 Posted December 4, 2008 Hi, Maybe something like this? expandcollapse popup#include <Bass.au3> #include <BassConstants.au3> #include <GUIConstantsEx.au3> $file = "LUN-COWT.xm" ;Open Bass.DLL. Required for all function calls. $bass_dll = DllOpen("BASS.dll") ;Initalize bass. Required for most functions. _BASS_Init($bass_dll, 0, -1, 44100, 0, "") ;Check if bass iniated. If not, we cannot continue. If @error Then MsgBox(0, "Error", "Could not initialize audio") Exit EndIf $HMUSIC = _BASS_MusicLoad($bass_dll, 0, $file, 0, 0, $BASS_SAMPLE_LOOP, 0) $Form1 = GUICreate("Music", 633, 450, 193, 125) $Button1 = GUICtrlCreateButton("Button 1", 48, 120, 73, 33, 0) $Button2 = GUICtrlCreateButton("Button 2", 136, 120, 97, 33, 0) GUISetState(@SW_SHOW) _BASS_ChannelPlay($bass_dll, $HMUSIC, 1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _BASS_Free($bass_dll) Exit Case $Button1 MsgBox (0, "", "Button 1 was pressed!") Case $Button2 MsgBox (0, "", "Button 2 was pressed!") EndSwitch WEnd Please note _Bass_MusicLoad has to be updated, here is the correct version: Func _BASS_MusicLoad($bass_dll, $mem, $file, $offset, $length, $flags, $freq) $fType = DllStructCreate("char[255]") DllStructSetData($fType, 1, $file) $BASS_ret_ = DllCall($bass_dll, "int", "BASS_MusicLoad", "int", $mem, "ptr", DllStructGetPtr($fType), "uint64", $offset, "DWORD", $length, "DWORD", $flags, "DWORD", $freq) $error = _BASS_ErrorGetCode($bass_dll) If $error <> 0 Then Return SetError($error, "", 0) Else Return SetError(0, "", $BASS_ret_[0]) EndIf EndFunc ;==>_BASS_MusicLoad Just rplace it in BASS.au3 Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
flxfxp Posted December 5, 2008 Author Posted December 5, 2008 Thanks Brett, this was exactly what I needed! You also thanks for your input, Zedna. Regards, FLX
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