Jump to content

BASS Function Library (Sound and Music Functions)


BrettF
 Share

Recommended Posts

#include "Bass.au3"

$bass_dll = DllOpen("..\BASS.dll")

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

----->

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\Perus\Omat tiedostot\helvetin hieno testi\aaa.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams    
+>12:34:32 Starting AutoIt3Wrapper v.2.0.0.1    Environment(Language:040B  Keyboard:0000040B  OS:WIN_XP/Service Pack 3  CPU:X64 OS:X86)
>Running AU3Check (1.54.19.0)  from:C:\Program Files\AutoIt3
+>12:34:32 AU3Check ended.rc:0
>Running:(3.3.2.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\Perus\Omat tiedostot\helvetin hieno testi\aaa.au3"    
C:\Documents and Settings\Perus\Omat tiedostot\helvetin hieno testi\Bass.au3 (404) : ==> Subscript used with non-Array variable.:
Return SetError(0, "", $BASS_ret_[0])
Return SetError(0, "", $BASS_ret_^ ERROR
->12:34:32 AutoIT3.exe ended.rc:1
+>12:34:33 AutoIt3Wrapper Finished
>Exit code: 1    Time: 1.769
Link to comment
Share on other sites

#include "Bass.au3"

$bass_dll = DllOpen("..\BASS.dll")

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

----->

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\Perus\Omat tiedostot\helvetin hieno testi\aaa.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams 
+>12:34:32 Starting AutoIt3Wrapper v.2.0.0.1 Environment(Language:040B Keyboard:0000040B OS:WIN_XP/Service Pack 3 CPU:X64 OS:X86)
>Running AU3Check (1.54.19.0) from:C:\Program Files\AutoIt3
+>12:34:32 AU3Check ended.rc:0
>Running:(3.3.2.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\Perus\Omat tiedostot\helvetin hieno testi\aaa.au3" 
C:\Documents and Settings\Perus\Omat tiedostot\helvetin hieno testi\Bass.au3 (404) : ==> Subscript used with non-Array variable.:
Return SetError(0, "", $BASS_ret_[0])
Return SetError(0, "", $BASS_ret_^ ERROR
->12:34:32 AutoIT3.exe ended.rc:1
+>12:34:33 AutoIt3Wrapper Finished
>Exit code: 1 Time: 1.769

I got the same problem -> #736862 (I assume since Beta v3.3.1.3+)

Solution is to use ProgAndy's modified version of bass.au3 - > #737112

UEZ

Edited 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

Prog Andy's work alleviated most issues. Please see his post here.

For me this code is working as it should:

#include "Bass.au3"

$ret = _BASS_Startup("bass.dll")
MsgBox (0, "", $ret & @CRLF & @error)
$ret = _BASS_Init(0, -1, 44100, 0, "")
MsgBox (0, "", $ret & @CRLF & @error)
Link to comment
Share on other sites

Not sure exactly what it was meant to equal, but I went out on a hunch and made it 2... Just because 2 meant unknown "return type" in the DLLCall. I hope that he will confirm or correct this though. I'm in the middle of updating all of the UDFs included with BASS to follow the same system as ProgAndy's and it also means I'm updating the versions of all the Dlls... You know :evil: It's been a while since I've worked on it ;)

Link to comment
Share on other sites

Got it working, thx. Maybe it was just me but i had to add line "Global $BASS_DWORD_ERR" in the bass.au3.

Bass.au3 by BrettF modified by ProgAndy: Click Me

BassConstants.au3:

#include-once
; ===============================================================================================================================
; Error codes returned by $BASS_ErrorGetCode
; ===============================================================================================================================
Global Const $BASS_OK = 0   ;all is OK
Global Const $BASS_ERROR_MEM = 1    ;memory error
Global Const $BASS_ERROR_FILEOPEN = 2 ;can;t open the file
Global Const $BASS_ERROR_DRIVER = 3     ;can;t find a free sound driver
Global Const $BASS_ERROR_BUFLOST = 4    ;the sample buffer was lost
Global Const $BASS_ERROR_HANDLE = 5     ;invalid handle
Global Const $BASS_ERROR_FORMAT = 6     ;unsupported sample format
Global Const $BASS_ERROR_POSITION = 7 ;invalid position
Global Const $BASS_ERROR_INIT = 8   ;$BASS_Init has not been successfully called
Global Const $BASS_ERROR_START = 9  ;$BASS_Start has not been successfully called
Global Const $BASS_ERROR_ALREADY = 14 ;already initialized/paused/whatever
Global Const $BASS_ERROR_NOCHAN = 18    ;can;t get a free channel
Global Const $BASS_ERROR_ILLTYPE = 19 ;an illegal type was specified
Global Const $BASS_ERROR_ILLPARAM = 20 ;an illegal parameter was specified
Global Const $BASS_ERROR_NO3D = 21  ;no 3D support
Global Const $BASS_ERROR_NOEAX = 22     ;no EAX support
Global Const $BASS_ERROR_DEVICE = 23    ;illegal device number
Global Const $BASS_ERROR_NOPLAY = 24    ;not playing
Global Const $BASS_ERROR_FREQ = 25  ;illegal sample rate
Global Const $BASS_ERROR_NOTFILE = 27 ;the stream is not a file stream
Global Const $BASS_ERROR_NOHW = 29  ;no hardware voices available
Global Const $BASS_ERROR_EMPTY = 31     ;the MOD music has no sequence data
Global Const $BASS_ERROR_NONET = 32     ;no internet connection could be opened
Global Const $BASS_ERROR_CREATE = 33    ;couldn;t create the file
Global Const $BASS_ERROR_NOFX = 34  ;effects are not available
Global Const $BASS_ERROR_NOTAVAIL = 37 ;requested data is not available
Global Const $BASS_ERROR_DECODE = 38    ;the channel is a "decoding channel"
Global Const $BASS_ERROR_DX = 39    ;a sufficient DirectX version is not installed
Global Const $BASS_ERROR_TIMEOUT = 40 ;connection timedout
Global Const $BASS_ERROR_FILEFORM = 41 ;unsupported file format
Global Const $BASS_ERROR_SPEAKER = 42 ;unavailable speaker
Global Const $BASS_ERROR_VERSION = 43 ;invalid BASS version (used by add-ons)
Global Const $BASS_ERROR_CODEC = 44     ;codec is not available/supported
Global Const $BASS_ERROR_ENDED = 45     ;the channel/file has ended
Global Const $BASS_ERROR_UNKNOWN = -1 ;some other mystery problem

; ===============================================================================================================================
; $BASS_SetConfig options
; ===============================================================================================================================
Global Const $BASS_CONFIG_BUFFER = 0
Global Const $BASS_CONFIG_UPDATEPERIOD = 1
Global Const $BASS_CONFIG_GVOL_SAMPLE = 4
Global Const $BASS_CONFIG_GVOL_STREAM = 5
Global Const $BASS_CONFIG_GVOL_MUSIC = 6
Global Const $BASS_CONFIG_CURVE_VOL = 7
Global Const $BASS_CONFIG_CURVE_PAN = 8
Global Const $BASS_CONFIG_FLOATDSP = 9
Global Const $BASS_CONFIG_3DALGORITHM = 10
Global Const $BASS_CONFIG_NET_TIMEOUT = 11
Global Const $BASS_CONFIG_NET_BUFFER = 12
Global Const $BASS_CONFIG_PAUSE_NOPLAY = 13
Global Const $BASS_CONFIG_NET_PREBUF = 15
Global Const $BASS_CONFIG_NET_PASSIVE = 18
Global Const $BASS_CONFIG_REC_BUFFER = 19
Global Const $BASS_CONFIG_NET_PLAYLIST = 21
Global Const $BASS_CONFIG_MUSIC_VIRTUAL = 22
Global Const $BASS_CONFIG_VERIFY = 23
Global Const $BASS_CONFIG_UPDATETHREADS = 24

; ===============================================================================================================================
; $BASS_SetConfigPtr options
; ===============================================================================================================================
Global Const $BASS_CONFIG_NET_AGENT = 16
Global Const $BASS_CONFIG_NET_PROXY = 17

; ===============================================================================================================================
; Initialization flags
; ===============================================================================================================================
Global Const $BASS_DEVICE_8BITS = 1     ;use 8 bit resolution, else 16 bit
Global Const $BASS_DEVICE_MONO = 2  ;use mono, else stereo
Global Const $BASS_DEVICE_3D = 4    ;enable 3D functionality
Global Const $BASS_DEVICE_LATENCY = 256 ;calculate device latency ($BASS_INFO struct)
Global Const $BASS_DEVICE_CPSPEAKERS = 1024 ;detect speakers via Windows control panel
Global Const $BASS_DEVICE_SPEAKERS = 2048 ;force enabling of speaker assignment
Global Const $BASS_DEVICE_NOSPEAKER = 4096 ;ignore speaker arrangement

; ===============================================================================================================================
; DirectSound interfaces (for use with $BASS_GetDSoundObject)
; ===============================================================================================================================
Global Const $BASS_OBJECT_DS = 1    ; DirectSound
Global Const $BASS_OBJECT_DS3DL = 2     ;IDirectSound3DListener

Global Const $BASS_DEVICEINFO = "ptr name;" & _     ;name Description of the device. 
    "ptr driver;" & _   ;driver The filename of the driver... NULL = no driver ("no sound" device)
    "dword flags;"  ;flags The device's current status...

; ===============================================================================================================================
; $BASS_DEVICEINFO flags
; ===============================================================================================================================
Global Const $BASS_DEVICE_ENABLED = 1
Global Const $BASS_DEVICE_DEFAULT = 2
Global Const $BASS_DEVICE_INIT = 4

$BASS_INFO = 'dword flags;' & _ ; device capabilities (DSCAPS_xxx flags)
    'dword hwsize;' & _     ; size of total device hardware memory
    'dword hwfree;' & _     ; size of free device hardware memory
    'dword freesam;' & _    ; number of free sample slots in the hardware
    'dword free3d;' & _     ; number of free 3D sample slots in the hardware
    'dword minrate;' & _    ; min sample rate supported by the hardware
    'dword maxrate;' & _    ; max sample rate supported by the hardware
    'int eax;' & _  ; device supports EAX? (always BASSFALSE if $BASS_DEVICE_3D was not used)
    'dword minbuf;' & _     ; recommended minimum buffer length in ms (requires $BASS_DEVICE_LATENCY)
    'dword dsver;' & _  ; DirectSound version
    'dword latency;' & _    ; delay (in ms) before start of playback (requires $BASS_DEVICE_LATENCY)
    'dword initflags;' & _  ; $BASS_Init "flags" parameter
    'dword speakers;' & _   ; number of speakers available
    'dword freq'    ; current output rate (OSX only)

; ===============================================================================================================================
; $BASS_INFO flags
; ===============================================================================================================================
Global Const $DSCAPS_CONTINUOUSRATE = 16    ; supports all sample rates between min/maxrate
Global Const $DSCAPS_EMULDRIVER = 32    ; device does NOT have hardware DirectSound support
Global Const $DSCAPS_CERTIFIED = 64     ; device driver has been certified by Microsoft
Global Const $DSCAPS_SECONDARYMONO = 256    ; mono
Global Const $DSCAPS_SECONDARYSTEREO = 512 ; stereo
Global Const $DSCAPS_SECONDARY8BIT = 1024 ; 8 bit
Global Const $DSCAPS_SECONDARY16BIT = 2048 ; 16 bit

; ===============================================================================================================================
; Recording device info structure
; ===============================================================================================================================
$BASS_RECORDINFO = "dword flags;" & _ ; device capabilities (DSCCAPS_xxx flags)
    'dword formats;' & _    ; supported standard formats (WAVE_FORMAT_xxx flags)
    'dword inputs;' & _     ; number of inputs
    'int singlein;' & _     ; BASSTRUE = only 1 input can be set at a time
    'dword freq'    ; current input rate (Vista/OSX only)

; ===============================================================================================================================
; $BASS_RECORDINFO flags
; ===============================================================================================================================
Global Const $DSCCAPS_EMULDRIVER = $DSCAPS_EMULDRIVER ; device does NOT have hardware DirectSound recording support
Global Const $DSCCAPS_CERTIFIED = $DSCAPS_CERTIFIED ; device driver has been certified by Microsoft

; ===============================================================================================================================
; defines for formats field of $BASS_RECORDINFO
; ===============================================================================================================================
Global Const $WAVE_FORMAT_1M08 = 0x1    ; 11.025 kHz, Mono, 8-bit
Global Const $WAVE_FORMAT_1S08 = 0x2    ; 11.025 kHz, Stereo, 8-bit
Global Const $WAVE_FORMAT_1M16 = 0x4    ; 11.025 kHz, Mono, 16-bit
Global Const $WAVE_FORMAT_1S16 = 0x8    ; 11.025 kHz, Stereo, 16-bit
Global Const $WAVE_FORMAT_2M08 = 0x10   ; 22.05 kHz, Mono, 8-bit
Global Const $WAVE_FORMAT_2S08 = 0x20   ; 22.05 kHz, Stereo, 8-bit
Global Const $WAVE_FORMAT_2M16 = 0x40   ; 22.05 kHz, Mono, 16-bit
Global Const $WAVE_FORMAT_2S16 = 0x80   ; 22.05 kHz, Stereo, 16-bit
Global Const $WAVE_FORMAT_4M08 = 0x100  ; 44.1 kHz, Mono, 8-bit
Global Const $WAVE_FORMAT_4S08 = 0x200  ; 44.1 kHz, Stereo, 8-bit
Global Const $WAVE_FORMAT_4M16 = 0x400  ; 44.1 kHz, Mono, 16-bit
Global Const $WAVE_FORMAT_4S16 = 0x800  ; 44.1 kHz, Stereo, 16-bit

; ===============================================================================================================================
; Sample info structure
; ===============================================================================================================================
$BASS_SAMPLE = 'dword freq;' & _    ; default playback rate
    'float volume;' & _     ; default volume (0-100)
    'float pan;' & _    ; default pan (-100=left, 0=middle, 100=right)
    'dword flags;' & _  ; $BASS_SAMPLE_xxx flags
    'dword length;' & _     ; length (in samples, not bytes)
    'dword max;' & _    ; maximum simultaneous playbacks
    'dword origres;' & _    ; original resolution
    'dword chans;' & _  ; number of channels
    'dword mingap;' & _     ; minimum gap (ms) between creating channels
    'dword mode3d;' & _     ; $BASS_3DMODE_xxx mode
    'float mindist;' & _    ; minimum distance
    'float MAXDIST;' & _    ; maximum distance
    'dword iangle;' & _     ; angle of inside projection cone
    'dword oangle;' & _     ; angle of outside projection cone
    'float outvol;' & _     ; delta-volume outside the projection cone
    'dword vam;' & _    ; voice allocation/management flags ($BASS_VAM_xxx)
    'dword priority;'   ; priority (0=lowest, 0xffffffff=highest)

Global Const $BASS_SAMPLE_8BITS = 1     ; 8 bit
Global Const $BASS_SAMPLE_FLOAT = 256   ; 32-bit floating-point
Global Const $BASS_SAMPLE_MONO = 2  ; mono
Global Const $BASS_SAMPLE_LOOP = 4  ; looped
Global Const $BASS_SAMPLE_3D = 8    ; 3D functionality
Global Const $BASS_SAMPLE_SOFTWARE = 16     ; not using hardware mixing
Global Const $BASS_SAMPLE_MUTEMAX = 32  ; mute at max distance (3D only)
Global Const $BASS_SAMPLE_VAM = 64  ; DX7 voice allocation & management
Global Const $BASS_SAMPLE_FX = 128  ; old implementation of DX8 effects
Global Const $BASS_SAMPLE_OVER_VOL = 0x10000 ; override lowest volume
Global Const $BASS_SAMPLE_OVER_POS = 0x20000 ; override dwordest playing
Global Const $BASS_SAMPLE_OVER_DIST = 0x30000 ; override furthest from listener (3D only)

Global Const $BASS_STREAM_PRESCAN = 0x20000 ; enable pin-point seeking/length (MP3/MP2/MP1)
Global Const $BASS_MP3_SETPOS = $BASS_STREAM_PRESCAN
Global Const $BASS_STREAM_AUTOFREE = 0x40000 ; automatically free the stream when it stop/ends
Global Const $BASS_STREAM_RESTRATE = 0x80000 ; restrict the download rate of internet file streams
Global Const $BASS_STREAM_BLOCK = 0x100000 ; download/play internet file stream in small blocks
Global Const $BASS_STREAM_DECODE = 0x200000 ; don;t play the stream, only decode ($BASS_ChannelGetData)
Global Const $BASS_STREAM_STATUS = 0x800000 ; give server status info (HTTP/ICY tags) in DOWNLOADPROC

Global Const $BASS_MUSIC_FLOAT = $BASS_SAMPLE_FLOAT
Global Const $BASS_MUSIC_MONO = $BASS_SAMPLE_MONO
Global Const $BASS_MUSIC_LOOP = $BASS_SAMPLE_LOOP
Global Const $BASS_MUSIC_3D = $BASS_SAMPLE_3D
Global Const $BASS_MUSIC_FX = $BASS_SAMPLE_FX
Global Const $BASS_MUSIC_AUTOFREE = $BASS_STREAM_AUTOFREE
Global Const $BASS_MUSIC_DECODE = $BASS_STREAM_DECODE
Global Const $BASS_MUSIC_PRESCAN = $BASS_STREAM_PRESCAN ; calculate playback length
Global Const $BASS_MUSIC_CALCLEN = $BASS_MUSIC_PRESCAN
Global Const $BASS_MUSIC_RAMP = 0x200   ; normal ramping
Global Const $BASS_MUSIC_RAMPS = 0x400  ; sensitive ramping
Global Const $BASS_MUSIC_SURROUND = 0x800   ; surround sound
Global Const $BASS_MUSIC_SURROUND2 = 0x1000 ; surround sound (mode 2)
Global Const $BASS_MUSIC_FT2MOD = 0x2000    ; play .MOD as FastTracker 2 does
Global Const $BASS_MUSIC_PT1MOD = 0x4000    ; play .MOD as ProTracker 1 does
Global Const $BASS_MUSIC_NONINTER = 0x10000 ; non-interpolated sample mixing
Global Const $BASS_MUSIC_SINCINTER = 0x800000 ; sinc interpolated sample mixing
Global Const $BASS_MUSIC_POSRESET = 32768 ; stop all notes when moving position
Global Const $BASS_MUSIC_POSRESETEX = 0x400000 ; stop all notes and reset bmp/etc when moving position
Global Const $BASS_MUSIC_STOPBACK = 0x80000 ; stop the music on a backwards jump effect
Global Const $BASS_MUSIC_NOSAMPLE = 0x100000 ; don;t load the samples

; ===============================================================================================================================
; Speaker assignment flags
; ===============================================================================================================================
Global Const $BASS_SPEAKER_FRONT = 0x1000000 ; front speakers
Global Const $BASS_SPEAKER_REAR = 0x2000000 ; rear/side speakers
Global Const $BASS_SPEAKER_CENLFE = 0x3000000 ; center & LFE speakers (5.1)
Global Const $BASS_SPEAKER_REAR2 = 0x4000000 ; rear center speakers (7.1)
Global Const $BASS_SPEAKER_LEFT = 0x10000000 ; modifier: left
Global Const $BASS_SPEAKER_RIGHT = 0x20000000 ; modifier: right
Global Const $BASS_SPEAKER_FRONTLEFT = $BASS_SPEAKER_FRONT + $BASS_SPEAKER_LEFT
Global Const $BASS_SPEAKER_FRONTRIGHT = $BASS_SPEAKER_FRONT + $BASS_SPEAKER_RIGHT
Global Const $BASS_SPEAKER_REARLEFT = $BASS_SPEAKER_REAR + $BASS_SPEAKER_LEFT
Global Const $BASS_SPEAKER_REARRIGHT = $BASS_SPEAKER_REAR + $BASS_SPEAKER_RIGHT
Global Const $BASS_SPEAKER_CENTER = $BASS_SPEAKER_CENLFE + $BASS_SPEAKER_LEFT
Global Const $BASS_SPEAKER_LFE = $BASS_SPEAKER_CENLFE + $BASS_SPEAKER_RIGHT
Global Const $BASS_SPEAKER_REAR2LEFT = $BASS_SPEAKER_REAR2 + $BASS_SPEAKER_LEFT
Global Const $BASS_SPEAKER_REAR2RIGHT = $BASS_SPEAKER_REAR2 + $BASS_SPEAKER_RIGHT

Global Const $BASS_UNICODE = 0x80000000

Global Const $BASS_RECORD_PAUSE = 32768 ; start recording paused

; ===============================================================================================================================
; DX7 voice allocation flags
; ===============================================================================================================================
Global Const $BASS_VAM_HARDWARE = 1
Global Const $BASS_VAM_SOFTWARE = 2
Global Const $BASS_VAM_TERM_TIME = 4
Global Const $BASS_VAM_TERM_DIST = 8
Global Const $BASS_VAM_TERM_PRIO = 16

; ===============================================================================================================================
; Channel info structure
; ===============================================================================================================================
$BASS_CHANNELINFO = 'dword freq;' & _ ; default playback rate
    'dword chans;' & _  ; channels
    'dword flags;' & _  ; $BASS_SAMPLE/STREAM/MUSIC/SPEAKER flags
    'dword ctype;' & _  ; type of channel
    'dword origres;' & _    ; original resolution
    'dword plugin;' & _     ; plugin
    'dword sample;' & _     ; sample
    'ptr filename;'     ;filename

; ===============================================================================================================================
; $BASS_CHANNELINFO types
; ===============================================================================================================================
Global Const $BASS_CTYPE_SAMPLE = 1
Global Const $BASS_CTYPE_RECORD = 2
Global Const $BASS_CTYPE_STREAM = 0x10000
Global Const $BASS_CTYPE_STREAM_OGG = 0x10002
Global Const $BASS_CTYPE_STREAM_MP1 = 0x10003
Global Const $BASS_CTYPE_STREAM_MP2 = 0x10004
Global Const $BASS_CTYPE_STREAM_MP3 = 0x10005
Global Const $BASS_CTYPE_STREAM_AIFF = 0x10006
Global Const $BASS_CTYPE_STREAM_WAV = 0x40000 ; WAVE flag, LOWORD=codec
Global Const $BASS_CTYPE_STREAM_WAV_PCM = 0x50001
Global Const $BASS_CTYPE_STREAM_WAV_FLOAT = 0x50003
Global Const $BASS_CTYPE_MUSIC_MOD = 0x20000
Global Const $BASS_CTYPE_MUSIC_MTM = 0x20001
Global Const $BASS_CTYPE_MUSIC_S3M = 0x20002
Global Const $BASS_CTYPE_MUSIC_XM = 0x20003
Global Const $BASS_CTYPE_MUSIC_IT = 0x20004
Global Const $BASS_CTYPE_MUSIC_MO3 = 0x100  ; MO3 flag

$BASS_PLUGINFORM = 'dword;ptr;ptr;'

$BASS_PLUGININFO = 'dword version;' & _     ; version (same form as $BASS_GetVersion)
    'dword formatc;' & _    ; number of formats
    'ptr formats;'  ; the array of formats

; ===============================================================================================================================
; 3D vector (for 3D positions/velocities/orientations)
; ===============================================================================================================================
$BASS_3DVECTOR = 'float X;' & _     ; + = right, - = left
    'float Y;' & _  ; + = up, - = down
    'float z;'  ; + = front, - = behind

; ===============================================================================================================================
; 3D channel modes
; ===============================================================================================================================
Global Const $BASS_3DMODE_NORMAL = 0    ; normal 3D processing
Global Const $BASS_3DMODE_RELATIVE = 1 ; position is relative to the listener
Global Const $BASS_3DMODE_OFF = 2   ; no 3D processing

; ===============================================================================================================================
; software 3D mixing algorithms (used with $BASS_CONFIG_3DALGORITHM)
; ===============================================================================================================================
Global Const $BASS_3DALG_DEFAULT = 0
Global Const $BASS_3DALG_OFF = 1
Global Const $BASS_3DALG_FULL = 2
Global Const $BASS_3DALG_LIGHT = 3

; ===============================================================================================================================
; EAX environments, use with $BASS_SetEAXParameters
; ===============================================================================================================================
Global Const $EAX_ENVIRONMENT_GENERIC = 0
Global Const $EAX_ENVIRONMENT_PADDEDCELL = 1
Global Const $EAX_ENVIRONMENT_ROOM = 2
Global Const $EAX_ENVIRONMENT_BATHROOM = 3
Global Const $EAX_ENVIRONMENT_LIVINGROOM = 4
Global Const $EAX_ENVIRONMENT_STONEROOM = 5
Global Const $EAX_ENVIRONMENT_AUDITORIUM = 6
Global Const $EAX_ENVIRONMENT_CONCERTHALL = 7
Global Const $EAX_ENVIRONMENT_CAVE = 8
Global Const $EAX_ENVIRONMENT_ARENA = 9
Global Const $EAX_ENVIRONMENT_HANGAR = 10
Global Const $EAX_ENVIRONMENT_CARPETEDHALLWAY = 11
Global Const $EAX_ENVIRONMENT_HALLWAY = 12
Global Const $EAX_ENVIRONMENT_STONECORRIDOR = 13
Global Const $EAX_ENVIRONMENT_ALLEY = 14
Global Const $EAX_ENVIRONMENT_FOREST = 15
Global Const $EAX_ENVIRONMENT_CITY = 16
Global Const $EAX_ENVIRONMENT_MOUNTAINS = 17
Global Const $EAX_ENVIRONMENT_QUARRY = 18
Global Const $EAX_ENVIRONMENT_PLAIN = 19
Global Const $EAX_ENVIRONMENT_PARKINGLOT = 20
Global Const $EAX_ENVIRONMENT_SEWERPIPE = 21
Global Const $EAX_ENVIRONMENT_UNDERWATER = 22
Global Const $EAX_ENVIRONMENT_DRUGGED = 23
Global Const $EAX_ENVIRONMENT_DIZZY = 24
Global Const $EAX_ENVIRONMENT_PSYCHOTIC = 25
Global Const $EAX_ENVIRONMENT_COUNT = 26 ; total number of environments

Global Const $BASS_STREAMPROC_END = 0x80000000 ; end of user stream flag

; ===============================================================================================================================
; special STREAMPROCs
; ===============================================================================================================================
Global Const $STREAMPROC_DUMMY = 0 ; "dummy" stream
Global Const $STREAMPROC_PUSH = -1 ; push stream

; ===============================================================================================================================
; $BASS_StreamCreateFileUser file systems
; ===============================================================================================================================
Global Const $STREAMFILE_NOBUFFER = 0
Global Const $STREAMFILE_BUFFER = 1
Global Const $STREAMFILE_BUFFERPUSH = 2

; ===============================================================================================================================
; $BASS_StreamPutFileData options
; ===============================================================================================================================
Global Const $BASS_FILEDATA_END = 0 ; end & close the file

; ===============================================================================================================================
; $BASS_StreamGetFilePosition modes
; ===============================================================================================================================
Global Const $BASS_FILEPOS_CURRENT = 0
Global Const $BASS_FILEPOS_DECODE = $BASS_FILEPOS_CURRENT
Global Const $BASS_FILEPOS_DOWNLOAD = 1
Global Const $BASS_FILEPOS_END = 2
Global Const $BASS_FILEPOS_START = 3
Global Const $BASS_FILEPOS_CONNECTED = 4
Global Const $BASS_FILEPOS_BUFFER = 5

; ===============================================================================================================================
; $BASS_ChannelSetSync types
; ===============================================================================================================================
Global Const $BASS_SYNC_POS = 0
Global Const $BASS_SYNC_END = 2
Global Const $BASS_SYNC_META = 4
Global Const $BASS_SYNC_SLIDE = 5
Global Const $BASS_SYNC_STALL = 6
Global Const $BASS_SYNC_DOWNLOAD = 7
Global Const $BASS_SYNC_FREE = 8
Global Const $BASS_SYNC_SETPOS = 11
Global Const $BASS_SYNC_MUSICPOS = 10
Global Const $BASS_SYNC_MUSICINST = 1
Global Const $BASS_SYNC_MUSICFX = 3
Global Const $BASS_SYNC_OGG_CHANGE = 12
Global Const $BASS_SYNC_MIXTIME = 0x40000000 ; FLAG: sync at mixtime, else at playtime
Global Const $BASS_SYNC_ONETIME = 0x80000000 ; FLAG: sync only once, else continuously

; ===============================================================================================================================
; $BASS_ChannelIsActive return values
; ===============================================================================================================================
Global Const $BASS_ACTIVE_STOPPED = 0
Global Const $BASS_ACTIVE_PLAYING = 1
Global Const $BASS_ACTIVE_STALLED = 2
Global Const $BASS_ACTIVE_PAUSED = 3

; ===============================================================================================================================
; Channel attributes
; ===============================================================================================================================
Global Const $BASS_ATTRIB_FREQ = 1
Global Const $BASS_ATTRIB_VOL = 2
Global Const $BASS_ATTRIB_PAN = 3
Global Const $BASS_ATTRIB_EAXMIX = 4
Global Const $BASS_ATTRIB_MUSIC_AMPLIFY = 0x100
Global Const $BASS_ATTRIB_MUSIC_PANSEP = 0x101
Global Const $BASS_ATTRIB_MUSIC_PSCALER = 0x102
Global Const $BASS_ATTRIB_MUSIC_BPM = 0x103
Global Const $BASS_ATTRIB_MUSIC_SPEED = 0x104
Global Const $BASS_ATTRIB_MUSIC_VOL_GLOBAL = 0x105
Global Const $BASS_ATTRIB_MUSIC_VOL_CHAN = 0x200 ; + channel #
Global Const $BASS_ATTRIB_MUSIC_VOL_INST = 0x300 ; + instrument #

; ===============================================================================================================================
; $BASS_ChannelGetData flags
; ===============================================================================================================================
Global Const $BASS_DATA_AVAILABLE = 0   ; query how much data is buffered
Global Const $BASS_DATA_FLOAT = 0x40000000  ; flag: return floating-point sample data
Global Const $BASS_DATA_FFT256 = 0x80000000 ; 256 sample FFT
Global Const $BASS_DATA_FFT512 = 0x80000001 ; 512 FFT
Global Const $BASS_DATA_FFT1024 = 0x80000002 ; 1024 FFT
Global Const $BASS_DATA_FFT2048 = 0x80000003 ; 2048 FFT
Global Const $BASS_DATA_FFT4096 = 0x80000004 ; 4096 FFT
Global Const $BASS_DATA_FFT8192 = 0x80000005 ; 8192 FFT
Global Const $BASS_DATA_FFT_INDIVIDUAL = 0x10 ; FFT flag: FFT for each channel, else all combined
Global Const $BASS_DATA_FFT_NOWINDOW = 0x20 ; FFT flag: no Hanning window

; ===============================================================================================================================
; $BASS_ChannelGetTags types : what;s returned
; ===============================================================================================================================
Global Const $BASS_TAG_ID3 = 0 ;ID3v1 tags : 128 byte block
Global Const $BASS_TAG_ID3V2 = 1 ;ID3v2 tags : variable length block
Global Const $BASS_TAG_OGG = 2 ;OGG comments : series of null-terminated UTF-8 strings
Global Const $BASS_TAG_HTTP = 3 ;HTTP headers : series of null-terminated ANSI strings
Global Const $BASS_TAG_ICY = 4 ;ICY headers : series of null-terminated ANSI strings
Global Const $BASS_TAG_META = 5 ;ICY metadata : ANSI string
Global Const $BASS_TAG_VENDOR = 9 ;OGG encoder : UTF-8 string
Global Const $BASS_TAG_LYRICS3 = 10 ;Lyric3v2 tag : ASCII string
Global Const $BASS_TAG_RIFF_INFO = 0x100 ;RIFF/WAVE tags : series of null-terminated ANSI strings
Global Const $BASS_TAG_MUSIC_NAME = 0x10000 ;MOD music name : ANSI string
Global Const $BASS_TAG_MUSIC_MESSAGE = 0x10001  ;MOD message : ANSI string
Global Const $BASS_TAG_MUSIC_INST = 0x10100 ;+ instrument #, MOD instrument name : ANSI string
Global Const $BASS_TAG_MUSIC_SAMPLE = 0x10300 ;+ sample #, MOD sample name : ANSI string

; ===============================================================================================================================
; $BASS_ChannelGetLength/GetPosition/SetPosition modes
; ===============================================================================================================================
Global Const $BASS_POS_BYTE = 0     ; byte position
Global Const $BASS_POS_MUSIC_ORDER = 1 ; order.row position, MAKEdword(order,row)

; ===============================================================================================================================
; $BASS_RecordSetInput flags
; ===============================================================================================================================
Global Const $BASS_INPUT_OFF = 0x10000
Global Const $BASS_INPUT_ON = 0x20000

Global Const $BASS_INPUT_TYPE_MASK = 0xFF000000
Global Const $BASS_INPUT_TYPE_UNDEF = 0x0
Global Const $BASS_INPUT_TYPE_DIGITAL = 0x1000000
Global Const $BASS_INPUT_TYPE_LINE = 0x2000000
Global Const $BASS_INPUT_TYPE_MIC = 0x3000000
Global Const $BASS_INPUT_TYPE_SYNTH = 0x4000000
Global Const $BASS_INPUT_TYPE_CD = 0x5000000
Global Const $BASS_INPUT_TYPE_PHONE = 0x6000000
Global Const $BASS_INPUT_TYPE_SPEAKER = 0x7000000
Global Const $BASS_INPUT_TYPE_WAVE = 0x8000000
Global Const $BASS_INPUT_TYPE_AUX = 0x9000000
Global Const $BASS_INPUT_TYPE_ANALOG = 0xA000000

; ===============================================================================================================================
; DX8 effect types, use with $BASS_ChannelSetFX
; ===============================================================================================================================
Global Const $BASS_FX_DX8_CHORUS = "BASS_FX_DX8_CHORUS"
Global Const $BASS_FX_DX8_CHORUS_VALUE = 0

Global Const $BASS_FX_DX8_COMPRESSOR = "BASS_FX_DX8_COMPRESSOR"
Global Const $BASS_FX_DX8_COMPRESSOR_VALUE = 1

Global Const $BASS_FX_DX8_DISTORTION = "BASS_FX_DX8_DISTORTION"
Global Const $BASS_FX_DX8_DISTORTION_VALUE = 2

Global Const $BASS_FX_DX8_ECHO = "BASS_FX_DX8_ECHO"
Global Const $BASS_FX_DX8_ECHO_VALUE = 3

Global Const $BASS_FX_DX8_FLANGER = "BASS_FX_DX8_FLANGER"
Global Const $BASS_FX_DX8_FLANGER_VALUE = 4

Global Const $BASS_FX_DX8_GARGLE = "BASS_FX_DX8_GARGLE"
Global Const $BASS_FX_DX8_GARGLE_VALUE = 5

Global Const $BASS_FX_DX8_I3DL2REVERB = "BASS_FX_DX8_I3DL2REVERB"
Global Const $BASS_FX_DX8_I3DL2REVERB_VALUE = 6

Global Const $BASS_FX_DX8_PARAMEQ = "BASS_FX_DX8_PARAMEQ"
Global Const $BASS_FX_DX8_PARAMEQ_VALUE = 7

Global Const $BASS_FX_DX8_REVERB = "BASS_FX_DX8_REVERB"
Global Const $BASS_FX_DX8_REVERB_VALUE = 8

$BASS_DX8_CHORUS = 'float;' & _     ;fWetDryMix
    'float;' & _    ;fDepth
    'float;' & _    ;fFeedback
    'float;' & _    ;fFrequency
    'dword;' & _    ;lWaveform, 0=triangle, 1=sine
    'float;' & _    ;fDelay
    'dword;'    ;lPhase

$BASS_DX8_COMPRESSOR = 'float;' & _ ;fGain
    'float;' & _    ;fAttack
    'float;' & _    ;fRelease
    'float;' & _    ;fThreshold
    'float;' & _    ;fRatio
    'float;'    ;fPredelay

$BASS_DX8_DISTORTION = 'float;' & _ ;fGain
    'float;' & _    ;fEdge
    'float;' & _    ;fPostEQCenterFrequency
    'float;' & _    ;fPostEQBandwidth
    'float;'    ;fPreLowpassCutoff

$BASS_DX8_ECHO = 'float;' & _   ;fWetDryMix
    'float;' & _    ;fFeedback
    'float;' & _    ;fLeftDelay
    'float;' & _    ;fRightDelay
    'int;'  ;lPanDelay 

$BASS_DX8_FLANGER = 'float;' & _    ;fWetDryMix
    'float;' & _    ;fDepth
    'float;' & _    ;fFeedback
    'float;' & _    ;fFrequency
    'dword;' & _    ;lWaveform, 0=triangle, 1=sine
    'float;' & _    ;fDelay
    'dword;'    ;lPhase

$BASS_DX8_GARGLE = 'dword;' & _     ;dwRateHz
    'dword;'    ;dwWaveShape, 0=triangle, 1=square

$BASS_DX8_I3DL2REVERB = 'int;' & _  ;lRoom  [-10000, 0]     default: -1000 mB
    'int;' & _  ;lRoomHF    [-10000, 0]     default: 0 mB
    'float;' & _    ;flRoomRolloffFactor    [0.0, 10.0]     default: 0.0
    'float;' & _    ;flDecayTime    [0.1, 20.0]     default: 1.49s
    'float;' & _    ;flDecayHFRatio     [0.1, 2.0]  default: 0.83
    'int;' & _  ;lReflections   [-10000, 1000] default: -2602 mB
    'float;' & _    ;flReflectionsDelay     [0.0, 0.3]  default: 0.007 s
    'int;' & _  ;lReverb    [-10000, 2000] default: 200 mB
    'float;' & _    ;flReverbDelay  [0.0, 0.1]  default: 0.011 s
    'float;' & _    ;flDiffusion    [0.0, 100.0]    default: 100.0 %
    'float;' & _    ;flDensity  [0.0, 100.0]    default: 100.0 %
    'float;'    ;flHFReference  [20.0, 20000.0] default: 5000.0 Hz

$BASS_DX8_PARAMEQ = 'float;' & _    ;fCenter
    'float;' & _    ;fBandwidth
    'float;'    ;fGain

$BASS_DX8_REVERB = 'float;' & _     ;fInGain    [-96.0,0.0]     default: 0.0 dB
    'float;' & _    ;fReverbMix     [-96.0,0.0]     default: 0.0 db
    'float;' & _    ;fReverbTime    [0.001,3000.0]  default: 1000.0 ms
    'float;'    ;fHighFreqRTRatio   [0.001,0.999]   default: 0.001

Global Const $BASS_DX8_PHASE_NEG_180 = 0
Global Const $BASS_DX8_PHASE_NEG_90 = 1
Global Const $BASS_DX8_PHASE_ZERO = 2
Global Const $BASS_DX8_PHASE_90 = 3
Global Const $BASS_DX8_PHASE_180 = 4
Global $BASS_DWORD_ERR

UEZ

Edited 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

UPDATED

Bass library has been updated to Version 7.

Changelog:

/> Slight Restructure of folders.
/> Updated version of Bass.dll to 2.4.5.
/> Updated version of BassEnc.dll to 2.4.6.
/> Updated version of BassASIO.dll to 1.0.1.
/> Updated version of BassFX.dll to 2.4.4.1.
/> Added modifications of BASS.au3. Thanks ProgAndy for making these modifications.
/> Modified BASS_Startup() to use some addition error checking. Also added UDF function header.
/> Modified BassAsio.au3 to reflect same structure as Bass.au3.
/> Modified BassEnc.au3 to reflect same structure as Bass.au3.
/> Modified BassFx.au3 to reflect same structure as Bass.au3.
+> Added BassCD.au3
+> Added BassVIS.au3
/> Update all examples to reflect changes in UDFs.

Please see the first post for download link.

Edited by BrettF
Link to comment
Share on other sites

hi nice work

one thing i couldnt yet figure out is how to extract the ID3 info from the returned pointer info from ?

$id3 = _BASS_ChannelGetTags($MusicHandle, $BASS_TAG_ID3)

ConsoleWrite($id3 & @crlf);

Edited by nobbe
Link to comment
Share on other sites

I'm all for ID3v2.

http://www.id3.org/id3v2.4.0-structure

To get the ptr to that use

$id3 = _BASS_ChannelGetTags($MusicHandle, $BASS_TAG_ID3V2)

Then it gets a bit more complicated because of how dynamic ID3V2 is. The easiest way is to start by reading the header (10 bytes), and then getting the length of the subsequent extended header, frames, padding and footer.

I will be having a short play for now...

Link to comment
Share on other sites

i tried so far

$id3_ptr = _BASS_ChannelGetTags($MusicHandle, $BASS_TAG_ID3)

$id3_ptr_text=_BASS_PtrStringRead($id3_ptr, FALSE, -1)

; substitute "TAG" in beginning

$id3_ptr_text = StringReplace($id3_ptr_text, "TAG", "", 0, 1);

ConsoleWrite("mp3 = " & $id3_ptr_text & @CRLF);

which only gives my the FIRST Tag Entry corresponding to title like "TAGOwner of a lonely Heart"

all others are omitted ?

it should return a 128 byte structure, but only returns the length of the first tag?

Link to comment
Share on other sites

Interesting. Let me investigate further.

Not sure for now, I'll have a look later tomorrow when I do some work on BassFX.

Edited by BrettF
Link to comment
Share on other sites

i figured it out

the function

$id3_ptr = _BASS_ChannelGetTags($MusicHandle, $BASS_TAG_ID3)

$id3_ptr_text = _BASS_PtrStringRead($id3_ptr, False, -1) ;

gives wrong Number of data, only 1st tag is detected

i changed it now to

$id3_ptr = _BASS_ChannelGetTags($MusicHandle, $BASS_TAG_ID3)

Local $struct = DllStructCreate("char v0[3]; char v1[30];char v2[30];char v3[30];char v4[4];char v5[30];char v6[1]", $id3_ptr)

$id3_ptr_text = DllStructGetData($struct, 1)

ConsoleWrite("mp3 1 = " & $id3_ptr_text & @CRLF);

$id3_ptr_text = DllStructGetData($struct, 2)

ConsoleWrite("mp3 2 = " & $id3_ptr_text & @CRLF);

$id3_ptr_text = DllStructGetData($struct, 3)

ConsoleWrite("mp3 3 = " & $id3_ptr_text & @CRLF);

$id3_ptr_text = DllStructGetData($struct, 4)

ConsoleWrite("mp3 4 = " & $id3_ptr_text & @CRLF);

$id3_ptr_text = DllStructGetData($struct, 5)

ConsoleWrite("mp3 5 = " & $id3_ptr_text & @CRLF);

$id3_ptr_text = DllStructGetData($struct, 6)

ConsoleWrite("mp3 6 = " & $id3_ptr_text & @CRLF);

which results in correct tag description like

mp3 1 = TAG

mp3 2 = I See You [Theme from Avatar]

mp3 3 = Leona Lewis

mp3 4 = AVATAR Music From The Motion P

mp3 5 =

mp3 6 =

Link to comment
Share on other sites

updated my sample: now releases filehandles and retrieves mp3 tags

;
; sample BASS player - based on example_3
;
; added / changed:

;   - time display
;   - slider working to set / get position
;   - volume display vertical
;   - added drag / drop from explorer
;   - display title / artist from bass mp3 tag
;
;
; author nobbe 2009
;

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

Global $WM_DROPFILES = 0x233
Global $gaDropFiles[1], $str = ""

GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC")

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



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

;Initalize bass.  Required for most functions.
_BASS_Init(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

;Prompt the user to select a MP3 file

#cs
    $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
#ce


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

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

$progress_slider = GUICtrlCreateSlider(8, 32, 370, 25)
GUICtrlSetLimit(-1, 100, 0)


$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(350, 80, 12, 100, $PBS_VERTICAL)
GUICtrlSetLimit(-1, 100, 0)


;GUICtrlCreateLabel("Right Channel Volume Level", 8, 64, 150, 17)
;GUICtrlCreateLabel("Left Channel Volume Level", 8, 112, 150, 17)
; $Close = GUICtrlCreateButton("Close", 296, 160, 75, 25, 0)


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

$lbl_time_info = GUICtrlCreateLabel("00:00:00 / 00:00:00", 10, 165, 115, 25, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

;Show GUI
GUISetState(@SW_SHOW)

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


;Get the length of the song in bytes.
$song_length = _BASS_ChannelGetLength($MusicHandle, $BASS_POS_BYTE)

$song_length_sec = _BASS_ChannelBytes2Seconds($MusicHandle, $song_length)
ConsoleWrite("MAX : " & format_time_hr_min_sec_from_sec($song_length_sec) & @CRLF);


While 1
    ;Only do this if a song is playing.

    If $playing_state = 1 Then

        ;Get cursor information for the GUI.  We use this to know if the user is using the slider or no.
        $GGCI = GUIGetCursorInfo($GUI)

        ;Can't be using the slider, so update.
        If IsArray($GGCI) And Not $GGCI[2] Then

            ;Get Current playback position
            $current = _BASS_ChannelGetPosition($MusicHandle, $BASS_POS_BYTE)
            ;Calculate the percentage
            $percent = Round(($current / $song_length) * 100, 0)

        EndIf

        ;User has clicked the slider, so we must not update the song position.
        If IsArray($GGCI) And $GGCI[4] = $progress_slider And $GGCI[2] Then
            ;While the slider is being moved
            While $GGCI[2]
                ;Get updated cursor info
                $GGCI = GUIGetCursorInfo($GUI)
                ;Get position
                $gpos = Round(GUICtrlRead($progress_slider) / 100 * $song_length, 0)
            WEnd

            ;Slider is no longer clicked, so we now can set the pos.
            _BASS_ChannelSetPosition($MusicHandle, $gpos, $BASS_POS_BYTE + $BASS_MUSIC_POSRESET)

        Else
            ;
            ;Set the slider to show percent
            GUICtrlSetData($progress_slider, $percent)

            ; set sliders here or it will cause some funny effect ?

            ;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)

        EndIf
    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 $Play_pause
            ;Check if playing or paused, then take appropriate action
            Switch $playing_state

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

                    AdlibEnable("_my_timer_adlib", 1000) ; every 1 sec


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

                    $playing_state = 1

                    AdlibDisable()

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

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

            EndSwitch

        Case $Stop
            ;Stop Song
            _BASS_ChannelStop($MusicHandle)
            $playing_state = -1

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

    EndSwitch
WEnd

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



;===============================================================================
;
;
; format time string to hr:min:sec
;
;
;===============================================================================
Func format_time_hr_min_sec_from_sec($t_in)

    Local $l_std
    Local $l_min
    Local $l_sec

    Local $t_str

    $l_std = Int($t_in / 3600);
    $l_min = Int(($t_in - ($l_std * 3600)) / 60) ;
    $l_sec = Int(($t_in - ($l_std * 3600) - ($l_min * 60))) ;

    $t_str = StringFormat("%02i:%02i:%02i", $l_std, $l_min, $l_sec)

    Return $t_str

EndFunc   ;==>format_time_hr_min_sec_from_sec



;
; drop my files here
;
Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i + 1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next

    ; files are 0....x but only 0 is used for now

    init_file($gaDropFiles[0])

EndFunc   ;==>WM_DROPFILES_FUNC



; open file and reset values
Func init_file($file)

    Local $struct


    ; open & play first song
    ;Stop Song
    _BASS_Start() ; in case PAUSE was pressed it wont work
    _BASS_ChannelStop($MusicHandle)

    $playing_state = -1

    ; here _BASS_StreamFree() should be used to release filehandle
    _BASS_StreamFree($MusicHandle)

    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, $BASS_MUSIC_PRESCAN)

    GUICtrlSetData($lblFileName, $file);

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

    ;Get the length of the song in bytes.
    $song_length = _BASS_ChannelGetLength($MusicHandle, $BASS_POS_BYTE)
    $song_length_sec = _BASS_ChannelBytes2Seconds($MusicHandle, $song_length)

    ConsoleWrite("MAX : " & format_time_hr_min_sec_from_sec($song_length_sec) & @CRLF);

    ; get ID3 tags now drectyl
    $id3_ptr = _BASS_ChannelGetTags($MusicHandle, $BASS_TAG_ID3)

    If $id3_ptr <> 0 Then ; no data ?
        $struct = DllStructCreate("char v0[3]; char v1[30];char v2[30];char v3[30];char v4[4];char v5[30];char v6[1]", $id3_ptr)
        $id3_ptr_text = DllStructGetData($struct, 1)
        $id3_title = DllStructGetData($struct, 2)
        $id3_artist = DllStructGetData($struct, 3)
        $id3_album = DllStructGetData($struct, 4)

        ;$id3_ptr_text = DllStructGetData($struct, 5)
        ; ConsoleWrite("mp3 5 = " & $id3_ptr_text & @CRLF);
        ; $id3_ptr_text = DllStructGetData($struct, 6)
        ; ConsoleWrite("mp3 6 = " & $id3_ptr_text & @CRLF);

        GUICtrlSetData($lbl_title, $id3_title);
        GUICtrlSetData($lbl_artist, $id3_artist);
    Else
        GUICtrlSetData($lbl_title, "--unknown--");
        GUICtrlSetData($lbl_artist, "--unknown--");

    EndIf

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

    AdlibEnable("_my_timer_adlib", 1000) ; every 1 sec

EndFunc   ;==>init_file

; update time every sec in timer adlib to avoid flicker
Func _my_timer_adlib()

    ;Get Current playback position
    $current = _BASS_ChannelGetPosition($MusicHandle, $BASS_POS_BYTE)
    $current_sec = _BASS_ChannelBytes2Seconds($MusicHandle, $current)
    GUICtrlSetData($lbl_time_info, format_time_hr_min_sec_from_sec($current_sec) & " / " & format_time_hr_min_sec_from_sec($song_length_sec));

EndFunc   ;==>_my_timer_adlib
Link to comment
Share on other sites

updated my sample: now releases filehandles and retrieves mp3 tags

;
; sample BASS player - based on example_3
;
; added / changed:

;   - time display
;   - slider working to set / get position
;   - volume display vertical
;   - added drag / drop from explorer
;   - display title / artist from bass mp3 tag
;
;
; author nobbe 2009
;

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

Global $WM_DROPFILES = 0x233
Global $gaDropFiles[1], $str = ""

GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC")

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



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

;Initalize bass. Required for most functions.
_BASS_Init(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

;Prompt the user to select a MP3 file

#cs
    $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
#ce


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

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

$progress_slider = GUICtrlCreateSlider(8, 32, 370, 25)
GUICtrlSetLimit(-1, 100, 0)


$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(350, 80, 12, 100, $PBS_VERTICAL)
GUICtrlSetLimit(-1, 100, 0)


;GUICtrlCreateLabel("Right Channel Volume Level", 8, 64, 150, 17)
;GUICtrlCreateLabel("Left Channel Volume Level", 8, 112, 150, 17)
; $Close = GUICtrlCreateButton("Close", 296, 160, 75, 25, 0)


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

$lbl_time_info = GUICtrlCreateLabel("00:00:00 / 00:00:00", 10, 165, 115, 25, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

;Show GUI
GUISetState(@SW_SHOW)

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


;Get the length of the song in bytes.
$song_length = _BASS_ChannelGetLength($MusicHandle, $BASS_POS_BYTE)

$song_length_sec = _BASS_ChannelBytes2Seconds($MusicHandle, $song_length)
ConsoleWrite("MAX : " & format_time_hr_min_sec_from_sec($song_length_sec) & @CRLF);


While 1
    ;Only do this if a song is playing.

    If $playing_state = 1 Then

        ;Get cursor information for the GUI. We use this to know if the user is using the slider or no.
        $GGCI = GUIGetCursorInfo($GUI)

        ;Can't be using the slider, so update.
        If IsArray($GGCI) And Not $GGCI[2] Then

            ;Get Current playback position
            $current = _BASS_ChannelGetPosition($MusicHandle, $BASS_POS_BYTE)
            ;Calculate the percentage
            $percent = Round(($current / $song_length) * 100, 0)

        EndIf

        ;User has clicked the slider, so we must not update the song position.
        If IsArray($GGCI) And $GGCI[4] = $progress_slider And $GGCI[2] Then
            ;While the slider is being moved
            While $GGCI[2]
                ;Get updated cursor info
                $GGCI = GUIGetCursorInfo($GUI)
                ;Get position
                $gpos = Round(GUICtrlRead($progress_slider) / 100 * $song_length, 0)
            WEnd

            ;Slider is no longer clicked, so we now can set the pos.
            _BASS_ChannelSetPosition($MusicHandle, $gpos, $BASS_POS_BYTE + $BASS_MUSIC_POSRESET)

        Else
            ;
            ;Set the slider to show percent
            GUICtrlSetData($progress_slider, $percent)

            ; set sliders here or it will cause some funny effect ?

            ;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)

        EndIf
    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 $Play_pause
            ;Check if playing or paused, then take appropriate action
            Switch $playing_state

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

                    AdlibEnable("_my_timer_adlib", 1000) ; every 1 sec


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

                    $playing_state = 1

                    AdlibDisable()

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

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

            EndSwitch

        Case $Stop
            ;Stop Song
            _BASS_ChannelStop($MusicHandle)
            $playing_state = -1

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

    EndSwitch
WEnd

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



;===============================================================================
;
;
; format time string to hr:min:sec
;
;
;===============================================================================
Func format_time_hr_min_sec_from_sec($t_in)

    Local $l_std
    Local $l_min
    Local $l_sec

    Local $t_str

    $l_std = Int($t_in / 3600);
    $l_min = Int(($t_in - ($l_std * 3600)) / 60) ;
    $l_sec = Int(($t_in - ($l_std * 3600) - ($l_min * 60))) ;

    $t_str = StringFormat("%02i:%02i:%02i", $l_std, $l_min, $l_sec)

    Return $t_str

EndFunc ;==>format_time_hr_min_sec_from_sec



;
; drop my files here
;
Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam)
    Local $nSize, $pFileName
    Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255)
    For $i = 0 To $nAmt[0] - 1
        $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0)
        $nSize = $nSize[0] + 1
        $pFileName = DllStructCreate("char[" & $nSize & "]")
        DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", DllStructGetPtr($pFileName), "int", $nSize)
        ReDim $gaDropFiles[$i + 1]
        $gaDropFiles[$i] = DllStructGetData($pFileName, 1)
        $pFileName = 0
    Next

    ; files are 0....x but only 0 is used for now

    init_file($gaDropFiles[0])

EndFunc ;==>WM_DROPFILES_FUNC



; open file and reset values
Func init_file($file)

    Local $struct


    ; open & play first song
    ;Stop Song
    _BASS_Start() ; in case PAUSE was pressed it wont work
    _BASS_ChannelStop($MusicHandle)

    $playing_state = -1

    ; here _BASS_StreamFree() should be used to release filehandle
    _BASS_StreamFree($MusicHandle)

    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, $BASS_MUSIC_PRESCAN)

    GUICtrlSetData($lblFileName, $file);

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

    ;Get the length of the song in bytes.
    $song_length = _BASS_ChannelGetLength($MusicHandle, $BASS_POS_BYTE)
    $song_length_sec = _BASS_ChannelBytes2Seconds($MusicHandle, $song_length)

    ConsoleWrite("MAX : " & format_time_hr_min_sec_from_sec($song_length_sec) & @CRLF);

    ; get ID3 tags now drectyl
    $id3_ptr = _BASS_ChannelGetTags($MusicHandle, $BASS_TAG_ID3)

    If $id3_ptr <> 0 Then ; no data ?
        $struct = DllStructCreate("char v0[3]; char v1[30];char v2[30];char v3[30];char v4[4];char v5[30];char v6[1]", $id3_ptr)
        $id3_ptr_text = DllStructGetData($struct, 1)
        $id3_title = DllStructGetData($struct, 2)
        $id3_artist = DllStructGetData($struct, 3)
        $id3_album = DllStructGetData($struct, 4)

        ;$id3_ptr_text = DllStructGetData($struct, 5)
        ; ConsoleWrite("mp3 5 = " & $id3_ptr_text & @CRLF);
        ; $id3_ptr_text = DllStructGetData($struct, 6)
        ; ConsoleWrite("mp3 6 = " & $id3_ptr_text & @CRLF);

        GUICtrlSetData($lbl_title, $id3_title);
        GUICtrlSetData($lbl_artist, $id3_artist);
    Else
        GUICtrlSetData($lbl_title, "--unknown--");
        GUICtrlSetData($lbl_artist, "--unknown--");

    EndIf

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

    AdlibEnable("_my_timer_adlib", 1000) ; every 1 sec

EndFunc ;==>init_file

; update time every sec in timer adlib to avoid flicker
Func _my_timer_adlib()

    ;Get Current playback position
    $current = _BASS_ChannelGetPosition($MusicHandle, $BASS_POS_BYTE)
    $current_sec = _BASS_ChannelBytes2Seconds($MusicHandle, $current)
    GUICtrlSetData($lbl_time_info, format_time_hr_min_sec_from_sec($current_sec) & " / " & format_time_hr_min_sec_from_sec($song_length_sec));

EndFunc ;==>_my_timer_adlib

Display of tags is not working although tags are available!

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

He's using ID3v1. Most things these days are ID3v2x. So yeah... ;)

I use a different Dll to get tags (Media Info DLL or something), which does the job fine for me! :evil:

Link to comment
Share on other sites

He's using ID3v1. Most things these days are ID3v2x. So yeah... :evil:

I use a different Dll to get tags (Media Info DLL or something), which does the job fine for me! :evil:

Yep, your are right, only v2 tags ;)

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

of course its easy to integrate the id3.au3 udf or any other library - but i was loooking for a way to do it with bass functions

i started with id3 v1 tags (which wasnt working as expected), im looking into the v2 now which is more complicated

; Name...........: _BASS_ChannelGetTags

$BASS_TAG_ID3

ID3v1 tags. A pointer to a 128 byte block is returned. See http://www.id3.org/ID3v1 for details

$BASS_TAG_ID3V2

ID3v2 tags. A pointer to a variable length block is returned. ID3v2 tags are supported at both

the start and end of the file. See http://www.id3.org/ for details of the block's structure.

Edited by nobbe
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...