Jump to content

Recommended Posts

Posted

First of all, stop putting the $bass_dll into every function call, none (or almost none) of these functions will accept you passing it this variable.

Second, the device is the number for the audio device that is being used. Usually starts at 1 and goes up from there. This function returns an array just as an FYI.

i must putting the $bass_dll because if not I get this:

"Incorrect number of parameters in function call"

and this is working:

$test = _BASS_GetDeviceInfo($bass_dll, 1)
MsgBox(0,"",$test[0])

thank you for your help!

Posted

Sorry, I am using an updated version of the UDF, I forgot the older version required the DLL argument every time.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted (edited)

Sorry, I am using an updated version of the UDF, I forgot the older version required the DLL argument every time.

Really?

I have a lot of problems because I always had to deal with the DLL ..

I updated the UDF now.

Please help me to update this example to work with the new UDF:

#include <BassEnc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>
Opt("GUIOnEventMode", 1)

Global $device , $RecHandle, $KHZ = 44100, $levelL = 0, $levelR = 0

$bass_dll = DllOpen("BASS.dll")
$bassenc_dll = DllOpen("BASSENC.dll")

$test = _BASS_GetDeviceInfo($bass_dll, 1) ; קבלת שם התקן האודיו הנבחר במערכת
;MsgBox(0,"",$test[0])
;Exit


$hGui = GUICreate("Bass.dll / BassEnc.dll Recording Test", 320, 320)
$hPeakL = GUICtrlCreateProgress(10, 160, 300, 10)
$hPeakR = GUICtrlCreateProgress(10, 175, 300, 10)
GUISetState()
WinSetOnTop($hGui,"",1)


_SelectDevice(2)


$begin = TimerInit()

;_GetDevices()
_BASS_SetConfig($bass_dll, $BASS_CONFIG_REC_BUFFER, 1000)
While 1
Sleep(5)
$peak = _BASS_ChannelGetLevel($bass_dll, $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)
;ToolTip($levelL)
$levelL -= 1
$levelR -= 1
EndIf

WEnd




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


Func _SelectDevice($DeviceSet)
_BASS_RecordFree($bass_dll)
_BASS_RecordSetDevice($bass_dll, $DeviceSet)
_BASS_Recordinit($bass_dll, $DeviceSet)
$RecHandle = _BASS_RecordStart($bass_dll, $KHZ, 2, _makelong($BASS_SAMPLE_FX, 500), "_RecCallBack")
$device = $DeviceSet
ConsoleWrite("$device: "&$DeviceSet&@CRLF)
EndFunc

if I'm combines the example into something more complex, which uses this UDF for other purposes, sometimes I have to reopen the DLLs by DllClose() and then DllOpen().

it solve some problam but it create new one... it is very not comfortable to mess with it.

If the new UDF does not require me to deal with it then it's worth it

Edited by Guest
Posted (edited)

i worte some code with a bug that i get.. this is the code:

#AutoIt3Wrapper_UseX64=n
#include "BassExt.au3"
_BASS_STARTUP()
$lopp = 1
While 1
$DeviceInfo = _BASS_GetDeviceInfo(1)
$ActiveSpDevice = $DeviceInfo[0]
ConsoleWrite("the Active Device is: "&$ActiveSpDevice&" (loop "&$lopp&")"&@CRLF)
$lopp = $lopp+1
Sleep(5000)
WEnd

the bug is that when i changing my audio device device while the code is runing, so the code/script still display my previous audio device..

the script not see any change..

only when i close the script and re-run so he will show the new audio device..

i am using the UDF v10 ..

i don't know whay the bug Happening.

Please help me.

Thanks for helpers!

Edited by Guest
Posted

What does the function return in the array after you've changed devices? The array's 3rd element should tell you more information.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

What does the function return in the array after you've changed devices? The array's 3rd element should tell you more information.

it was 3 and after i change the device (while the code is runing), it return 1
Posted

Global Const $BASS_DEVICE_ENABLED = 1
Global Const $BASS_DEVICE_DEFAULT = 2

This is telling you that first time around, it's the default device, second time around it's telling that it's not, but it's enabled both times.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted (edited)

Global Const $BASS_DEVICE_ENABLED = 1
Global Const $BASS_DEVICE_DEFAULT = 2

This is telling you that first time around, it's the default device, second time around it's telling that it's not, but it's enabled both times.

ok

i just need to know what is the new default device..

what it's telling me is not enough information.

i have more then 2 devices so i can't guess from this info if the other device is the default one

Edited by Guest
Posted

Don't use _BASS_GetDeviceInfo(1), loop through your devices, probably just 1 and 2, and see which one shows up as the default.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted (edited)

ok thanks

i am traying to create Multi Device Listening monitor and it is not going so well...

Posted Image

this is my code:

#AutoIt3Wrapper_UseX64=n
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include "BassExt.au3"



#Region ### START Koda GUI section ### Form=
$hGui = GUICreate("Multi Device Listening", 321, 365, 300, 188, -1, BitOR($WS_EX_RIGHT,$WS_EX_WINDOWEDGE))
$hPeakL1 = GUICtrlCreateProgress(10, 114, 300, 10)
$hPeakR1 = GUICtrlCreateProgress(10, 129, 300, 10)
$Audio1Lab = GUICtrlCreateLabel("Device 2", 248, 88, 61, 17)
$hPeak1 = GUICtrlCreateLabel("$hPeak", 24, 88, 120, 17)
$hPeakL2 = GUICtrlCreateProgress(9, 41, 300, 10)
$hPeakR2 = GUICtrlCreateProgress(9, 56, 300, 10)
$Audio2Lab = GUICtrlCreateLabel("Device 1", 247, 15, 62, 17)
$hPeak2 = GUICtrlCreateLabel("$hPeak", 23, 15, 41, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

WinSetOnTop($hGui,"",1)


Local $SetAction = True

Global $Adevice1 = 2; <-------------================ PUT HERE YOUR FIRST DEVICE NUMBER
Global $Adevice2 = 3; <-------------================ PUT HERE YOUR SECOND DEVICE NUMBER

Global $device , $RecHandle, $KHZ = 44100, $levelL = 0, $levelR = 0
Local $Set1 = True
_BASS_STARTUP()
_BASS_SetConfig($BASS_CONFIG_REC_BUFFER, 1000)
$DeviceSet = $Adevice1
_SelectDevice($DeviceSet)
_SelectDevice($Adevice1)
$Tsleep = 5
$begin2 = TimerInit()
While 1
    If $SetAction = True Then
        Sleep($Tsleep)
        $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
            $levelL -= 1
            $levelR -= 1
        EndIf
        
        $levelRL = ($levelL+$levelR)/2
        If $DeviceSet = $Adevice1 Then
            GUICtrlSetData($hPeakL1, $levelL)
            GUICtrlSetData($hPeakR1, $levelR)
            GUICtrlSetData($hPeak1,$levelRL)
        ElseIf $DeviceSet = $Adevice2 Then
            GUICtrlSetData($hPeakL2, $levelL)
            GUICtrlSetData($hPeakR2, $levelR)
            GUICtrlSetData($hPeak2,$levelRL)
        EndIf
    EndIf
    $dif2 = TimerDiff($begin2)
    If $dif2 > 250 Then
        If $DeviceSet = $Adevice1 And $Set1 = True Then
            $DeviceSet = $Adevice2
            $Set1 = False
        ElseIf $DeviceSet = $Adevice2 And $Set1 = True Then
            $DeviceSet = $Adevice1
            $Set1 = False
        EndIf
        $Set1 = True
        $begin2 = TimerInit()
        _SelectDevice($DeviceSet)
    EndIf
WEnd


Func _SelectDevice($DeviceSet)
    _BASS_RecordFree()
    _BASS_RecordSetDevice($DeviceSet)
    _BASS_Recordinit($DeviceSet)
    $RecHandle = _BASS_RecordStart(44100, 2, 0, $BASS_EXT_RecordProc)
    $device = $DeviceSet
    ConsoleWrite("$RecHandle: "&$RecHandle&@CRLF)
EndFunc


Func _MakeLong($lo_value, $hi_value)
    Return BitOR(BitAND($hi_value * 0x10000, 0xFFFF0000), BitAND($lo_value, 0xFFFF))
EndFunc   ;==>_MakeLong
Func _LoWord($value)
    Return BitAND($value, 0xFFFF)
EndFunc   ;==>_LoWord
Func _HiWord($value)
    Return BitShift($value, 16)
EndFunc   ;==>_HiWord

to test it you need to write tow device numbers..

it is not working good..

It works hardly .. Not so good.

What I want to do is listen to two devices at a same time.

In my case - I want to listen to the microphone and speakers at the same time.

How can I do it right?

Edited by Guest
Posted

You got me, because I can't understand your request. You want to listen to an input device and an output device at the same time? What does that mean?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted (edited)

You got me, because I can't understand your request. You want to listen to an input device and an output device at the same time? What does that mean?

Sorry .. Maybe it's because my English.

EDIT:

to an input device and an output device at the same time?

yes

I have two sound devices(. All I need is to get in real-time the input/output of two audio devices.

this for exmple:

#AutoIt3Wrapper_UseX64=n
#include "BassExt.au3"

Global $device , $RecHandle, $KHZ = 44100, $levelL = 0, $levelR = 0

_BASS_STARTUP()


$hGui = GUICreate("SoundIn Monitor", 320, 320)
$hPeakL = GUICtrlCreateProgress(10, 160, 300, 10)
$hPeakR = GUICtrlCreateProgress(10, 175, 300, 10)
GUISetState()
WinSetOnTop($hGui,"",1)

;_GetDevices()
_SelectDevice(2)
;$test = _BASS_ChannelGetInfo($RecHandle)
;MsgBox(0,"",$test[5])
;Exit


$begin = TimerInit()

;_GetDevices()
_BASS_SetConfig($BASS_CONFIG_REC_BUFFER, 1000)
While 1
    Sleep(5)
    $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)
        ;ToolTip($levelL)
        $levelL -= 1
        $levelR -= 1
    EndIf
WEnd




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] & "|"
            ConsoleWrite("$info[0]: "&$info[0]&" , $count: "&$count-1&@CRLF)
        EndIf
        If BitAND($info[2], $BASS_DEVICE_DEFAULT) Then
            $sdef = $info[0]
            $idef = $count
        EndIf
    WEnd
    Return $idef - 1
EndFunc


Func _SelectDevice($DeviceSet)
    _BASS_RecordFree()
    _BASS_RecordSetDevice($DeviceSet)
    _BASS_Recordinit($DeviceSet)
    $RecHandle = _BASS_RecordStart(44100, 2, 0, $BASS_EXT_RecordProc)
    $device = $DeviceSet
    ConsoleWrite("$RecHandle: "&$RecHandle&@CRLF)
EndFunc


Func _MakeLong($lo_value, $hi_value)
    Return BitOR(BitAND($hi_value * 0x10000, 0xFFFF0000), BitAND($lo_value, 0xFFFF))
EndFunc ;==>_MakeLong

Func _LoWord($value)
    Return BitAND($value, 0xFFFF)
EndFunc ;==>_LoWord

Func _HiWord($value)
    Return BitShift($value, 16)
EndFunc ;==>_HiWord

give me the input/output of one Audio device in real-time.

i need 2 slots for TWO Audio devices..

i hope now it is cleer for you..

thanks for your help :)

Edited by Guest
Posted (edited)

Update:

i have success to do it with the old UDF and with 2 bass DLLs !!

i am so hapy now.. it is so fun to success do something after days of trying alone :sorcerer:

works only with the old udf and with 2 bass DLLs.

don't try this with one dll.. it will not work. (don't know whay)

Edited by Guest
Posted
Posted (edited)

you can't download BASS1.dll and BASS2.dll. you must to create them. it was not the easy part for me to get it

Edited by Guest
Posted (edited)

When I said it was not easy, I mean it was not easy to accept the idea (to use an old UDF and copy DLLs)

When I say create, I meant that you need to create two copies of the DLLs and call them what you want ..

I'm not a programmer DLLs for it.

Edited by Guest

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