18 May '13 - 16:39 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: .wav -> mixer -> lame  (Read 1856 times)
bigpawed
Posts: 8


« on: 29 Jan '10 - 01:53 »
Reply with quoteQuote

I want to send a wav file through a mixer and then pass the output to LAME to create an mp3. I've got most of it worked out but I am missing one critical piece.

Here is the idea (not the actual code):

int stream = BASS_StreamCreateFile("input.wav", 0, 0, BASSFlag.BASS_STREAM_DECODE);
BASS_CHANNELINFO info = BASS_ChannelGetInfo(stream);
int mixer = BassMix.BASS_Mixer_StreamCreate(info.freq, 2, BASSFlag.BASS_DEFAULT);
... set up mixer as needed ...
Misc.EncoderLAME encoder = new Misc.EncoderLAME(mixer);
encoder.LAME_Mode = EncoderLAME.LAMEMode.Mono;
encoder.LAME_Bitrate = Misc.EncoderLAME.BITRATE.kbps_16;
encoder.OutputFile = "output.mp3";
encoder.Start(null, 0, false);
... what goes here? ...
encoder.Stop();
My question is: How do I cause the mixer to send its output to the encoder?

Thanks,
Mark
Logged
radio42
Posts: 4012


« Reply #1 on: 29 Jan '10 - 07:58 »
Reply with quoteQuote

As the mixer is a non-decoding one, you can simply call BASS_ChannelPlay(mixer).
Logged
bigpawed
Posts: 8


« Reply #2 on: 29 Jan '10 - 17:19 »
Reply with quoteQuote

So I thought, but when I tried it, it played through the speakers in real time. I want the conversion to occur silently and rapidly, as though I had used Misc.BaseEncoder.EncodeFile to convert a wav file to mp3.
Dim encoder As New Misc.EncoderLAME(0)
encoder.LAME_Mode = EncoderLAME.LAMEMode.Mono
encoder.LAME_Bitrate = Misc.EncoderLAME.BITRATE.kbps_16
Misc.BaseEncoder.EncodeFile("input.wav", "output.mp3", encoder, _
  AddressOf FileEncodingNotification, False, False)
That works fine, but it doesn't allow modifying the sound as it's converted.
Logged
bigpawed
Posts: 8


« Reply #3 on: 29 Jan '10 - 17:25 »
Reply with quoteQuote

Perhaps I should ask an additional question: The reason I'm doing this is I want to select just the left or right channel of the stereo input.wav file to be converted to a mono mp3 file. I'm using the mixer with a matrix to accomplish this. Is there a better way that might also indicate a different way to do the LAME processing?
Logged
radio42
Posts: 4012


« Reply #4 on: 29 Jan '10 - 17:38 »
Reply with quoteQuote

No, that is fine.
In such case you should make the mixer channel a decoding one as well (add the BASS_STREAM_DECODE).
Then you can simply call BASS_ChannelGetData in a loop to process the mixer.
An example is actually given in the Bass.Net docs - see the BaseEncoder class for details.
Logged
bigpawed
Posts: 8


« Reply #5 on: 29 Jan '10 - 19:50 »
Reply with quoteQuote

Thanks. That works. But I find that the loop continues endlessly unless I check whether the len is zero, otherwise it never stops.
While Bass.BASS_ChannelIsActive(mixer) = BASSActive.BASS_ACTIVE_PLAYING
   Dim len As Integer = Bass.BASS_ChannelGetData(mixer, encBuffer, encBuffer.Length)
   If len = 0 Then Exit While
End While
Is there some setting that I missed that will cause the mixer to become inactive when the end is reached?
Logged
radio42
Posts: 4012


« Reply #6 on: 29 Jan '10 - 21:59 »
Reply with quoteQuote

A mixer channel has no specific end unless the BASS_MIXER_END flag is used when created.
That's why a mixer itself keeps returning BASS_ACTIVE_PLAYING.
So it is correct to check the returned length value of BASS_ChannelGetData.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines