MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / load_audio

Method load_audio

src/common/audio/audio_reader.cpp:80–101  ·  view source on GitHub ↗

---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

78
79// ---------------------------------------------------------------------------
80bool AudioReader::load_audio(const std::string& filename,
81 audio_data_t& out_audio,
82 int target_sample_rate,
83 MonoDownmixMode downmix)
84{
85 init_ffmpeg_once();
86
87 if (!std::filesystem::exists(filename)) {
88 std::cerr << "Error: audio file not found: " << filename << std::endl;
89 return false;
90 }
91
92 AVFormatContext* format_ctx = nullptr;
93 if (avformat_open_input(&format_ctx, filename.c_str(), nullptr, nullptr) < 0) {
94 std::cerr << "Error: could not open audio file: " << filename << std::endl;
95 return false;
96 }
97
98 bool ok = decode_audio(format_ctx, out_audio, target_sample_rate, downmix);
99 avformat_close_input(&format_ctx);
100 return ok;
101}
102
103// ---------------------------------------------------------------------------
104bool AudioReader::load_audio_from_memory(const uint8_t* data, size_t size,

Callers 3

runMethod · 0.45
mainFunction · 0.45

Calls 1

init_ffmpeg_onceFunction · 0.85

Tested by 1

mainFunction · 0.36