Jump to content

Recommended Posts

  • 2 weeks later...
Posted (edited)

Is it possible to display channel levels (L/R) from sound card when another program is producing the sound output?

E.g. when mediaplayer or other source is playing a mp3 and I just want to display channel levels, e.g with GDI+ Visualization: Analog Meter I wrote?

If yes, how?

Sorry, but I'm not so familiar with bass.dll :unsure:

Thanks,

UEZ

PS: nice job :P

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

on most soundcards you can capture the output.

you have to choose an input called "What you hear" or "Stereomix" or something like that! (= $BASS_INPUT_TYPE_WAVE flag ?!?)

#include "Bass.au3"
#include "BassConstants.au3"
#include <WinAPI.au3>

$bassdll = DllOpen(@ScriptDir & "\bass.dll")

_BASS_SetConfig($bassdll, $BASS_CONFIG_REC_BUFFER, 1000)

_BASS_RecordInit($bassdll, -1)

$Cnt = 0
$Name = _BASS_RecordGetInputName($bassdll, 0)
While $Name <> ""
    $Input = _BASS_RecordGetInput($bassdll, $Cnt)
    If BitAND($Input[0], $BASS_INPUT_TYPE_WAVE) Then _BASS_RecordSetInput($bassdll, $Cnt, $BASS_INPUT_ON, 1)
    $Cnt += 1
    $Name = _BASS_RecordGetInputName($bassdll, $Cnt)
WEnd

$RecHandle = _BASS_RecordStart($bassdll, 44100, 2, _WinAPI_MakeLong(0, 10))

GUICreate("BassTest", 220, 50)
$hMeterLeft = GUICtrlCreateProgress(10, 10, 200, 18, 1)
$hMeterRight = GUICtrlCreateProgress(10, 30, 200, 18, 1)
GUISetState()

While GUIGetMsg() <> -3
    $Level = _BASS_ChannelGetLevel($bassdll, $RecHandle)
    $LevelL = _WinAPI_LoWord($Level) * 100 / 32768
    $LevelR = _WinAPI_HiWord($Level) * 100 / 32768
    GUICtrlSetData($hMeterLeft, $LevelL)
    GUICtrlSetData($hMeterRight, $LevelR)
    Sleep(5)
WEnd

E

Posted

on most soundcards you can capture the output.

you have to choose an input called "What you hear" or "Stereomix" or something like that! (= $BASS_INPUT_TYPE_WAVE flag ?!?)

#include "Bass.au3"
 #include "BassConstants.au3"
 #include <WinAPI.au3>
 
 $bassdll = DllOpen(@ScriptDir & "\bass.dll")
 
 _BASS_SetConfig($bassdll, $BASS_CONFIG_REC_BUFFER, 1000)
 
 _BASS_RecordInit($bassdll, -1)
 
 $Cnt = 0
 $Name = _BASS_RecordGetInputName($bassdll, 0)
 While $Name <> ""
     $Input = _BASS_RecordGetInput($bassdll, $Cnt)
     If BitAND($Input[0], $BASS_INPUT_TYPE_WAVE) Then _BASS_RecordSetInput($bassdll, $Cnt, $BASS_INPUT_ON, 1)
     $Cnt += 1
     $Name = _BASS_RecordGetInputName($bassdll, $Cnt)
 WEnd
 
 $RecHandle = _BASS_RecordStart($bassdll, 44100, 2, _WinAPI_MakeLong(0, 10))
 
 GUICreate("BassTest", 220, 50)
 $hMeterLeft = GUICtrlCreateProgress(10, 10, 200, 18, 1)
 $hMeterRight = GUICtrlCreateProgress(10, 30, 200, 18, 1)
 GUISetState()
 
 While GUIGetMsg() <> -3
     $Level = _BASS_ChannelGetLevel($bassdll, $RecHandle)
     $LevelL = _WinAPI_LoWord($Level) * 100 / 32768
     $LevelR = _WinAPI_HiWord($Level) * 100 / 32768
     GUICtrlSetData($hMeterLeft, $LevelL)
     GUICtrlSetData($hMeterRight, $LevelR)
     Sleep(5)
 WEnd

E

Thanks for your example but it is not working on my Toshiba notebook :P No L/R levels!

I will test it also on my other Dell notebook later (tomorrow?).

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

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

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
I'm still a bit confused on how to implement it :P
Posted (edited)

Mmmhhh, it is also not working on my Dell notebook!

When put the line ConsoleWrite(@error & " : " & $Name & @CRLF) just after $Name = _BASS_RecordGetInputName($bassdll, 0) before While $Name <> "" loop I

get following output:

0 : Master Volume

It that the value which is expected?

I'm using hasta la Vista x32!

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

Mmmhhh, it is also not working on my Dell notebook!

When put the line ConsoleWrite(@error & " : " & $Name & @CRLF) just after $Name = _BASS_RecordGetInputName($bassdll, 0) before While $Name <> "" loop I

get following output:

0 : Master Volume

It that the value which is expected?

I'm using hasta la Vista x32!

UEZ

What I´ve done is to check the flag of each input.

If the flag = $BASS_INPUT_TYPE_WAVE then this input is the right one to capture the output (I thought :P)

please put this line: ConsoleWrite($Cnt & " " & $Name & " " & $Input[0] & @LF)

after $Input = _BASS_RecordGetInput($bassdll, $Cnt)

and post the result.

E

Posted

The output is: 0 Master Volume 50331648

But I got a peak when I comment out the lines starting from $Cnt = 0 until WEnd and add after WEnd _BASS_RecordSetInput($bassdll, 0, $BASS_INPUT_TYPE_WAVE, 1)!

That's the microphone input!

Thanks,

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

Here the screenshots of my device:

Only 2 Audio Devices!

ASIO is empty.

UEZ

PS: screenshots removed due to low attachments space!

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted

Everything says there should be a stero mix to me...

I get

0 CD Volume 83951616

1 Line Volume 33619968

2 Mic Volume 50397184

3 Stereo Mix 167772160

but I will sit back and let euka do his thing, as he knows more about this than me :P

Posted

Ok - it´s Vista

bassforum:

I guess you're referring to changing the active input via BASS_RecordSetInput? If so, I'm afraid that is not possible as Vista presents each input as a separate device.

If you do not have a StereoMix-device, you can´t capture the output, I think...

Maybe there is an other way on Vista?!?

Posted (edited)

Ok - it´s Vista

bassforum:

I guess you're referring to changing the active input via BASS_RecordSetInput? If so, I'm afraid that is not possible as Vista presents each input as a separate device.

If you do not have a StereoMix-device, you can´t capture the output, I think...

Maybe there is an other way on Vista?!?

Thanks for investigation!

Let's wait for workaround... hasta la Vista baby :unsure:

Btw, nice application eukalyptus :P

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

I'm still a bit confused on how to implement it :P

I saw this right now and have an update for it :unsure:

You won't need extra funcs to load DLLs anymore, since AutoIt checks the DLL-Load error itself since 3.3.0.0 :D

But if you use Global Variables for them, like i recommend, it is useful to load DLLs with a function:

Global $_BASS_BASSDLL=-1
Func _BASS_LoadDLL($DLLFile="bass.dll")
    ; Prog@ndy
    If $_BASS_BASSDLL > -1 Then Return $_BASS_BASSDLL
    Local $ret =  DllOpen($DLLFile)
    If $ret = -1 Then Return SetError(1,0,-1)
    Global $_BASS_BASSDLL = $ret
    Return $ret
EndFunc
Func _BASS_UnloadDLL()
    ; Prog@ndy
    If $_BASS_BASSDLL > -1 Then 
        DllClose($_BASS_BASSDLL)
        $_BASS_BASSDLL = -1
        Return True
    EndIf
    Return False
EndFunc

//Edit: and use similar functions for each BASS-plugin.

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 (edited)

I get back negative values on some MP3' using the _BASS_ChannelGetLevel() function (range 0-0x7FFF is exceeded to value 0x8000):

Here for left channel:

...

11851

13160

12649

12136

14412

32028

-32768

25042

20662

23209

19470

21297

18689

16944

25140

19822

-32768

26505

22165

23393

20573

15723

16311

15859

...

I saw on my Analog Meter that the left channel moves to the left bottom sometimes on some MP3s :P (code already fixed)!

Is this a bug in the bass.dll?

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Posted (edited)

Bass returns left & right channels in loword and hiword...

try this code to show the problem:

#include <WinApi.au3>

$X=32768
$Y=32768

$Z=_WinAPI_MakeLong($X, $Y)

ConsoleWrite($Z & " " & _WinAPI_HiWord($Z) & " " & _WinAPI_LoWord($Z) & @LF)

E

Edited by eukalyptus
Posted

Bass returns left & right channels in loword and hiword...

try this code to show the problem:

#include <WinApi.au3>
   
   $X=32768
   $Y=32768
   
   $Z=_WinAPI_MakeLong($X, $Y)
   
   ConsoleWrite($Z & " " & _WinAPI_HiWord($Z) & " " & _WinAPI_LoWord($Z) & @LF)

E

I know this already but I though that both values for l/r should be in the same range-> 0x0000 - 0x7FFF

but bass.dll return also 0x8000 which causes negative value for high word only.

Is this a bug?

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

  • 1 month later...
Posted

It worked/s great!

However, with newer versions of Autoit I get the following error:

: ERROR: $error previously declared as a 'Const'

$error = _BASS_ErrorGetCode($bass_dll)

if I comment out the error line it works fine, but it would be better to fix it for debugging purposes.

How do I fix this error?

Thanks,

Dennis

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