mit winmm.dll mp3 aufnehmen

  • Hallo Leutz, habe folgendes vor:
    ich möchte mit der winmm.dll von meinem Micro aufnehmen und das ganze gleich onthefly in mp3wandeln.

    Unter Linux hab ich sowas schon mal mit arecord realisiert, doch mit windows stell ich mich a bissal an.
    gibt es da eine möglichkeit?
    Oder hab ich da ganz falsch angesetzt?

    Meine Vorstellung (Vision):

    Code
    DllCall("winmm.dll.... |  lame.exe -b 192 -h  ... ausgabedatei.mp3
  • so, nach langem Codewälzen des übrigens hammermäßigen Eukalyptus-Recorders habe ich jetzt einen riesigen Knoten im Hirn.

    Momentan habe ich mir jetzt folgendermaßen beholfen:

    Spoiler anzeigen
    [autoit]

    $wav = "aufnahme.wav"
    $mp3 = "fertig.mp3"
    [attach='9635'][/attach]
    $Abtast = "16"
    $Samp = "48000"
    $Kanal = "2"
    $Bytes = $Abtast / 8 * $Kanal * $Samp
    $Alignment = $Kanal * $Abtast / 8

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

    mciSendString("open new type waveaudio alias aufnahme")
    mciSendString("set aufnahme time format ms bitspersample " & $Abtast & " channels " & $Kanal & " samplespersec " & $Samp & " BYTESPERSEC " & $Bytes & " ALIGNMENT " & $Alignment)
    mciSendString("record aufnahme")
    MsgBox(0,"Aufnahme","Aufnahme läuft! Abbrechen?")
    mciSendString("save aufnahme " & $wav)
    mciSendString("close aufnahme")
    RunWait('lame.exe -b 192 -h "' & $wav & '" "' & $mp3 & '"', @ScriptDir, @SW_HIDE)
    FileDelete(@scriptdir & "\" & $wav)

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

    Exit

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

    Func mciSendString($string)
    DllCall("winmm.dll", "int", "mciSendStringA", "str", $string, "str", "", "int", 65534, "hwnd", 0)
    EndFunc

    [/autoit]

    Dieses Konstrukt funzt, doch was ich immer noch nicht weiß: wie kann ich direkt wandeln? wie kriege ich die Daten von der Winmm.dll in den Lame rein?
    autoit.de/wcf/attachment/9635/

  • Nochmal meld! damit ich nicht in Vergessenheit gerate.

    Hier nochmal meine Frage:

    Mit welcher Funktion/Vorgehensweise kann ich von der DLL direkt in LAME streamen?
    Ich steig nicht dahinter.
    Hat da jemand einen Tipp für mich?

  • wie schon gesagt, dafür brauchst du die bass.dll. Mit winmm geht das nicht.

  • ok, dann werd ich mich doch mit der bass.dll befasen müssen.
    Danke für die klare Aussage.

  • Lade dir aus dem englischen Forum die aktuellste Version der Bass.au3 runter:
    http://www.autoitscript.com/forum/index.php?showtopic=83481&view=findpost&p=597106
    (Auch die Patches nicht vergessen)

    Im Unterverzeichnis Bass_enc findest du ein Aufnahme-Beispiel.
    BrettF hat leider noch nicht die ganz neue Version veröffentlicht, deshalb hier das gebugfixte Beispiel:

    Spoiler anzeigen
    [autoit]

    #include "..\..\Bass\Bass.au3"
    #include "..\BassEnc.au3"
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GuiComboBox.au3>

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

    Opt("GUIOnEventMode", 1)

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

    Global $device, $input, $EncHandle, $RecHandle, $Bitrate = 128, $KHZ = 44100, $levels, $levelL = 0, $levelR = 0, $temp, $EncState = False

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

    _BASS_STARTUP("..\..\Bass\Bass.dll")
    _BASS_Encode_STARTUP("..\BassEnc.dll")
    $basscb_dll = DllOpen("..\BASSCB.dll")

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

    $hGui = GUICreate("Bass.dll / BassEnc.dll Recording Test", 320, 320)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUICtrlCreateLabel("Select AudioDevice:", 10, 10)
    $hDevice = GUICtrlCreateCombo("", 10, 30, 300, 20, BitOR($CBS_DROPDOWN, $CBS_DROPDOWNLIST, $WS_VSCROLL))
    GUICtrlSetOnEvent(-1, "_SelectDevice")
    GUICtrlCreateLabel("Select AudioInput:", 10, 60)
    $hInput = GUICtrlCreateCombo("", 10, 80, 300, 20, BitOR($CBS_DROPDOWN, $CBS_DROPDOWNLIST, $WS_VSCROLL))
    GUICtrlSetOnEvent(-1, "_SelectInput")
    $hMp3 = GUICtrlCreateRadio("Mp3", 50, 110, 50)
    $hWav = GUICtrlCreateRadio("Wav", 50, 130, 50)
    GUICtrlSetState(-1, $GUI_CHECKED)
    $hBitrate = GUICtrlCreateCombo("", 120, 110, 50, 20, BitOR($CBS_DROPDOWN, $CBS_DROPDOWNLIST, $WS_VSCROLL))
    GUICtrlSetData(-1, "32|40|48|56|64|80|96|112|128|160|192|224|256|320", "128")
    GUICtrlCreateLabel("KBit/s", 180, 113, 50)
    $hPeakL = GUICtrlCreateProgress(10, 160, 300, 10)
    $hPeakR = GUICtrlCreateProgress(10, 175, 300, 10)
    GUICtrlCreateLabel("Encoder Active:", 10, 200)
    $hEncActive = GUICtrlCreateLabel("", 120, 200, 200)
    GUICtrlCreateLabel("Data sent to Encoder:", 10, 220)
    $hEncCount = GUICtrlCreateLabel("", 120, 220, 200)
    GUICtrlCreateLabel("Filesize:", 10, 240)
    $hFilesize = GUICtrlCreateLabel("", 120, 240, 200)
    $hStart = GUICtrlCreateButton("Start", 20, 280, 130, 20)
    GUICtrlSetOnEvent(-1, "_Start")
    $hStop = GUICtrlCreateButton("Stop", 170, 280, 130, 20)
    GUICtrlSetOnEvent(-1, "_Stop")
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState()

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

    ;_BASS_SetConfig($BASS_CONFIG_REC_BUFFER, 1000)
    $device = _GetDevices()
    $r = _BASS_RecordInit($device)
    $input = _GetInputs()
    $temp = DllCall($basscb_dll, "dword", "RecordStart", "dword", $KHZ, "dword", 2, "dword", _makelong($BASS_SAMPLE_FX, 10))
    $RecHandle = $temp[0]

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

    $timer = TimerInit()
    While 1
    Sleep(20)
    $peak = _BASS_ChannelGetLevel($RecHandle)
    If Not @error Then
    $temp = (_LoWord($peak) / 32768) * 100
    If $temp > $levelL Then $levelL = $temp
    $temp = (_HiWord($peak) / 32768) * 100
    If $temp > $levelR Then $levelR = $temp
    GUICtrlSetData($hPeakL, $levelL)
    GUICtrlSetData($hPeakR, $levelR)
    $levelL -= 4
    $levelR -= 4
    Else
    ToolTip(@error)
    EndIf
    If TimerDiff($timer) > 200 Then
    $timer = TimerInit()
    GUICtrlSetData($hEncActive, _BASS_Encode_IsActive($EncHandle))
    If $EncState Then
    GUICtrlSetData($hEncCount, _BASS_Encode_GetCount($EncHandle, $BASS_ENCODE_COUNT_IN))
    If GUICtrlRead($hWav) = $GUI_CHECKED Then
    GUICtrlSetData($hFilesize, Round(FileGetSize(@ScriptDir & "\Test.wav") / 1024, 2) & " kb")
    Else
    GUICtrlSetData($hFilesize, Round(FileGetSize(@ScriptDir & "\Test.mp3") / 1024, 2) & " kb")
    EndIf
    EndIf
    EndIf
    WEnd

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

    Func _Start()
    GUICtrlSetState($hDevice, $GUI_DISABLE)
    GUICtrlSetState($hInput, $GUI_DISABLE)
    GUICtrlSetState($hStart, $GUI_DISABLE)
    GUICtrlSetState($hMp3, $GUI_DISABLE)
    GUICtrlSetState($hWav, $GUI_DISABLE)
    GUICtrlSetState($hBitrate, $GUI_DISABLE)
    GUICtrlSetState($hStop, $GUI_ENABLE)
    If GUICtrlRead($hWav) = $GUI_CHECKED Then
    $EncHandle = _BASS_Encode_Start($RecHandle, @ScriptDir & "\Test.wav", $BASS_ENCODE_PCM)
    Else
    $EncHandle = _BASS_Encode_Start($RecHandle, 'lame -r -x -b' & GUICtrlRead($hBitrate) & ' -h - "' & @ScriptDir & '\Test.mp3"', 0)
    EndIf
    $EncState = True
    EndFunc ;==>_Start

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

    Func _Stop()
    GUICtrlSetState($hDevice, $GUI_ENABLE)
    GUICtrlSetState($hInput, $GUI_ENABLE)
    GUICtrlSetState($hStart, $GUI_ENABLE)
    GUICtrlSetState($hMp3, $GUI_ENABLE)
    GUICtrlSetState($hWav, $GUI_ENABLE)
    GUICtrlSetState($hBitrate, $GUI_ENABLE)
    GUICtrlSetState($hStop, $GUI_DISABLE)
    _BASS_Encode_Stop($EncHandle)
    $EncState = False
    EndFunc ;==>_Stop

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

    Func _SelectDevice()
    Local $new = _GUICtrlComboBox_GetCurSel($hDevice)
    If $new = $device Then Return
    _BASS_RecordFree()
    _BASS_RecordSetDevice($new)
    _BASS_Recordinit($new)
    GUICtrlSetData($hInput, "", "")
    _GetInputs()
    $temp = DllCall($basscb_dll, "dword", "RecordStart", "dword", $KHZ, "dword", 2, "dword", _makelong($BASS_SAMPLE_FX, 10))
    $RecHandle = $temp[0]
    $device = $new
    EndFunc ;==>_SelectDevice

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

    Func _SelectInput()
    Local $new = _GUICtrlComboBox_GetCurSel($hInput)
    If $new = $input Then Return
    _BASS_RecordSetInput($new, $BASS_INPUT_ON, -1)
    $input = $new
    EndFunc ;==>_SelectInput

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

    Func _GetDevices()
    Local $count = 0, $info, $name = "", $sdef = "", $idef = 0
    While 1
    $info = _BASS_RecordGetDeviceInfo($count)
    If @error Then ExitLoop
    $count += 1
    If BitAND($info[2], $BASS_DEVICE_ENABLED) Then $name &= $info[0] & "|"
    If BitAND($info[2], $BASS_DEVICE_DEFAULT) Then
    $sdef = $info[0]
    $idef = $count
    EndIf
    WEnd
    GUICtrlSetData($hDevice, $name, $sdef)
    Return $idef - 1
    EndFunc ;==>_GetDevices

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

    Func _GetInputs()
    Local $count = 0, $info, $name = "", $flags, $sdef = "", $idef = 0
    $info = _BASS_RecordGetInputName($count)
    While $info <> ""
    $flags = _BASS_RecordGetInput($count)
    If Not IsArray($flags) Then ExitLoop
    $count += 1
    $name &= $info & "|"
    If BitAND($flags[0], $BASS_INPUT_OFF) = 0 Then
    $sdef = $info
    $idef = $count
    EndIf
    $info = _BASS_RecordGetInputName($count)
    WEnd
    GUICtrlSetData($hInput, $name, $sdef)
    Return $idef - 1
    EndFunc ;==>_GetInputs

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

    Func _Exit()
    If _BASS_Encode_IsActive($EncHandle) Then _BASS_Encode_Stop($EncHandle)
    _BASS_RecordFree()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    mfgE

  • Vielen Dank für die großartige Hilfe.
    sobald ich wieder mehr Zeit hab, werd ich mich da mal reinknien