Buchempfehlung
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
Windows-Programmierung. Das Entwicklerhandbuch zur WIN32-API
"Der" Petzold, das über 1000 Seiten starke Standardwerk zum Win32-API - besonders nützlich u. a. bei der GUI-Programmierung in FreeBASIC! [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

pintercom.bas

Uploader:MitgliedThePuppetMaster
Datum/Zeit:21.08.2017 20:31:43

'(c) By.: Martin Wiemann (freebasic@deltalabs.de)

#include "bass.bi"
#include "bassmix.bi"


Dim TDevName as String = "C-Media USB Audio Device: USB Audio"
Dim TDeviceT as BASS_DEVICEINFO
Dim X as Integer

Type DevInTyp
    V_DevID         as Integer
    V_Chan          as HRECORD
    V_Spliter       as HSTREAM
    V_Split(1 to 8) as HSTREAM
End Type
Dim TDevInD(1 to 8) as DevInTyp
Dim TDevInC as Integer


Type DevOutTyp
    V_DevID         as Integer
    V_Chan          as HRECORD
    V_Mixer         as HSTREAM
End Type
Dim TDevOutD(1 to 8) as DevOutTyp
Dim TDevOutC as Integer

Dim TFreq as Integer = 44100
Dim TChans as Integer = 2

Print "SEARCH Outputs..."
X = 0
Do
    X += 1
    If BASS_GetDeviceInfo(X, @TDeviceT) <> 1 Then Exit Do
    Print "Checking:" & X & " (" & *TDeviceT.name & ")"
    If *TDeviceT.name = TDevName Then
        Print "FOUND!"
        TDevOutC += 1
        With TDevOutD(TDevOutC)
            .V_DevID = X
            If BASS_Init(X, 44100, 0, 0, 0) <> 1 Then Print "Can't BASS_Init:" & TDevOutC: Print "ERR:" & BASS_ErrorGetCode(): End -1
            If BASS_SetDevice(.V_DevID) <> 1 Then Print "Can't BASS_SetDevice:" & TDevOutC: Print "ERR:" & BASS_ErrorGetCode(): End -1
            If BASS_SetVolume(1) <> 1 Then Print "Can't BASS_SetVolume:" & TDevOutC: Print "ERR:" & BASS_ErrorGetCode(): End -1
            .V_Mixer = BASS_Mixer_StreamCreate(TFreq, TChans, BASS_STREAM_DECODE or BASS_MIXER_END)
            BASS_ChannelSetDevice(.V_Mixer, .V_DevID)
        End With
        If TDevOutC >= 8 Then Exit Do
    End If
Loop

Print "SEARCH Inputs..."
X = -1
Do
    X += 1
    If BASS_RecordGetDeviceInfo(X, @TDeviceT) <> 1 Then Exit Do
    Print "Checking:" & X & " (" & *TDeviceT.name & ")"
    If *TDeviceT.name = TDevName Then
        Print "FOUND!"
        TDevInC += 1
        With TDevInD(TDevInC)
            .V_DevID = X
            If BASS_RecordInit(X) <> 1 Then Print "Can't BASS_RecordInit:" & TDevInC: Print "ERR:" & BASS_ErrorGetCode(): End -1
            .V_Chan = BASS_RecordStart(TFreq, TChans, 0, 0, 0)
            If .V_Chan = 0 Then Print "Can't BASS_RecordStart:" & TDevInC: Print "ERR:" & BASS_ErrorGetCode(): End -1
            For Y as Integer = 1 to TDevOutC
                'If TDevInD(TDevInC).V_DevID <> TDevOutD(Y).V_DevID Then
                    .V_Split(Y) = BASS_Split_StreamCreate(.V_Chan, BASS_STREAM_DECODE, 0)
                    If .V_Split(Y) = 0 Then Print "Can't BASS_Split_StreamCreate:" & TDevInC & "-" & Y: Print "ERR:" & BASS_ErrorGetCode(): End -1
                    Print .V_Split(Y)
                'End If
            Next
        End With
        If TDevInC >= 8 Then Exit Do
    End If
Loop

Print "DEV-Out:" & TDevOutC
Print "DEV-In:" & TDevInC

'Print "Linking Inputs to Outputs..."
'For X = 1 to TDevOutC
'   For Y as Integer = 1 to TDevInC
'       'If TDevOutD(X).V_DevID <> TDevInD(Y).V_DevID Then
'           If BASS_Mixer_StreamAddChannel(TDevOutD(X).V_Mixer, TDevInD(Y).V_Split(X), 0) <> 1 Then Print "Can't BASS_Mixer_StreamAddChannel:" & X & "-" & Y: Print "ERR:" & BASS_ErrorGetCode(): End -1
'       'End If
'   Next
'Next

'Print "PIntercom ready!"

'Do Until InKey() = chr(27)
'   Sleep 10, 1
'Loop



Print "Stopping PIntercom..."

For X = 1 to TDevInC
    BASS_StreamFree(TDevInD(X).V_Chan)
    BASS_RecordSetDevice(TDevInD(X).V_DevID)
    BASS_RecordFree()
Next
For X = 1 to TDevOutC
    BASS_SetDevice(TDevOutD(X).V_DevID)
    BASS_Free()
Next

End