I'm trying to combine one or more mp3s into one mp3, back to back.
I took the contest.c example and tried to port it into VB.NET I got pretty far. I'm passing in "44100 2 <file1> <file2>"
Depending on the BASS_Init device, and the decode flags, I'm getting it to show the times, and run through the first file, then it hangs. The MP3 it created is the right size, but no sound.
Otherwise it gives me this error:
mixing/streaming files...
c:\My Music\Black Eyed Peas, The - My Humps.mp3
c:\My Music\Chris Brown - Run It!.mp3
Error: The encoder died!
All is OK
Press Enter to close this application
Here's the source code:
Sub Main()
Dim argv() As String = System.Environment.GetCommandLineArgs
' check that BASS 2.2 was loaded
If Bass.BASS_GetVersion <> Utils.MakeLong(2, 2) Then
printf("BASS version 2.2 was not loaded\n")
Return
End If
If argv.Length < 4 Then
printf("usage: %s <freq> <chans> <file1> <file2> ...\n")
printf("\nPress Enter to close this application\n")
Console.Read()
Return
End If
' not playing anything, so don't need an update thread
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0)
If Not (Bass.BASS_Init(-1, 44100, 0, 0, Nothing)) Then
printf("error: can't open output device\n")
printf("\nPress Enter to close this application\n")
Console.Read()
Return
End If
If Not Bass.BASS_Start() Then
printf("error: can't start output\n")
printf("\nPress Enter to close this application\n")
Console.Read()
Return
End If
Chan = AddOn.Mix.BassMix.BASS_Mixer_StreamCreate(atol(argv(1)), atol(argv(2)), 0) 'BASSStream.BASS_STREAM_DECODE)
If Chan = 0 Then
printf("error: can't create mixer output\n")
printf("\nPress Enter to close this application\n")
Console.Read()
Bass.BASS_Free()
Return
End If
printf("mixing/streaming files...\n")
For A = 3 To argv.Length - 1
' insert channels into mixer
If AddOn.Mix.BassMix.BASS_Mixer_StreamAddChannel(Chan, Bass.BASS_StreamCreateFile(argv(A), 0, 0, BASSStream.BASS_STREAM_DECODE), 0) Then 'BASSStream.BASS_STREAM_DECODE) Then
printf(argv(A) + "\n")
End If
Next
printf("\n")
'Encoder = EncodeType.MP3
EncodeCommands(EncodeType.OGG) = "oggenc.exe -b 128 -o """ + OutputFile + """ -"
EncodeCommands(EncodeType.MP3) = "lame.exe -b 128 - """ + OutputFile + """"
EncHandle = AddOn.Enc.BassEnc.BASS_Encode_Start(Chan, EncodeCommands(1), AddOn.Enc.BASSEncode.BASS_ENCODE_FP_16BIT, Nothing, 0)
If EncHandle = 0 Then
printf(BASS_GetErrorDescription(Bass.BASS_ErrorGetCode) + "\n")
printf("\nPress Enter to close this application\n")
Console.Read()
Bass.BASS_Free()
End If
If Not Bass.BASS_ChannelPlay(Chan, True) Then
printf("Cannot play... " + BASS_GetErrorDescription(Bass.BASS_ErrorGetCode) + "\n")
printf("\nPress Enter to close this application\n")
Console.Read()
Bass.BASS_Free()
Return
End If
Do While Bass.BASS_ChannelIsActive(Chan) = Un4seen.Bass.BASSActive.BASS_ACTIVE_PLAYING
' display some stuff and wait a bit
level = Bass.BASS_ChannelGetLevel(Chan)
pos = Bass.BASS_ChannelGetPosition(Chan)
sTime = Bass.BASS_ChannelBytes2Seconds(Chan, pos)
RetVal = Bass.BASS_ChannelGetData(Chan, MusicTemp(0), 20000)
If AddOn.Enc.BassEnc.BASS_Encode_IsActive(EncHandle) <> BASSActive.BASS_ACTIVE_PLAYING Then
printf("Error: The encoder died!\n")
printf(BASS_GetErrorDescription(Bass.BASS_ErrorGetCode) + "\n")
Exit Do
End If
If tmp <> Utils.FixTimespan(sTime, "MMSS") Then
tmp = Utils.FixTimespan(sTime, "MMSS")
printf("pos " + tmp + "\n")
End If
System.Threading.Thread.CurrentThread.Sleep(1)
Loop
Bass.BASS_ChannelStop(Chan)
AddOn.Enc.BassEnc.BASS_Encode_Stop(Chan)
Bass.BASS_StreamFree(Chan)
Bass.BASS_Stop()
Bass.BASS_Free()
printf("\nPress Enter to close this application\n")
Console.Read()
Return
End Sub
Thanks for your help!
Rick