Jump to content

Recommended Posts

Posted
Posted (edited)

windows xp sp3

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\@username\Desktop\decompiler\newbass\BASS\BASS\Example 2.au3"

C:\Program Files\AutoIt3\Include\Bass.au3 (404) : ==> Subscript used with non-Array variable.:

Return SetError(0, "", $BASS_ret_[0])

Return SetError(0, "", $BASS_ret_^ ERROR

>Exit code: 1 Time: 0.812

Edit: figured it out :) it wasn't returning an array because it wasn't reading the dll

Edited by youknowwho4eva

Giggity

Posted

Try this script:

Please post the contents of the SciTE console (but not all of the loops. One or two will do :))

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

Global $playing_state = -1
;Open Bass.DLL.  Required for all function calls.
$bass_dll = DllOpen("..\BASS.dll")
_Memo ("Dll Open", $bass_dll, @error, @extended)

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

_Memo ("Bass Init", $int, @error, @extended)
;Check if bass iniated.  If not, we cannot continue.
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf

;Prompt the user to select a MP3 file
$file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")
_Memo ("File Open", $file, @error, @extended)

;Create a stream from that file.
$MusicHandle = _BASS_StreamCreateFile($bass_dll, False, $file, 0, 0, 0)
_Memo ("Stream Creation", $MusicHandle, @error, @extended)
;Check if we opened the file correctly.
If @error Then
    MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error)
    Exit
EndIf

;Iniate playback
$rettt = _BASS_ChannelPlay($bass_dll, $MusicHandle, 1)
_Memo ("Play", $rettt, @error, @extended)
;Get the length of the song in bytes.
$song_length = _BASS_ChannelGetLength($bass_dll, $MusicHandle, $BASS_POS_BYTE)
_Memo ("Length of song", $song_length, @error, @extended)
While 1
    ConsoleWrite ("+>  START LOOP!" & @CRLF)
    Sleep(20)
;Get the current position in bytes
    $current = _BASS_ChannelGetPosition($bass_dll, $MusicHandle, $BASS_POS_BYTE)
    _Memo ("Current Position", $current, @error, @extended)
;Calculate the percentage
    $percent = Round(($current / $song_length) * 100, 0)
    _Memo ("Percent", $percent, @error, @extended)
;Display that to the user
    ToolTip("Completed " & $percent & "%", 0, 0)
;If the song is complete, then exit.
    If $current >= $song_length Then ExitLoop
WEnd

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

Func _Memo ($text, $ret, $err, $ext)
    ConsoleWrite (  $text & " Results: " & @CRLF & _
                    @TAB & "Return: " & $ret & @CRLF & _
                    @TAB & "Error: " & $err & @CRLF & _
                    @TAB & "Extended: " & $ext & @CRLF)
EndFunc
Posted (edited)

thanks, awesome udf. here's my edit to example one to give it a playlist and global hotkeys. the playlist is annoying to use atm and it isn't saved but I'll fix that eventually.

#include <..\Bass.au3>
#include <..\BassConstants.au3>
#NoTrayIcon

Global $playing_state = -1
;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

$song_num=InputBox("Song #","howmany songs in playlist?")
dim $song_array[$song_num]
for $i = 0 to $song_num-1
    ToolTip("Song " & $i+1 & " out of " & $song_num & ".",100,100)
    $song_array[$i] = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")
Next
ToolTip("")

HotKeySet("^+=","FFWD");=========> skip to next track
HotKeySet("^+-","RWND");=========> skip to previous track
HotKeySet("^+p","Pause_play");===> Pause  or resume track
hotkeyset("^+e", "Stop");========> exit player

For $i = 0 to $song_num-1
    
;Create a stream from that file.
$MusicHandle = _BASS_StreamCreateFile($bass_dll, False, $song_array[$i], 0, 0, 0)

;Check if we opened the file correctly.
If @error Then
    MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error)
    Exit
EndIf

;Iniate playback
_BASS_ChannelStop ($bass_dll, $MusicHandle)
_BASS_ChannelPlay($bass_dll, $MusicHandle, 1)
$isplay=1
;Get the length of the song in bytes.
$song_length = _BASS_ChannelGetLength($bass_dll, $MusicHandle, $BASS_POS_BYTE)
While 1
    Sleep(20)
;Get the current position in bytes
    $current = _BASS_ChannelGetPosition($bass_dll, $MusicHandle, $BASS_POS_BYTE)
;Calculate the percentage
    $percent = Round(($current / $song_length) * 100, 0)
;Display that to the user
    ToolTip("Completed " & $percent & "%", 0, 0)
;If the song is complete, then exit.
    If $current >= $song_length Then ExitLoop
WEnd

Next

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

Func FFWD()
    _BASS_ChannelStop ($bass_dll, $MusicHandle)
    $i = $i+1
    if $i > UBound($song_array)-1 Then
        $i = 0
        EndIf
    $MusicHandle = _BASS_StreamCreateFile($bass_dll, False, $song_array[$i], 0, 0, 0)
    _BASS_ChannelStop ($bass_dll, $MusicHandle)
    _BASS_ChannelPlay($bass_dll, $MusicHandle, 1)
    $song_length = _BASS_ChannelGetLength($bass_dll, $MusicHandle, $BASS_POS_BYTE)
EndFunc

func RWND()
    _BASS_ChannelStop ($bass_dll, $MusicHandle)
    $i = $i-1
        if $i < 0 Then
        $i = UBound($song_array)-1
        EndIf
    $MusicHandle = _BASS_StreamCreateFile($bass_dll, False, $song_array[$i], 0, 0, 0)
    _BASS_ChannelStop ($bass_dll, $MusicHandle)
    _BASS_ChannelPlay($bass_dll, $MusicHandle, 1)
    $song_length = _BASS_ChannelGetLength($bass_dll, $MusicHandle, $BASS_POS_BYTE)
EndFunc

Func Pause_Play()
    Switch $isplay
    Case 1
        _BASS_Pause ($bass_dll)
        $isplay = 0
    Case 0
        _BASS_Start($bass_dll)
        $isplay = 1
    EndSwitch
EndFunc

func stop()
    _BASS_Free($bass_dll)
    Exit
EndFunc
Edited by Darth
  • 2 weeks later...
  • 3 weeks later...
Posted

Excellent work BrettF and eukalyptus, thanks!

I'm having loads of fun with Bass.au3. I do have a question and possibly a request.

I've created a very simple surround sound mixer and am able to route the playback of 6 mono wavs to any of the channels with your fine function library. I'm wondering how I can add a few more abilities. For one, I'd like to be able control the volume of any of the 6 channels. Can I do this with BassFx or do I need BassMix?

All I can find in Bass.au3 is SetVolume for the master. I do see $BASS_FX_BFX_VOLUME in BassFxConstants.au3 though, but I have no idea how to assign it to a channel. I will keep reading the examples and see if I can figure it out but any help would be greatly appreciated.

I'd also like to add mute and solo for each channel as well. I think I'm really going to need to use BassMix.dll but I know when I'm over my head when trying to follow your examples and code the functions myself.

My humble request would be for a BassMix.AU3 and some insight on how to use it if it appears that more multi-channel functionality could be achieved.

All the best,

Joe

Are you experienced?

Posted

Thank you very much Eukalyptus!

That and BASS_ATTRIB_VOL did the trick. I was able to make the individual volume sliders work as well as the mute and solo buttons! I looked in your MP3DJ app to cheat :) Very Cool!

Now on to making some VU Meters.

All the best,

Joe

Are you experienced?

Posted (edited)

Well I've finally got back here and had time to do another translation... This one was done over the course of today, so I fear it may be slightly rushed. But netherless I've finished BassCD, which means added support for digital and analouge CD playback, as well as fixed some other stuff.

BassCD with probably have some bugs in translation from VB, but oh well, please tell me.

I still need to get _BASS_CD_GetInfo and _BASS_CD_GetID working properly.

The download is active, direct is here:

http://signa5.com/downloads/BASS.zip

Next to come is either BassVideo or something else wacky and fun they have...

Cheers,

Brett

EDIT:

Just noticed something with the examples:

In the example update the includes to the following:

#include <..\BASSCDConstants.au3>
#include <..\BASSCD.au3>
#include <..\..\BASS\Bass.au3>
#include <..\..\BASS\BassConstants.au3>

$BASS_DLL = DllOpen ("..\..\BASS\Bass.dll")
$BASS_CD_DLL = DllOpen ("..\BassCD.dll")

and in BASSCD.au3

;Include Constants and Bass Library
#include <..\BASS\Bass.au3>
#include <..\BASS\BassConstants.au3>
#include <BASSCDConstants.au3>

Will be updated when I finish my TODO list.

Edited by BrettF
Posted

Hi, why don't you use Global variables for the DLL-Handles? Then the funktion calls would be a lot easier :P

*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

Posted (edited)

I think I see what you mean but I'm happy with how it is :P

EDIT:

Thanks to ProgAndy, _BASSCD_GETID is working, now to make it work with freedb... :unsure:

Cheers,

Brett

Edited by BrettF
Posted

Updated!

Download should be active soon.

Version 8
+> Added the BASSCD CDPlayer example.
+> Added FREEDB.org information and example
/> Fixed BASS Example 2
/> Fixed Includes in BASSCD.au3 and examples
/> Fixed _BASS_CD_GetID (Thanks ProgAndy)

Bugs? Comments? Suggestions?

Cheers,

Brett

Posted (edited)

I have some CDDB-UDFs, if you want to include them.

I think I see what you mean but I'm happy with how it is happy.gif

OK, then it will be this way. Then i have 2 funcs for easier loding of DLLs, with checking for success. I use such funcs in all my UDFs which need DLLs, so you can react on missing DLLs.

Func _BASS_LoadDLL($Path,$DLL)
    ; Prog@ndy
    If StringLen($Path) And StringRight($Path,1)<>"\" Then $Path &= "\"
    Local $ret =  DllOpen($Path &  $DLL)
    If Not __BASS_CheckLoadDLL($DLL) Then
        Return SetError(1,0,-1)
    EndIf
    Return $ret
EndFunc
; internal use
Func __BASS_CheckLoadDLL($DLL)
    ; Prog@ndy
    Local $ret = DllCall("kernel32.dll","ptr","GetModuleHandleW","wstr",$DLL)
    If @error Or $ret[0]=0 Then Return False
    Return True
EndFunc

CDDB.au3

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

Posted

I see what you mean now, I'll work on doing the DLL tomorow after work.

And thanks for the CDDB udf! Really awesome. I shall work on implementing them... :P

Cheers,

Brett

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
  • Recently Browsing   0 members

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