Jump to content

Audio Spectrascope


ConsultingJoe
 Share

Recommended Posts

  • 3 months later...
  • Replies 43
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

hello all,
I simplified and eliminate redundancies.

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

Dim $box
Dim $marker
init_graph()

$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")
AdlibRegister("Draw_wav", 50)
$point = 0
$run = False

While 1
    Sleep(5000)
WEnd

Func Draw_wav()
    If $run = True Then
        $mciError = _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, 0);
        If $mciError[0] <> 0 Then _mciShowError($mciError[0])
        GUICtrlSetGraphic( $box, $GUI_GR_COLOR, $graph)
        If $dot = True Then            
            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)+$mciError[2]/2)
        GUICtrlSetGraphic( $box, $GUI_GR_LINE, $point, (107/2)-$mciError[2]/2 )
        EndIf
        $point = $point + 1 ;parcours
        If $point > 280 Then clear()
        GUICtrlSetPos ( $marker, $point, 8 )
    EndIf
EndFunc

Func init_graph()
    $point = 0
    $box = GuiCtrlCreateGraphic(0, 8, 281, 107) ;objet graphique
    GUICtrlSetBkColor($box,$bg)
    GUICtrlSetGraphic($box, $GUI_GR_COLOR, 0)
    GUICtrlSetGraphic( $box, $GUI_GR_MOVE, 0, 107/2)
    GUICtrlSetGraphic( $box, $GUI_GR_LINE, 281, 107/2) ;ligne central
    $marker = GuiCtrlCreateGraphic(0, 8, 1, 107);curseur
    GUICtrlSetBkColor($marker,0xFFFFFF)
    GUICtrlSetGraphic( $box, $GUI_GR_REFRESH) 
EndFunc

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()
    $dot = Not $dot
EndFunc

Func start()
    $run = True
EndFunc

Func stop()
    $run = False
EndFunc

Func clear()
    GUICtrlDelete( $box )
    GUICtrlDelete( $marker )
    init_graph()
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
Edited by sigmoon
Link to comment
Share on other sites

  • 5 years later...

When i try to port to x64 with update dll i get a  0xc0000005 crash in 604 line:

$hStatus = DllCall($ghGDIPDll, "int", "GdipSetLineBlend", "handle", $aRet[6], "ptr", $pFactors, "ptr", $pPositions, "int", $iCount)

do it have a solution?

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