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

  • SpVoice mit Bass.dll abfangen

    • eukalyptus
    • 9. November 2010 um 23:14

    bitteschön:

    Spoiler anzeigen
    [autoit]

    #include "Bass.au3"

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

    _SpeakToWAV("speak to wav file", @ScriptDir & "\Output.wav")

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

    _BASS_Startup()
    _BASS_Init(0, -1, 44100, 0, "")
    _SpeakToStream("speak to bass memory stream")
    _BASS_Free()

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

    Func _SpeakToWAV($sText, $sFile)
    Local $oVoice = ObjCreate("Sapi.SpVoice")
    Local $oFileStream = ObjCreate("SAPI.SpFileStream.1")
    $oFileStream.Open($sFile, 3)
    $oVoice.AudioOutputStream = $oFileStream
    $oVoice.Speak($sText)
    EndFunc ;==>_SpeakToWAV

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

    Func _SpeakToStream($sText, $iTimeout = 10000)
    Local $oVoice = ObjCreate("Sapi.SpVoice")
    Local $oMemStream = ObjCreate("SAPI.SpMemoryStream.1")
    $oVoice.AudioOutputStream = $oMemStream
    $oVoice.Speak($sText)
    $oVoice.WaitUntilDone($iTimeout)

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

    Local $bData = $oMemStream.GetData()
    Local $iSize = BinaryLen($bData)
    Local $tData = DllStructCreate("byte[" & $iSize & "]")
    DllStructSetData($tData, 1, $bData)

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

    Local $hStream = _BASS_StreamCreate(22050, 1, 0, $STREAMPROC_PUSH)

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

    _BASS_ChannelPlay($hStream, True)
    _BASS_StreamPutData($hStream, DllStructGetPtr($tData), $iSize)
    Sleep(_BASS_ChannelBytes2Seconds($hStream, $iSize) * 1000)
    _BASS_StreamFree($hStream)
    EndFunc ;==>_SpeakToStream

    [/autoit]

    mfgE

    Edit:
    Wenn man den Sampledaten noch einen Wav-Header hinzufügt, kann man einen "normalen" Stream daraus erstellen.

    Spoiler anzeigen
    [autoit]

    #include "Bass.au3"
    ;#include "BassExt.au3"

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

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

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

    $tWave = _BASS_EXT_SpVoice2Memory("this is a test")
    $hStream = _BASS_StreamCreateFile(True, DllStructGetPtr($tWave), 0, DllStructGetData($tWave, "Len"), 0)

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

    _BASS_ChannelPlay($hStream, True)

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

    While _BASS_ChannelIsActive($hStream)
    Sleep(10)
    WEnd

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

    _BASS_StreamFree($hStream)
    _BASS_Free()

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

    Func _BASS_EXT_SpVoice2Memory($sText, $iRate = 0, $iVolume = 100)
    Local $oVoice = ObjCreate("Sapi.SpVoice")
    If @error Or Not IsObj($oVoice) Then Return SetError(1, 1, 0)

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

    Local $oMemStream = ObjCreate("SAPI.SpMemoryStream.1")
    If @error Or Not IsObj($oVoice) Then Return SetError(1, 2, 0)
    Local $vSpAudioFormat = $oMemStream.Format
    $vSpAudioFormat.Type = 0x00000023

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

    $oVoice.AudioOutputStream = $oMemStream
    $oVoice.Rate = $iRate
    $oVoice.Volume = $iVolume

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

    $oVoice.Speak($sText)

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

    Local $bData = $oMemStream.GetData()
    Local $iSize = BinaryLen($bData)
    If $iSize <= 0 Then Return SetError(1, 2, 0)

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

    Local $tWave = DllStructCreate("char RIFF [4];uint FileSize;char WAVE [4];char fmt [4];uint fmt_len;word Format;word Channels;uint Samplerate;uint Bytes;word Block;word BitsPerSample;char DATA [4];uint Len;byte WAVDATA[" & $iSize & "]")
    DllStructSetData($tWave, "RIFF", "RIFF")
    DllStructSetData($tWave, "FileSize", $iSize + 44 - 8)
    DllStructSetData($tWave, "WAVE", "WAVE")
    DllStructSetData($tWave, "fmt", "fmt ")
    DllStructSetData($tWave, "fmt_len", 16)
    DllStructSetData($tWave, "Format", 1)
    DllStructSetData($tWave, "Channels", 2)
    DllStructSetData($tWave, "Samplerate", 44100)
    DllStructSetData($tWave, "Bytes", 176400)
    DllStructSetData($tWave, "Block", 4)
    DllStructSetData($tWave, "BitsPerSample", 16)
    DllStructSetData($tWave, "DATA", "data")
    DllStructSetData($tWave, "Len", $iSize)
    DllStructSetData($tWave, "WAVDATA", $bData)

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

    Return SetError(0, $iSize, $tWave)
    EndFunc ;==>_BASS_EXT_SpVoice2Memory

    [/autoit]
  • Lieder aus internet abspielen

    • eukalyptus
    • 9. November 2010 um 15:15

    Mit der bass.dll (und bassext.dll) sollte das so funktionieren:

    [autoit]

    #include "Bass.au3"
    #include "BassExt.au3"

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

    _BASS_Startup()
    _BASS_Ext_Startup()

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

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

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

    $sUrl = "http://....... .mp3"
    $hStream = _BASS_StreamCreateURL($sUrl, 0, 0, $BASS_EXT_DownloadProc, 0)

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

    _BASS_ChannelPlay($hStream, True)

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

    While _BASS_ChannelIsActive($hStream)
    Sleep(20)
    WEnd

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

    _BASS_Free()

    [/autoit]
  • Stream schneiden (Bass.dll)

    • eukalyptus
    • 7. November 2010 um 18:22

    Wenn du einen DecodingStream zu einem Mixerstream hinzufügst, dann kannst du mit Channelsetpos einstellen, ab welcher Position des Streams begonnen wird.

    Eine einfachere Möglkichkeit wäre noch eine Lautstärken-Hüllkurve - damit kannst du einstellen, welche Stellen mit welcher Lautstärke gespielt werden
    Also einfach auf 0 setzen, wenn du etwas "rausschneiden" willst

    Dieses Beispiel hilft dir vielleicht:

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_UseX64=n
    #include "Bass.au3"
    #include "BassMix.au3"

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

    OnAutoItExitRegister("_FreeBass")

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

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

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

    $sFile1 = FileOpenDialog("Open...", "", "playable formats (*.MP3;*.MP2;*.MP1;*.OGG;*.WAV;*.AIFF;*.AIF)")
    ___Debug($sFile1 = "", $sFile1)

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

    $sFile2 = FileOpenDialog("Open...", "", "playable formats (*.MP3;*.MP2;*.MP1;*.OGG;*.WAV;*.AIFF;*.AIF)")
    ___Debug($sFile2 = "", $sFile2)

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

    _BASS_Startup(@ScriptDir & "\bass.dll")
    ___Debug(@error, "load bass.dll")

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

    _BASS_MIX_Startup(@ScriptDir & "\bassmix.dll")
    ___Debug(@error, "load bassmix.dll")

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

    _BASS_Init(0, -1, 44100, 0, "")
    ___Debug(@error, "initialize bass")

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

    $hStream1 = _BASS_StreamCreateFile(False, $sFile1, 0, 0, $BASS_STREAM_DECODE)
    ___Debug(@error, "create stream from file 1")

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

    $hStream2 = _BASS_StreamCreateFile(False, $sFile2, 0, 0, $BASS_STREAM_DECODE)
    ___Debug(@error, "create stream from file 2")

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

    $hMixer = _BASS_Mixer_StreamCreate(44100, 2, $BASS_MIXER_END)
    ___Debug(@error, "create mixer stream")

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

    _BASS_Mixer_StreamAddChannel($hMixer, $hStream1, 0)
    ___Debug(@error, "add stream to mixer")
    _BASS_Mixer_StreamAddChannel($hMixer, $hStream2, 0)
    ___Debug(@error, "add stream to mixer")

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

    $i2Sec_Bytes = _BASS_ChannelSeconds2Bytes($hMixer, 5)
    ___Debug(@error, "2 seconds = " & $i2Sec_Bytes & " bytes")

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

    Global $aNodes1[4][2]
    $aNodes1[0][0] = 3
    $aNodes1[1][0] = 0
    $aNodes1[1][1] = 0
    $aNodes1[2][0] = $i2Sec_Bytes
    $aNodes1[2][1] = 1
    $aNodes1[3][0] = $i2Sec_Bytes * 2
    $aNodes1[3][1] = 0

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

    Global $aNodes2[4][2]
    $aNodes2[0][0] = 3
    $aNodes2[1][0] = 0
    $aNodes2[1][1] = 1
    $aNodes2[2][0] = $i2Sec_Bytes
    $aNodes2[2][1] = 0
    $aNodes2[3][0] = $i2Sec_Bytes * 2
    $aNodes2[3][1] = 1

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

    _BASS_Mixer_ChannelSetEnvelope($hStream1, BitOR($BASS_MIXER_ENV_VOL, $BASS_MIXER_ENV_LOOP), $aNodes1)
    ___Debug(@error, "set volume envelope")

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

    _BASS_Mixer_ChannelSetEnvelope($hStream2, BitOR($BASS_MIXER_ENV_VOL, $BASS_MIXER_ENV_LOOP), $aNodes2)
    ___Debug(@error, "set volume envelope")

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

    _BASS_ChannelPlay($hMixer, True)
    ___Debug(@error, "start channel")

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

    While _BASS_ChannelIsActive($hMixer)
    $aEnv1 = _BASS_Mixer_ChannelGetEnvelopePos($hStream1, $BASS_MIXER_ENV_VOL)
    $aEnv2 = _BASS_Mixer_ChannelGetEnvelopePos($hStream2, $BASS_MIXER_ENV_VOL)
    ToolTip("Volume channel 1: " & $aEnv1[1] & @CRLF & "Volume channel 2: " & $aEnv2[1])
    Sleep(10)
    WEnd

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

    Func _Exit()
    Exit
    EndFunc ;==>_Exit

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

    Func _FreeBass()
    _BASS_StreamFree($hStream1)
    _BASS_StreamFree($hStream2)
    _BASS_Free()
    EndFunc ;==>_FreeBass

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

    Func ___DeBug($iError, $sAction)
    Switch $iError
    Case -1
    ConsoleWrite(@CRLF & "-" & $sAction & @CRLF)
    Case -2
    ConsoleWrite(@CRLF & ">" & $sAction & @CRLF)
    Case 0
    ConsoleWrite(@CRLF & "+" & $sAction & " - OK" & @CRLF)
    Case Else
    ConsoleWrite(@CRLF & "!" & $sAction & " - FAILED, @error: " & $iError & @CRLF)
    Exit
    EndSwitch
    EndFunc ;==>___DeBug

    [/autoit]
  • Stream schneiden (Bass.dll)

    • eukalyptus
    • 7. November 2010 um 18:10

    Im Prinzip wie in diesem Beispiel: [ gelöst ] Fehler in meinem Script (Bass.dll)

    Du musst halt nach jeder "Pause" den Stream erneut adden.
    und mit _Bass_channelSetPos den Offset einstellen.

    Oder ein Audiofile mehrmals laden und zu Beginn die gewünschten Offsets und Abspiellänge einstellen...

    E

  • mit GDI+ Stream Amplitude (Bass.dll) anzeigen

    • eukalyptus
    • 7. November 2010 um 09:21

    Hier ein kleines Beispielscrip, welches zeigt wie es in etwa funktioniert (ist jedoch extrem langsam)

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_UseX64=n
    #include "Bass.au3"
    #include <GDIPlus.au3>

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

    Global $iBufferSize = 20000 ; bytes

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

    Global $tBuffer = DllStructCreate("float[" & $iBufferSize / 4 & "]")
    Global $pBuffer = DllStructGetPtr($tBuffer)

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

    _GDIPlus_Startup()
    Global $hGui = GUICreate("Test", 1000, 230)
    GUISetBkColor(0x000000)
    GUISetState()
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    Global $hPenL = _GDIPlus_PenCreate(0xFF00FF00)
    Global $hPenR = _GDIPlus_PenCreate(0xFFFF0000)

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

    _BASS_Startup()

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

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

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

    Global $sFile = FileOpenDialog("Open...", "", "Wav Files (*.wav)")
    Global $hStream = _BASS_StreamCreateFile(False, $sFile, 0, 0, $BASS_STREAM_DECODE)

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

    Global $iBytes = _BASS_ChannelGetLength($hStream, $BASS_POS_BYTE)

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

    Global $fXStep = 990 / ($iBytes / 8)

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

    For $i = 1 To $iBytes Step $iBufferSize
    ToolTip(Round($i * 100 / $iBytes, 1) & "%")
    If $i + $iBufferSize <= $iBytes Then
    _BASS_ChannelGetData($hStream, $pBuffer, BitOR($iBufferSize, $BASS_DATA_FLOAT))
    _Analyze($iBufferSize, $fXStep)
    Else
    _BASS_ChannelGetData($hStream, $pBuffer, BitOR($iBytes - $i, $BASS_DATA_FLOAT))
    _Analyze($iBytes - $i, $fXStep)
    EndIf
    Next
    _BASS_FREE()

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

    While GUIGetMsg() <> -3
    Sleep(10)
    WEnd

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

    _GDIPlus_PenDispose($hPenL)
    _GDIPlus_PenDispose($hPenR)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()

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

    Func _Analyze($iBytes, $fXStep)
    Local Static $fX = 0
    Local $fL = 0
    Local $fR = 0
    For $i = 1 To $iBytes / 4 Step 2
    $fL = DllStructGetData($tBuffer, 1, $i)
    $fR = DllStructGetData($tBuffer, 1, $i + 1)
    _GDIPlus_GraphicsDrawLine($hGraphics, $fX, 60, $fX, 60 + $fL * 50, $hPenL)
    _GDIPlus_GraphicsDrawLine($hGraphics, $fX, 170, $fX, 170 + $fR * 50, $hPenR)
    $fX += $fXStep
    Next
    EndFunc ;==>_Analyze

    [/autoit]


    Und hier ein Beispiel zu BassExt.dll:

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_UseX64=n
    #include "Bass.au3"
    #include "BassExt.au3"
    #include <GDIPlus.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $sFile = FileOpenDialog("Open...", "", "playable formats (*.MP3;*.MP2;*.MP1;*.OGG;*.WAV;*.AIFF;*.AIF)")
    ___Debug($sFile = "", $sFile)

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

    $hGui = GUICreate("WaveformDecode", 800, 250)
    GUISetOnEvent(-3, "_EXIT")
    GUISetState()

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

    _GDIPlus_Startup()
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics(800, 250, $hGraphics)
    $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)

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

    $hBmpBk = _GDIPlus_BitmapCreateFromGraphics(800, 250, $hGraphics)
    $hGfxBk = _GDIPlus_ImageGetGraphicsContext($hBmpBk)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBk, 2)

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

    $hPenL = _GDIPlus_PenCreate(0xFF00FF00, 1)
    $hPenR = _GDIPlus_PenCreate(0xFFFF0000, 1)
    $hBrushL = _GDIPlus_BrushCreateSolid(0xBB00BB00)
    $hBrushR = _GDIPlus_BrushCreateSolid(0xBBBB0000)
    $hPenPos = _GDIPlus_PenCreate(0xFF000099, 3)
    $hPenPos2 = _GDIPlus_PenCreate(0x99FFFF00, 1)

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

    _BASS_Startup(@ScriptDir & "\bass.dll")
    ___Debug(@error, "load bass.dll")

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

    _BASS_EXT_Startup(@ScriptDir & "\bassExt.dll")
    ___Debug(@error, "load bassext.dll")

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

    _BASS_Init(0, -1, 44100, 0, "")
    ___Debug(@error, "initialize bass")

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

    $hStreamDecode = _BASS_StreamCreateFile(False, $sFile, 0, 0, $BASS_STREAM_DECODE)
    ___Debug(@error, "create stream from file")

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

    $hStreamPlay = _BASS_StreamCreateFile(False, $sFile, 0, 0, 0)
    ___Debug(@error, "create stream from file")

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

    $iBytes = _BASS_ChannelGetLength($hStreamDecode, $BASS_POS_BYTE)
    $iLength = _BASS_ChannelBytes2Seconds($hStreamDecode, $iBytes)

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

    $iRes = 88; polygon segments per second

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

    $iWidth = $iLength * $iRes
    $aWave = _BASS_EXT_ChannelGetWaveformDecode($hStreamDecode, $iWidth, 200, 0, $iLength, $iRes, "_WaveformGetProc")

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

    _BASS_StreamFree($hStreamDecode)

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

    $hBmpWave = _BASS_EXT_GDIpBitmapCreateWaveform($hGraphics, $aWave, $hBrushL, $hPenL, $hBrushR, $hPenR, 0, 1)
    ToolTip("")

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

    _GDIPlus_GraphicsClear($hGfxBk, 0xFF000000)
    Switch $iWidth
    Case 0 To 30000
    _GDIPlus_GraphicsDrawImageRect($hGfxBk, $hBmpWave, 0, 200, 800, 50)
    Case Else
    For $i = 0 To $iWidth Step 30000
    _GDIPlus_GraphicsDrawImageRectRect($hGfxBk, $hBmpWave, $i, 0, 30000, 200, Round($i * 800 / $iWidth), 200, Ceiling(30000 * 800 / $iWidth), 50)
    Next
    EndSwitch

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

    _BASS_ChannelPlay($hStreamPlay, True)
    ___Debug(@error, "start stream")

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

    GUIRegisterMsg(0x000F, "WM_PAINT")
    GUIRegisterMsg(0x0014, "WM_ERASEBKGND")

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

    $iTimer = TimerInit()
    While _BASS_ChannelIsActive($hStreamPlay)
    If TimerDiff($iTimer) > 20 Then
    $iTimer = TimerInit()
    $iPosByte = _BASS_ChannelGetPosition($hStreamPlay, $BASS_POS_BYTE)
    $iPosSec = _BASS_ChannelBytes2Seconds($hStreamPlay, $iPosByte)
    $iOffset = Round($iPosSec * $iRes)
    _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBmpBk, 0, 0)
    _GDIPlus_GraphicsDrawLine($hGfxBuffer, 400, 2, 400, 198, $hPenPos)
    _GDIPlus_GraphicsDrawLine($hGfxBuffer, 800 * $iOffset / $iWidth, 202, 800 * $iOffset / $iWidth, 248, $hPenPos2)
    Select
    Case $iOffset < 400
    _GDIPlus_GraphicsDrawImageRectRect($hGfxBuffer, $hBmpWave, 0, 0, 800, $aWave[6] * 4, 400 - $iOffset, 0, 800, $aWave[6] * 4)
    Case $iOffset >= $iWidth - 800
    _GDIPlus_GraphicsDrawImageRectRect($hGfxBuffer, $hBmpWave, $iWidth - ($iWidth - $iOffset) - 400, 0, $iWidth - $iOffset + 400, $aWave[6] * 4, 0, 0, $iWidth - $iOffset + 400, $aWave[6] * 4)
    Case Else
    _GDIPlus_GraphicsDrawImageRectRect($hGfxBuffer, $hBmpWave, $iOffset - 400, 0, 800, $aWave[6] * 4, 0, 0, 800, $aWave[6] * 4)
    EndSelect
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    EndIf
    Sleep(10)
    WEnd

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

    _Exit()

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

    Func _WaveformGetProc($handle, $percent)
    ToolTip("Get Waveform: " & $percent & "%")
    EndFunc ;==>_WaveformGetProc

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

    Func _Exit()
    _BASS_ChannelStop($hStreamPlay)
    ___Debug(@error, "stop stream")

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

    _BASS_StreamFree($hStreamPlay)
    ___Debug(@error, "free stream")

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

    _BASS_Free()
    ___Debug(@error, "free bass")

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

    GUIRegisterMsg(0x000F, "")
    GUIRegisterMsg(0x0014, "")
    _GDIPlus_PenDispose($hPenL)
    _GDIPlus_PenDispose($hPenR)
    _GDIPlus_BrushDispose($hBrushL)
    _GDIPlus_BrushDispose($hBrushR)
    _GDIPlus_PenDispose($hPenPos)
    _GDIPlus_PenDispose($hPenPos2)
    _GDIPlus_BitmapDispose($hBmpBk)
    _GDIPlus_GraphicsDispose($hGfxBk)
    _GDIPlus_BitmapDispose($hBmpWave)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

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

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return 'GUI_RUNDEFMSG'
    EndFunc ;==>WM_PAINT

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

    Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return True
    EndFunc ;==>WM_ERASEBKGND

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

    Func ___DeBug($iError, $sAction)
    Switch $iError
    Case -1
    ConsoleWrite(@CRLF & "-" & $sAction & @CRLF)
    Case 0
    ConsoleWrite(@CRLF & "+" & $sAction & " - OK" & @CRLF)
    Case Else
    ConsoleWrite(@CRLF & "!" & $sAction & " - FAILED" & @CRLF)
    Exit
    EndSwitch
    EndFunc ;==>___DeBug

    [/autoit]

    benötigte Dateien findest du hier:
    Audio Visualization Collection

    E

  • Fehler in meinem Script (Bass.dll)

    • eukalyptus
    • 1. November 2010 um 12:48

    Hab einen kleinen Fehler gemacht!

    Bei _BASS_ChannelSeconds2Bytes musst du den Handle des Mixerstreams verwenden, sonst stimmen die Sekunden nicht, wenn du Samples mit anderer Samplingfrequenz verwendest!

    Hier noch ein kurzes Beispiel:

    Spoiler anzeigen
    [autoit]

    #include "Bass.au3"
    #include "BassMix.au3"
    #include "BassEnc.au3"

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

    ;result: 0s 10s
    ;output.wav: |----------------------------|
    ;sample1.wav: |----------|
    ;sample2.wav: |----------------|
    ;sample3.wav: |-------------|

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

    $iBufferSize = 20000 ; bytes

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

    _BASS_Startup()
    _BASS_MIX_Startup()
    _BASS_Encode_Startup()

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

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

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

    $hStream1 = _BASS_StreamCreateFile(False, @ScriptDir & "\sample1.wav", 0, 0, $BASS_STREAM_DECODE)

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

    $hStream2 = _BASS_StreamCreateFile(False, @ScriptDir & "\sample2.wav", 0, 0, $BASS_STREAM_DECODE)
    _BASS_ChannelSetPosition($hStream2, _BASS_ChannelSeconds2Bytes($hStream2, 5), $BASS_POS_BYTE) ;sample offset: 5s

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

    $hStream3 = _BASS_StreamCreateFile(False, @ScriptDir & "\sample3.wav", 0, 0, $BASS_STREAM_DECODE)

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

    $hMixer = _BASS_Mixer_StreamCreate(44100, 2, BitOR($BASS_MIXER_END, $BASS_STREAM_DECODE))

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

    _BASS_Mixer_StreamAddChannelEx($hMixer, $hStream1, BitOR($BASS_MIXER_FILTER, $BASS_STREAM_AUTOFREE), _
    _BASS_ChannelSeconds2Bytes($hMixer, 1), _BASS_ChannelSeconds2Bytes($hMixer, 4)) ;sample1.wav: start: 1s / duration: 4s

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

    _BASS_Mixer_StreamAddChannelEx($hMixer, $hStream2, BitOR($BASS_MIXER_FILTER, $BASS_STREAM_AUTOFREE), _
    _BASS_ChannelSeconds2Bytes($hMixer, 3), _BASS_ChannelSeconds2Bytes($hMixer, 6)) ;sample2.wav: start: 3s (sample offset 5s) / duration: 6s

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

    _BASS_Mixer_StreamAddChannelEx($hMixer, $hStream3, BitOR($BASS_MIXER_FILTER, $BASS_STREAM_AUTOFREE), _
    _BASS_ChannelSeconds2Bytes($hMixer, 6), _BASS_ChannelSeconds2Bytes($hMixer, 5)) ;sample3.wav: start: 6s / duration: 5s

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

    _BASS_Encode_Start($hMixer, @ScriptDir & "\output.wav", $BASS_ENCODE_PCM)

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

    $tBuffer = DllStructCreate("byte[" & $iBufferSize & "]")
    $pBuffer = DllStructGetPtr($tBuffer)

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

    $iBytesEncode = _BASS_ChannelSeconds2Bytes($hMixer, 10); max length of output.wav

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

    For $i = 1 To $iBytesEncode Step $iBufferSize
    If $i + $iBufferSize <= $iBytesEncode Then
    _BASS_ChannelGetData($hMixer, $pBuffer, $iBufferSize)
    Else
    _BASS_ChannelGetData($hMixer, $pBuffer, $iBytesEncode - $i)
    EndIf
    Next

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

    _BASS_FREE()

    [/autoit]
  • Fehler in meinem Script (Bass.dll)

    • eukalyptus
    • 1. November 2010 um 11:47

    Encoded 10 Sekunden von test1.mp3, nach 5 Sekunden startet test2.wav für 3 Sekunden:

    Spoiler anzeigen
    [autoit]

    #include "Bass.au3"
    #include "BassFX.au3"
    #include "BassMix.au3"
    #include "BassExt.au3"
    #include "BassEnc.au3"
    _BASS_Startup(@ScriptDir & "\bass.dll")
    _BASS_MIX_Startup(@ScriptDir & "\bassmix.dll")
    _BASS_FX_Startup(@ScriptDir & "\bass_fx.dll")
    _BASS_EXT_Startup(@ScriptDir & "\bassext.dll")
    _BASS_Init(0, -1, 44100, 0, "")
    _BASS_Encode_Startup()

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

    $smpl1 = _BASS_StreamCreateFile(False, @ScriptDir & "\test1.mp3", 0, 0, $BASS_STREAM_DECODE)
    $smpl2 = _BASS_StreamCreateFile(False, @ScriptDir & "\test2.wav", 0, 0, $BASS_STREAM_DECODE)

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

    $hTempo1 = _BASS_FX_TempoCreate($smpl1, $BASS_STREAM_DECODE)
    _BASS_ChannelSetAttribute($hTempo1, $BASS_ATTRIB_TEMPO, 0)
    _BASS_ChannelSetAttribute($hTempo1, $BASS_ATTRIB_TEMPO_PITCH, 0)
    $hTempo2 = _BASS_FX_TempoCreate($smpl2, $BASS_STREAM_DECODE)
    _BASS_ChannelSetAttribute($hTempo2, $BASS_ATTRIB_TEMPO, 0)
    _BASS_ChannelSetAttribute($hTempo2, $BASS_ATTRIB_TEMPO_PITCH, 0)

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

    $hMixer = _BASS_Mixer_StreamCreate(44100, 2, BitOR($BASS_MIXER_END, $BASS_STREAM_DECODE))
    _BASS_Mixer_StreamAddChannel($hMixer, $hTempo1, 0)

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

    $iBytesStart = _BASS_ChannelSeconds2Bytes($hTempo2, 5)
    $iBytesLength = _BASS_ChannelSeconds2Bytes($hTempo2, 3)
    ConsoleWrite(@CRLF & "! Start nach 5s = " & $iBytesStart & " bytes / spiele 3s = " & $iBytesLength & " bytes" & @CRLF & @CRLF)
    _BASS_Mixer_StreamAddChannelEx($hMixer, $hTempo2, 0, $iBytesStart, $iBytesLength)
    _BASS_Encode_Start($hMixer, @ScriptDir & "\test.wav", $BASS_ENCODE_PCM)

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

    Global $tBuffer = DllStructCreate("byte[20000]")
    Global $pBuffer = DllStructGetPtr($tBuffer)

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

    $iBytesEncode = _BASS_ChannelSeconds2Bytes($hMixer, 10) ; 10 sekunden Aufnahmelänge

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

    For $i = 1 To $iBytesEncode Step 20000
    If $i + 20000 <= $iBytesEncode Then
    _BASS_ChannelGetData($hMixer, $pBuffer, 20000)
    Else
    _BASS_ChannelGetData($hMixer, $pBuffer, $iBytesEncode - $i)
    EndIf
    Next

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

    _BASS_FREE()

    [/autoit]
  • Fehler in meinem Script (Bass.dll)

    • eukalyptus
    • 1. November 2010 um 11:32

    Um die Samples zum Encoder zu bekommen, gibt es 2 Möglichkeiten:

    1) Normalen Stream abspielen (wie jetzt)
    2) Decoding Stream verwenden und mit _BASS_ChannelGetData die Samples "auslesen"

    Vielleicht hilft dir dieses Beispiel etwas weiter:

    Spoiler anzeigen
    [autoit]

    #AutoIt3Wrapper_UseX64=n
    #include "Bass.au3"
    #include "BassMix.au3"
    #include "BassEnc.au3"

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

    Global $iOutputFreq = 32000

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

    _BASS_Startup()
    ___Debug(@error, "load bass.dll")

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

    _BASS_ENCODE_Startup()
    ___Debug(@error, "load bassenc.dll")

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

    _BASS_MIX_Startup()
    ___Debug(@error, "load bassmix.dll")

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

    _BASS_Init(0, -1, 44100, 0, "")
    ___Debug(@error, "initialize bass")

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

    Global $tBuffer = DllStructCreate("byte[20000]")
    Global $pBuffer = DllStructGetPtr($tBuffer)
    Global $iBuffer = DllStructGetSize($tBuffer)

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

    $sFile = FileOpenDialog("Open...", "", "Wav Files (*.wav)")
    ___Debug($sFile = "", $sFile)

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

    $hMusicHandle = _BASS_StreamCreateFile(False, $sFile, 0, 0, $BASS_STREAM_DECODE)
    ___Debug(@error, "create stream from file")
    $aInfo = _BASS_ChannelGetInfo($hMusicHandle)
    ___Debug(@error, "get channel infos")

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

    $hMixer = _BASS_Mixer_StreamCreate($iOutputFreq, $aInfo[1], BitOR($BASS_MIXER_END, $BASS_STREAM_DECODE))
    ___Debug(@error, "create mixer stream")

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

    _BASS_Mixer_StreamAddChannel($hMixer, $hMusicHandle, $BASS_MIXER_FILTER)
    ___Debug(@error, "add channel to mixer")

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

    $hEncoder = _BASS_Encode_Start($hMixer, @ScriptDir & "\Resampled.wav", $BASS_ENCODE_PCM)
    ___Debug(@error, "set up encoder")

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

    $iBytes = _BASS_ChannelGetLength($hMusicHandle, $BASS_POS_BYTE)
    ___Debug(@error, "get filesize: " & $iBytes)

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

    $iBytes = $iBytes * $iOutputFreq / $aInfo[0]
    $iDone = 0

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

    While _BASS_ChannelIsActive($hMixer)
    $iLength = _BASS_ChannelGetData($hMixer, $pBuffer, $iBuffer)
    ___Debug(@error, "read data: " & $iLength & " bytes")

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

    $iDone += $iLength
    ___Debug(-1, Round($iDone * 100 / $iBytes) & "% done")
    WEnd

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

    _BASS_Encode_Stop($hEncoder)
    ___Debug(@error, "stop encoder")

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

    _BASS_StreamFree($hMixer)
    ___Debug(@error, "free stream")

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

    _BASS_Free()
    ___Debug(@error, "free bass")

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

    Func ___DeBug($iError, $sAction)
    Switch $iError
    Case -1
    ConsoleWrite(@CRLF & "-" & $sAction & @CRLF)
    Case 0
    ConsoleWrite(@CRLF & "+" & $sAction & " - OK" & @CRLF)
    Case Else
    ConsoleWrite(@CRLF & "!" & $sAction & " - FAILED" & @CRLF)
    Exit
    EndSwitch
    EndFunc ;==>___DeBug

    [/autoit]

    mfgE

  • Fehler in meinem Script (Bass.dll)

    • eukalyptus
    • 1. November 2010 um 11:23

    Du willst also eine Audiodatei erstellen, ohne daß etwas abgespielt wird?

  • Fehler in meinem Script (Bass.dll)

    • eukalyptus
    • 1. November 2010 um 11:06

    Im Prinzip ganz einfach:

    [autoit]

    $iBytesStart = _BASS_ChannelSeconds2Bytes($hTempo2, 5)
    $iBytesLength = _BASS_ChannelSeconds2Bytes($hTempo2, 3)
    ConsoleWrite(@CRLF & "! Start nach 5s = " & $iBytesStart & " bytes / spiele 3s = " & $iBytesLength & " bytes" & @CRLF & @CRLF)
    _BASS_Mixer_StreamAddChannelEx($hMixer, $hTempo2, 0, $iBytesStart, $iBytesLength)

    [/autoit]

    Allerdings hat die BassMix.au3 hier einen Bug:
    Zeile 599 :

    [autoit]

    Local $BASS_ret_ = DllCall($_ghBassMixDll, "int", "BASS_Mixer_StreamAddChannelEx", "hwnd", $handle, "dword", $channel, "uint64", $length)

    [/autoit]


    muss natürlich so aussehen:

    [autoit]

    Local $BASS_ret_ = DllCall($_ghBassMixDll, "int", "BASS_Mixer_StreamAddChannelEx", "hwnd", $handle, "dword", $channel, "dword", $flags, "uint64", $start, "uint64", $length)

    [/autoit]

    E

    Edit: Alternativ dazu kann man auch einen Syncpunkt (BASS_ChannelSetSync) erstellen, an dem dann das nächste Sample gestartet wird - das muss ich mir aber erst mal genauer ansehen

  • GDI+ Heatmap

    • eukalyptus
    • 31. Oktober 2010 um 13:18

    Hi

    Je öfter man mit der Maus über die selbe Stelle fährt, desto "heißer" wird diese
    Weiß nicht, wie ich das anders beschreiben soll :D

    Vielen Dank an UEZ für die großartige Vorarbeit

    Benötigt GDIp.au3!

    Spoiler anzeigen
    [autoit]

    #include <GDIP.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    Global $iWidth = 800
    Global $iHeight = 580

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

    Global $fSize = 0.2
    Global $iRad = 8

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

    Global $aMPos[2] = [0, 0], $aMPos_Old[2] = [0, 0]

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

    _GDIPlus_Startup()

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

    Global $hGui = GUICreate("HeatMap", $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_EXIT")
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    Global $hBmpHeat = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    Global $hGfxHeat = _GDIPlus_ImageGetGraphicsContext($hBmpHeat)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxHeat, 2)

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

    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)

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

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")
    GUISetState()

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

    While 1
    $aMPos = _MouseGetPos($hGui)
    If $aMPos[0] > 0 And $aMPos[0] < $iWidth And $aMPos[1] > 0 And $aMPos[1] < $iHeight And ($aMPos[0] <> $aMPos_Old[0] Or $aMPos[1] <> $aMPos_Old[1]) Then
    _DrawHeat($aMPos[0], $aMPos[1])
    $aMPos_Old = $aMPos
    EndIf
    WEnd

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

    Func _DrawHeat($iX, $iY)
    $iX = $iX * $fSize
    $iY = $iY * $fSize

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

    Local $hPath = _GDIPlus_PathCreate(0)
    _GDIPlus_PathAddEllipse($hPath, $iX, $iY, $iRad * 2, $iRad * 2)
    Local $aColor[2] = [1, 0x00000000]
    Local $hPathBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hPathBrush, 0x20000000)
    _GDIPlus_PathBrushSetSurroundColorsWithCount($hPathBrush, $aColor)
    _GDIPlus_GraphicsFillPath($hGfxHeat, $hPath, $hPathBrush)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hPathBrush)

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

    Local $BitmapData = _GDIPlus_BitmapLockBits($hBmpHeat, $iX, $iY, $iRad * 2, $iRad * 2, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB)
    Local $Stride = DllStructGetData($BitmapData, "Stride")
    Local $Width = DllStructGetData($BitmapData, "Width")
    Local $Height = DllStructGetData($BitmapData, "Height")
    Local $Scan0 = DllStructGetData($BitmapData, "Scan0")
    Local $PixelData, $Color, $Alpha, $R, $G, $B, $Tmp

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

    For $row = 0 To $Height - 1
    $PixelData = DllStructCreate("dword[" & $Width & ']', $Scan0 + ($row * $Stride))
    For $col = 1 To $Width
    $Color = DllStructGetData($PixelData, 1, $col)

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

    $Alpha = BitAND(BitShift($Color, 24), 0xFF)
    $R = BitAND(BitShift($Color, 16), 0xFF)
    $G = BitAND(BitShift($Color, 8), 0xFF)
    $B = BitAND($Color, 0xFF)
    Switch $Alpha
    Case 235 To 255
    $Tmp = 255 - $Alpha
    $R = 255 - $Tmp
    $G = $Tmp * 12
    Case 200 To 234
    $Tmp = 234 - $Alpha
    $R = 255 - ($Tmp * 8)
    $G = 255
    Case 150 To 199
    $Tmp = 199 - $Alpha
    $G = 255
    $B = $Tmp * 5
    Case 100 To 149
    $Tmp = 149 - $Alpha
    $G = 255 - ($Tmp * 5)
    $B = 255
    Case Else
    $B = 255
    EndSwitch
    If $R < 0 Then $R = 0
    If $R > 0xFF Then $R = 0xFF
    If $G < 0 Then $G = 0
    If $G > 0xFF Then $G = 0xFF
    If $B < 0 Then $B = 0
    If $B > 0xFF Then $B = 0xFF
    DllStructSetData($PixelData, 1, BitOR(BitShift($Alpha, -24), BitShift($R, -16), BitShift($G, -8), $B), $col)
    Next
    Next
    _GDIPlus_BitmapUnlockBits($hBmpHeat, $BitmapData)

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

    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
    _GDIPlus_GraphicsDrawImageRectRect($hGfxBuffer, $hBmpHeat, $iRad, $iRad, $iWidth * $fSize, $iHeight * $fSize, 0, 0, $iWidth, $iHeight)

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

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    EndFunc ;==>_DrawHeat

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

    Func _MouseGetPos($hWnd = 0)
    Local $tPoint = DllStructCreate("long X;long Y")
    Local $aResult = DllCall("user32.dll", "bool", "GetCursorPos", "ptr", DllStructGetPtr($tPoint))
    If @error Then Return SetError(@error, @extended, 0)
    If $hWnd Then _WinAPI_ScreenToClient($hWnd, $tPoint)
    Local $aReturn[2]
    $aReturn[0] = DllStructGetData($tPoint, 1)
    $aReturn[1] = DllStructGetData($tPoint, 2)
    Return $aReturn
    EndFunc ;==>_MouseGetPos

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

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

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

    Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return True
    EndFunc ;==>WM_ERASEBKGND

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

    Func _Exit()
    _GDIPlus_GraphicsDispose($hGfxHeat)
    _GDIPlus_BitmapDispose($hBmpHeat)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    viel Vergnügen...

    E

  • BassFx Parameter

    • eukalyptus
    • 31. Oktober 2010 um 12:53

    sind beim bass.au3-Paket aus dem englischen Forum dabei http://www.signa5.com/autoit/BASS/BASS.zip
    oder bei den original downloads von https://autoit.de/www.un4seen.com...

  • BassFx Parameter

    • eukalyptus
    • 31. Oktober 2010 um 04:14

    Hi

    Bei dem Beispiel funktioniert bei mir nur der letzte Effekt - es dürfte sich noch um ein Beispiel der vorletzten Bass Version handeln
    Hab das mal kurz aktualisiert: Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.

    Der 3 Effekt ist ein DirectX Effekt (erkennbar an der Konstante $BASS_FX_DX8_REVERB)
    Die Parameter dazu findest du in der Bass.chm unter BASS_ChannelSetFX

    Die ersten beiden sind Effekte aus der bass_fx.dll ($BASS_FX_BFX_CHORUS)
    Parameter hierzu stehen in bass_fx.chm

    mfgE

    Dateien

    Example.zip 250,46 kB – 240 Downloads
  • Profifrage(?):Aus einem 8 Byte hex string den uint64 ermitteln.

    • eukalyptus
    • 30. Oktober 2010 um 15:38
    [autoit]

    #include "BigNum.au3"

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

    $sHex = "0xCD4C18F701001001"
    ConsoleWrite(_Hex2Dec($sHex) & @CRLF)

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

    Func _Hex2Dec($sHex)
    If StringLeft($sHex, 2) = "0x" Then $sHex = StringTrimLeft($sHex, 2)
    Local $sRes = "0", $sTmp, $iCnt = -1
    Local $iLen = StringLen($sHex)
    For $i = 1 To $iLen Step 6
    $iCnt += 1
    $sTmp = StringRight($sHex, 6)
    $sHex = StringTrimRight($sHex, 6)
    $sTmp = _BigNum_Mul(Dec($sTmp), _BigNum_Pow(16777216, $iCnt))
    $sRes = _BigNum_Add($sRes, $sTmp)
    Next
    Return $sRes
    EndFunc ;==>_Hex2Dec

    [/autoit]
  • DllCall und Array of Struct übergeben - ist das möglich?

    • eukalyptus
    • 29. Oktober 2010 um 11:44

    Nach int fehlt noch ein ;

    [autoit]

    $_Struct = "byte[2];ushort;int;"
    for $i=1 to 199
    $_Struct &= "byte[2];ushort;int;"
    next

    [/autoit]


    Kommt darauf an, wie die Dll aussieht - evtl. auch so:

    [autoit]

    "byte[400];ushort[200];int[200];"

    [/autoit]
  • MouseGetPos - relativ + Berücksichtigung Caption

    • eukalyptus
    • 21. Oktober 2010 um 18:53

    Wenn man die Mausposition relativ zur Clientarea eines Fensters benötigt, dann ist diese Funktion ganz hilfreich (funktioniert unabhängig von MouseCoordMode)
    Gibt man kein Fensterhandle an, dann werden absolute Bildschirmkooordinaten zurückgegeben

    Spoiler anzeigen
    [autoit]

    #include <WinAPI.au3>

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

    $hGui = GUICreate("Test", 400, 300)
    GUISetState()

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

    While GUIGetMsg() <> -3
    ;$aPos = _MouseGetPos()
    $aPos = _MouseGetPos($hGui)
    ;$aPos = _MouseGetPos(WinGetHandle("Rechner"))
    ToolTip($aPos[0] & " " & $aPos[1])
    Sleep(10)
    WEnd

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

    Func _MouseGetPos($hWnd = 0)
    Local $tPoint = DllStructCreate("long X;long Y")
    Local $aResult = DllCall("user32.dll", "bool", "GetCursorPos", "ptr", DllStructGetPtr($tPoint))
    If @error Then Return SetError(@error, @extended, 0)
    If $hWnd Then _WinAPI_ScreenToClient($hWnd, $tPoint)
    Local $aReturn[2]
    $aReturn[0] = DllStructGetData($tPoint, 1)
    $aReturn[1] = DllStructGetData($tPoint, 2)
    Return $aReturn
    EndFunc ;==>_MouseGetPos

    [/autoit]
  • Bild als drehende Spirale

    • eukalyptus
    • 17. Oktober 2010 um 21:17
    Zitat von moritz1243

    Cool,

    ist das Absicht: Zeile 43 $iHeight *= $fScaleX ? oder müsste es 43 $iHeight *= $fScaleY

    Ja, das ist Absicht!
    Breite und Höhe des Bildes müssen mit dem selben Faktor multipliziert werden, damit das Seitenverhältnis erhalten bleibt

  • Bild als drehende Spirale

    • eukalyptus
    • 16. Oktober 2010 um 12:43

    Eine kleine Spielerei

    Spoiler anzeigen
    [autoit]

    #include <GDIP.au3>
    #include <GDIPlus.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

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

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

    $sFile = FileOpenDialog("Öffnen", "", "(*.jpg;*.bmp;*.png;*.tif)")
    If @error Or Not $sFile Or Not FileExists($sFile) Then Exit

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

    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    If @error Or Not $hImage Then Exit

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

    $iWidth = _GDIPlus_ImageGetWidth($hImage)
    $iHeight = _GDIPlus_ImageGetHeight($hImage)

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

    _ResizeImage($hImage, $iWidth, $iHeight, @DesktopWidth * 0.7, @DesktopHeight * 0.7)

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

    $hGui = GUICreate("Test", $iWidth, $iHeight, Default, Default, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED, $WS_EX_TRANSPARENT))
    GUISetState()

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

    $hPath = _CreateSpiralPath($iWidth, $iHeight, 2, 1.06, 0.05)
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, $iWidth / 2, $iHeight / 2)
    _GDIPlus_MatrixRotate($hMatrix, -12)
    _GDIPlus_MatrixTranslate($hMatrix, -$iWidth / 2, -$iHeight / 2)

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

    While 1
    _DrawImage($hGui, $hImage, $hPath, $hMatrix, $iWidth, $iHeight)
    Sleep(10)
    WEnd

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

    Func _ResizeImage(ByRef $hImage, ByRef $iWidth, ByRef $iHeight, $iNewWidth, $iNewHeight)
    Local $fScaleX = $iNewWidth / $iWidth
    Local $fScaleY = $iNewHeight / $iHeight
    If $fScaleY < $fScaleX Then $fScaleX = $fScaleY

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

    $iWidth *= $fScaleX
    $iHeight *= $fScaleX
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, 0, 0, $iWidth, $iHeight)
    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hImage)
    $hImage = $hBitmap
    EndFunc ;==>_ResizeImage

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

    Func _DrawImage($hWnd, $hImage, $hPath, $hMatrix, $iW, $iH)
    Local $tSize = DllStructCreate("long X;long Y")
    DllStructSetData($tSize, "X", $iW)
    DllStructSetData($tSize, "Y", $iH)
    Local $tSource = DllStructCreate("long X;long Y")
    Local $tBlendI = DllStructCreate("byte Op;byte Flags;byte Alpha;byte Format")
    DllStructSetData($tBlendI, "Alpha", 0xFF)
    DllStructSetData($tBlendI, "Format", 1)

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

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

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

    _GDIPlus_PathTransform($hPath, $hMatrix)
    Local $hRegion = _GDIPlus_RegionCreateFromPath($hPath)
    _GDIPlus_GraphicsSetClipRegion($hContext, $hRegion)
    _GDIPlus_RegionDispose($hRegion)

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

    _GDIPlus_GraphicsDrawImage($hContext, $hImage, 0, 0)

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

    Local $hPen = _GDIPlus_PenCreate(0xFF000000, 3)
    _GDIPlus_GraphicsDrawPath($hContext, $hPath, $hPen)
    _GDIPlus_PenDispose($hPen)

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

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_GraphicsDispose($hGraphics)

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

    Local $hDCD = _WinAPI_GetDC($hWnd)
    Local $hDCS = _WinAPI_CreateCompatibleDC($hDCD)
    Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Local $hOrig = _WinAPI_SelectObject($hDCS, $hBmp)

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

    _WinAPI_UpdateLayeredWindow($hWnd, $hDCD, 0, DllStructGetPtr($tSize), $hDCS, DllStructGetPtr($tSource), 0, DllStructGetPtr($tBlendI), 2)

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

    _WinAPI_SelectObject($hDCS, $hOrig)
    _WinAPI_DeleteObject($hBmp)
    _WinAPI_DeleteDC($hDCS)
    _WinAPI_ReleaseDC($hWnd, $hDCD)
    EndFunc ;==>_DrawImage

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

    Func _CreateSpiralPath($iW, $iH, $fSqr = 2, $fMul = 1.1, $fStep = 0.03)
    Local $hPath = _GDIPlus_PathCreate(0)
    Local $iCnt = 0, $iW2 = $iW / 2, $iH2 = $iH / 2
    Local $iX, $iY, $iXOld = $iW2, $iYOld = $iH2
    Do
    $iX = Cos($iCnt) * $iCnt ^ $fSqr + $iW2
    $iY = Sin($iCnt) * $iCnt ^ $fSqr + $iH2
    _GDIPlus_PathAddLine($hPath, $iXOld, $iYOld, $iX, $iY)
    $iXOld = $iX
    $iYOld = $iY
    $iCnt += $fStep
    Until ($iX < 0 Or $iX > $iW) And ($iY < 0 Or $iY > $iH)
    _GDIPlus_PathReverse($hPath)
    $iXOld = $iW2
    $iYOld = $iH2
    $fSqr *= $fMul
    For $i = 0 To $iCnt Step $fStep
    $iX = Cos($i) * $i ^ $fSqr + $iW2
    $iY = Sin($i) * $i ^ $fSqr + $iH2
    _GDIPlus_PathAddLine($hPath, $iXOld, $iYOld, $iX, $iY)
    $iXOld = $iX
    $iYOld = $iY
    Next
    _GDIPlus_PathCloseFigures($hPath)
    _GDIPlus_PathFlatten($hPath)
    Return $hPath
    EndFunc ;==>_CreateSpiralPath

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

    Func _EXIT()
    _GDIPlus_BitmapDispose($hImage)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_EXIT

    [/autoit]

    benötigt GDIp.au3

    E

  • Bilder auf Bildschirm zeichnen

    • eukalyptus
    • 15. Oktober 2010 um 21:07

    Hi

    Kommt darauf an, was du genau machen willst.
    Recht einfach finde ich diese Version:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

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

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

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

    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile("rgbhsv.jpg")
    $iWidth = _GDIPlus_ImageGetWidth($hImage)
    $iHeight = _GDIPlus_ImageGetHeight($hImage)

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

    $hGui = GUICreate("Test", $iWidth, $iHeight, Default, Default, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED, $WS_EX_TRANSPARENT))
    GUISetState()

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

    _DrawImage($hGui, $hImage, $iWidth, $iHeight)

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

    While 1
    Sleep(100)
    WEnd

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

    Func _DrawImage($hWnd, $hBitmap, $iW, $iH)
    Local $tSize = DllStructCreate("long X;long Y")
    DllStructSetData($tSize, "X", $iW)
    DllStructSetData($tSize, "Y", $iH)
    Local $tSource = DllStructCreate("long X;long Y")
    Local $tBlendI = DllStructCreate("byte Op;byte Flags;byte Alpha;byte Format")
    DllStructSetData($tBlendI, "Alpha", 0xFF)
    DllStructSetData($tBlendI, "Format", 1)

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

    Local $hDCD = _WinAPI_GetDC($hWnd)
    Local $hDCS = _WinAPI_CreateCompatibleDC($hDCD)
    Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    Local $hOrig = _WinAPI_SelectObject($hDCS, $hBmp)

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

    _WinAPI_UpdateLayeredWindow($hWnd, $hDCD, 0, DllStructGetPtr($tSize), $hDCS, DllStructGetPtr($tSource), 0, DllStructGetPtr($tBlendI), 2)

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

    _WinAPI_SelectObject($hDCS, $hOrig)
    _WinAPI_DeleteObject($hBmp)
    _WinAPI_DeleteDC($hDCS)
    _WinAPI_ReleaseDC($hWnd, $hDCD)
    EndFunc ;==>_DrawImage

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

    Func _EXIT()
    _GDIPlus_BitmapDispose($hImage)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_EXIT

    [/autoit]

    mfgE

  • [Auswertung läuft...] µitLight September/Oktober

    • eukalyptus
    • 14. Oktober 2010 um 17:55

    Mein Beitrag ist vorerst mal fertig und ich hab mal abgegeben.

    Das ist eigentlich ein Projekt, das ich vor fast 1,5 Jahren mal begonnen hab, jedoch nie wirklich fertig wurde.
    Deshalb war dieser µIt der perfekte Grund es nun endlich doch noch zu vollenden!

    Ich verwende einige Funktionen aus der GDIp.au3, jedoch direkt via DllCall -> GDIp.au3 wird nicht benötigt.
    Des weiteren benutze ich auch noch ein paar Funktionen aus user32.dll und shell32.dll, die es noch nicht in den Standard Includes gibt.
    konkret sind dies die Funktionen: SetWinEventHook, UnhookWinEvent, TrackMouseEvent und SHExtractIconsW
    (user32.dll und shell32.dll werden standardmässig von AutoIt verwendet, deshalb hoffe ich, daß das eine oder andere Auge zugedrückt werden kann ^^ )


    Allen anderen Teilnehmern noch viel Spaß und Glück beim Weiterbasteln :thumbup:
    E

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™