MP3-Datei mit BASS auf 5.1 Soundsystem abspielen

    • Offizieller Beitrag

    Ich bin schon seit Stunden damit beschäftigt, zu versuchen eine MP3-Datei auf einem 5.1 Soundsystem auszugeben.
    Irgendwas übersehe ich wahrscheinlich dabei. Hier mal mein Testscript:

    Spoiler anzeigen
    [autoit]


    #AutoIt3Wrapper_UseX64=n
    ;~ #include <Array.au3>
    #include 'Bass.au3'

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

    OnAutoItExitRegister('_Exit')
    HotKeySet('{ESC}', '_Exit')

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

    ; BASS starten
    _BASS_Startup(@ScriptDir & '\bass.dll')

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

    ; Deviceliste anzeigen
    Global $iIndex = 0, $sDevices = '', $aInfo = '', $error = 0
    Do
    $iIndex += 1
    $aInfo = _BASS_GetDeviceInfo($iIndex)
    If IsArray($aInfo) Then $sDevices &= '[' & $iIndex & '] ' & $aInfo[0] & @CRLF
    Until $aInfo = 0
    MsgBox(0, 'Devicelist', $sDevices)

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

    ; Device auswählen
    $idDevice = Int(InputBox('Choose Device', 'Enter Device Id', '1'))
    If $idDevice >= $iIndex Or @error Then Exit MsgBox(16, 'Wrong Device', 'Device does not exist!')

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

    ; Device initialisieren
    If Not _BASS_Init(0, $idDevice, 44100, '', 0) Then Exit MsgBox(16, 'Device error', 'Device could not be initialized.')
    ;~ $aInfo = _BASS_GetInfo()
    ;~ _ArrayDisplay($aInfo)
    ;~ _Exit()

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

    ; Audiodatei laden
    $sMP3File = FileOpenDialog('Bitte MP3-Datei auswählen', '', 'MP3s (*.mp3)')
    If Not FileExists($sMP3File) Then Exit MsgBox(16, 'Datei nicht gefunden!', $sMP3File)

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

    ; Stream erstellen
    $hStream = _BASS_StreamCreateFile(0, $sMP3File, 0, 0, $BASS_STREAM_AUTOFREE + $BASS_SPEAKER_REAR) ; $BASS_SPEAKER_FRONT oder $BASS_SPEAKER_REAR

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

    ; Stream abspielen
    _BASS_ChannelPlay($hStream, 1)

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

    $iSongLenght = _BASS_ChannelGetLength($hStream, $BASS_POS_BYTE)
    $iSongSeconds = Int(_BASS_ChannelBytes2Seconds($hStream, $iSongLenght))
    Do
    $iPos = _BASS_ChannelGetPosition($hStream, $BASS_POS_BYTE)
    $iSeconds = Int(_BASS_ChannelBytes2Seconds($hStream, $iPos))
    ToolTip($iSeconds & ' / ' & $iSongSeconds)
    Sleep(500)
    Until $iSeconds >= $iSongSeconds
    _Exit()

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

    Func _Exit()
    ; Bass freigeben
    _BASS_Free()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    Die Infos von _BASS_GetInfo() sehen so aus:

    Spoiler anzeigen


    [12] = 6 es werden also 6 Lautsprecher erkannt. :huh:

    Ich habs auch schon versucht mit:

    [autoit]

    _BASS_SetConfig($BASS_CONFIG_3DALGORITHM, $BASS_3DALG_DEFAULT)

    [/autoit]


    aber das alles hilft nichts. Die MP3-Datei wird immer nur über die Front- oder die Rear-Lautsprecher ausgegeben.
    Ich möchte aber gern eine Ausgabe auf allen Lautsprechern. Jemand eine Idee?

    • Offizieller Beitrag

    Ich habs selbst gelöst! :D
    Man erstelle einfach 3 Streams und spiele alle ab. :rolleyes:
    Hier das Lösungsscript:

    Spoiler anzeigen
    [autoit]


    #AutoIt3Wrapper_UseX64=n
    ;~ #include <Array.au3>
    #include 'Bass.au3'

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

    OnAutoItExitRegister('_Exit')
    HotKeySet('{ESC}', '_Exit')

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

    ; BASS starten
    _BASS_Startup(@ScriptDir & '\bass.dll')

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

    ; Deviceliste anzeigen
    Global $iIndex = 0, $sDevices = '', $aInfo = '', $error = 0
    Do
    $iIndex += 1
    $aInfo = _BASS_GetDeviceInfo($iIndex)
    If IsArray($aInfo) Then $sDevices &= '[' & $iIndex & '] ' & $aInfo[0] & @CRLF
    Until $aInfo = 0
    MsgBox(0, 'Devicelist', $sDevices)

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

    ; Device auswählen
    $idDevice = Int(InputBox('Choose Device', 'Enter Device Id', '1'))
    If $idDevice >= $iIndex Or @error Then Exit MsgBox(16, 'Wrong Device', 'Device does not exist!')

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

    ; Device initialisieren
    If Not _BASS_Init(0, $idDevice, 44100, '', 0) Then Exit MsgBox(16, 'Device error', 'Device could not be initialized.')
    ;~ $aInfo = _BASS_GetInfo()
    ;~ _ArrayDisplay($aInfo)
    ;~ _Exit()

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

    ; Audiodatei laden
    $sMP3File = FileOpenDialog('Bitte MP3-Datei auswählen', '', 'MP3s (*.mp3)')
    If Not FileExists($sMP3File) Then Exit MsgBox(16, 'Datei nicht gefunden!', $sMP3File)

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

    ; Stream erstellen
    $hStream1 = _BASS_StreamCreateFile(0, $sMP3File, 0, 0, $BASS_STREAM_AUTOFREE + $BASS_SPEAKER_FRONT)
    $hStream2 = _BASS_StreamCreateFile(0, $sMP3File, 0, 0, $BASS_STREAM_AUTOFREE + $BASS_SPEAKER_REAR)
    $hStream3 = _BASS_StreamCreateFile(0, $sMP3File, 0, 0, $BASS_STREAM_AUTOFREE + $BASS_SPEAKER_CENLFE)

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

    ; Stream abspielen
    _BASS_ChannelPlay($hStream1, 1)
    _BASS_ChannelPlay($hStream2, 1)
    _BASS_ChannelPlay($hStream3, 1)

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

    $iSongLenght = _BASS_ChannelGetLength($hStream1, $BASS_POS_BYTE)
    $iSongSeconds = Int(_BASS_ChannelBytes2Seconds($hStream1, $iSongLenght))
    Do
    $iPos = _BASS_ChannelGetPosition($hStream1, $BASS_POS_BYTE)
    $iSeconds = Int(_BASS_ChannelBytes2Seconds($hStream1, $iPos))
    ToolTip($iSeconds & ' / ' & $iSongSeconds)
    Sleep(500)
    Until $iSeconds >= $iSongSeconds
    _Exit()

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

    Func _Exit()
    ; Bass freigeben
    _BASS_Free()
    Exit
    EndFunc ;==>_Exit

    [/autoit]
  • Hi

    Mit Split_Streams sollte das viel eleganter gehen.
    Dann kannst du auch bestimmen, auf welchen Speakern der linke bzw. rechte Kanal rauskommt.

    Zumindest solltest du die einzelnen Streams syncen, das sollte mit _BASS_ChannelSetLink gehn.

    Mitte nächster Woche bin ich wieder zuhaus und kann dann mal einen MP3-Upmixer ausprobieren ;)

    • Offizieller Beitrag

    Zu Split_Streams konnte ich nichts finden. Das mit dem syncen ist aber klasse! :thumbup:

    Ist das so ok?

    Spoiler anzeigen
    [autoit]


    #AutoIt3Wrapper_UseX64=n
    ;~ #include <Array.au3>
    #include 'Bass.au3'

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

    OnAutoItExitRegister('_Exit')
    HotKeySet('{ESC}', '_Exit')

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

    ; BASS starten
    _BASS_Startup(@ScriptDir & '\bass.dll')

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

    ; Deviceliste anzeigen
    Global $iIndex = 0, $sDevices = '', $aInfo = '', $error = 0
    Do
    $iIndex += 1
    $aInfo = _BASS_GetDeviceInfo($iIndex)
    If IsArray($aInfo) Then $sDevices &= '[' & $iIndex & '] ' & $aInfo[0] & @CRLF
    Until $aInfo = 0
    MsgBox(0, 'Devicelist', $sDevices)

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

    ; Device auswählen
    $idDevice = Int(InputBox('Choose Device', 'Enter Device Id', '1'))
    If $idDevice >= $iIndex Or @error Then Exit MsgBox(16, 'Wrong Device', 'Device does not exist!')

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

    ; Device initialisieren
    If Not _BASS_Init(0, $idDevice, 44100, '', 0) Then Exit MsgBox(16, 'Device error', 'Device could not be initialized.')
    ;~ $aInfo = _BASS_GetInfo()
    ;~ _ArrayDisplay($aInfo)
    ;~ _Exit()

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

    ; Audiodatei laden
    $sMP3File = FileOpenDialog('Bitte MP3-Datei auswählen', '', 'MP3s (*.mp3)')
    If Not FileExists($sMP3File) Then Exit MsgBox(16, 'Datei nicht gefunden!', $sMP3File)

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

    ; Stream erstellen
    $hStream1 = _BASS_StreamCreateFile(0, $sMP3File, 0, 0, $BASS_STREAM_AUTOFREE + $BASS_SPEAKER_FRONT)
    $hStream2 = _BASS_StreamCreateFile(0, $sMP3File, 0, 0, $BASS_STREAM_AUTOFREE + $BASS_SPEAKER_REAR)
    $hStream3 = _BASS_StreamCreateFile(0, $sMP3File, 0, 0, $BASS_STREAM_AUTOFREE + $BASS_SPEAKER_CENLFE)
    _BASS_ChannelSetLink($hStream1, $hStream2)
    _BASS_ChannelSetLink($hStream1, $hStream3)

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

    ; Stream abspielen
    _BASS_ChannelPlay($hStream1, 1)

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

    $iSongLenght = _BASS_ChannelGetLength($hStream1, $BASS_POS_BYTE)
    $iSongSeconds = Int(_BASS_ChannelBytes2Seconds($hStream1, $iSongLenght))
    Do
    $iPos = _BASS_ChannelGetPosition($hStream1, $BASS_POS_BYTE)
    $iSeconds = Int(_BASS_ChannelBytes2Seconds($hStream1, $iPos))
    ToolTip($iSeconds & ' / ' & $iSongSeconds)
    Sleep(500)
    Until $iSeconds >= $iSongSeconds
    _Exit()

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

    Func _Exit()
    _BASS_ChannelRemoveLink($hStream1, $hStream3)
    _BASS_ChannelRemoveLink($hStream1, $hStream2)
    ; Bass freigeben
    _BASS_Free()
    Exit
    EndFunc ;==>_Exit

    [/autoit]