0
votes

I am developing a C# application that records streaming audio to MP3.

I’m new to this but from what I’ve seen so far, the easiest way to do this is record to WAV using NAudio and then create an MP3 version using either LameMP3FileWriter or MediaFoundationEncoder.

I’m running into problems with the conversion, however, as my PC sound system is 5.1 and the MP3 conversion crashes due to the number of channels in the recorded WAV file. It works fine when I reconfigure my sound system to stereo but this is a bit of a pain; firstly, it means I cannot use my 5.1 system when recording the music but more of an issue, for some reason that I cannot figure out, if I set my speakers to stereo, they revert to quadraphonic when the PC (Windows 10) is rebooted!

Can anyone suggest how I can do this conversion without the need to configure my 5.1 sound?

One obvious solution to do something like resampling the WAV file to 2 channels before the conversion to MP3 but that seems something of a ‘long shortcut’. I’m also unclear as to the advantage of recording to WAV in the first place – audio streams are compressed and unlikely to have more than 2 channels to start with so playing it over 5.1, no matter how good it sounds, is really a bit illusory.

It would seem more sensible to just record the stream direct to MP3 but I cannot find any straightforward way of doing that.

1
"however, as my PC sound system is 5.1 and the MP3 conversion crashes due to the number of channels in the recorded WAV file" Don't capture in 5.1 then, capture in stereo. "I’m also unclear as to the advantage of recording to WAV in the first place" WAV is typically lossless PCM audio. MP3 encodes it in a lossy way for distribution, and isn't suitable for anything else. MP3 is also not a codec I'd use today unless I had no choice... Opus and AAC are much better.Brad
"audio streams are compressed and unlikely to have more than 2 channels to start with so playing it over 5.1, no matter how good it sounds, is really a bit illusory" No, you're mixing up pretty much everything here. The point of 5.1 is for a surround sound mix.Brad
@Brad Point 1: What I meant by ‘no clear advantage’ is that for various reasons (see point 2), I specifically want to end up with MP3 format and have no interest in retaining the Wav file so, the WAV file is an unnecessary step in that process. Unfortunately, NAudio only records streaming audio to WAV and I can’t find a C# library that does. In regard to recording in stereo, I’ve said in my question that that does work fine, it’s losing the advantage of listening to 5.1 when recording plus the inconvenience of having to switch between stereo and 5.1.mharran
@Brad Point 2: What I want to do is listen to streams in 5.1 at my desktop but record it to MP3 for playing on other devices e.g. my car CD player which supports MP3 but not AAC.What I meant by ‘illusory’ is that as I understand it, when you listen to something recorded in 5 tracks and play it through 5.1, you get a distinct track going to each speaker/subwoofer. If you listen to an MP3 or audio stream on 5.1, you’re getting 2 tracks replicated across the speakers. Yes, there is a true sound effect – which is why I don’t want to have to revert to stereo – but it’s not true surround sound.mharran
Sorry, meant "surround sound effect" not "true sound effect".mharran

1 Answers

3
votes

Mp3 specification does not handle 5.1. So it seems your mp3 encoders fail with 5.1.

Perhaps you can try an encoder that support MP3 Surround, an mp3 extension for 5.1.

Also, Perhaps you should consider using AAC encondig, a more friendly codec for 5.1.