Home Converting a 24 khz mp3 audio to 16 khz wav using libmad library in C?
Reply: 1

Converting a 24 khz mp3 audio to 16 khz wav using libmad library in C?

reevec
1#
reevec Published in 2017-12-05 12:09:14Z

I m writing a small application in C that receives mp3 audio data from a cloud based voice engine and converts it to pcm data (wav format) at 16 khz sample rate. I m using libmad for decoding mp3 data but i m not finding an option to downsample it from 24 khz to 16 khz. Can we do this using libmad or do we need another separate library to achieve this ? Any information relevant to this would be helpful. Thanks,

~Reev

Omkaar.K
2#
Omkaar.K Reply to 2017-12-05 12:23:22Z

The lamehelper library can be used for this... Use this website to help you: https://www.codeproject.com/Articles/656543/The-LAME-wrapper-An-audio-converter

Your code should look somewhat like this-

#include "lameHelper.h"
struct settings_t //make a struct to store settings
{
    char* title;
    char* artist;
    char* album;
    char* comment;
    char* year;
    char* track;
    char* genre;
    char* albumart;

    encode_channel_e channels;
    bitrate_e abr_bitrate;
    bitrate_e cbr_bitrate;
    int quality;
    encode_mode_e enc_mode;
    samplerate_e resample_frequency; // This is what you are going to need
    samplerate_e in_samplerate;

    //The constructor: used to set default values
    settings_t();
};

int main()
{
    settings_t settings;
    settings.enc_mode = EM_ABR;
    settings.abr_bitrate = BR_128kbps;//If you are going to use ABR encode mode @ 128kbps
    settings.album = "The Album";//Setting the album (id3 tag)
    settings.albumart = "c:/.../art.jpg";//Setting the albumart
    settings.track = "01";//Setting the track

    //..and various other settings

    lameHelper lhHandle;
    lhHandle.encode("c:/.../song.mp3", "c:/.../song.wav", settings);

    return 0;
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.307286 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO