I had a litttle conversation with Chris off this thread, because the problem was not bass.dll-related. However, we might have worked it out, but I still cannot succeed, because there's another problem that I ran into:
When I do this:
EncoderHandle = BassEnc_Mp3.BASS_Encode_MP3_Start(mixer, Nothing, BASSEncode.BASS_ENCODE_LIMIT Or BASSEncode.BASS_ENCODE_AUTOFREE, Nothing, Nothing)
I get the error code 6: Unsupported sample format
Actually I already had this working out, but I must have changed something relevant when I added a third channel to the mixer: A microphone... It's a USB device and actually does not act as a microphone, but as an analog input device, because it has a built-in audio nterface that enables you to connect another analog device via line-in... However, the microphone is a mono device...
I think there might be something wrong with the order that the single commands are in. Here's my code (VB.NET):
Option Strict On
Imports Un4seen.Bass 'the imports
Imports Un4seen.Bass.AddOn.Enc
Imports Un4seen.Bass.AddOn.EncMp3
Imports Un4seen.Bass.AddOn.Mix
Imports Un4seen.Bass.Misc
Imports System.Environment
Imports System.Net
Public Class Form1 'main class
Private streamA As Integer 'declaring the variables
Private streamB As Integer
Private mixer As Integer
Private EncoderHandle As Integer
Private MikroRecordingProc As RECORDPROC
Private MikroInput As Integer
Private MikroOutput As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'this code is executed when the appplication is loaded
For i = 0 To Bass.BASS_RecordGetDeviceInfos.Count - 1 'this for...next-loop I guess is less relevant, but you never know...
Dim GeraeteInfo As BASS_DEVICEINFO
GeraeteInfo = Bass.BASS_RecordGetDeviceInfo(i)
If GeraeteInfo.type = BASSDeviceInfo.BASS_DEVICE_TYPE_MICROPHONE Then
Debug.WriteLine("Mikrofon: " & GeraeteInfo.name.ToString)
End If
If GeraeteInfo.type = BASSDeviceInfo.BASS_DEVICE_TYPE_LINE Then
Debug.WriteLine("Line-In: " & GeraeteInfo.name.ToString)
End If
If GeraeteInfo.type = BASSDeviceInfo.BASS_DEVICE_TYPE_HEADSET Then
Debug.WriteLine("Headset: " & GeraeteInfo.name.ToString)
End If
If GeraeteInfo.type = BASSDeviceInfo.BASS_DEVICE_TYPE_DIGITAL Then
Debug.WriteLine("Digitaler Eingang: " & GeraeteInfo.name.ToString)
End If
If GeraeteInfo.type = BASSDeviceInfo.BASS_DEVICE_TYPE_SPDIF Then
Debug.WriteLine("SPDIF: " & GeraeteInfo.name.ToString)
End If
Next
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle) 'initializing output device
mixer = Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamCreate(44100, 3, BASSFlag.BASS_DEFAULT) 'setting up the mixer channel
Bass.BASS_ChannelSetAttribute(mixer, BASSAttribute.BASS_ATTRIB_BUFFER, 0) ' disable playback buffering
Bass.BASS_RecordInit(-1) 'initializing input device
MikroRecordingProc = New RECORDPROC(AddressOf MikroRecordingCallback) 'handling the "microphone stuff"
MikroOutput = Bass.BASS_StreamCreate(44100, 1, BASSFlag.BASS_DEFAULT, BASSStreamProc.STREAMPROC_PUSH)
MikroInput = Bass.BASS_RecordStart(44100, 1, BASSFlag.BASS_STREAM_DECODE, MikroRecordingProc, IntPtr.Zero)
BassMix.BASS_Mixer_StreamAddChannel(mixer, MikroOutput, BASSFlag.BASS_MIXER_NORAMPIN Or BASSFlag.BASS_STREAM_AUTOFREE)
Bass.BASS_ChannelPlay(mixer, False) 'playing the mixer
End Sub
Public Function MikroRecordingCallback(ByVal handle As Integer, ByVal buffer As IntPtr, ByVal length As Integer, ByVal user As IntPtr) As Boolean 'microphone callback function
Bass.BASS_StreamPutData(MikroOutput, buffer, length)
Bass.BASS_ChannelPlay(MikroOutput, False) 'I'm not sure about this line, maybe this has to do with the issue??
'Because the other channels being put in the mix are not explicitely told to playback; but when I skip this line, I still get the same error "Unsupported sample format and I will not hear the mic on speakers...
Return True
End Function
Private Sub btnPlayFile1_Click(sender As Object, e As EventArgs) Handles btnPlayFile1.Click 'play file 1 on click
streamA = Bass.BASS_StreamCreateFile("C:\Users\alpha\Music\dancehall\Macka B\01 Macka B - 01.mp3", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_STREAM_PRESCAN Or BASSFlag.BASS_STREAM_DECODE)
Debug.WriteLine("streamAhandle:" & CStr(streamA) & "Fehler:" & CStr(Bass.BASS_ErrorGetCode))
Dim success As Boolean = BassMix.BASS_Mixer_StreamAddChannel(mixer, streamA, BASSFlag.BASS_MIXER_NORAMPIN Or BASSFlag.BASS_STREAM_AUTOFREE)
Debug.WriteLine(CStr(success))
End Sub
Private Sub btnPlayFile2_Click(sender As Object, e As EventArgs) Handles btnPlayFile2.Click play file 2 on click
streamB = Bass.BASS_StreamCreateFile("C:\Users\alpha\Music\pop\Clueso\Weit Weg\14 Chicago.mp3", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_STREAM_PRESCAN Or BASSFlag.BASS_STREAM_DECODE)
Debug.WriteLine("streamBhandle:" & CStr(streamB) & "Fehler:" & CStr(Bass.BASS_ErrorGetCode))
Dim success As Boolean = BassMix.BASS_Mixer_StreamAddChannel(mixer, streamB, BASSFlag.BASS_MIXER_NORAMPIN Or BASSFlag.BASS_STREAM_AUTOFREE)
Debug.WriteLine(CStr(success))
End Sub
Private Sub btnMixToHD_Click(sender As Object, e As EventArgs) Handles btnMixToHD.Click 'Start th encoder on click...
EncoderHandle = BassEnc_Mp3.BASS_Encode_MP3_Start(mixer, Nothing, BASSEncode.BASS_ENCODE_LIMIT Or BASSEncode.BASS_ENCODE_AUTOFREE, Nothing, Nothing)
MessageBox.Show("EncoderHandle: " & CStr(EncoderHandle))
MessageBox.Show("Errorcode: " & CStr(Bass.BASS_ErrorGetCode))
End Sub
Private Sub btnStreamToServer_Click(sender As Object, e As EventArgs) Handles btnStreamToServer.Click 'start streaming on click
Dim Erfolg As Boolean = BassEnc.BASS_Encode_CastInit(EncoderHandle, "xx.xxx.xxx.xxx:8000/stream.mp3", "hackme", BassEnc.BASS_ENCODE_TYPE_MP3, "MeinErsterStream", Nothing, "MeinGenre", "MeineBeschreibung", Nothing, 128, True)
If Erfolg = True Then
MessageBox.Show("erfolgreich")
Else
MessageBox.Show("nicht erfolgreich")
End If
MessageBox.Show("Fehler: " & CStr(Bass.BASS_ErrorGetCode))
End Sub
End Class