gpt4 book ai didi

audio - 使用C中的libmad库将24 khz mp3音频转换为16 khz wav?

转载 作者:行者123 更新时间:2023-12-02 23:34:35 24 4
gpt4 key购买 nike

我正在用C编写一个小型应用程序,该应用程序从基于云的语音引擎接收mp3音频数据,并以16 khz采样率将其转换为pcm数据(wav格式)。我正在使用libmad解码mp3数据,但没有找到将其从24 khz降采样到16 khz的选项。我们可以使用libmad来做到这一点吗,还是需要另一个单独的库来实现呢?与此相关的任何信息都将有所帮助。谢谢,

〜里夫

最佳答案

lamehelper库可用于此...
使用此网站可以帮助您:
https://www.codeproject.com/Articles/656543/The-LAME-wrapper-An-audio-converter

您的代码应该看起来像这样-

#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;
}

关于audio - 使用C中的libmad库将24 khz mp3音频转换为16 khz wav?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47653292/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com