Hey Ian, thanks for the reply :-)!
Do you mean you want the mixer to continue producing output (silence) when its sources are finished? If so, you can achieve that by replacing the BASS_MIXER_END flag with BASS_MIXER_NONSTOP in the BASS_Mixer_StreamCreate call. Note that will mean that the "processing loop" never exits and you will end up with a quickly expanding output file from the encoder, but if you add a caster to the encoder then it will by default automatically limit the processing to realtime speed.
I am working on a DJ software which has two "mixing desks", which each one will play an mp3 file. Also I added some effects to each channel like volume, tempo, pitch, equalizer and so on...
Now I want to record the output sound of my entire application (my 2 mixing desks) to hard disk, and its supposed two record all the effects with it.
Of course when the mp3 file of each one of the desks is done playing it will play the next file in playlist.
I want to record the whole thing to hard disk until I hit a button "Stop Recording".
Now I've tried the code below, but as you said it does not work in realtime and I get a huge file of about 40MB, even though the three mp3s only have about 4MP each... It has been recorded until the end of the longest track.
Here's my code so far (VB.NET):
Option Strict On
Imports Un4seen.Bass
Imports Un4seen.Bass.AddOn.Enc
Public Class Form1
Private streamA As Integer
Private streamB As Integer
Private streamC As Integer
Private mixer As Integer
Private DecoderA As Integer
Private DecoderB As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle)
End Sub
Private Sub btnPlayFile1_Click(sender As Object, e As EventArgs) Handles btnPlayFile1.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)
Bass.BASS_ChannelPlay(streamA, False)
End Sub
Private Sub btnPlayFile2_Click(sender As Object, e As EventArgs) Handles btnPlayFile2.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)
Bass.BASS_ChannelPlay(streamB, False)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles btnPlayFile3.Click
Bass.BASS_ChannelStop(streamA)
streamC = Bass.BASS_StreamCreateFile("C:\Users\alpha\Music\elektronic\chillout\Dave G\Chill Out In Miami\01 Miles Apart.mp3", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_STREAM_PRESCAN)
Bass.BASS_ChannelPlay(streamC, False)
End Sub
Private Sub btnMixToHD_Click(sender As Object, e As EventArgs) Handles btnMixToHD.Click
mixer = Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_MIXER_END)
DecoderA = 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_DECODE)
DecoderB = Bass.BASS_StreamCreateFile("C:\Users\alpha\Music\pop\Clueso\Weit Weg\14 Chicago.mp3", 0, 0, BASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_STREAM_DECODE)
Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamAddChannel(mixer, DecoderA, 0)
Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamAddChannel(mixer, DecoderB, 0)
BassEnc.BASS_Encode_Start(mixer, "F:\Ablage\RecordMixToHDTest.mp3", BASSEncode.BASS_ENCODE_PCM, Nothing, IntPtr.Zero) ' Set a mp3 writer On the mixer
' processing loop
While True
Dim encBuffer As Byte() = New Byte(20000) {} 'Byte[] buf = New Byte[20000] ' processing buffer
Dim r As Integer = Bass.BASS_ChannelGetData(mixer, encBuffer, 20000) ' process the mixer
If r = -1 Then BassEnc.BASS_Encode_Stop(mixer) ' done
End While
End Sub
Private Sub btnStopRecording_Click(sender As Object, e As EventArgs) Handles btnStopRecording.Click
BassEnc.BASS_Encode_Stop(mixer)
End Sub
End Class
Can you tell me how what I described above can be done? I guess I have to add a caster to the encoder if I understood you right...
What is a caster and how does it work?
And for the second issue (streaming the mixer channel to the internet):
So far I got this:
Dim encoder = BassEnc_Mp3.BASS_Encode_MP3_Start(_recHandle, "-b 56", 0, 0, 0)
BassEnc.BASS_Encode_CastInit(encoder, strStream1Ip + ":" + strStream1Port, strStream1Password, BASS_ENCODE_TYPE_MP3, strStream1Name, strStream1url, Nothing, Nothing, Nothing, Val(strStream1Bitrate), blStream1)
But thats about it. But how can I get the arguments for
BASS_Encode_CastInit, like server, password, name, url, genre, desc, headers, bitrate, pub?
Do I have to register at shoutcast respectively icecast to get these?
Which steps am I missing? I do not really understand the cast example in C from the BassEnc package... Something in C# or VB.NET would help a lot...