Jump to content

Audio Spectrascope


ConsultingJoe
 Share

Recommended Posts

Hi!

I've written a code with two Progressbars. the second progressbar showes not the rigth side, its only cause its looks nice ;) But the code is only ReWritten from the original, also not full selfwritten but a little bit selfwritte :whistle: ...

#Include <string.au3>
#Include <GUIConstants.au3>
#include <misc.au3>
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 1)

$dot = False
$bg = 0x222222
$graph = 0xFFFFFF
$run = True
Dim $lpszDevice
Dim $lpszDeviceID
Dim $lpszOpenFlags
Dim $lpszRequest
Dim $lpszFlags
Dim $lpszCommand
Dim $lpszReturnString
Dim $cchReturn
Dim $mciError
$lpszDevice = "new type waveaudio"
$lpszOpenFlags = "alias mywave"
$lpszFlags = ""
$lpszCommand = StringFormat("open %s %s %s", $lpszDevice, $lpszOpenFlags, $lpszFlags)
$lpszReturnString = _StringRepeat(" ", 100)
$cchReturn = StringLen($lpszReturnString)
$mciError = _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, 0);
If $mciError[0] <> 0 Then _mciShowError($mciError[0])
$lpszDeviceID = "mywave"
$lpszRequest = "level"
$lpszFlags = ""
$lpszCommand = StringFormat("status %s %s %s", $lpszDeviceID, $lpszRequest, $lpszFlags);
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 105, 183, 193, 115, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE))
$Progress1 = GUICtrlCreateProgress(9, 8, 39, 169, $PBS_VERTICAL+$PBS_SMOOTH)
GUICtrlSetColor(-1,0x0)
GUICtrlSetbkColor(-1,0x00FF00)
$Progress2 = GUICtrlCreateProgress(57, 8, 39, 169, $PBS_VERTICAL+$PBS_SMOOTH)

GUICtrlSetBkColor(-1,0x0)
GUICtrlSetColor(-1,0x00FF00)


GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$run = True
While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
;~  If $run = True Then
        $mciError = _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, 0);
        If $mciError[0] <> 0 Then _mciShowError($mciError[0])
        $mciError = (100*$mciError[2])/128
        If $mciError > 100 Then $mciError = 100
        GUICtrlSetData($Progress1,$mciError)
        GUICtrlSetData($Progress2,$mciError)
;~      Sleep(50)
;~  EndIf
    Sleep(10)
WEnd






Func SpecialEvents()
    Exit
EndFunc ;==>SpecialEvents

Func _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, $hwndCallback)
    Return DllCall("winmm.dll", "long", "mciSendStringA", "str", $lpszCommand, "str", $lpszReturnString, "long", $cchReturn, "long", 0)
EndFunc ;==>_mciSendString
Func _mciShowError($mciError)
    Dim $errStr; Error message
    $errStr = _StringRepeat(" ", 100); Reserve some space for the error message
    $Result = DllCall("winmm.dll", "long", "mciGetErrorStringA", "long", $mciError, "string", $errStr, "long", StringLen($errStr))
    MsgBox(0, "MCI test", "MCI Error Number " & $mciError & ":" & $Result[2])
EndFunc ;==>_mciShowError

Mfg/So long Spider

Edited by GtaSpider

www.AutoIt.de - Moderator of the German AutoIt Forum

 

Link to comment
Share on other sites

  • Replies 43
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

;;;;DllCall("winmm.dll", "long", "mciSendStringA", "str", $lpszCommand, "str", $lpszReturnString, "long", $cchReturn, "long", 0)

I am not good with dlls.

Can you plaese help me out with writing the full code for this line.(My alias is "MMFILE")

I tried replacing the variables but alas, i get nothing.

Thanks.

Link to comment
Share on other sites

Has anyone gotten anywhere yet with doing a Wave Out monitor? I've had requests for stuff that could do somethng when the computer makes a noise (just a noise... not any particular noise... yet :whistle: ), and this would be a great way to do it.

Link to comment
Share on other sites

Has anyone gotten anywhere yet with doing a Wave Out monitor? I've had requests for stuff that could do somethng when the computer makes a noise (just a noise... not any particular noise... yet :whistle: ), and this would be a great way to do it.

I believe you'll find that harder to impliment

just a couple of links to give you the idea of what may be involved.

http://www.codeproject.com/audio/oscilloscope.asp

http://www.codeproject.com/audio/waveInFFT.asp

http://www.codeguru.com/cpp/g-m/multimedia...icle.php/c4725/

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I believe you'll find that harder to impliment

just a couple of links to give you the idea of what may be involved.

:whistle: For future reference: when Gary says something is "harder", he doesn't mean "herding cats" hard or "lifting a car" hard, he's talking "achieving sustainable peace in the Middle East using only raw sugar and a co-ed pyjama party" hard. What were these Microsoft engineers thinking when they wrote this API? ;)

No good way to tell if the computer is making a noise then? No system-wide hooks for events that trigger audio, anything like that? Wow. WMP visualizations just became a lot less trivial...

Edited by sohfeyr
Link to comment
Share on other sites

:whistle: For future reference: when Gary says something is "harder", he doesn't mean "herding cats" hard or "lifting a car" hard, he's talking "achieving sustainable peace in the Middle East using only raw sugar and a co-ed pyjama party" hard. What were these Microsoft engineers thinking when they wrote this API? ;)

No good way to tell if the computer is making a noise then? No system-wide hooks for events that trigger audio, anything like that? Wow. WMP visualizations just became a lot less trivial...

lmao

Think you understand why the ones who make the Spectrum analyzers sell them and don't supply the code, too much hard work goes into making them work.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

When I try to run this buy double clicking on the icon for the file I get and error box that says "Error reading the file: misc.au3" What am I doing wrongly?

1.) by, not buy. buy means purchase

2.) you are doing something wrong, not wrongly (I think..)

dunno why I even did that, it just bugs me a little :"> :whistle:

anyway, did you install autoit using the installer or did you download the zip file? Do you have a protection program that might have blocked the installer from writing to the registry?

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

  • 1 year later...
  • 4 months later...
  • 4 months later...

Hi everyone,

Can anyone help with the syntax to extract the left and right channel volumes as opposed to the average sound level represented at the mo...? I've had a look at the msdn links and tried substituting different values for $lpszRequest as mentioned here MSDN link ; should be easy right!?

TIA

Link to comment
Share on other sites

  • 6 months later...

hi guys, love this script but have a question, on one pc it works great, on another the progress bars show nothing when sound is playing, I get no error, I was just wondering if anyone knew the cause of this. I have XP on both machines, and using latest autoit.

Who needs puzzles when we have AutoIt!!

Link to comment
Share on other sites

hi guys, love this script but have a question, on one pc it works great, on another the progress bars show nothing when sound is playing, I get no error, I was just wondering if anyone knew the cause of this. I have XP on both machines, and using latest autoit.

This scripts has nothing to do with any playing of sounds, it monitors your "recording device". If nothing shows up you most likely didn't change from mic/"line in" (the two mostly used) to "Stereo mix" or whatever it's called for your soundcard. Edited by AdmiralAlkex
Link to comment
Share on other sites

  • 1 year later...

Hello.

Great script! I try to use it to listen watch ticking and analyse it after that. Actually I use just _mciSendString function but i suspect this gave me some delay. I mean I just see the miliseconds when some noise goes over specific level, but the miliseconds looks too rounded 360, 330, 350... its not normal.

My question is can i monitor the microphone input more directly, to make the analyse more precise.

Link to comment
Share on other sites

  • 5 months later...
  • 2 years later...

This is not my code but im guiding my selft by it. Im not a pro and i would like to know if its possible to do this but instead of drawing sounds from micro it would draw the sound that was coming from a program.

Is it possible? 

#Include <string.au3>
#Include <GUIConstants.au3>
#include <misc.au3>
$dot = False
$bg = 0x222222
$graph = 0xFFFFFF
Opt( "GUIOnEventMode", 1 )
Dim $lpszDevice
Dim $lpszDeviceID
Dim $lpszOpenFlags
Dim $lpszRequest
Dim $lpszFlags
Dim $lpszCommand
Dim $lpszReturnString
Dim $cchReturn
Dim $mciError
$lpszDevice = "new type waveaudio"
$lpszOpenFlags = "alias mywave"
$lpszFlags = ""
$lpszCommand = StringFormat( "open %s %s %s", $lpszDevice, $lpszOpenFlags, $lpszFlags)
$lpszReturnString = _StringRepeat( " ", 100)
$cchReturn = StringLen($lpszReturnString)
$mciError = _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, 0);
If $mciError[0] <> 0 Then _mciShowError($mciError[0])
$lpszDeviceID = "mywave"
$lpszRequest = "level"
$lpszFlags = ""
$lpszCommand = StringFormat( "status %s %s %s", $lpszDeviceID, $lpszRequest, $lpszFlags);
$Form1 = GUICreate("GRAPHICAL WAVE BY ZEROCOOL", 281, 197, 193, 115)
$box = GuiCtrlCreateGraphic(0, 8, 281, 107)
GUICtrlSetBkColor(-1,$bg)
GUICtrlSetColor(-1,0)
GUICtrlSetGraphic( -1, $GUI_GR_MOVE, 0, 107/2)
GUICtrlSetGraphic( -1, $GUI_GR_LINE, 281, 107/2)
$marker = GuiCtrlCreateGraphic(0, 8, 1, 107)
GUICtrlSetBkColor(-1,0xFFFFFF)
$Button1 = GUICtrlCreateButton("Start", 0, 120, 89, 33, 0)
$Button2 = GUICtrlCreateButton("Stop", 96, 120, 89, 33, 0)
$Button3 = GUICtrlCreateButton("Clear", 192, 120, 89, 33, 0)
$Button4 = GUICtrlCreateButton("BG Color", 0, 160, 89, 33, 0)
$Button5 = GUICtrlCreateButton("Graph Color", 192, 160, 89, 33, 0)
$Button6 = GUICtrlCreateButton("Lines/Dots", 96, 160, 89, 33, 0)
GUISetState(@SW_SHOW)
GUICtrlSetOnEvent ( $Button1, "start" )
GUICtrlSetOnEvent ( $Button2, "stop" )
GUICtrlSetOnEvent ( $Button3, "clear" )
GUICtrlSetOnEvent ( $Button4, "graph_color" )
GUICtrlSetOnEvent ( $Button5, "bg_color" )
GUICtrlSetOnEvent ( $Button6, "toggle" )
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
$point = 0
$run = False
While 1
    If $run = True Then
        $mciError = _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, 0);
        If $mciError[0] <> 0 Then _mciShowError($mciError[0])
        If $dot = True Then
            GUICtrlSetGraphic( $box, $GUI_GR_COLOR, $graph)
            GUICtrlSetGraphic( $box, $GUI_GR_DOT, $point, (107/2)+$mciError[2]/2 )
            GUICtrlSetGraphic( $box, $GUI_GR_DOT, $point, (107/2)-$mciError[2]/2 )
        Else
            GUICtrlSetGraphic( $box, $GUI_GR_MOVE, $point, 107/2)
            GUICtrlSetGraphic( $box, $GUI_GR_COLOR, $graph)
            GUICtrlSetGraphic( $box, $GUI_GR_LINE, $point, (107/2)+$mciError[2]/2 )
            GUICtrlSetGraphic( $box, $GUI_GR_LINE, $point, (107/2)-$mciError[2]/2 )
        EndIf
        $point = $point + 1
        If $point > 280 Then
            GUICtrlDelete( $box )
            GUICtrlDelete( $marker )
            $box = GuiCtrlCreateGraphic(0, 8, 281, 107)
            GUICtrlSetGraphic( -1, $GUI_GR_MOVE, 0, 107/2)
            GUICtrlSetGraphic( -1, $GUI_GR_COLOR, $graph)
            GUICtrlSetGraphic( -1, $GUI_GR_LINE, 281, 107/2)
            GUICtrlSetBkColor(-1,$bg)
            GUICtrlSetColor(-1,0)
            GUICtrlSetGraphic( -1, $GUI_GR_MOVE, 0, 107/2)
            GUICtrlSetGraphic( -1, $GUI_GR_COLOR, $graph)
            GUICtrlSetGraphic( -1, $GUI_GR_LINE, 281, 107/2)
            $marker = GuiCtrlCreateGraphic(0, 8, 3, 107)
            GUICtrlSetBkColor(-1,0xFFFFFF)
            $point = 0
            Sleep(10)
        EndIf
        GUICtrlSetPos ( $marker, $point, 8 )
    EndIf
    Sleep(10)
WEnd

Func bg_color()
    Global $bg = _ChooseColor(2, $bg, 2)
    GUICtrlSetBkColor($box,$bg)
EndFunc

Func graph_color()
    Global $graph = _ChooseColor(2, $graph, 2)
    GUICtrlSetBkColor($marker,$graph)
EndFunc

Func toggle()
    If $dot = False Then
        $dot = True
    Else
        $dot = False
    EndIf
EndFunc

Func start()
    $run = True
EndFunc

Func stop()
    $run = False
EndFunc

Func clear()
    GUICtrlDelete( $box )
    GUICtrlDelete( $marker )
    $box = GuiCtrlCreateGraphic(0, 8, 281, 107)
    GUICtrlSetBkColor(-1,$bg)
    GUICtrlSetColor(-1,0)
    GUICtrlSetGraphic( -1, $GUI_GR_MOVE, 0, 107/2)
    GUICtrlSetGraphic( -1, $GUI_GR_COLOR, $graph)
    GUICtrlSetGraphic( -1, $GUI_GR_LINE, 281, 107/2)
    $marker = GuiCtrlCreateGraphic(0, 8, 3, 107)
    GUICtrlSetBkColor(-1,$graph)
    $point = 0
EndFunc

Func SpecialEvents()
    Exit
EndFunc

Func _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, $hwndCallback)
    Return DllCall("winmm.dll", "long", "mciSendStringA", "str", $lpszCommand, "str", $lpszReturnString, "long", $cchReturn, "long", 0)
EndFunc   ;==>_mciSendString
Func _mciShowError($mciError)
    Dim $errStr; Error message
    $errStr = _StringRepeat( " ", 100) ; Reserve some space for the error message
    $Result = DllCall("winmm.dll", "long", "mciGetErrorStringA", "long", $mciError, "string", $errStr, "long", StringLen($errStr))
    MsgBox(0, "MCI test", "MCI Error Number " & $mciError & ":" & $Result[2])
EndFunc   ;==>_mciShowError

 This code belongs to zerocool60544

Link to comment
Share on other sites

@TheWebz - You have resurrected a very old topic, that hasn't been replied to by the OP, since October 2006. In fact, only one other person has responded more recently, and that was in February 2009.

You would have been far better served starting your own topic, with a more suitable title, instead of Necroing this one.

And it should also be in General Help & Support, as you are asking your own question, not a question about the OP.

You could have linked to this topic, if you felt it relevant, but AutoIt versions have changed and current compatibility with OP code is probably an issue .... that's if what you are asking is even close enough related ... I didn't check. 

I'm not into the Zombie Awards myself, but no doubt one of the others who are, will now add your resurrection.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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