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

Media Foundation 48kHz files?

Jan 12, 2015 at 4:45 AM
Edited Jan 16, 2015 at 4:12 AM
Mark,
Awesome library/utility man... Nice work!

I have written an application that allows the user to convert audio files while copying to a new/better file structure for the QSC TouchMix 16.

The file format is recorded from the device onto a USB drive to a 44.1k or 48k 32 bit IEEE wav format. I give the option to change the bit rate to 16 or 24 while copying. This works great for the 44.1 files, but the 48k files fail to load. I tried to load the file in your sample app and it fails as well. Are 48k files supported in Media Foundation? If they're not, is there another way to convert the bit rate of 48k wav files using your utility? Or if there's a better way to do this not using the Media Foundation library would be nice as well (example code please).

Here's a link to one of the files I was trying to convert:
https://app.box.com/s/o8h8241cwvypcj2epjjd

Thanks again man for a great tool! Let me know what you think.
Thanks!
Scott

Do you guys have any answer on this? BTW, the file I'm trying to convert is 48k, 32 bit PCM - I just want to change them to 24 or 16bit. Thanks!
Feb 12, 2015 at 11:04 PM
hey, sorry for the delay. my article here is the most thorough thing I've written on converting between audio formats. When you say "fails to load" what error do you get? Is it initializing the soundcard? Perhaps you have a soundcard that doesn't support above 48kHz.
Feb 13, 2015 at 2:51 AM

Mark,

Thanks so much for the reply. I did see that article. It’s great and very thorough but doesn’t give me anything for changing the bit rate from 32 to 24. The MediaFoundation framework would work great for me but doesn’t seem to load 48/32 bit PCM files. Try loading this file (https://app.box.com/s/o8h8241cwvypcj2epjjd) in your MediaFoundation example for changing formats. I can definitely play this file on my system but won’t load using MediaFoundation. Check it out and let me know what you think.

Thanks!
Scott

Feb 13, 2015 at 7:47 AM
haven't had a chance to check out your file yet, but you should be able to load it with WaveFileReader and then use Pcm32BitToSampleProvider to get to floating point samples. Then multiply each sample by sampleValue * 8388607.0 to get an int. Then write three least significant bytes of that int to file. Would like to add better bit depth conversion support into NAudio in the future as this is something a lot of people struggle with. We could probably do with a SampleToWaveProvider24 as well, which would make your task easy.
Feb 13, 2015 at 8:04 AM
OK, had a few minutes to spare so have made a SampleToWaveProvider24. It's in the latest NAudio source. Convert your 32 bit PCM file into 24 like this:
            using (var reader = new WaveFileReader(input))
            {
                var sp = reader.ToSampleProvider();
                var wp24 = new SampleToWaveProvider24(sp);
                WaveFileWriter.CreateWaveFile(output, wp24);
            }
Feb 14, 2015 at 4:40 AM

Dude, you are awesome! Thanks so much for that. I will check it out and let you know how it works. BTW, if you’re a musician or do any recording, check out the QSC Touchmix, it really rocks if you play small clubs and don’t want to haul around 200 lbs. of equipment. It replaces your mixer and outboard effects. It sounds great too! This application I’m writing just rearranges the session recording files for easier mixing/mastering and I’m using your tool to convert the audio files while moving them because there some DAWs out there that don’t read 32bit PCM files.

Thanks again!
Scott

Feb 14, 2015 at 5:34 AM

Worked perfectly!

Feb 14, 2015 at 7:54 AM
Glad it worked for you. That QSC Touchmix looks a nice piece of kit.