1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. eukalyptus

Beiträge von eukalyptus

  • Another AutoIt PreProcessor

    • eukalyptus
    • 23. April 2010 um 08:57
    Zitat von KaFu

    Hiho Eukalyptus, hast mich endlich dazu gebracht mich hier auch anzumelden :). Vielen Dank für den netten PreProcessor, werd mal versuchen SMF mit ner vernünftigen Kombo an switches compiled zu bekommen. Ein kleiner Punkt ist mir bisher aufgefallen, $CmdLineRaw darf auch nicht umbenannt werden.

    Gruß nach Wien :)...

    Herzlich Willkommen hier im Forum!
    Und Danke für $CmdLineRaw - kannte ich nocht nicht und hätte ich schon ein paar mal gebraucht. :thumbup:

    c.u.

  • GDI+ Laser-Text

    • eukalyptus
    • 23. April 2010 um 08:37

    Eine kleine Spielerei von mir.

    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.

    folgende Includes werden benötigt:
    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.
    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.

    mfgE

    Dateien

    Laser_text.au3 3,75 kB – 477 Downloads
  • Sinuswellen-Generator

    • eukalyptus
    • 21. April 2010 um 20:20

    Hab mich mal an weiteren Waveformen versucht...

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GuiComboBoxEx.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ;Das Script erstellt eine WAV-Datei im Speicher, spielt diese ab und speichert anschließend in eine Datei

    [/autoit] [autoit][/autoit] [autoit]

    ;Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $pi = 4 * ATan(1) ;pi=3,1415926....
    Global $struct, $wavstruct, $sekunden, $samplingrate, $Channels, $samplefaktor
    Global $freq_sliderold = 440, $volm_sliderold = 50

    [/autoit] [autoit][/autoit] [autoit]

    $gui = GUICreate("Wave Generator ", 450, 450, -1, -1)
    ;label
    $freq_lbl = GUICtrlCreateLabel("Frequenz Hz", 16, 16, 64, 17)
    $grph_lbl = GUICtrlCreateLabel("Wave Form", 16, 184, 59, 17)
    $samp_lbl = GUICtrlCreateLabel("Sampling Bits/Sec", 16, 48, 90, 17)
    $bits_lbl = GUICtrlCreateLabel("Bits per Sample", 16, 120, 90, 17)
    $chan_lbl = GUICtrlCreateLabel("Channels", 16, 152, 48, 17)
    $show_lbl = GUICtrlCreateLabel("Show Samples ", 16, 216, 77, 17)
    $volm_lbl = GUICtrlCreateLabel("Volume", 16, 80, 39, 17)

    [/autoit] [autoit][/autoit] [autoit]

    ;input
    Global $freq_inp = GUICtrlCreateInput("440.0", 120, 16, 81, 21, $ES_NUMBER)
    Global $volm_inp = GUICtrlCreateInput("50", 120, 80, 81, 21, $ES_NUMBER)
    ;combo
    $bits_cbo = GUICtrlCreateCombo("", 120, 120, 81, 25)
    GUICtrlSetData(-1, "8|16|24", "16")
    $samp_cbo = GUICtrlCreateCombo("", 120, 48, 81, 21)
    GUICtrlSetData(-1, "8000|11025|12000|16000|22050|24000|32000|44100|48000", "44100")
    $chan_cbo = GUICtrlCreateCombo("", 120, 152, 81, 25)
    GUICtrlSetData(-1, "1|2|4", "1")
    $form_cbo = GUICtrlCreateCombo("", 120, 184, 81, 25)
    GUICtrlSetData(-1, "Sinus|Dreieck|Rechteck|Sägezahn aufsteigend|Sägezahn absteigend", "Sinus")
    ;slider
    $freq_sld = GUICtrlCreateSlider(216, 16, 217, 25)
    GUICtrlSetLimit($freq_sld, 20000, 1)
    GUICtrlSetData($freq_sld, 441)
    $volm_sld = GUICtrlCreateSlider(216, 80, 217, 25)
    GUICtrlSetData($volm_sld, 100, 50)
    GUICtrlSetData($volm_sld, 50)
    ;button
    $test_btn = GUICtrlCreateButton("Test Channels", 224, 152, 105, 25, $WS_GROUP)
    $play_btn = GUICtrlCreateButton("Play Wave", 16, 400, 129, 25, $WS_GROUP)
    $save_btn = GUICtrlCreateButton("Save Wave to File", 160, 400, 129, 25, $WS_GROUP)
    $exit_btn = GUICtrlCreateButton("Exit", 304, 400, 129, 25, $WS_GROUP)
    ;graphic
    $graphic_line = GUICtrlCreateGraphic(16, 235, 420, 150)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While Sleep(20)
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
    Case $GUI_EVENT_CLOSE, $exit_btn
    Exit
    Case $play_btn
    If GUICtrlRead($play_btn) = "Stop playing" Then
    GUICtrlSetData($play_btn, "Play Wave")
    _playsound("") ;sound stoppen
    Else
    GUICtrlSetData($play_btn, "Stop playing")
    _playwave(0) ;sound abspielen
    EndIf
    Case $GUI_EVENT_MOUSEMOVE
    $mpos = GUIGetCursorInfo()
    If $mpos[4] = $freq_sld And $mpos[2] Then _freq_sld() ;nur wenn maus über slider und mausbutton down, dann neue frequenz holen
    If $mpos[4] = $volm_sld And $mpos[2] Then _volm_sld()
    Case $save_btn
    _playwave(1) ;sound speichern
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _playwave($save = 0) ;bei save=1 datei speichern

    [/autoit] [autoit][/autoit] [autoit]

    $sekunden = 5 ;so lange soll der ton inb der abgespeicherten Datei abgespielt werden
    $samplingrate = GUICtrlRead($samp_cbo) ;abtastungen pro sekunde
    $BitsPerSample = GUICtrlRead($bits_cbo);guictrlread( ;8,16,24 äquivalent die "Farbtiefe bei einem Bild",
    $Channels = GUICtrlRead($chan_cbo) ;1,2,4, Kanäle, mono, stereo usw
    Local $iType, $nTemp
    Switch GUICtrlRead($form_cbo)
    Case "Square", "Rechteck"
    $iType = 1
    Case "Triangle", "Dreieck"
    $iType = 2
    Case "Sawtooth ascending", "Sägezahn aufsteigend"
    $iType = 3
    Case "Sawtooth descending", "Sägezahn absteigend"
    $iType = 4
    Case Else
    $iType = 0
    EndSwitch
    ConsoleWrite("iType: " & $iType & @LF)

    [/autoit] [autoit][/autoit] [autoit]

    $block = Int($Channels * $BitsPerSample / 8) ;1
    $bytes = $samplingrate * $block
    $samplefaktor = $BitsPerSample / 8 ;lokale hilfsvariable
    $filesize = $samplefaktor * $sekunden * $samplingrate * $Channels + 44 - 8

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;struktur mit dem Header einer WAV-Datei erstellen
    Local $struct = DllStructCreate("byte[" & $samplefaktor * $sekunden * $samplingrate * $Channels + 44 & "]") ;platz für unser sampling

    [/autoit] [autoit][/autoit] [autoit]

    Local $s = "char RIFF [4];" & _ ;RIFF
    "uint FileSize;" & _ ;Dateigröße-8 Bytes
    "char WAVE [4];" & _ ;WAVE
    "char fmt [4];" & _ ;fmt Header Signatur
    "uint fmt_len;" & _ ;länge restl. fmt
    "word Format;" & _ ;Datenformat s. Tabelle z.B. Wikipedia 1=PCM
    "word Channels;" & _ ;Anzahl Kanäle 1=MONO
    "uint Samplerate;" & _ ;Abtastrate pro Sekunde (22050)
    "uint Bytes;" & _ ;Abtastrate * Block (22050)
    "word Block;" & _ ;Channels * BitsPerSample / 8 (1)
    "word BitsPerSample;" & _ ;8, 16, oder 24 (8)
    "char DATA [4];" & _ ;DATA Header Signatur
    "uint Len;" ;Länge des folgenden Datenblocks

    [/autoit] [autoit][/autoit] [autoit]

    Switch $samplefaktor ;je nach einstellungen platz für die wav-Daten reservieren
    Case 1
    $s &= "byte WAVDATA[" & $sekunden * $samplefaktor * $samplingrate * $Channels & "]"
    Case 2
    $s &= "word WAVDATA[" & $sekunden * $samplefaktor * $samplingrate * $Channels & "]"
    Case 4
    $s &= "dword WAVDATA[" & $sekunden * $samplefaktor * $samplingrate * $Channels & "]"
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    Local $wavstruct = DllStructCreate($s, DllStructGetPtr($struct)) ;struct "überlagern" damit alle Daten byteweise in eine Datei geschrieben werden können

    [/autoit] [autoit][/autoit] [autoit]

    ;Unsere Daten für die Sinuswelle
    $f = GUICtrlRead($freq_inp) ;frequenz in hertz
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $f = ' & $f & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    $w = 2 * $pi * $f ;omega=2*pi*f für Maschinenbauer gilt: OMEGA das weiß ich, Pi mal N durch dreißig!!! :o)
    ConsoleWrite("!W: " & $w & @LF)
    $Amplitude = (GUICtrlRead($volm_inp) * 1.81019) ^ $samplefaktor ;Lautstärke, bei 8 bit maximal 2^8, bei 16 bit maximal 2^16
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Amplitude = ' & $Amplitude & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    $i = 0 ;anzahl der geschriebenen bytes (funktionswerte)
    If $save = 1 Then
    $f = 1 / $sekunden ;falls gespeichert werden soll, anzahl Sekunden festlegen
    Else
    GUICtrlDelete($graphic_line) ;grafik kurven-linien löschen
    GUICtrlSetColor($graphic_line, 0)
    $graphic_line = GUICtrlCreateGraphic(16, 235, 420, 150) ;kurven-linien
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, 75)
    GUICtrlSetGraphic($graphic_line, $GUI_GR_LINE, 420, 75)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetColor($graphic_line, 0xFF0000)
    GUICtrlSetBkColor($graphic_line, 0xFFFFFF)
    GUICtrlSetGraphic($graphic_line, $GUI_GR_COLOR, 0xFF0000, 0xFFFFF0)
    ;GUICtrlSetGraphic($graphic_line, $GUI_GR_RECT, 0, 0, 20, 150)

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    ;hier gehts los, wir erstellen eine komplette sinuswelle, diese wird so lange wiederholt, bis die Abspieldauer in sekunden erreicht ist
    For $t = 0 To 1 / $f Step 1 / $samplingrate ;samplingrate y(t)-Werte ()Amplituden) ermitteln
    $i += 1 ;anzahl der samples
    $yt = Int($Amplitude * Sin($w * $t)) ;unsere altbekannte formel
    Switch $iType
    Case 0 ; Sine
    Case 1 ; Square
    Switch $yt
    Case 0 To $Amplitude
    $yt = $Amplitude
    Case Else
    $yt = -$Amplitude
    EndSwitch
    Case 2 ; Triangle
    $nTemp = Mod($w * $t, $pi) / $pi
    Switch $nTemp
    Case 0 To 0.5
    $nTemp = $Amplitude * $nTemp * 2
    Case Else
    $nTemp = $Amplitude * (1 - $nTemp) * 2
    EndSwitch
    Switch $yt
    Case 0 To $Amplitude
    $yt = $nTemp
    Case Else
    $yt = -$nTemp
    EndSwitch
    Case 3 ; Sawtooth ascending
    $nTemp = Mod($w * $t, $pi * 2) / ($pi * 2)
    $yt = $Amplitude * (-1 + $nTemp * 2)
    Case 4 ; Sawtooth descending
    $nTemp = Mod($w * $t, $pi * 2) / ($pi * 2)
    $yt = $Amplitude * (1 - $nTemp * 2)
    EndSwitch
    If $i < 210 Then ConsoleWrite($i & " " & $yt & @CRLF)
    DllStructSetData($wavstruct, "WAVDATA", $yt, $i) ;schreiben von y(t) in die struct
    If $save = 0 Then ;wenn speichern gewählt, keine welle zeichnen
    GUICtrlSetGraphic($graphic_line, $GUI_GR_MOVE, Int(420 * $f * $t), 75) ;punkt auf x-achse
    GUICtrlSetGraphic($graphic_line, $GUI_GR_LINE, Int($t * 420 * $f), Int(75 - ($yt / $Amplitude * 75 * GUICtrlRead($volm_inp) / 100))) ;linie zeichnen (hoehe y(t))
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $Channels = 2 Then ;wenn 2 kanäle (stereo), dann das byte für den 2. Kanal hinzufügen
    $i += 1
    DllStructSetData($wavstruct, "WAVDATA", $yt, $i)
    EndIf
    Next
    GUICtrlSetGraphic($graphic_line, $GUI_GR_REFRESH)
    ;jetzt werden die Daten in die struct geschrieben, es entsteht eine WAV-Datei im Speicher
    DllStructSetData($wavstruct, "RIFF", "RIFF")
    DllStructSetData($wavstruct, "FileSize", $filesize)
    DllStructSetData($wavstruct, "WAVE", "WAVE")
    DllStructSetData($wavstruct, "fmt", "fmt ")
    DllStructSetData($wavstruct, "fmt_len", 16)
    DllStructSetData($wavstruct, "Format", 1) ;PCM
    DllStructSetData($wavstruct, "Channels", $Channels)
    DllStructSetData($wavstruct, "Samplerate", $samplingrate)
    DllStructSetData($wavstruct, "Bytes", $bytes) ;samplerate*block
    DllStructSetData($wavstruct, "Block", $block)
    DllStructSetData($wavstruct, "BitsPerSample", $BitsPerSample)
    DllStructSetData($wavstruct, "DATA", "data")
    DllStructSetData($wavstruct, "Len", ($samplingrate / $f * $Channels * $samplefaktor));hier wird NUR DIE LÄNGE DER ERSTEN SINUSWELLE eingetragen, um den Sound im speicher abzuspielen
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : ($samplingrate / $f * $Channels * $samplefaktor) = ' & ($samplingrate / $f * $Channels * $samplefaktor) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

    [/autoit] [autoit][/autoit] [autoit]

    ;~ $data = ""
    ;~ For $i = 1 To 14 ;anzeigen des WAV-Headers
    ;~ $data &= DllStructGetData($wavstruct, $i) & @CRLF
    ;~ Next
    ;MsgBox(0, "Daten WAV-Header", StringLeft($data, 100))

    [/autoit] [autoit][/autoit] [autoit]

    If $save = 0 Then
    _playsound("") ;aktuellen sound beenden
    _Playsound(DllStructGetPtr($wavstruct), 1) ;abspielen des sounds aus dem speicher, Ton wird immer wiederholt
    Else
    $sdat = DllStructGetData($struct, 1) ;struktur in eine Datei schreiben
    $wavdata = StringLeft(BinaryToString($sdat), $sekunden * $samplingrate * $Channels * $samplefaktor + 44)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $wavdata = ' & StringLen($wavdata) & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    $wav = FileOpen("test1.wav", 18)
    $bindata = FileWrite($wav, $wavdata)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $bindata = ' & $bindata & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    FileClose($wav)
    ShellExecute("test1.wav") ;wavedatei abspielen
    EndIf
    ;Msgbox(0,"Ton mit Frequenz "&$f&" Hz","Spieldauer "&$sekunden&" Sekunden",$sekunden)
    EndFunc ;==>_playwave

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _freq_sld()
    If GUICtrlRead($freq_sld) = $freq_sliderold Then Return
    $freq_sliderold = GUICtrlRead($freq_sld)
    GUICtrlSetData($freq_inp, GUICtrlRead($freq_sld))
    If GUICtrlRead($play_btn) = "Stop playing" Then _playwave()
    EndFunc ;==>_freq_sld

    [/autoit] [autoit][/autoit] [autoit]

    Func _volm_sld()
    If GUICtrlRead($volm_sld) = $volm_sliderold Then Return
    $volm_sliderold = GUICtrlRead($freq_sld)
    GUICtrlSetData($volm_inp, GUICtrlRead($volm_sld))
    If GUICtrlRead($play_btn) = "Stop playing" Then _playwave()
    EndFunc ;==>_volm_sld

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _PlaySound($sSoundFile, $mem = 0) ;mem=1 spielt sound aus dem speicher, dann muss $sSoundfile der pointer zum anfang der struct sein
    Local Const $SND_ALIAS = 0x10000
    Local Const $SND_ALIAS_ID = 0x110000
    Local Const $SND_APPLICATION = 0x80
    Local Const $SND_ASYNC = 0x1
    Local Const $SND_FILENAME = 0x20000
    Local Const $SND_LOOP = 0x8
    Local Const $SND_MEMORY = 0x4
    Local Const $SND_NODEFAULT = 0x2
    Local Const $SND_NOSTOP = 0x10
    Local Const $SND_NOWAIT = 0x2000
    Local Const $SND_PURGE = 0x40
    Local Const $SND_RESOURCE = 0x40004
    Local Const $SND_SYNC = 0x0
    If $sSoundFile = "" Then
    DllCall('winmm.dll', 'int', 'PlaySoundA', 'ptr', 0, 'int', 0, 'int', 0)
    Return
    EndIf
    If $mem = 1 Then
    $a = DllCall('winmm.dll', 'int', 'PlaySoundA', 'ptr', $sSoundFile, 'int', 0, 'int', BitOR(4, 1, 8))

    [/autoit] [autoit][/autoit] [autoit]

    Else
    $a = DllCall('winmm.dll', 'int', 'PlaySoundA', 'str', $sSoundFile, 'int', 0, 'int', BitOR(1, 2, 0x10))
    EndIf
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $a = ' & $a[0] & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    EndFunc ;==>_PlaySound

    [/autoit]
  • Bildschirmschoner incl. Config und Preview

    • eukalyptus
    • 20. April 2010 um 13:52

    Ja, das weiß ich.

    Der Prozess wird erst beendet, wenn das BS-Einstellungsfenster geschlossen wird, oder eine andere Instanz vom BS (Preview, Config, Fullscreen...) gestartet wird.
    Ich hab leider noch nicht herausgefunden, wie ich besser erkennen kann, daß der BS beendet werden soll.

    Normalerweise sollte doch Windows irgendeine Message schicken!?

    E

  • Bildschirmschoner incl. Config und Preview

    • eukalyptus
    • 20. April 2010 um 08:07

    Ich habe etwas experimentiert mit der _GDIPlus_TextureCreate Funktion aus GDI+ Kreisförmiger Ausschnitt einer Bitmap
    und daraus ist dann dieser Bildschirmschoner entstanden

    Kompilieren, Rechtsklick auf Datei -> Installieren
    Man landet direkt in den Bildschirmschoner-Eigenschaften und sollte dort das Script im Previewfenster bereits in Aktion sehen

    (Die .EXE wird nach dem Kompilieren automatisch in .SCR umbenannt; sollte dem nicht so sein, dann muß man das manuell machen)

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_Run_After="CMD.exe /c del "%scriptdir%\%scriptfile%.scr""
    #AutoIt3Wrapper_Run_After="CMD.exe /c rename "%scriptdir%\%scriptfile%.exe" "%scriptfile%.scr""
    #NoTrayIcon

    [/autoit] [autoit][/autoit] [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <ScreenCapture.au3>
    #include <SendMessage.au3>
    #include <StaticConstants.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    While WinExists("Eukalyptus Bubble ScreenSaver")
    $hWnd = WinGetHandle("Eukalyptus Bubble ScreenSaver")
    _SendMessage($hWnd, $WM_DESTROY)
    WinWaitClose("Eukalyptus Bubble ScreenSaver", "", 2)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Global $iMode = 0, $hParent, $aTemp, $sCmdLine = ""
    Global $iWidth = @DesktopWidth
    Global $iHeight = @DesktopHeight
    Global $iGuiX = 0, $iGuiY = 0, $iGuiW = $iWidth, $iGuiH = $iHeight

    [/autoit] [autoit][/autoit] [autoit]

    Global $iBubbleCnt = RegRead("HKEY_CURRENT_USER\SOFTWARE\BubbleScreenSaver", "BubbleCount")
    If Not $iBubbleCnt Then $iBubbleCnt = 50
    If $iBubbleCnt < 1 Then $iBubbleCnt = 1
    If $iBubbleCnt > 200 Then $iBubbleCnt = 200

    [/autoit] [autoit][/autoit] [autoit]

    Global $iBubbleSizeMin = RegRead("HKEY_CURRENT_USER\SOFTWARE\BubbleScreenSaver", "BubbleSizeMin")
    If Not $iBubbleSizeMin Then $iBubbleSizeMin = 50
    If $iBubbleSizeMin < 10 Then $iBubbleSizeMin = 10
    If $iBubbleSizeMin > 499 Then $iBubbleSizeMin = 499

    [/autoit] [autoit][/autoit] [autoit]

    Global $iBubbleSizeMax = RegRead("HKEY_CURRENT_USER\SOFTWARE\BubbleScreenSaver", "BubbleSizeMax")
    If Not $iBubbleSizeMax Then $iBubbleSizeMax = 200
    If $iBubbleSizeMax <= $iBubbleSizeMin Then $iBubbleSizeMax = $iBubbleSizeMin + 1
    If $iBubbleSizeMax > 500 Then $iBubbleSizeMax = 500

    [/autoit] [autoit][/autoit] [autoit]

    Global $iBubbleSpeedMin = RegRead("HKEY_CURRENT_USER\SOFTWARE\BubbleScreenSaver", "BubbleSpeedMin")
    If Not $iBubbleSpeedMin Then $iBubbleSpeedMin = 2
    If $iBubbleSpeedMin < 1 Then $iBubbleSpeedMin = 1
    If $iBubbleSpeedMin > 49 Then $iBubbleSpeedMin = 49

    [/autoit] [autoit][/autoit] [autoit]

    Global $iBubbleSpeedMax = RegRead("HKEY_CURRENT_USER\SOFTWARE\BubbleScreenSaver", "BubbleSpeedMax")
    If Not $iBubbleSpeedMax Then $iBubbleSpeedMax = 10
    If $iBubbleSpeedMax <= $iBubbleSpeedMin Then $iBubbleSpeedMax = $iBubbleSpeedMin + 1
    If $iBubbleSpeedMax > 50 Then $iBubbleSpeedMax = 50

    [/autoit] [autoit][/autoit] [autoit]

    Global $iBubbleFillMode = RegRead("HKEY_CURRENT_USER\SOFTWARE\BubbleScreenSaver", "BubbleFillMode")
    If Not $iBubbleFillMode Then $iBubbleFillMode = 4

    [/autoit] [autoit][/autoit] [autoit]

    Global $aBubble[201][4]
    For $i = 0 To $iBubbleCnt
    $aBubble[$i][0] = Random(0, $iWidth, 1)
    $aBubble[$i][1] = Random(0, $iHeight, 1) + $iHeight
    $aBubble[$i][2] = Random($iBubbleSizeMin, $iBubbleSizeMax, 1)
    $aBubble[$i][3] = Random($iBubbleSpeedMin, $iBubbleSpeedMax)
    Next

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Switch $CmdLine[0]
    Case 0
    Exit
    Case Else
    For $i = 1 To $CmdLine[0]
    $sCmdLine &= $CmdLine[$i]
    Next
    $aTemp = StringRegExp($sCmdLine, "/(\w)", 1)
    If @error Or Not IsArray($aTemp) Then Exit
    Switch $aTemp[0]
    Case "c"
    $iMode = 2
    Case "p"
    $iMode = 3
    Case "s"
    $iMode = 1
    Case Else
    Exit
    EndSwitch
    Switch $iMode
    Case 1
    $hParent = _WinAPI_GetDesktopWindow()
    Case Else
    $aTemp = StringRegExp($sCmdLine, "\d+", 1)
    If @error Or Not IsArray($aTemp) Then Exit
    $hParent = HWnd($aTemp[0])
    EndSwitch
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    Switch $iMode
    Case 2 ; Config
    $iGuiW = 270
    $iGuiH = 330
    $iGuiX = $iWidth / 2 - $iGuiW / 2
    $iGuiY = $iHeight / 2 - $iGuiH / 2
    Case 3 ; Preview
    Local $aPos = WinGetPos($hParent)
    If @error Or Not IsArray($aPos) Then Exit
    $iGuiX = $aPos[0]
    $iGuiY = $aPos[1]
    $iGuiW = $aPos[2]
    $iGuiH = $aPos[3]
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $hBmp = _ScreenCapture_Capture("", 0, 0, $iWidth, $iHeight, False)
    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    Global $hUser32dll = DllOpen("User32.dll")

    [/autoit] [autoit][/autoit] [autoit]

    Switch $iMode
    Case 2 ; Config
    Global $hGui = GUICreate("Eukalyptus Bubble ScreenSaver", $iGuiW, $iGuiH, $iGuiX, $iGuiY, Default, $WS_EX_TOPMOST, $hParent)
    GUICtrlCreateLabel("Anzahl der Blasen:", 10, 10, $iGuiW - 50, 20)
    Global $hSliderCnt = GUICtrlCreateSlider(10, 30, $iGuiW - 20, 20)
    GUICtrlSetLimit(-1, 200, 1)
    GUICtrlSetData(-1, $iBubbleCnt)
    Global $hLabelCnt = GUICtrlCreateLabel($iBubbleCnt, $iGuiW - 100, 10, 90, 20, $SS_RIGHT)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateLabel("Minimale Größe der Blasen:", 10, 60, $iGuiW - 50, 20)
    Global $hSliderSizeMin = GUICtrlCreateSlider(10, 80, $iGuiW - 20, 20)
    GUICtrlSetLimit(-1, 499, 10)
    GUICtrlSetData(-1, $iBubbleSizeMin)
    Global $hLabelSizeMin = GUICtrlCreateLabel($iBubbleSizeMin, $iGuiW - 50, 60, 40, 20, $SS_RIGHT)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateLabel("Maximale Größe der Blasen:", 10, 110, $iGuiW - 50, 20)
    Global $hSliderSizeMax = GUICtrlCreateSlider(10, 130, $iGuiW - 20, 20)
    GUICtrlSetLimit(-1, 500, 11)
    GUICtrlSetData(-1, $iBubbleSizeMax)
    Global $hLabelSizeMax = GUICtrlCreateLabel($iBubbleSizeMax, $iGuiW - 50, 110, 40, 20, $SS_RIGHT)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateLabel("Minimale Geschwindigkeit der Blasen:", 10, 160, $iGuiW - 50, 20)
    Global $hSliderSpeedMin = GUICtrlCreateSlider(10, 180, $iGuiW - 20, 20)
    GUICtrlSetLimit(-1, 49, 1)
    GUICtrlSetData(-1, $iBubbleSpeedMin)
    Global $hLabelSpeedMin = GUICtrlCreateLabel($iBubbleSpeedMin, $iGuiW - 50, 160, 40, 20, $SS_RIGHT)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateLabel("Maximale Geschwindigkeit der Blasen:", 10, 210, $iGuiW - 50, 20)
    Global $hSliderSpeedMax = GUICtrlCreateSlider(10, 230, $iGuiW - 20, 20)
    GUICtrlSetLimit(-1, 50, 2)
    GUICtrlSetData(-1, $iBubbleSpeedMax)
    Global $hLabelSpeedMax = GUICtrlCreateLabel($iBubbleSpeedMax, $iGuiW - 50, 210, 40, 20, $SS_RIGHT)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hCheckbox=GUICtrlCreateCheckbox("Keine Füllung bei Überschneidung",10,260,$iGuiW-20,20)
    If $iBubbleFillMode = 1 Then GUICtrlSetState($hCheckbox, $GUI_CHECKED)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hButtonSave = GUICtrlCreateButton("OK", 10, 300, $iGuiW / 2 - 20, 20)
    Global $hButtonExit = GUICtrlCreateButton("Abbrechen", $iGuiW / 2 + 10, 300, $iGuiW / 2 - 20, 20)
    Case Else
    Global $hGui = GUICreate("Eukalyptus Bubble ScreenSaver", $iGuiW, $iGuiH, $iGuiX, $iGuiY, $WS_POPUP, $WS_EX_TOPMOST, $hParent)
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Switch $iMode
    Case 3
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hParent)
    GUISetState(@SW_HIDE)
    Case Else
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    Global $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
    Global $hBrush = _GDIPlus_TextureCreate($hBitmap)
    Global $hBrushTrans = _GDIPlus_BrushCreateSolid(0xF6000010)
    Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
    Global $hPen = _GDIPlus_PenCreate(0xFF101000)

    [/autoit] [autoit][/autoit] [autoit]

    Global $iTimer = TimerInit()

    [/autoit] [autoit][/autoit] [autoit]

    If $iMode = 1 Then
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
    _WinAPI_ShowCursor(False)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $iMode <> 2 Then
    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_DESTROY, "WM_DESTROY")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch $iMode
    Case 2 ; Config
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
    _Exit()
    Case $hSliderCnt
    $iBubbleCnt = GUICtrlRead($hSliderCnt)
    GUICtrlSetData($hLabelCnt, $iBubbleCnt)
    Case $hSliderSizeMin
    $iBubbleSizeMin = GUICtrlRead($hSliderSizeMin)
    If $iBubbleSizeMin >= $iBubbleSizeMax Then
    $iBubbleSizeMin = $iBubbleSizeMax - 1
    GUICtrlSetData($hSliderSizeMin, $iBubbleSizeMin)
    EndIf
    GUICtrlSetData($hLabelSizeMin, $iBubbleSizeMin)
    Case $hSliderSizeMax
    $iBubbleSizeMax = GUICtrlRead($hSliderSizeMax)
    If $iBubbleSizeMax <= $iBubbleSizeMin Then
    $iBubbleSizeMax = $iBubbleSizeMin + 1
    GUICtrlSetData($hSliderSizeMax, $iBubbleSizeMax)
    EndIf
    GUICtrlSetData($hLabelSizeMax, $iBubbleSizeMax)
    Case $hSliderSpeedMin
    $iBubbleSpeedMin = GUICtrlRead($hSliderSpeedMin)
    If $iBubbleSpeedMin >= $iBubbleSpeedMax Then
    $iBubbleSpeedMin = $iBubbleSpeedMax - 1
    GUICtrlSetData($hSliderSpeedMin, $iBubbleSpeedMin)
    EndIf
    GUICtrlSetData($hLabelSpeedMin, $iBubbleSpeedMin)
    Case $hSliderSpeedMax
    $iBubbleSpeedMax = GUICtrlRead($hSliderSpeedMax)
    If $iBubbleSpeedMax <= $iBubbleSpeedMin Then
    $iBubbleSpeedMax = $iBubbleSpeedMin + 1
    GUICtrlSetData($hSliderSpeedMax, $iBubbleSpeedMax)
    EndIf
    GUICtrlSetData($hLabelSpeedMax, $iBubbleSpeedMax)
    Case $hCheckbox
    $iBubbleFillMode=GUICtrlRead($hCheckbox)
    If $iBubbleFillMode <> 1 And $iBubbleFillMode <> 4 Then $iBubbleFillMode = 4
    Case $hButtonExit
    _Exit()
    Case $hButtonSave
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\BubbleScreenSaver", "BubbleCount", "REG_DWORD", $iBubbleCnt)
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\BubbleScreenSaver", "BubbleSizeMin", "REG_DWORD", $iBubbleSizeMin)
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\BubbleScreenSaver", "BubbleSizeMax", "REG_DWORD", $iBubbleSizeMax)
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\BubbleScreenSaver", "BubbleSpeedMin", "REG_DWORD", $iBubbleSpeedMin)
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\BubbleScreenSaver", "BubbleSpeedMax", "REG_DWORD", $iBubbleSpeedMax)
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\BubbleScreenSaver", "BubbleFillMode", "REG_DWORD", $iBubbleFillMode)
    _Exit()
    EndSwitch
    Case Else
    If TimerDiff($iTimer) > 20 Then
    If $iMode = 3 And Not WinExists($hParent) Then _Exit()
    $iTimer = TimerInit()
    _Bubbles()
    EndIf
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_DESTROY($hWnd, $uMsgm, $wParam, $lParam)
    _Exit()
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_DESTROY

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _Draw()
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _Draw()
    Return True
    EndFunc ;==>WM_ERASEBKGND

    [/autoit] [autoit][/autoit] [autoit]

    Func _Draw()
    Switch $iMode
    Case 1 ; FullScreen
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Case 3 ; Preview
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBmpBuffer, 0, 0, $iGuiW, $iGuiH)
    EndSwitch
    EndFunc ;==>_Draw

    [/autoit] [autoit][/autoit] [autoit]

    Func _Bubbles()
    If $iBubbleFillMode = 1 Then Local $hPath = _GDIPlus_CreatePath()
    Local $sKeyBoard = _GetKeyboardState()
    Local Static $sKeyBoard_Old = $sKeyBoard
    If $iMode = 1 And $sKeyBoard_Old <> $sKeyBoard Then _Exit()
    $sKeyBoard_Old = $sKeyBoard
    _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBitmap, 0, 0)
    _GDIPlus_GraphicsFillRect($hGfxBuffer, 0, 0, $iWidth, $iHeight, $hBrushTrans)
    For $i = 1 To $iBubbleCnt
    If $aBubble[$i][1] + $aBubble[$i][2] / 2 < 0 Then
    $aBubble[$i][0] = Random(0, $iWidth, 1)
    $aBubble[$i][2] = Random($iBubbleSizeMin, $iBubbleSizeMax, 1)
    $aBubble[$i][1] = $iHeight + $aBubble[$i][2] / 2
    $aBubble[$i][3] = Random($iBubbleSpeedMin, $iBubbleSpeedMax)
    EndIf
    $aBubble[$i][1] -= $aBubble[$i][3]
    Switch $iBubbleFillMode
    Case 1
    _GDIPlus_AddPathEllipse($hPath,$aBubble[$i][0] - $aBubble[$i][2] / 2, $aBubble[$i][1] - $aBubble[$i][2] / 2, $aBubble[$i][2], $aBubble[$i][2])
    Case Else
    _GDIPlus_GraphicsFillEllipse($hGfxBuffer, $aBubble[$i][0] - $aBubble[$i][2] / 2, $aBubble[$i][1] - $aBubble[$i][2] / 2, $aBubble[$i][2], $aBubble[$i][2], $hBrush)
    _GDIPlus_GraphicsDrawEllipse($hGfxBuffer, $aBubble[$i][0] - $aBubble[$i][2] / 2, $aBubble[$i][1] - $aBubble[$i][2] / 2, $aBubble[$i][2], $aBubble[$i][2], $hPen)
    EndSwitch
    Next
    If $iBubbleFillMode = 1 Then
    _GDIPlus_ClosePathFigure($hPath)
    _GDIPlus_FillPath($hGfxBuffer, $hBrush, $hPath)
    _GDIPlus_PathDispose($hPath)
    EndIf
    _Draw()
    EndFunc ;==>_Bubbles

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_CreatePath($brushMode = 0)
    Local $hPath
    $hPath = DllCall($ghGDIPDll, "int", "GdipCreatePath", "int", $brushMode, "handle*", 0)
    If @error Then Return SetError(1, @error, 0)
    Return SetError($hPath[0], 0, $hPath[2])
    EndFunc ;==>_GDIPlus_CreatePath

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_AddPathEllipse($hPath, $iX, $iY, $iWidth, $iHeight)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipAddPathEllipse", "handle", $hPath, "float", $iX, "float", $iY, "float", $iWidth, "float", $iHeight)
    If @error Then Return SetError(1, @error, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
    EndFunc ;==>_GDIPlus_AddPathEllipse

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_FillPath($hGraphic, $hBrushGrad, $hPath)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipFillPath", "handle", $hGraphic, "handle", $hBrushGrad, "handle", $hPath)
    If @error Then Return SetError(1, @error, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
    EndFunc ;==>_GDIPlus_FillPath

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_ClosePathFigure($hPath)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipClosePathFigure", "handle", $hPath)
    If @error Then Return SetError(1, @error, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
    EndFunc ;==>_GDIPlus_ClosePathFigure

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_PathDispose($hPath)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeletePath", "handle", $hPath)
    If @error Then Return SetError(1, @error, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
    EndFunc ;==>_GDIPlus_PathDispose

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_MOUSEMOVE($hWnd, $uMsgm, $wParam, $lParam)
    If $iMode <> 1 Then Return 0
    Local $iMouseX = MouseGetPos(0)
    Local $iMouseY = MouseGetPos(1)
    Local Static $iMouseX_Old = $iMouseX
    Local Static $iMouseY_Old = $iMouseY
    If $hWnd = $hGui Then
    If $iMouseX < $iMouseX_Old - 3 Or $iMouseX > $iMouseX_Old + 3 Or $iMouseY < $iMouseY_Old - 3 Or $iMouseY > $iMouseY_Old + 3 Then _Exit()
    $iMouseX_Old = $iMouseX
    $iMouseY_Old = $iMouseY
    EndIf
    Return 0
    EndFunc ;==>WM_MOUSEMOVE

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetKeyboardState()
    Local $sReturn = ""
    Local $lpKeyState = DllStructCreate("byte[256]")
    Local $aRet = DllCall($hUser32dll, "int", "GetKeyboardState", "ptr", DllStructGetPtr($lpKeyState))
    For $i = 1 To 256
    $sReturn &= DllStructGetData($lpKeyState, 1, $i)
    Next
    Return $sReturn
    EndFunc ;==>_GetKeyboardState

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GDIPlus_TextureCreate
    ; Description ...: Creates a TextureBrush object based on an image and a wrap mode
    ; Syntax.........: _GDIPlus_TextureCreate($hImage[, $iWrapMode = 0])
    ; Parameters ....: $hImage - Pointer to an Image object
    ; $iWrapMode - Wrap mode that specifies how repeated copies of an image are used to tile an area when it is
    ; +painted with the texture brush:
    ; |0 - Tiling without flipping
    ; |1 - Tiles are flipped horizontally as you move from one tile to the next in a row
    ; |2 - Tiles are flipped vertically as you move from one tile to the next in a column
    ; |3 - Tiles are flipped horizontally as you move along a row and flipped vertically as you move along a column
    ; |4 - No tiling takes place
    ; Return values .: Success - Pointer to a new TextureBrush object
    ; Failure - 0 and either:
    ; |@error and @extended are set if DllCall failed
    ; |$GDIP_STATUS contains a non zero value specifying the error code
    ; Remarks .......: The size of the brush defaults to the size of the image, so the entire image is used by the brush
    ; After you are done with the object, call _GDIPlus_BrushDispose to release the object resources
    ; Related .......: _GDIPlus_BrushDispose
    ; Link ..........; @@MsdnLink@@ GdipCreateTexture
    ; Example .......; No
    ; ===============================================================================================================================
    Func _GDIPlus_TextureCreate($hImage, $iWrapMode = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "hwnd", $hImage, "int", $iWrapMode, "int*", 0)

    [/autoit] [autoit][/autoit] [autoit]

    If @error Then Return SetError(@error, @extended, 0)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[3]
    EndFunc ;==>_GDIPlus_TextureCreate

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_BrushDispose($hBrushTrans)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _WinAPI_DeleteObject($hBmp)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    DllClose($hUser32dll)
    GUIDelete($hGui)
    _WinAPI_ShowCursor(True)
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    Viel Spaß

  • Sinus-Ton ausgeben

    • eukalyptus
    • 16. April 2010 um 11:17

    Moment, ihr verwechselt da was!

    Bei Beep wird die Sinusberechnung automatisch durchgeführt und man muß nur die Frequenz angeben.

    Selber berechnen und über die SOundkarte ausgeben ist etwas komplizierter
    Beispiel: SinusTon - Synth mit Bass.dll

    mfgE

  • Aufnahme mit _BASS_Record

    • eukalyptus
    • 15. April 2010 um 10:35

    Schaut doch nicht so schlecht aus ;)

    Das sollte doch eigentlich so funktionieren:

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_UseX64=n

    [/autoit] [autoit][/autoit] [autoit]

    #include "Bass.au3"
    #include "BassConstants.au3"

    [/autoit] [autoit][/autoit] [autoit]

    Global $File = "1kHz.wav"

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_STARTUP("BASS.dll") ;Open Bass.DLL.
    _BASS_Init(0, 2, 44100, 0, "") ;Initalize bass.
    If @error Then
    MsgBox(0,"ERROR","ERROR Audio Out")
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_RecordInit(0)
    If @error Or _BASS_RecordGetDevice() > 10 Or _BASS_RecordGetDevice() < 0 Then
    MsgBox(0,"ERROR","ERROR Audio In")
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_RecordSetInput(0, $BASS_INPUT_ON,-1)

    [/autoit] [autoit][/autoit] [autoit]

    $hRecord = _BASS_RecordStart(44100, 2, 0, "", 0)

    [/autoit] [autoit][/autoit] [autoit]

    $hMusic = _BASS_StreamCreateFile(False, $File, 0, 0, 0)
    _BASS_ChannelPlay($hMusic, 1)

    [/autoit] [autoit][/autoit] [autoit]

    While _BASS_ChannelIsActive($hMusic) = $BASS_ACTIVE_PLAYING
    $iFreqOut = _GetFreq($hMusic)
    $iFreqIn = _GetFreq($hRecord)
    ToolTip("Frequenz Out: " & $iFreqOut & @LF & "Frequenz In: " & $iFreqIn)
    Sleep(100)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_Free()
    _BASS_RecordFree()

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetFreq($hHandle)
    Local $TmpData = 0, $TmpNr = 0, $fft = 0
    Local $fftstruct = DllStructCreate("float[4096]")
    _BASS_ChannelGetData($hHandle, DllStructGetPtr($fftstruct), $BASS_DATA_FFT8192)
    For $i = 0 To 4095
    $TmpData = Round(DllStructGetData($fftstruct, 1, $i + 1) * 100)
    If $TmpData > 0.2 And $fft < $TmpData Then ;Bestimme den Ort des Maximalwerts der FFT Analyse
    $fft = $TmpData
    $TmpNr = $i + 1
    EndIf
    Next
    Return Round(22000 / 4096 * $TmpNr) ;Max 22kHz.
    EndFunc ;==>_GetFreq

    [/autoit]
  • Aufnahme mit _BASS_Record

    • eukalyptus
    • 15. April 2010 um 09:49

    Probier doch mal dieses Script unter Win7 mit den verschiedenen Möglichkeiten (Kabel eingesteckt, ausgesteckt...)
    und poste wieder den Consolenoutput

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_UseX64=n

    [/autoit] [autoit][/autoit] [autoit]

    #include "Bass.au3"
    #include "BassConstants.au3"

    [/autoit] [autoit][/autoit] [autoit]

    Global $File = "1kHz.wav"

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_STARTUP("BASS.dll") ;Open Bass.DLL.
    _BASS_Init(0, -1, 44100, 0, "") ;Initalize bass.
    _BASS_SetVolume(1)

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_RecordInit(-1)
    ConsoleWrite(@LF & "-Default Device: " & _BASS_RecordGetDevice() & @LF)
    _BASS_RecordFree()

    [/autoit] [autoit][/autoit] [autoit]

    $hMusic = _BASS_StreamCreateFile(False, $File, 0, 0, $BASS_SAMPLE_LOOP)
    _BASS_ChannelPlay($hMusic, 1)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    For $iDevice = 0 To 10
    $aInfo = _BASS_RecordGetDeviceInfo($iDevice)
    If @error Then ExitLoop
    _BASS_RecordInit($iDevice)
    For $iInput = 0 To 10
    $sName=_BASS_RecordGetInputName($iInput)
    If @error Then ExitLoop
    For $i=0 To 10
    _BASS_RecordSetInput($iInput, $BASS_INPUT_OFF,-1)
    Next
    _BASS_RecordSetInput($iInput, $BASS_INPUT_ON,1)
    $hRecord = _BASS_RecordStart(44100, 2, 0, "", 0)
    $nMax=0
    For $i=1 To 5
    $nLevel=_LoWord(_BASS_ChannelGetLevel($hRecord)) / 32768
    If $nLevel > $nMax Then $nMax = $nLevel
    Sleep(200)
    Next
    If $nMax > 0.1 Then
    ConsoleWrite("+" & $aInfo[0] & " " & $sName & ": Device " & $iDevice & " / Input " & $iInput & " / Level " & Round($nMax*100) & "%" & @LF)
    Else
    ConsoleWrite("!" & $aInfo[0] & " " & $sName & ": Device " & $iDevice & " / Input " & $iInput & " / Level " & Round($nMax*100) & "%" & @LF)
    EndIf
    _BASS_ChannelStop($hRecord)
    Next
    _BASS_RecordFree()
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ConsoleWrite(@LF)

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_RecordFree()
    _BASS_Free()

    [/autoit]
  • Sprach-Streaming mit bass.dll

    • eukalyptus
    • 14. April 2010 um 20:57

    Ein normaler Stream muß mit Sampledaten gefüllt werden und nicht mit MP3-Daten - deshalb das Rauschen

    Du kannst entweder richtige Sampledaten versenden (das werden jedoch zu große Datenmengen sein)
    Oder StreamCreateFileUser verwenden; dieser kann auch mit MP3-Daten befüllt werden

    Hab das mal kurz probiert:

    Sender

    Spoiler anzeigen
    [autoit]

    #include <BassEnc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $bMp3Data

    [/autoit] [autoit][/autoit] [autoit]

    Global $ConnectedSocket, $szData
    Global $szIPADDRESS = InputBox("IP", "IP-Adresse eingeben:", "192.168.0.100")
    Global $nPORT = 3344

    [/autoit] [autoit][/autoit] [autoit]

    TCPStartup()

    [/autoit] [autoit][/autoit] [autoit]

    $ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT)
    If @error Then
    MsgBox(4112, "Fehler", "TCP-Connect schlug mit folgendem WSA-Fehler fehl: " & @error)
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Global $hRecHandle, $hEncHandle

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("{ESC}", "_Exit")

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_STARTUP()
    _BASS_Encode_STARTUP()
    _BASS_SetConfig($BASS_CONFIG_REC_BUFFER, 1000)

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_RecordInit(-1)
    $hRecHandle = _BASS_RecordStart(44100, 2, _makelong($BASS_SAMPLE_FX, 500), "_Bass_Callback_Rec")
    $hEncHandle = _BASS_Encode_Start($hRecHandle, 'lame -r -x -b128 -h - -', 0, "_Bass_Callback_Enc")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    If BinaryLen($bMp3Data) Then
    TCPSend($ConnectedSocket, $bMp3Data)
    $bMp3Data = ""
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Bass_Callback_Rec($handle, $buffer, $length, $user)
    Return 1
    EndFunc ;==>_Bass_Callback_Rec

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    If _BASS_Encode_IsActive($hEncHandle) Then _BASS_Encode_Stop($hEncHandle)
    _BASS_RecordFree()
    TCPShutdown()
    Exit
    EndFunc ;==>_EXIT

    [/autoit] [autoit][/autoit] [autoit]

    Func _Bass_Callback_Enc($handle, $channel, $buffer, $length, $user)
    Local $tempbuffer = DllStructCreate("byte[" & $length & "]", $buffer) ;???
    $bMp3Data = Binary($bMp3Data & DllStructGetData($tempbuffer, 1))
    EndFunc ;==>_Bass_Callback_Enc

    [/autoit]

    Empfänger

    Spoiler anzeigen
    [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_STARTUP()

    [/autoit] [autoit][/autoit] [autoit]

    Global $bMp3Data

    [/autoit] [autoit][/autoit] [autoit]

    $proc = DllStructCreate("ptr;ptr;ptr;ptr")
    $cb_close = DllCallbackRegister("Bass_Callback_Close", "none", "ptr")
    $cb_length = DllCallbackRegister("Bass_Callback_Length", "uint64", "ptr")
    $cb_read = DllCallbackRegister("Bass_Callback_Read", "dword", "ptr;dword;ptr")
    $cb_seek = DllCallbackRegister("Bass_Callback_Seek", "int", "uint64;ptr")
    DllStructSetData($proc, 1, DllCallbackGetPtr($cb_close))
    DllStructSetData($proc, 2, DllCallbackGetPtr($cb_length))
    DllStructSetData($proc, 3, DllCallbackGetPtr($cb_read))
    DllStructSetData($proc, 4, DllCallbackGetPtr($cb_seek))

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $szIPADDRESS = @IPAddress1
    Global $nPORT = 3344
    Global $MainSocket, $GOOEY, $edit, $ConnectedSocket, $szIP_Accepted
    Global $msg, $recv, $hStream

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    TCPStartup()

    [/autoit] [autoit][/autoit] [autoit]

    $MainSocket = TCPListen($szIPADDRESS, $nPORT)
    If $MainSocket = -1 Then Exit

    [/autoit] [autoit][/autoit] [autoit]

    $GOOEY = GUICreate("Server (IP: " & $szIPADDRESS & ")", 300, 200)
    $edit = GUICtrlCreateEdit("", 10, 10, 280, 180)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    ;Auf Verbindung warten
    $ConnectedSocket = -1

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $ConnectedSocket = TCPAccept($MainSocket)
    Until $ConnectedSocket <> -1

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    $bMp3Data = Binary($bMp3Data & TCPRecv($ConnectedSocket, 4096, 1))
    $iSize = BinaryLen($bMp3Data)
    If $iSize >= 4096 And Not $hStream Then
    $hStream = _BASS_StreamCreateFileUser($STREAMFILE_BUFFERPUSH, BitOR($BASS_STREAM_RESTRATE, $BASS_STREAM_BLOCK), DllStructGetPtr($proc), 0)
    _BASS_ChannelPlay($hStream, False)
    EndIf
    If $iSize And $hStream Then
    $tempbuffer = DllStructCreate("byte[" & $iSize & "]")
    DllStructSetData($tempbuffer, 1, BinaryMid($bMp3Data, 1, $iSize))
    $bMp3Data = BinaryMid($bMp3Data, $iSize)
    _BASS_StreamPutFileData($hStream, DllStructGetPtr($tempbuffer), DllStructGetSize($tempbuffer))
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func Bass_Callback_Close($pUser)
    ConsoleWrite("Bass wants to close the file." & @CRLF)
    EndFunc ;==>Bass_Callback_Close

    [/autoit] [autoit][/autoit] [autoit]

    Func Bass_Callback_Length($pUser)
    ConsoleWrite("Bass wants the length of the file." & @CRLF)
    ; Returning 0 means Bass will get the data when bass gets it.
    Return 0
    EndFunc ;==>Bass_Callback_Length

    [/autoit] [autoit][/autoit] [autoit]

    Func Bass_Callback_Read($pBuffer, $iSize, $pUser)
    ;ConsoleWrite($iSize & @LF)
    ; Write data to the buffer pointer Bass supplied us with.
    ; Hopefully bass don't want more than 8 kB (the amount of data guarantied to be in the buffer)
    $tBuffer = DllStructCreate("byte[" & $iSize & "]", $pBuffer)
    DllStructSetData($tBuffer, 1, BinaryMid($bMp3Data, 1, $iSize))
    $bMp3Data = BinaryMid($bMp3Data, $iSize)
    ConsoleWrite("Bass wants to read " & $iSize & " bytes. " & BinaryLen($bMp3Data) & " left" & @CRLF)
    Return $iSize
    EndFunc ;==>Bass_Callback_Read

    [/autoit] [autoit][/autoit] [autoit]

    Func Bass_Callback_Seek($iOffset, $pUser)
    ConsoleWrite("Bass wants to seek the file." & @CRLF)
    EndFunc ;==>Bass_Callback_Seek

    [/autoit] [autoit][/autoit] [autoit]

    Func _BASS_StreamCreateFileUser($system, $flags, $procs, $user)
    Local $BASS_ret_ = DllCall($_ghBassDll, "hwnd", "BASS_StreamCreateFileUser", "dword", $system, "dword", $flags, "ptr", $procs, "ptr", $user)
    If @error Then Return SetError(1, 1, 0)
    If $BASS_ret_[0] = 0 Then Return SetError(_BASS_ErrorGetCode(), 0, 0)
    Return $BASS_ret_[0]
    EndFunc ;==>_BASS_StreamCreateFileUser

    [/autoit]


    (Siehe auch http://www.autoitscript.com/forum/index.php?showtopic=98861&view=findpost&p=710665)

    Das Problem ist allerdings, daß Autoit hierfür zu langsam ist und das Senderscript nach einiger Zeit abstürzt
    Das lässt sich beheben indem man die Callback-Funktionen in eine DLL auslagert - Das kann ich aber erst morgen probieren


    mfgE

  • Aufnahme mit _BASS_Record

    • eukalyptus
    • 14. April 2010 um 17:51

    Windows 7 ( und auch Vista ) listen die Inputs anders auf als XP

    Bei Bass.dll unter XP ist jedes Device eine eigene Soundkarte, die mehrere Out/Inputs haben kann
    zb:
    Device 1 Realtek HD Audio Input
    - Input CD-Lautstärke
    - Input Mikrofon
    - Input Line-Lautstärke
    - Input Aux-Lautstärke
    - Input Stereomix

    Device 2...


    Unter WIn7 und Vista werden alle Out/Inputs als eigenes Device mit dem Input "Hauptinput" dargestellt
    zb:
    Device 1 Realtek CD-Lautstärke
    - Input Hauptinput

    Device 2 Realtek Mikrofon
    - Input Hauptinput

    Device 3 Realtek Line-In
    - Input Hauptinput

    usw...


    Zudem sind viele deaktiviert und müssen in der Systemsteuerung aktiviert werden (Audiogeräte - deaktivierte Geräte anzeigen)

    Probier mal meinen Recorder unter Win7 aus...

  • Aufnahme mit _BASS_Record

    • eukalyptus
    • 14. April 2010 um 13:40

    das "+" am Anfang bedeutet, daß der Input aktiv ist!
    bei nicht aktiven sollte ein "!" davorstehen

    Das ist komisch.
    Es sollte eigentlich nur 1 Input aktiv sein

    StereoMix ist ein Input, welcher alles aufnimmt was über den Output rauskommt
    Und da auch dieser aktiv ist wird wahrscheinlich hiermit der Sinus "aufgenommen"

    Probier mal mit _BASS_RecordSetInput alle zu deaktivieren und nur den gewünschten Input zu aktivieren
    in etwa so sollte das gehen:
    For $i=0 to 5
    _BASS_RecordSetInput($i, $BASS_INPUT_OFF)
    Next
    _BASS_RecordSetInput(1, $BASS_INPUT_ON)

  • Aufnahme mit _BASS_Record

    • eukalyptus
    • 14. April 2010 um 12:57

    Probier mal dieses Script poste hier dann den Consolenoutput (in Scite unten)

    Spoiler anzeigen
    [autoit]

    #include "Bass.au3"
    #include "BassConstants.au3"

    [/autoit] [autoit][/autoit] [autoit]

    Global $File = "1kHz.wav"

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_STARTUP("BASS.dll") ;Open Bass.DLL.
    _BASS_Init(0, -1, 44100, 0, "") ;Initalize bass.

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_RecordInit(-1)

    [/autoit] [autoit][/autoit] [autoit]

    _ListDevices()
    _ListRecDevices()

    [/autoit] [autoit][/autoit] [autoit]

    $hRecord = _BASS_RecordStart(44100, 1, 0, "", 0)

    [/autoit] [autoit][/autoit] [autoit]

    $hMusic = _BASS_StreamCreateFile(False, $File, 0, 0, 0)
    _BASS_ChannelPlay($hMusic, 1)

    [/autoit] [autoit][/autoit] [autoit]

    While _BASS_ChannelIsActive($hMusic) = $BASS_ACTIVE_PLAYING
    $iFreqOut = _GetFreq($hMusic)
    $iFreqIn = _GetFreq($hRecord)
    ToolTip("Frequenz Out: " & $iFreqOut & @LF & "Frequenz In: " & $iFreqIn)
    Sleep(100)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_Free()
    _BASS_RecordFree()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ListDevices()
    Local $aInfo
    For $i = 0 To 5
    $aInfo = _BASS_GetDeviceInfo($i)
    If @error Then ExitLoop
    If IsArray($aInfo) Then
    If BitAND($aInfo[2], $BASS_DEVICE_INIT) Then
    ConsoleWrite("+Output " & $i & ": <" & $aInfo[0] & "> <" & $aInfo[1] & "> <" & $aInfo[2] & ">" & @LF)
    Else
    ConsoleWrite("-Output " & $i & ": <" & $aInfo[0] & "> <" & $aInfo[1] & "> <" & $aInfo[2] & ">" & @LF)
    EndIf
    EndIf
    Next
    ConsoleWrite(@LF)
    EndFunc ;==>_ListDevices

    [/autoit] [autoit][/autoit] [autoit]

    Func _ListRecDevices()
    Local $aInfo, $aInfo2
    For $i = 0 To 5
    $aInfo = _BASS_RecordGetDeviceInfo($i)
    If @error Then ExitLoop
    If IsArray($aInfo) Then
    If BitAND($aInfo[2], $BASS_DEVICE_INIT) Then
    ConsoleWrite("+Input " & $i & ": <" & $aInfo[0] & "> <" & $aInfo[1] & "> <" & $aInfo[2] & ">" & @LF)
    $aInfo = _BASS_RecordGetInfo()
    For $j = 0 To $aInfo[2]
    $sName = _BASS_RecordGetInputName($j)
    If @error Then ExitLoop
    $aInfo2 = _BASS_RecordGetInput($j)
    If BitAND($aInfo2[0], $BASS_INPUT_OFF) Then
    ConsoleWrite("!" & @TAB & $sName & @LF)
    Else
    ConsoleWrite("+" & @TAB & $sName & @LF)
    EndIf
    Next
    Else
    ConsoleWrite("-Input " & $i & ": <" & $aInfo[0] & "> <" & $aInfo[1] & "> <" & $aInfo[2] & ">" & @LF)
    EndIf
    EndIf
    Next
    ConsoleWrite(@LF)
    EndFunc ;==>_ListRecDevices

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _GetFreq($hHandle)
    Local $TmpData = 0, $TmpNr = 0, $fft = 0
    Local $fftstruct = DllStructCreate("float[4096]")
    _BASS_ChannelGetData($hHandle, DllStructGetPtr($fftstruct), $BASS_DATA_FFT8192)
    For $i = 0 To 4095
    $TmpData = Round(DllStructGetData($fftstruct, 1, $i + 1) * 100)
    If $TmpData > 0.2 And $fft < $TmpData Then ;Bestimme den Ort des Maximalwerts der FFT Analyse
    $fft = $TmpData
    $TmpNr = $i + 1
    EndIf
    Next
    Return Round(22000 / 4096 * $TmpNr) ;Max 22kHz.
    EndFunc ;==>_GetFreq

    [/autoit]
  • Aufnahme mit _BASS_Record

    • eukalyptus
    • 14. April 2010 um 11:58

    Dann prüfe auch mal, ob der Pegel der FFT auch einen gewissen Wert überschreitet:
    If $TmpData > 0.2 And $fft < $TmpData Then

    Dann sollte ein evtl Übersprechen nicht erkannt werden

  • Aufnahme mit _BASS_Record

    • eukalyptus
    • 14. April 2010 um 11:38

    Vielleicht nimmt deine Soundkarte automatisch den Mic-In, wenn kein Kabel im Line-In steckt!?
    Versuch mal gleichzeitig wärend des Sinus in einer anderen Frequenz zu pfeifen
    Dann siehst du, ob das Signal vom eingebauten Mikro kommt... :D

  • Aufnahme mit _BASS_Record

    • eukalyptus
    • 14. April 2010 um 11:24

    Hab grad meinen letzten Post editiert!

  • Aufnahme mit _BASS_Record

    • eukalyptus
    • 14. April 2010 um 11:08

    Hi

    Du musst auch $TmpNr auf 0 setzen.
    Bzw. wär es besser, wenn du die Variablen in der Funktion als Local deklarierst

    Edit:
    So kannst du den Record-Input direkt auslesen:

    Spoiler anzeigen
    [autoit]

    #include "Bass.au3"
    #include "BassConstants.au3"

    [/autoit] [autoit][/autoit] [autoit]

    Global $File = "1kHz.wav"

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_STARTUP("BASS.dll") ;Open Bass.DLL.
    _BASS_Init(0, -1, 44100, 0, "") ;Initalize bass.

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_RecordInit(-1)
    $hRecord = _BASS_RecordStart(44100, 1, 0, "", 0)

    [/autoit] [autoit][/autoit] [autoit]

    $hMusic = _BASS_StreamCreateFile(False, $File, 0, 0, 0)
    _BASS_ChannelPlay($hMusic, 1)

    [/autoit] [autoit][/autoit] [autoit]

    While _BASS_ChannelIsActive($hMusic) = $BASS_ACTIVE_PLAYING
    $iFreqOut = _GetFreq($hMusic)
    $iFreqIn = _GetFreq($hRecord)
    ToolTip("Frequenz Out: " & $iFreqOut & @LF & "Frequenz In: " & $iFreqIn)
    Sleep(100)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_Free()
    _BASS_RecordFree()

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetFreq($hHandle)
    Local $TmpData = 0, $TmpNr = 0, $fft = 0
    Local $fftstruct = DllStructCreate("float[4096]")
    _BASS_ChannelGetData($hHandle, DllStructGetPtr($fftstruct), $BASS_DATA_FFT8192)
    For $i = 0 To 4095
    $TmpData = Round(DllStructGetData($fftstruct, 1, $i + 1) * 100)
    If $fft < $TmpData Then ;Bestimme den Ort des Maximalwerts der FFT Analyse
    $fft = $TmpData
    $TmpNr = $i + 1
    EndIf
    Next
    Return Round(22000 / 4096 * $TmpNr) ;Max 22kHz.
    EndFunc ;==>_GetFreq

    [/autoit]

    Beachte, daß beim Output und Input des Audiointerfaces jeweils der standard gewählt wird, d.h. der Out/Input, welcher auch im Windows-Mixer ausgewählt ist.
    In einem der Beispiele der Bass UDF wird gezeigt, wie man diese auswählen kann

    mfgE

  • Hex 6 in Hex 8 umwandeln?

    • eukalyptus
    • 8. April 2010 um 10:08
    [autoit]

    BitOR(0xFF000000, 3881263)

    [/autoit]
  • Visualizer - gesammtes Spektrum

    • eukalyptus
    • 3. April 2010 um 22:00
    Zitat von JuraX

    Kann mir jmd sagen welcher teil des scripts hierfür verantwortlich ist?

    Hier hab ich ein Peakmeter-Beispielscript für dich:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <Bass.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_STARTUP(@ScriptDir & '\BASS.dll')
    _BASS_Init(0, -1, 44100, 0, '')
    If @error Then
    MsgBox(0, 'Error', 'Sound konnte nicht Initialisiert werden!')
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Global $File = FileOpenDialog('Bitte wählen Sie eine Sounddatei aus!', '', 'MP3 Datei (*.mp3;*.wav)')
    If @error Then
    MsgBox(0, 'Fehler', 'Die Datei ist ungültig!' & @LF & 'Das Programm wird beendet!')
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Global $hMusicHandle = _BASS_StreamCreateFile(False, $File, 0, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Peakmeter", 800, 70)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetBkColor(0x000000)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics(800, 70, $hGraphics)
    Global $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsClear($hContext,0xFF000022)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hPeakMeterLeft = _PeakMeterCreate($hContext, 10, 10, 780, 20, 0xFF000022, 0xFF004488)
    Global $hPeakMeterRight = _PeakMeterCreate($hContext, 10, 40, 780, 20,0xFF000022, 0xFF004488)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    _BASS_ChannelPlay($hMusicHandle, 0)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(20)
    _PeakMeterSet($hMusicHandle)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _PeakMeterSet($hStream)
    Local Static $nLeft = 0, $nRight = 0
    Local $iLevel = _BASS_ChannelGetLevel($hStream), $nTemp
    $nLeft -= 0.02
    $nRight -= 0.02
    $nTemp = _DecibelFloat(_LoWord($iLevel) / 32768)
    If $nTemp > $nLeft Then $nLeft = $nTemp
    $nTemp = _DecibelFloat(_HiWord($iLevel) / 32768)
    If $nTemp > $nRight Then $nRight = $nTemp
    _PeakMeterDraw($hPeakMeterLeft, $nLeft)
    _PeakMeterDraw($hPeakMeterRight, $nRight)
    EndFunc ;==>_PeakMeterSet

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _PeakMeterDraw($aPM, $nLevel)
    If $nLevel < 0 Then $nLevel = 0
    If $nLevel > 1 Then $nLevel = 1
    _GDIPlus_GraphicsFillRect($aPM[0], $aPM[2]-2, $aPM[3]-2, $aPM[4]+4, $aPM[5]+4, $aPM[7])
    _GDIPlus_GraphicsFillRect($aPM[0], $aPM[2], $aPM[3], $aPM[4], $aPM[5], $aPM[6])
    _GDIPlus_GraphicsDrawImageRectRect($aPM[0], $aPM[1], 0, 0, $aPM[4] * $nLevel, 1, $aPM[2], $aPM[3], $aPM[4] * $nLevel, $aPM[5])
    EndFunc ;==>_PeakMeterDraw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _PeakMeterCreate($hGraphics, $iX, $iY, $iW, $iH, $nColorBkg = 0xFF000000, $nColorRect=0xFFFFFFFF)
    Local $aReturn[8]
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, 2, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    Local $hBrush[6], $iTile = $iW / 12
    $hBrush[0] = _GDIPlus_BrushCreateSolid(0xFF00FF00)
    $hBrush[1] = _GDIPlus_LineBrushCreate($iTile * 6 - 1, 0, $iTile * 9, 0, 0xFF00FF00, 0xFFFFFF00)
    $hBrush[2] = _GDIPlus_BrushCreateSolid(0xFFFFFF00)
    $hBrush[3] = _GDIPlus_LineBrushCreate($iTile * 10 - 1, 0, $iTile * 11, 0, 0xFFFFFF00, 0xFFFF0000)
    $hBrush[4] = _GDIPlus_BrushCreateSolid(0xFFFF0000)
    $hBrush[5] = _GDIPlus_LineBrushCreate(0, 0, 4, 0, 0x00000000, 0x99000000)
    _GDIPlus_GraphicsFillRect($hContext, 0, 0, $iTile * 8, 2, $hBrush[0])
    _GDIPlus_GraphicsFillRect($hContext, $iTile * 6, 0, $iTile * 3, 2, $hBrush[1])
    _GDIPlus_GraphicsFillRect($hContext, $iTile * 9, 0, $iTile, 2, $hBrush[2])
    _GDIPlus_GraphicsFillRect($hContext, $iTile * 10, 0, $iTile, 2, $hBrush[3])
    _GDIPlus_GraphicsFillRect($hContext, $iTile * 11, 0, $iTile, 2, $hBrush[4])
    For $i = 0 To $iW Step 4
    _GDIPlus_GraphicsFillRect($hContext, $i, 0, 4, 2, $hBrush[5])
    Next
    For $i = 0 To 5
    _GDIPlus_BrushDispose($hBrush[$i])
    Next
    _GDIPlus_GraphicsDispose($hContext)
    $aReturn[0] = $hGraphics
    $aReturn[1] = $hBitmap
    $aReturn[2] = $iX
    $aReturn[3] = $iY
    $aReturn[4] = $iW
    $aReturn[5] = $iH
    $aReturn[6] = _GDIPlus_BrushCreateSolid($nColorBkg)
    $aReturn[7] = _GDIPlus_BrushCreateSolid($nColorRect)
    Return $aReturn
    EndFunc ;==>_PeakMeterCreate

    [/autoit] [autoit][/autoit] [autoit]

    Func _DecibelFloat($iLevel)
    $iLevel = Log($iLevel) / Log(10) * 20
    If $iLevel < -64 Then $iLevel = -64
    $iLevel = ($iLevel + 64) / 64
    Return $iLevel
    EndFunc ;==>_DecibelFloat

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _BASS_Stop()
    _BASS_Free()
    _GDIPlus_BrushDispose($hPeakMeterLeft[6])
    _GDIPlus_BrushDispose($hPeakMeterRight[6])
    _GDIPlus_BitmapDispose($hPeakMeterLeft[0])
    _GDIPlus_BitmapDispose($hPeakMeterRight[0])
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGui)
    Exit
    EndFunc ;==>_Exit

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_LineBrushCreate($nX1, $nY1, $nX2, $nY2, $iARGBClr1, $iARGBClr2, $iWrapMode = 0)
    Local $tPointF1, $pPointF1
    Local $tPointF2, $pPointF2
    Local $aResult
    $tPointF1 = DllStructCreate("float;float")
    $pPointF1 = DllStructGetPtr($tPointF1)
    $tPointF2 = DllStructCreate("float;float")
    $pPointF2 = DllStructGetPtr($tPointF2)
    DllStructSetData($tPointF1, 1, $nX1)
    DllStructSetData($tPointF1, 2, $nY1)
    DllStructSetData($tPointF2, 1, $nX2)
    DllStructSetData($tPointF2, 2, $nY2)
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateLineBrush", "ptr", $pPointF1, "ptr", $pPointF2, "uint", $iARGBClr1, "uint", $iARGBClr2, "int", $iWrapMode, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[6]
    EndFunc ;==>_GDIPlus_LineBrushCreate

    [/autoit]
  • SuperMario Gameplay und Download

    • eukalyptus
    • 3. April 2010 um 20:51

    Hi

    Wenn du im Leveleditor auf ein Objekt rechtsklickst, dann kannst du die Eigenschaften editieren.
    Oder meintest du was anderes?

    mfgE

  • [Beendet] µitLight März

    • eukalyptus
    • 31. März 2010 um 19:54

    Hier ist mein Beitrag.

    sind insg. 4 Versionen, wobei ich eigentlich nur die erste für den Contest relevant halte.

    Version 1:
    Algo zum ermitteln beliebig vieler Primzahlen ohne vorher definierte Obergrenze.
    Eine Zahl, welche durch keine der kleineren Primzahlen teilbar ist, ist eine Primzahl.
    Normalerweise bedient man sich hierbei der Mod-Funktion, es gibt aber auch die sogenannte Summierungsmethode, die etwas schneller ist weil sie nur mit Additionen rechnet.
    Leider ist die Summierungsmethode in AutoIt langsamer als Modulo!
    Durch Tests hab ich herausgefunden, daß IsInt($iN / $aP[$i]) schneller ist als Not Mod($iN , $aP[$i])

    Spoiler anzeigen
    [autoit]

    Global $iCnt = InputBox("Wieviele Primzahlen?", "Wieviele Primzahlen sollen gefunden werden?", "100000")

    [/autoit] [autoit][/autoit] [autoit]

    Global $Timer = TimerInit()
    _Loesungsfunktion($Timer, $iCnt)

    [/autoit] [autoit][/autoit] [autoit]

    Func _Loesungsfunktion(ByRef $Timer, $iM = 100000)
    Local $aP[16777215], $iC = 1, $iN = 3, $iS, $iDiff
    $aP[0] = 2
    $aP[1] = 3
    While $iC < $iM
    $iN += 2
    $iS = Sqrt($iN)
    For $i = 1 To $iC
    If $aP[$i] > $iS Then ExitLoop
    If IsInt($iN / $aP[$i]) Then ContinueLoop 2
    Next
    $iC += 1
    $aP[$iC] = $iN
    WEnd
    $iDiff=TimerDiff($Timer)
    MsgBox(0, "", "Zeit: " & $iDiff & @LF & "Ausgabe erfolgt in Console")
    For $i = 0 To $iM - 1
    ConsoleWrite($aP[$i] & @CRLF)
    Next
    EndFunc ;==>_Loesungsfunktion

    [/autoit]


    Version 2:
    Stinknormales Sieb des Eratosthenes mit wohl definierter Obergrenze
    Eigentlich sinnlos für die gestellte Aufgabe "finde die ersten 100000 Primzahlen", aber für "finde alle Primzahlen bis 1299710" super geeignet.
    Diese Version hab ich optimiert, wo es nur geht.
    Auch das "Auslesen" des Arrays findet erst bei der Ausgabe statt :whistling:

    Spoiler anzeigen
    [autoit]

    Global $Timer = TimerInit()
    _Loesungsfunktion($Timer)

    [/autoit] [autoit][/autoit] [autoit]

    Func _Loesungsfunktion(ByRef $Timer)
    Local $hF, $aN[1299709 + 1], $iDiff
    For $i = 2 To 1141
    If Not $aN[$i] Then
    For $j = $i * $i To 1299709 Step $i
    $aN[$j] = 1
    Next
    EndIf
    Next
    $iDiff=TimerDiff($Timer)
    MsgBox(0, "", "Zeit: " & $iDiff & @LF & "Ausgabe erfolgt in Console")
    For $i = 2 To 1299709
    If Not $aN[$i] Then ConsoleWrite($i & @CRLF)
    Next
    EndFunc ;==>_Loesungsfunktion

    [/autoit]

    Version 3 und 4 sind nicht für den Contest gedacht!
    Version 3 verwendet den gleichen Algo, wie Version 1, allerdings in FreePascal programmiert und via DllCall aufgerufen.
    Man sieht eindrucksvoll den Geschwindigkeitsunterschied zwischen Pascal und AutoIt...
    Version 4 ist der selbe Algo wie Version 2 als FreePascal-Dll.
    Auch nicht für den Contest, aber als direkter Konkurrent zu den ASM-Versionen :D

    ZIP-Passwort:

    Code
    AP#n6OiHIu4A

    E

    Dateien

    eukalyptus.zip 70,58 kB – 291 Downloads

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™