Jump to content

Fmod UDF Help


flxfxp
 Share

Recommended Posts

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:

#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])
EndFunc

I know its stupid, please don't ridicule me :) I appreciate the help.

Thank you in advance.

Regards,

Dennis

Link to comment
Share on other sites

I don't know what do you want exactly

so I have arranged your code little:

#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 by Zedna
Link to comment
Share on other sites

Hi,

Maybe something like this?

#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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...