Jump to content

BASS Function Library (Sound and Music Functions)


BrettF
 Share

Recommended Posts

You could use id3lib ;) ATM, i am creteing some wrapper UDFs ...

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Since your here, what is the correct value of $BASS_DWORD_ERR?

Oh! This is what I use.

http://mediainfo.sourceforge.net/en/Download/Windows

Edited by BrettF
Link to comment
Share on other sites

Is it possible to combine MediaInfo with _BASS_ChannelGetTags?

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Who cares? I got something going with the Tags addon library.

I'll add it to the main release. When I finish working on fully implementing BassFx, I'll re-upload.

BassTags

; #INDEX# =======================================================================================================================
; Title .........: BassTags.au3
; Description ...: Allows easy retrieval of tags using the handle of the currently playing stream.
; Author ........: Brett Francis (BrettF)
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
;           _Bass_Tags_Startup()
;           _Bass_Tags_Read()
;           _Bass_Tags_GetLastErrorDesc()
;           _Bass_Tags_GetVersion()
; ===============================================================================================================================

Global $_ghBassTagsDll = -1
Global $BASS_TAGS_DLL_UDF_VER = "0.0.0.15"
Global $BASS_ERR_DLL_NO_EXIST = -1

; #FUNCTION# ====================================================================================================================
; Name...........: _Bass_Tags_Startup
; Description ...: Starts up BASS functions.
; Syntax.........: _Bass_Tags_Startup($sBassTagsDll)
; Parameters ....: -    $sBassTagsDll   -   The relative path to tags.dll.
; Return values .: Success  - Returns True
;   Failure     - Returns False and sets @ERROR
;                                   @error will be set to-
;                                       - $BASS_ERR_DLL_NO_EXIST    -   File could not be found.
;
;                                If the version of this UDF is not compatabile with this version of Bass, then the following
;                                error will be displayed to the user. This can be disabled by setting
;                                       $BASS_STARTUP_BYPASS_VERSIONCHECK = 1
;                                This is the error show to the user:
;                                       This version of BassTags.au3 is not made for tags.dll VX.X.X.X. Please update.
; Author ........: Prog@ndy
; Modified.......: Brett Francis (BrettF)
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _Bass_Tags_Startup($sBassTagsDll="tags.dll")
    ;Check if bass has already been started up.
    If $_ghBassTagsDll <> -1 Then Return True
    ;Check if $sBassTagsDll exists.
    If Not FileExists ($sBassTagsDll) Then Return SetError ($BASS_ERR_DLL_NO_EXIST, 0, False)
    ;Check to make sure that the version of tags.dll is compatabile with this UDF version. If not we will throw a text error.
    ;Then we will exit the program
    If $BASS_STARTUP_BYPASS_VERSIONCHECK Then
        If _VersionCompare(FileGetVersion ($sBassTagsDll), $BASS_TAGS_DLL_UDF_VER) = -1 Then
            MsgBox (0, "ERROR", "This version of BassTags.au3 is made for tags.dll V" & $BASS_TAGS_DLL_UDF_VER & ". Please update")
            Exit
        EndIf
    EndIf
    ;Open the DLL
    $_ghBassTagsDll = DllOpen($sBassTagsDll)

    ;Check if the DLL was opened correctly.
    If $_ghBassTagsDll <> 1 Then
        Return True
    Else
        Return False
    EndIf
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _Bass_Tags_
; Description ...:
; Syntax.........: _Bass_Tags_
; Parameters ....: -    $   -
; Return values .: Success  - Returns True
;   Failure     - Returns False and sets @ERROR as set by _Bass_ErrorGetCode()
;                                   @error will be set to-
;                                       - $ -
; Author ........: Brett Francis (BrettF)
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _Bass_Tags_Read ($hHandle, $sFMT)
    $_bTags_Ret_ = DllCall ($_ghBassTagsDll, "str", "TAGS_Read", "dword", $hHandle, "str", $sFMT)
    If @error Then Return SetError (1, @error, 0)
    Return $_bTags_Ret_[0]
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _Bass_Tags_
; Description ...:
; Syntax.........: _Bass_Tags_
; Parameters ....: -    $   -
; Return values .: Success  - Returns True
;   Failure     - Returns False and sets @ERROR as set by _Bass_ErrorGetCode()
;                                   @error will be set to-
;                                       - $ -
; Author ........: Brett Francis (BrettF)
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _Bass_Tags_GetLastErrorDesc ()
    $_bTags_Ret_ = DllCall ($_ghBassTagsDll, "str", "TAGS_GetLastErrorDesc")
    If @error Then Return SetError (1, @error, 0)
    Return $_bTags_Ret_[0]
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _Bass_Tags_
; Description ...:
; Syntax.........: _Bass_Tags_
; Parameters ....: -    $   -
; Return values .: Success  - Returns True
;   Failure     - Returns False and sets @ERROR as set by _Bass_ErrorGetCode()
;                                   @error will be set to-
;                                       - $ -
; Author ........: Brett Francis (BrettF)
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _Bass_Tags_GetVersion ()
    $_bTags_Ret_ = DllCall ($_ghBassTagsDll, "dword", "TAGS_GetVersion")
    If @error Then Return SetError (1, @error, 0)
    Return $_bTags_Ret_[0]
EndFunc

Example:

#include <Bass.au3>
#include <BassConstants.au3>
#include <BassTags.au3>

;Open Bass.DLL. Required for all function calls.
_BASS_STARTUP("BASS.dll")
_Bass_Tags_Startup("BassTags.dll")

;Initalize bass. Required for most functions.
_BASS_Init(0, -1, 44100, 0, "")

$file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")
;Create a stream from that file.
$MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, $BASS_MUSIC_PRESCAN)
;Check if we opened the file correctly.
If @error Then
    MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error)
    Exit
EndIf

$tags = _Bass_Tags_Read ($MusicHandle, "%IFV1(%TRCK,%TRCK. )%IFV2(%ARTI,%ICAP(%ARTI),no artist) - %IFV2(%TITL,%ICAP(%TITL) -,no title -) %IFV1(%ALBM,%IUPC(%ALBM))%IFV1(%YEAR, %(%YEAR%))")
MsgBox (0, "", $tags)

_Bass_Free()

Syntax for getting data is as follows:

- plain text like "Some song". This text is merely copied to the output.
    - special identifier, beginning with '%' to substitute for the tag value:
    "%TITL" - song title;
    "%ARTI" - song artist;
    "%ALBM" - album name;
    "%GNRE" - song genre;
    "%YEAR" - song/album year;
    "%CMNT" - comment;
    "%TRCK" - track number;
    "%COMP" - composer;
    "%COPY" - copyright;
    "%SUBT" - subtitle;
    "%AART" - album artist;
    - expression:
    "%IFV1(x,a)" - if x is not empty, then %IFV1() evaluates to a, 
    or to an empty string otherwise;
    "%IFV2(x,a,b)" - if x is not empty, then %IFV2() evaluates to a,
    else to b;
    "%IUPC(x)" - brings x to uppercase, so "%IUPC(foO)" yields "FOO";
    "%ILWC(x)" - brings x to lowercase, so "%ILWC(fOO)" yields "foo";
    "%ICAP(x)" - capitalizes first letter in each word of x, so
    "%ICAP(FoO bAR)" yields "Foo Bar";
    "%ITRM(x)" - removes beginning and trailing spaces from x;
    "%UTF8(x)" - encodes the tags in UTF-8 form (otherwise ANSI);

    - escaped symbols:
    "%%" - "%"
    "%(" - "("
    "%," - ","
    "%)" - ")"
    
    Example. Assume we have the following information in the tag:
        Title: "Nemo"
        Artist: "nightwish"
        Album: "Once"
        Track: "3"
        Year: "2004"
        
    Format string: "%IFV1(%TRCK,%TRCK. )%IFV2(%ARTI,%ICAP(%ARTI),no artist) - %IFV2(%TITL,%ICAP(%TITL) -,no title -) %IFV1(%ALBM,%IUPC(%ALBM))%IFV1(%YEAR, %(%YEAR%))"
    Output: "3.- Nightwish - Nemo - ONCE (2004)"
    
    if 'Artist' and 'Title' are empty, the output will be:
    "3. - no artist - no title - ONCE (2004)"
    
    if only 'Track' is empty, the output will be
    "Nightwish - Nemo - ONCE (2004)"

    Caution:
    "%IFV2(sometext ,a,b)" always evaluates to a, because a space after
    "sometext" causes the condition string to be not empty. This is 
    intentional.

    Another caution:
    "symbols '%(,)' are reserved, that is, they must be escaped if they are
    inteded to appear in the output. See the above example: the parens 
    around %YEAR are escaped with '%' to prevent misinterpretation.

Cheers!

Brett

Link to comment
Share on other sites

yes thats very nice !

meanwhile i wrote a gui interface to the web radio station player

i also added another "selfmade" volume display just for fun

;;;; ADDITIONAL STUFF FOR CALLBACK

; #FUNCTION# ====================================================================================================================
; Name...........: __BASS_LoadLibrary
; Author ........: Paul Campbell (PaulIA)
; ===============================================================================================================================
Func __BASS_LoadLibrary($sFileName)
    Local $aResult = DllCall("Kernel32.dll", "hwnd", "LoadLibraryA", "str", $sFileName)
    If @error Then Return SetError(1, 0, 0)
    Return $aResult[0]
EndFunc   ;==>__BASS_LoadLibrary
; #FUNCTION# ====================================================================================================================
; Name...........: __BASS_LoadLibrary
; Author ........: Prog@ndy
; ===============================================================================================================================
Func __BASS_GetProcAddress($hModule, $sFunctionName)
    Local $aResult = DllCall("Kernel32.dll", "hwnd", "GetProcAddress", "hwnd", $hModule, "str", $sFunctionName)
    If @error Then Return SetError(1, 0, 0)
    Return $aResult[0]
EndFunc   ;==>__BASS_GetProcAddress
; #FUNCTION# ====================================================================================================================
; Name...........: __BASS_LoadLibrary
; Author ........: Prog@ndy
; ===============================================================================================================================
Func __BASS_GetModuleHandle($sFileName)
    Local $aResult = DllCall("Kernel32.dll", "hwnd", "GetModuleHandleA", "str", $sFileName)
    If @error Then Return SetError(1, 0, HWnd(0))
    Return $aResult[0]
EndFunc   ;==>__BASS_GetModuleHandle
; #FUNCTION# ====================================================================================================================
; Name...........: __BASS_DLLSLOADED
; Author ........: Prog@ndy
; Return Values: Bass.dll loaded: return 1
;                Bassvb.dll loaded return 2
;                both loaded: return 3
;                none loaded: return 0
; ===============================================================================================================================
Func __BASS_DLLSLOADED()
    Local $bass = Number(__BASS_GetModuleHandle("BASS")) > 0
    Local $basscb = Number(__BASS_GetModuleHandle("BASSCB")) > 0
    Return $bass + ($basscb * 2)
EndFunc   ;==>__BASS_DLLSLOADED

Global Const $hLibBassCB = __BASS_LoadLibrary("BassCB.dll")

Global Const $DownloadProc = __BASS_GetProcAddress($hLibBassCB, "DownloadProc@12")
Global Const $StreamProc = __BASS_GetProcAddress($hLibBassCB, "StreamProc@16")
Global Const $StreamProcWriteFile = __BASS_GetProcAddress($hLibBassCB, "StreamProcWriteFile@16")


; ===============================================================================================================================
; ===============================================================================================================================
; ===============================================================================================================================

;
; Bass Radio Station Player GUI
; code based on Example_3 and bass_ext.au3
;
; author Nobbe 2009


;   swr3.de
;   http://edge.live.mp3.mdn.newmedia.nacamar.net/swr3live/livestream.mp3

;   dasding.de
;   http://62.27.44.15/swrdasdinglive/livestream.mp3

;   trance
;   http://scfire-ntc-aa03.stream.aol.com/stream/1065
;
; 977 hitz
; http://scfire-mtc-aa02.stream.aol.com:80/stream/1074

; top 100 station.de
; http://188.72.209.66:80


#include <Bass.au3>
#include <BassConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>

Global $playing_state = -1
Global $MusicHandle = -1
Global $file

Global $vol_left[51], $vol_right[51];
global $glob_update_display


;Open Bass.DLL.  Required for all function calls.
_BASS_STARTUP("BASS.dll")

;Initalize bass.  Required for most functions.
_BASS_Init(0, -1, 44100, 0, "")
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf







;Create GUI and controls
$GUI = GUICreate("Radio Station Player", 380, 190, 193, 115);

;$lblFileName = GUICtrlCreateLabel($file, 8, 8, 379, 17)
$lblFileName = GUICtrlCreateLabel("", 8, 8, 379, 17)

$lbl_title = GUICtrlCreateLabel("", 10, 80, 200, 25, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

$lbl_artist = GUICtrlCreateLabel("", 10, 105, 200, 25, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

; set vertical now for volume
$progress_leftVol = GUICtrlCreateProgress(330, 80, 12, 100, $PBS_VERTICAL)
GUICtrlSetLimit(-1, 100, 0)
$progress_rightVol = GUICtrlCreateProgress(343, 80, 12, 100, $PBS_VERTICAL)
GUICtrlSetLimit(-1, 100, 0)


$edit_input = GUICtrlCreateInput("http://scfire-ntc-aa03.stream.aol.com/stream/1065", 10, 40, 350, 20)
$btn_tune_in = GUICtrlCreateButton("tune in", 216, 70, 75, 25, 0)

;
$Play_pause = GUICtrlCreateButton("Play/Pause", 216, 160, 75, 25, 0)


;Show GUI
GUISetState(@SW_SHOW)

GUICtrlSetData($progress_rightVol, 0)
GUICtrlSetData($progress_leftVol, 0)


_setup_volume()
;; loop

While 1

    If $playing_state = 1 Then


        ;Get Channel levels.
        $levels = _BASS_ChannelGetLevel($MusicHandle)

        ;Get Right and calculate percentage
        $rightChLvl = _LoWord($levels)
        $rightChLvlper = Round(($rightChLvl / 32768) * 100, 0)
        ;Get Left and calculate percentage
        $LeftChLvl = _HiWord($levels)
        $leftChLvlper = Round(($LeftChLvl / 32768) * 100, 0)
        ;Set the levels on GUI.

        GUICtrlSetData($progress_rightVol, $rightChLvlper)
        GUICtrlSetData($progress_leftVol, $leftChLvlper)
        
        _show_volume($leftChLvlper, $rightChLvlper);

    EndIf

    ;Get GUI Message
    $nMsg = GUIGetMsg()
    Switch $nMsg

        ;If Close button or red x, then exit.  Alway remember to free resources
        Case $GUI_EVENT_CLOSE ; , $Close
            Exit

        Case $btn_tune_in
            $st = GUICtrlRead($edit_input)
            ;MsgBox(0, '', "Stream is: " & $st)
            init_station($st);



        Case $Play_pause
            ;Check if playing or paused, then take appropriate action
            Switch $playing_state

                Case 0; Song Paused, Resume.
                    ;Resume Song
                    _BASS_Start() ; was bug
                    $playing_state = 1

                Case - 1 ; Song stopped, start from begining.
                    ;Play Song
                    _BASS_ChannelPlay($MusicHandle, 1)
                    $playing_state = 1

                Case 1 ; Song Playing, Pause
                    ;Pause song
                    _BASS_Pause()
                    $playing_state = 0

                    GUICtrlSetData($progress_rightVol, 0)
                    GUICtrlSetData($progress_leftVol, 0)
                    
                    _show_volume(0, 0)
                    

            EndSwitch


    EndSwitch

    Sleep(20)
WEnd

Func OnAutoItExit()
    ;Free Resources
    _BASS_Free()
EndFunc   ;==>OnAutoItExit



; open station and reset values
Func init_station($station)

    _BASS_StreamFree($MusicHandle)

    ;Create a stream from that URL.
    $MusicHandle = _BASS_StreamCreateURL($station, 0, 0, $DownloadProc, 0)

    GUICtrlSetData($lblFileName, $file);

    GUICtrlSetData($progress_rightVol, 0)
    GUICtrlSetData($progress_leftVol, 0)

    _show_volume(0, 0)


    ; start playback
    _BASS_ChannelPlay($MusicHandle, 1)
    $playing_state = 1

EndFunc   ;==>init_station



;
; setup a bunch of controls as array to display the volume
;
Func _setup_volume()
    Local $color_red = 0xff0000
    Local $color_grey = 0xcccccc
    
    $left   = 10
    $top    = 180
    $height     = 3
    $width = 10
    
    For $m = 0 To 25
        $vol_left[$m] = GUICtrlCreateLabel("", $left, $top, $width, $height)
        GUICtrlSetBkColor($vol_left[$m], $color_grey)
        $top = $top - $height - 1 ;
    Next

    $left = $left + $width + 3
    $top = 180

    ;right slider
    For $m = 0 To 25
        $vol_right[$m] = GUICtrlCreateLabel("", $left, $top, $width, $height)
        GUICtrlSetBkColor($vol_right[$m], $color_grey)
        $top = $top - $height - 1 ;
    Next
    
    
EndFunc   ;==>_setup_volume




;
; set the volume "display" to ....
;
; his takes o LOT of cpu cycles :-(
;
Func _show_volume($l, $r)
    Local $color_red = 0xff0000
    Local $color_grey = 0xcccccc

if $glob_update_display = 4 then ; every 4th 

    For $m = 0 To 50
        If ($l / 4) > $m Then
            
            GUICtrlSetBkColor($vol_left[$m], $color_red)
        Else
            GUICtrlSetBkColor($vol_left[$m], $color_grey)
        EndIf

        If ($r / 4) > $m Then
            
            GUICtrlSetBkColor($vol_right[$m], $color_red)
        Else
            GUICtrlSetBkColor($vol_right[$m], $color_grey)
        EndIf
    Next
    
    $glob_update_display =0
endif   
$glob_update_display = $glob_update_display +1 ;
    
EndFunc   ;==>_show_volume
Edited by nobbe
Link to comment
Share on other sites

a bug with 64 bit

when i run it from the 64 bit version "AutoIt3_x64.exe" it fails on the function

"Could not initialize audio" from the routine

;Initalize bass. Required for most functions.

_BASS_Init(0, -1, 44100, 0, "")

If @error Then

MsgBox(0, "Error", "Could not initialize audio")

Exit

EndIf

when i use the 32 bit "AutoIt3.exe" it works fine

Link to comment
Share on other sites

a bug with 64 bit

when i run it from the 64 bit version "AutoIt3_x64.exe" it fails on the function

"Could not initialize audio" from the routine

;Initalize bass. Required for most functions.

_BASS_Init(0, -1, 44100, 0, "")

If @error Then

MsgBox(0, "Error", "Could not initialize audio")

Exit

EndIf

when i use the 32 bit "AutoIt3.exe" it works fine

The bass.dll is compiled as 32bit. So it works only with AutoIt in 32bit mode and not in a x64-script.

//Edit: try the x64-builds from here. There could be some bugs in the AutoIt UDFs though due to wrong datatypes in the DLLCalls (no problem on 32bit, but on 64bit)

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

  • 2 weeks later...

How to use the examples? i downloaded the bass.rar unzipped it, and i ran the example recorder in BASS_ENC\Examples.

I ofcourse i also put all the dlls and au3 in the same directory, but i get tons of errors still.

C:\AudioRecordings\BassEnc.au3(108,38) : WARNING: $bassenc_dll: possibly used before declaration.   $BASSENC_ret_ = DllCall($bassenc_dll,   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(109,42) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.    $error = _BASS_ErrorGetCode($bassenc_dll)   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(159,39) : WARNING: $bass_dll: possibly used before declaration.    $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(159,39) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.   $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(183,39) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.   $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(210,39) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.   $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(235,39) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.   $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(263,39) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.   $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(297,39) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.   $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(325,39) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.   $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(350,39) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.   $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(374,39) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.   $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(411,39) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.   $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(437,39) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.   $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(466,39) : ERROR: _BASS_ErrorGetCode() called with wrong number of args.   $error = _BASS_ErrorGetCode($bass_dll)  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode(). Func _BASS_ErrorGetCode() ~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\BassEnc.au3(108,38) : ERROR: $bassenc_dll: undeclared global variable.    $BASSENC_ret_ = DllCall($bassenc_dll,   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\example.au3(11,19) : ERROR: _BASS_ENC_STARTUP(): undefined function. _BASS_ENC_STARTUP() ~~~~~~~~~~~~~~~~~~^ C:\AudioRecordings\example.au3 - 15 error(s), 2 warning(s)
Link to comment
Share on other sites

It seems I never finished it.

#include-once

;Include Bass.au3
#include <Bass.au3>

;Include Constants
#include <BassEncConstants.au3>

; #INDEX# =======================================================================================================================
; Title .........: _BassEnc.au3
; Description ...: Almost all of BASSENC.DLL translated ready for easy use with AutoIt
;   Bass.dll and Bass.au3 is needed
; Author ........: Eukalyptus, based on BASS.au3/Brett Francis (BrettF)
; Modified ......: BrettF
; ===============================================================================================================================

; #ToDo#=========================================================================================================================
;function BASS_Encode_GetACMFormat(handle:DWORD; form:Pointer; formlen:DWORD; title:PChar; flags:DWORD): DWORD;
;function BASS_Encode_StartACM(handle:DWORD; form:Pointer; flags:DWORD; proc:ENCODEPROC; user:Pointer): HENCODE;
;function BASS_Encode_StartACMFile(handle:DWORD; form:Pointer; flags:DWORD; filename:PChar): HENCODE; stdcall;
; ===============================================================================================================================

; #CURRENT# =====================================================================================================================
;   _BASS_Encode_GetVersion()
;   _BASS_Encode_Start()
;   _BASS_Encode_IsActive()
;   _BASS_Encode_Stop()
;   _BASS_Encode_SetPaused()
;   _BASS_Encode_Write()
;   _BASS_Encode_SetNotify()
;   _BASS_Encode_GetCount()
;   _BASS_Encode_SetChannel()
;   _BASS_Encode_GetChannel()
;   _BASS_Encode_CastInit()
;   _BASS_Encode_CastSetTitle()
;   _BASS_Encode_CastGetStats()
; ===============================================================================================================================

; #INTERNAL_USE_ONLY#============================================================================================================
; _MakeLong()
; ===============================================================================================================================

Global $_ghBassEncDll = -1
Global $BASS_ENC_DLL_UDF_VER = "2.4.6.0"
Global $BASS_ERR_DLL_NO_EXIST = -1

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_Startup
; Description ...: Starts up BassCD functions.
; Syntax.........: _BASS_EncodeStartup($sBassEncDll)
; Parameters ....: -    $sBassEncDll    -   The relative path to BassEnc.dll.
; Return values .: Success  - Returns True
;   Failure     - Returns False and sets @ERROR
;                                   @error will be set to-
;                                       - $BASS_ERR_DLL_NO_EXIST    -   File could not be found.
;                                If the version of this UDF is not compatabile with this version of Bass, then the following
;                                error will be displayed to the user. This can be disabled by setting
;                                       $BASS_STARTUP_BYPASS_VERSIONCHECK = 1
;                                This is the error show to the user:
;                                       This version of Bass.au3 is not made for Bass.dll VX.X.X.X. Please update.
; Author ........: Prog@ndy
; Modified.......: Brett Francis (BrettF)
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_Startup($sBassEncDll = "bassenc.dll")
    ;Check if bass has already been started up.
    If $_ghBassEncDll <> -1 Then Return True
    ;Check if $sBassDLL exists.
    If Not FileExists($sBassEncDll) Then Return SetError($BASS_ERR_DLL_NO_EXIST, 0, False)
    ;Check to make sure that the version of Bass.DLL is compatabile with this UDF version. If not we will throw a text error.
    ;Then we will exit the program
    If $BASS_STARTUP_BYPASS_VERSIONCHECK Then
        If _VersionCompare(FileGetVersion($sBassEncDll), $BASS_ENC_DLL_UDF_VER) = -1 Then
            MsgBox(0, "ERROR", "This version of BASSASIO.au3 is made for BassASIO.dll V" & $BASS_ENC_DLL_UDF_VER & ". Please update")
            Exit
        EndIf
    EndIf
    ;Open the DLL
    $_ghBassEncDll = DllOpen($sBassEncDll)

    ;Check if the DLL was opened correctly.
    If $_ghBassEncDll <> 1 Then
        Return True
    Else
        Return False
    EndIf
EndFunc ;==>_BASS_Encode_Startup

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_GetVersion
; Description ...: Retrieves the version of BASSENC that is loaded.
; Syntax.........: _BASS_Encode_GetVersion()
; Parameters ....: $bass_dll    -   Handle to opened Bass.dll
;   $_ghBassEncDll  -   Handle to opened Bassenc.dll
; Return values .: Success  -   Returns Version
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_GetVersion()
    $BASSENC_ret_ = DllCall($_ghBassEncDll, "int", "BASS_Encode_GetVersion")
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_GetVersion

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_Start
; Description ...: Sets up an encoder on a channel.
; Syntax.........: _BASS_Encode_Start($handle, $cmdline, $flags, $proc = "", $user = "")
; Parameters ....: $handle      -   The channel handle... a HSTREAM, HMUSIC, or HRECORD.
;                $cmdline   -   The encoder command-line, including the executable filename and any options. Or the output filename if the BASS_ENCODE_PCM flag is specified.
;                $flags         -   A combination of these flags:
;                       |$BASS_ENCODE_PCM       -   Write plain PCM sample data to a file, without an encoder. The output filename is given in the cmdline parameter.
;                       |BASS_ENCODE_NOHEAD     -   Don't send a WAVE header to the encoder. If this flag is used then the sample format must be passed to the encoder some other way, eg. via the command-line.
;                       |$BASS_ENCODE_BIGEND    -   Send big-endian sample data to the encoder, else little-endian. This flag is ignored unless the BASS_ENCODE_NOHEAD flag is used, as WAV files are little-endian.
;                       |$BASS_ENCODE_FP_8BIT
;                       |$BASS_ENCODE_FP_16BIT
;                       |$BASS_ENCODE_FP_24BIT
;                       |$BASS_ENCODE_FP_32BIT  -   When you want to encode a floating-point channel, but the encoder does not support 32-bit floating-point sample data, then you can use one of these flags to have the sample data converted to 8/16/24/32 bit integer data before it is passed on to the encoder. These flags are ignored if the channel's sample data is not floating-point.
;                       |$BASS_ENCODE_PAUSE     -   Start the encoder paused.
;                       |$BASS_ENCODE_AUTOFREE  -   Automatically free the encoder when the source channel is freed.
;                       |$BASS_UNICODE          -   cmdline is Unicode (UTF-16).
;                $proc      -   Optional callback function to receive the encoded data...To have the encoded data received by a callback function, the encoder needs to be told to output to STDOUT (instead of a file).
;   |Callback function has the following paramaters:
;                       |$handle    -   The stream that needs writing.
;                       |$buffer    -   Pointer to the buffer to write the sample data in.
;                       |$length    -   The maximum number of bytes to write.
;                       |$user      -   The user instance data:
;                $user      -   User instance data to pass to the callback function.
; Return values .: Success  -   Returns Encoder Handle
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_Start($handle, $cmdline, $flags, $proc = "", $user = "")
    If $proc <> "" Then
        $dc = DllCallbackRegister($proc, "int", "dword;ptr;dword;ptr;")
        $dsUser = DllStructCreate("char[255]")
        DllStructSetData($dsUser, 1, $user)
        $BASSENC_ret_ = DllCall($_ghBassEncDll, "dword", "BASS_Encode_Start", "dword", $handle, "str", $cmdline, "dword", $flags, "ptr", DllCallbackGetPtr($dc), "ptr", DllStructGetPtr($dsUser))
    Else
        $BASSENC_ret_ = DllCall($_ghBassEncDll, "dword", "BASS_Encode_Start", "dword", $handle, "str", $cmdline, "dword", $flags, "ptr", 0, "ptr", 0)
    EndIf
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_Start

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_Stop
; Description ...: Stops an encoder or all encoders on a channel.
; Syntax.........: _BASS_Encode_Stop($handle)
; Parameters ....: $handle      -   The encoder or channel handle... a HENCODE, HSTREAM, HMUSIC, or HRECORD.
; Return values .: Success  -   Returns True
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_Stop($handle)
    $BASSENC_ret_ = DllCall($_ghBassEncDll, "int", "BASS_Encode_Stop", "dword", $handle)
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_Stop

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_IsActive
; Description ...: Checks if an encoder is running.
; Syntax.........: _BASS_Encode_IsActive($handle)
; Parameters ....: $handle      -   The encoder or channel handle... a HENCODE, HSTREAM, HMUSIC, or HRECORD.
; Return values .: Success      -   The return value is one of the following:
;                       |$BASS_ACTIVE_STOPPED   -   The encoder isn't running.
;                       |BASS_ACTIVE_PLAYING    -   The encoder is running.
;                       |$BASS_ACTIVE_PAUSED    -   The encoder is paused.
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_IsActive($handle)
    $BASSENC_ret_ = DllCall($_ghBassEncDll, "dword", "BASS_Encode_IsActive", "dword", $handle)
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_IsActive

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_SetPaused
; Description ...: Pauses or resumes an encoder, or all encoders on a channel.
; Syntax.........: _BASS_Encode_SetPaused($handle, $paused)
; Parameters ....: $handle      -   The encoder or channel handle... a HENCODE, HSTREAM, HMUSIC, or HRECORD.
;   $paused     -   True = paused, False = Not paused
; Return values .: Success      -   Returns True
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_SetPaused($handle, $paused)
    $BASSENC_ret_ = DllCall($_ghBassEncDll, "int", "BASS_Encode_SetPaused", "dword", $handle, "int", $paused)
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_SetPaused

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_Write
; Description ...: Sends sample data to an encoder or all encoders on a channel.
; Syntax.........: _BASS_Encode_Write($handle, $buffer, $length)
; Parameters ....: $handle      -   The encoder or channel handle... a HENCODE, HSTREAM, HMUSIC, or HRECORD.
;   $buffer     -   The buffer containing the sample data.
;   $length     -   The number of BYTES in the buffer.
; Return values .: Success      -   Returns True
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_Write($handle, $buffer, $length)
    $ds_buffer = DllStructCreate("char[255]")
    DllStructSetData($ds_buffer, 1, $buffer)
    $BASSENC_ret_ = DllCall($_ghBassEncDll, "int", "BASS_Encode_Write", "dword", $handle, "ptr", DllStructGetPtr($ds_buffer), "DWORD", $length)
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_Write

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_SetNotify
; Description ...: Sets a callback function on an encoder (or all encoders on a channel) to receive notifications about its status.
; Syntax.........: _BASS_Encode_SetNotify($handle, $proc, $user)
; Parameters ....: $handle      -   The encoder or channel handle... a HENCODE, HSTREAM, HMUSIC, or HRECORD.
;   $proc       -   Callback function to receive the notifications
;   |Callback function has the following paramaters:
;                       |$handle    -   The stream that needs writing.
;                       |$buffer    -   Pointer to the buffer to write the sample data in.
;                       |$length    -   The maximum number of bytes to write.
;                       |$user      -   The user instance data:
;   $user       -   User instance data to pass to the callback function
; Return values .: Success      -   Returns True
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_SetNotify($handle, $proc, $user)
    $dc = DllCallbackRegister($proc, "int", "dword;ptr;dword;ptr;")
    $dsUser = DllStructCreate("char[255]")
    DllStructSetData($dsUser, 1, $user)
    $BASSENC_ret_ = DllCall($_ghBassEncDll, "int", "BASS_Encode_SetNotify", "dword", $handle, "ptr", DllCallbackGetPtr($dc), "ptr", DllStructGetPtr($dsUser))
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_SetNotify

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_GetCount
; Description ...: Retrieves the amount data sent to or received from an encoder, or sent to a cast server.
; Syntax.........: _BASS_Encode_GetCount($handle, $count)
; Parameters ....: $handle      -   The encoder handle
;   $count      -   The count to retrieve. One of the following:
;           |$BASS_ENCODE_COUNT_IN      -   Data sent to the encoder.
;           |$BASS_ENCODE_COUNT_OUT     -   Data received from the encoder. This only applies when the encoder outputs to STDOUT or it is an ACM encoder.
;           |$BASS_ENCODE_COUNT_CAST    -   Data sent to a cast server.
; Return values .: Success  -   the requested count (in bytes) is returned
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_GetCount($handle, $count)
    $BASSENC_ret_ = DllCall($_ghBassEncDll, "dword", "BASS_Encode_GetCount", "dword", $handle, "dword", $count)
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_GetCount

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_SetChannel
; Description ...: Moves an encoder (or all encoders on a channel) to another channel.
; Syntax.........: _BASS_Encode_SetChannel($handle, $channel)
; Parameters ....: $handle      -   The encoder or channel handle... a HENCODE, HSTREAM, HMUSIC, or HRECORD.
;   $channel        -   The channel to move the encoder(s) to... a HSTREAM, HMUSIC, or HRECORD.
; Return values .: Success      -   Returns True
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_SetChannel($handle, $channel)
    $BASSENC_ret_ = DllCall($_ghBassEncDll, "int", "BASS_Encode_SetChannel", "dword", $handle, "dword", $channel)
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_SetChannel

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_GetChannel
; Description ...: Retrieves the channel that an encoder is set on.
; Syntax.........: _BASS_Encode_GetChannel($handle)
; Parameters ....: $handle      -   The encoder or channel handle... a HENCODE, HSTREAM, HMUSIC, or HRECORD.
; Return values .: Success  -   the encoder's channel handle is returned
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_GetChannel($handle)
    $BASSENC_ret_ = DllCall($_ghBassEncDll, "dword", "BASS_Encode_GetChannel", "dword", $handle)
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_GetChannel

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_CastInit
; Description ...: Initializes sending an encoder's output to a Shoutcast or Icecast server.
; Syntax.........: _BASS_Encode_CastInit($handle, $server, $pass, $content, $name, $url, $genre, $desc, $headers, $bitrate, $pub)
; Parameters ....: $handle      -   The encoder handle.
;   $server         -   The server to send to, in the form of "address:port" (Shoutcast) or "address:port/mount" (Icecast).
;   $pass       -   The server password.
;   $content    -   The MIME type of the encoder output. This can be one of the following:
;           |$BASS_ENCODE_TYPE_MP3  -   MP3.
;           |$BASS_ENCODE_TYPE_OGG  -   OGG.
;           |$BASS_ENCODE_TYPE_AAC  -   AAC.
;   $name       -   The stream name... NULL = no name.
;   $url        -   The URL, for example, of the radio station's webpage... NULL = no URL.
;   $genre      -   The genre... NULL = no genre.
;   $desc       -   Description... NULL = no description. This applies to Icecast only.
;   $headers    -   Other headers to send to the server... NULL = none. Each header should end with a carriage return and line feed ("\r\n").
;   $bitrate    -   The bitrate (in kbps) of the encoder output... 0 = undefined bitrate. In cases where the bitrate is a "quality" (rather than CBR) setting, the headers parameter can be used to communicate that instead, eg. "ice-bitrate: Quality 0\r\n".
;   $pub        -   Public? If TRUE, the stream is added to the public directory of streams, at shoutcast.com or dir.xiph.org (or as defined in the server config).
; Return values .: Success  -   Returns True
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_CastInit($handle, $server, $pass, $content, $name, $url, $genre, $desc, $headers, $bitrate, $pub)
    $BASSENC_ret_ = DllCall($_ghBassEncDll, "int", "BASS_Encode_CastInit", "dword", $handle, "str", $server, "str", $pass, "str", $content, "str", $name, "str", $url, "str", $genre, "str", $desc, "str", $headers, "dword", $bitrate, "int", $pub)
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_CastInit

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_CastSetTitle
; Description ...: Sets the title of a cast stream.
; Syntax.........: _BASS_Encode_CastSetTitle($title, $url)
; Parameters ....: $handle      -   The encoder handle
;   $title      -   The title.
;   $url            -   URL to go with the title... NULL = no URL. This applies to Shoutcast only.
; Return values .: Success      -   Returns True
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_CastSetTitle($handle, $title, $url)
    $BASSENC_ret_ = DllCall($_ghBassEncDll, "int", "BASS_Encode_CastSetTitle", "dword", $handle, "str", $title, "str", $url)
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_CastSetTitle

; #FUNCTION# ====================================================================================================================
; Name...........: _BASS_Encode_CastGetStats
; Description ...: Retrieves stats from the Shoutcast or Icecast server.
; Syntax.........: _BASS_Encode_CastGetStats($stype, $pass)
; Parameters ....: $handle      -   The encoder handle
;   $stype      -   The type of stats to retrieve. One of the following.
;           |$BASS_ENCODE_STATS_SHOUT       -   Shoutcast stats, including listener information and additional server information.
;           |$BASS_ENCODE_STATS_ICE         -   Icecast mount-point listener information.
;           |$BASS_ENCODE_STATS_ICESERV     -   Icecast server stats, including information on all mount points on the server.
;   $pass       -   Password when retrieving Icecast server stats... NULL = use the password provided in the _BASS_Encode_CastInit call.
; Return values .: Success      -   the stats are returned
;                Failure    -   Returns 0 and sets @ERROR to error returned by _BASS_ErrorGetCode()
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _BASS_Encode_CastGetStats($handle, $stype, $pass)
    $BASSENC_ret_ = DllCall($_ghBassEncDll, "int", "BASS_Encode_CastGetStats", "dword", $handle, "dword", $stype, "str", $pass)
    $error = _BASS_ErrorGetCode()
    If $error <> 0 Then
        Return SetError($error, "", 0)
    Else
        Return SetError(0, "", $BASSENC_ret_[0])
    EndIf
EndFunc ;==>_BASS_Encode_CastGetStats

; #INTERNAL# ====================================================================================================================
; Name...........: _MakeLong
; Description ...: Returns longword where $lo_value is the lo_word and $hi_value is the hi_word
; Syntax.........: _MakeLong($lo_value, $hi_value)
; Parameters ....:  -   $lo_value
;   - $hi_value
; Return values .: Success  - Returns longword value
; Author ........: Eukalyptus
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......;
; ===============================================================================================================================
Func _MakeLong($lo_value, $hi_value)
    Return BitOR(BitAND($hi_value * 0x10000, 0xFFFF0000), BitAND($lo_value, 0xFFFF))
EndFunc ;==>_MakeLong
Link to comment
Share on other sites

Hi,

First of all congratulations and thanks for the work you guys are putting to this lbi, it's truly wonderful.

I'm having issues with the example script in the latest version. I can't seem to be able to run bass_encoder properly. I tried modifying the lines that gave errors and it sort of worked, as in it didn't give me errors, but then it wasn't showing any devices, wouldn't list them, etc.

Frist it told me soemthing about the dll variable not benig an array, which only coems to say that bass_encoder doesn't have proper error handling... and then when I fixed that there was an error because bass_enc_Startup doesn't exist and it was encode_startup.. and some other stuff I had to fix related to error handling, and then ti ran fine but wasn't showing or doing anything.

I hope this can get fixed, this is truly an awesome lib.

Link to comment
Share on other sites

Hi there,

It took a while but I think I've found the issue.

First step is to open Bass.au3. Find the function _BASS_RecordGetInputName. Replace it with the following:

Func _BASS_RecordGetInputName($inputn)
    Local $BASS_ret_ = DllCall($_ghBassDll, "ptr", "BASS_RecordGetInputName", "int", $inputn)
    If @error Then Return SetError(1,1,0)
    If $BASS_ret_[0] = "" Then Return SetError(_BASS_ErrorGetCode(),0,$BASS_ret_[0])
    $struc = DllStructCreate ("char[255]", $BASS_ret_[0])
    Return DllStructGetData ($struc, 1)
EndFunc ;==>_BASS_RecordGetInputName

Make sure the following files are present with the example:

  • Bass.au3
  • bass.dll
  • basscb.dll
  • BassConstants.au3
  • BassEnc.au3
  • bassenc.dll
  • BassEncConstants.au3
  • lame.exe
The example (slightly updated) should be (BassEnc\Example\example.au3):

#include <BassEnc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>

Opt("GUIOnEventMode", 1)

Global $device, $input, $EncHandle, $RecHandle, $Bitrate = 128, $KHZ = 44100, $levels, $levelL = 0, $levelR = 0, $temp, $EncState = False

_BASS_STARTUP()
_BASS_Encode_STARTUP()
$basscb_dll = DllOpen("BASSCB.dll")

$hGui = GUICreate("Bass.dll / BassEnc.dll Recording Test", 320, 320)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUICtrlCreateLabel("Select AudioDevice:", 10, 10)
$hDevice = GUICtrlCreateCombo("", 10, 30, 300, 20, BitOR($CBS_DROPDOWN, $CBS_DROPDOWNLIST, $WS_VSCROLL))
GUICtrlSetOnEvent(-1, "_SelectDevice")
GUICtrlCreateLabel("Select AudioInput:", 10, 60)
$hInput = GUICtrlCreateCombo("", 10, 80, 300, 20, BitOR($CBS_DROPDOWN, $CBS_DROPDOWNLIST, $WS_VSCROLL))
GUICtrlSetOnEvent(-1, "_SelectInput")
$hMp3 = GUICtrlCreateRadio("Mp3", 50, 110, 50)
$hWav = GUICtrlCreateRadio("Wav", 50, 130, 50)
GUICtrlSetState(-1, $GUI_CHECKED)
$hBitrate = GUICtrlCreateCombo("", 120, 110, 50, 20, BitOR($CBS_DROPDOWN, $CBS_DROPDOWNLIST, $WS_VSCROLL))
GUICtrlSetData(-1, "32|40|48|56|64|80|96|112|128|160|192|224|256|320", "128")
GUICtrlCreateLabel("KBit/s", 180, 113, 50)
$hPeakL = GUICtrlCreateProgress(10, 160, 300, 10)
$hPeakR = GUICtrlCreateProgress(10, 175, 300, 10)
GUICtrlCreateLabel("Encoder Active:", 10, 200)
$hEncActive = GUICtrlCreateLabel("", 120, 200, 200)
GUICtrlCreateLabel("Data sent to Encoder:", 10, 220)
$hEncCount = GUICtrlCreateLabel("", 120, 220, 200)
GUICtrlCreateLabel("Filesize:", 10, 240)
$hFilesize = GUICtrlCreateLabel("", 120, 240, 200)
$hStart = GUICtrlCreateButton("Start", 20, 280, 130, 20)
GUICtrlSetOnEvent(-1, "_Start")
$hStop = GUICtrlCreateButton("Stop", 170, 280, 130, 20)
GUICtrlSetOnEvent(-1, "_Stop")
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()


;_BASS_SetConfig($BASS_CONFIG_REC_BUFFER, 1000)
$device = _GetDevices()
$r = _BASS_RecordInit($device)
$input = _GetInputs()
$temp = DllCall($basscb_dll, "dword", "RecordStart", "dword", $KHZ, "dword", 2, "dword", _makelong($BASS_SAMPLE_FX, 10))
$RecHandle = $temp[0]

$timer = TimerInit()
While 1
    Sleep(20)
    $peak = _BASS_ChannelGetLevel($RecHandle)
    If Not @error Then
        $temp = (_LoWord($peak) / 32768) * 100
        If $temp > $levelL Then $levelL = $temp
        $temp = (_HiWord($peak) / 32768) * 100
        If $temp > $levelR Then $levelR = $temp
        GUICtrlSetData($hPeakL, $levelL)
        GUICtrlSetData($hPeakR, $levelR)
        $levelL -= 4
        $levelR -= 4
    Else
        ToolTip(@error)
    EndIf
    If TimerDiff($timer) > 200 Then
        $timer = TimerInit()
        GUICtrlSetData($hEncActive, _BASS_Encode_IsActive($EncHandle))
        If $EncState Then
            GUICtrlSetData($hEncCount, _BASS_Encode_GetCount($EncHandle, $BASS_ENCODE_COUNT_IN))
            If GUICtrlRead($hWav) = $GUI_CHECKED Then
                GUICtrlSetData($hFilesize, Round(FileGetSize(@ScriptDir & "\Test.wav") / 1024, 2) & " kb")
            Else
                GUICtrlSetData($hFilesize, Round(FileGetSize(@ScriptDir & "\Test.mp3") / 1024, 2) & " kb")
            EndIf
        EndIf
    EndIf
WEnd

Func _Start()
    GUICtrlSetState($hDevice, $GUI_DISABLE)
    GUICtrlSetState($hInput, $GUI_DISABLE)
    GUICtrlSetState($hStart, $GUI_DISABLE)
    GUICtrlSetState($hMp3, $GUI_DISABLE)
    GUICtrlSetState($hWav, $GUI_DISABLE)
    GUICtrlSetState($hBitrate, $GUI_DISABLE)
    GUICtrlSetState($hStop, $GUI_ENABLE)
    If GUICtrlRead($hWav) = $GUI_CHECKED Then
        $EncHandle = _BASS_Encode_Start($RecHandle, @ScriptDir & "\Test.wav", $BASS_ENCODE_PCM)
    Else
        $EncHandle = _BASS_Encode_Start($RecHandle, 'lame -r -x -b' & GUICtrlRead($hBitrate) & ' -h - "' & @ScriptDir & '\Test.mp3"', 0)
    EndIf
    $EncState = True
EndFunc ;==>_Start

Func _Stop()
    GUICtrlSetState($hDevice, $GUI_ENABLE)
    GUICtrlSetState($hInput, $GUI_ENABLE)
    GUICtrlSetState($hStart, $GUI_ENABLE)
    GUICtrlSetState($hMp3, $GUI_ENABLE)
    GUICtrlSetState($hWav, $GUI_ENABLE)
    GUICtrlSetState($hBitrate, $GUI_ENABLE)
    GUICtrlSetState($hStop, $GUI_DISABLE)
    _BASS_Encode_Stop($EncHandle)
    $EncState = False
EndFunc ;==>_Stop

Func _SelectDevice()
    Local $new = _GUICtrlComboBox_GetCurSel($hDevice)
    If $new = $device Then Return
    _BASS_RecordFree()
    _BASS_RecordSetDevice($new)
    _BASS_Recordinit($new)
    GUICtrlSetData($hInput, "", "")
    _GetInputs()
    $temp = DllCall($basscb_dll, "dword", "RecordStart", "dword", $KHZ, "dword", 2, "dword", _makelong($BASS_SAMPLE_FX, 10))
    $RecHandle = $temp[0]
    $device = $new
EndFunc ;==>_SelectDevice

Func _SelectInput()
    Local $new = _GUICtrlComboBox_GetCurSel($hInput)
    If $new = $input Then Return
    _BASS_RecordSetInput($new, $BASS_INPUT_ON, -1)
    $input = $new
EndFunc ;==>_SelectInput

Func _GetDevices()
    Local $count = 0, $info, $name = "", $sdef = "", $idef = 0
    While 1
        $info = _BASS_RecordGetDeviceInfo($count)
        If @error Then ExitLoop
        $count += 1
        If BitAND($info[2], $BASS_DEVICE_ENABLED) Then $name &= $info[0] & "|"
        If BitAND($info[2], $BASS_DEVICE_DEFAULT) Then
            $sdef = $info[0]
            $idef = $count
        EndIf
    WEnd
    GUICtrlSetData($hDevice, $name, $sdef)
    Return $idef - 1
EndFunc ;==>_GetDevices

Func _GetInputs()
    Local $count = 0, $info, $name = "", $flags, $sdef = "", $idef = 0
    $info = _BASS_RecordGetInputName($count)
    While $info <> ""
        $flags = _BASS_RecordGetInput($count)
        $count += 1
        $name &= $info & "|"
        If BitAND($flags[0], $BASS_INPUT_OFF) = 0 Then
            $sdef = $info
            $idef = $count
        EndIf
        $info = _BASS_RecordGetInputName($count)
    WEnd
    GUICtrlSetData($hInput, $name, $sdef)
    Return $idef - 1
EndFunc ;==>_GetInputs

Func _Exit()
    If _BASS_Encode_IsActive($EncHandle) Then _BASS_Encode_Stop($EncHandle)
    _BASS_RecordFree()
    Exit
EndFunc ;==>_Exit

This is something i just recorded to an MP3 using the example. Seemed to work fine once you do that ;)

Test.mp3

Link to comment
Share on other sites

Nice guitar playing there *grins*. Anyway, I put all the files in the example folder and now it just crashes on my box. I'm going to see if I can bring some debugging messages to see where it crashes.

Alright it seems at though it opens the gui but when it goes to get the devices or something it crashes...

Usually it'll do that when the dll is not present, but the 3 dll's are there.

Link to comment
Share on other sites

Hi there,

Did you update the function? Make sure that has been done. If it still doesn't work, please try the following:

Replace the line between GUISetState() and $timer = TimerInit() with the following:

ConsoleWrite ("STARTING TO DEBUG BASS_ENC_EXAMPLE." & @CRLF & _
    "OS = " & @OSVersion & " (" & @OSArch & ") (SERVICE PACK = " & @OSServicePack & ") BUILD = " & @OSBuild & @CRLF & _
    "KB Layout = " & @KBLayout & @CRLF & _
    "Running AutoIt V" & @AutoItVersion & "(64 bit native = " & @AutoItX64 & ")" & @CRLF)

;_BASS_SetConfig($BASS_CONFIG_REC_BUFFER, 1000)
$device = _GetDevices()
ConsoleWrite ("GETTING DEVICES FAILED" & @CRLF & @TAB & $device & @TAB & @error & @CRLF)
$r = _BASS_RecordInit($device)
ConsoleWrite ("INITATING RECORDING FAILED" & @CRLF & @TAB & $r & @TAB & @error & @CRLF)
$input = _GetInputs()
ConsoleWrite ("GETTING INPUTS FAILED" & @CRLF & @TAB & $input & @TAB & @error & @CRLF)
$temp = DllCall($basscb_dll, "dword", "RecordStart", "dword", $KHZ, "dword", 2, "dword", _makelong($BASS_SAMPLE_FX, 10))
ConsoleWrite ("BASSCB RECORD START FAILED" & @CRLF & @TAB & $device & @TAB & @error & @CRLF)
$RecHandle = $temp[0]

Using the full version of SciTE (link is in my sig), please run the code and provide the output from console.

From there I can analyze where it is failing and provide more specific error checking.

Cheers,

Brett.

Oh and thanks... But rusty if you ask me :evil: I wasn't going to sing, so that was the next best thing ;)

Edited by BrettF
Link to comment
Share on other sites

Alright it does work now, well sorta. The problem was that it was including the <> way so it was getting the old files in au3/include. Now It sees one device, just my virtual audio cable 3. Not sure if it's because of the new console updates, but scite doesn't let me run it. Supposedly, we're calling the dll twice. Here.

C:\shared\BASS\BASS_ENC\Examples\BassEnc.au3(108,38) : WARNING: $bassenc_dll: possibly used bef

$BASSENC_ret_ = DllCall($bassenc_dll,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\shared\BASS\BASS_ENC\Examples\BassEnc.au3(109,42) : ERROR: _BASS_ErrorGetCode() called with

$error = _BASS_ErrorGetCode($bassenc_dll)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\Include\Bass.au3(447,26) : REF: definition of _BASS_ErrorGetCode().

Func _BASS_ErrorGetCode()

~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\shared\BASS\BASS_ENC\Examples\BassEnc.au3(159,39) : WARNING: $bass_dll: possibly used before

$error = _BASS_ErrorGetCode($bass_dll)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\shared\BASS\BASS_ENC\Examples\BassEnc.au3(159,39) : ERROR: _BASS_ErrorGetCode() called with

$error = _BASS_ErrorGetCode($bass_dll)

Do you want to stop the Run? Stop Continue anyway

Link to comment
Share on other sites

UPDATED

Bass library has been updated to Version 8.

Changelog:

/> Fixed BassEnc.au3
/> Fixed _Bass_RecordGetInputName
/> Updated BassEnc Example
/> Updated BassFx.au3
+> Added BassTags

Please see the first post for download link.

Link to comment
Share on other sites

IT crashes when i try to start it, and i dled the latest files and checked that i have all these files in the folder:

* Bass.au3

* bass.dll

* basscb.dll

* BassConstants.au3

* BassEnc.au3

* bassenc.dll

* BassEncConstants.au3

* lame.exe

Why does it still crash =/

Link to comment
Share on other sites

Hi,

bass_enc still crashes, but I'm having another issue now... how can I create a stream loading the file into memory first? I tried using StreamCreateFile, with the true flag and 0 to use all the data, but it needs something else... tried FileGetSize($file) but it gives me a pointer error, memory could not be read.

Anyway, I just downloaded bassmidi and bassmix. Gonna try to port them to au3 if you're ok with that and if you're not working on it already.

Link to comment
Share on other sites

This is loading from a resource. What I'm trying to do is load an ogg file into memory, which is int he same folder as the script, not inside a resource or anything..

I'm probably missing something obvious here... I'm just not too familiar with memory stuff. :D

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...