This project has moved and is read-only. For the latest updates, please go here.

Record/Mix/Change BitRate, SampleRate & Convert to Mp3.

Mar 31, 2014 at 8:39 AM
Edited Mar 31, 2014 at 8:52 AM
Hi Mark Heath (And everyone)

Many thanks for your great library !!! I need your help for my situation.

I'm writing a Sound Recorder Program and dealing with this case:
  • A function which Record from both Mic/Speaker and then Mix into 1 mp3 file at the desired BitRate/SampleRate (It have to do realtime - output file keep up to date and not corrupted event in the case the computer is down when recording).
My implementation is like this.
  • Record from Mic/Speaker into separated file (Using WaveIn/WasapiLoopbackCapture)
  • Mix those files (using WaveMixerStream32)
  • Convert Mixed file to Mp3 (Using Mp3Writer)
My questions is:
  1. Can I do all those step in realtime and write directly to mp3 file?
  2. Record process could take hours... Why your WaveWriter only flush the Stream when it disposing ? It took time and make program freezing.
    (I'm modified the Flush function and added 3 Update......Chunk function and it work fine.
    Is it better? Do you have any comments about this modification? I'm concern about the seek process when file size is to long...)
Apr 23, 2014 at 3:22 PM

the answer to question 1 is that it is a bit tricky to do in real-time but can be done. I've used commandline lame for this in the past.

Allowing the user to "Flush" and update the length chunk might be a nice enhancement to WaveFileWriter. I'll consider it for a future version

Apr 29, 2014 at 3:08 PM
Edited Apr 29, 2014 at 3:16 PM
Hi Mark !

I can't wait for your answer, so I'm try to Do It My Self and it's done. (Mostly)

I build a class called "Listener" to listen from both Record/Playback Device
  • It raise DataAvailable for each "Chanel" just like the IWaveIn
  • And an other event when listener is stoped
The second class called "MixWriter" which receive Raw Wave Data
  • It add data to the queue for each Chanel
  • When all queue have enough data for 1 wave block, MixWriter process Mix data & Write to mp3 file directly. (use Yeti wrapper for Lame_enc.dll)
Between 2 class is main process, implement in a business class
  • Forward data from Listener to MixWriter
  • Control UI and User's Interactions.
Don't need WaveFileWriter any more !

I will post my solution here with a sample. (Still dealing with few issues... serious one)
Hope that you have any advise & improvement. :)