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

Class AudioReader

src/include/audio/audio_reader.hpp:33–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31};
32
33class AudioReader {
34public:
35 AudioReader();
36 ~AudioReader();
37
38 /// Load audio from a file, decode, resample to target_sample_rate, and convert to mono float32.
39 /// Supports any format FFmpeg can demux (mp3, wav, flac, ogg, etc.).
40 /// @param filename path to the audio file
41 /// @param out_audio output struct filled with samples and metadata
42 /// @param target_sample_rate desired output sample rate (default 16000)
43 /// @return true on success
44 bool load_audio(const std::string& filename, audio_data_t& out_audio, int target_sample_rate = 16000, MonoDownmixMode downmix = MonoDownmixMode::NONE);
45
46 /// Load audio from an in-memory buffer (e.g. received over network).
47 /// @param data raw file bytes (mp3, wav, etc.)
48 /// @param size byte count
49 /// @param out_audio output struct filled with samples and metadata
50 /// @param target_sample_rate desired output sample rate (default 16000)
51 /// @param downmix how to downmix multi-channel audio to mono
52 /// @return true on success
53 bool load_audio_from_memory(const uint8_t* data, size_t size, audio_data_t& out_audio, int target_sample_rate = 16000, MonoDownmixMode downmix = MonoDownmixMode::NONE);
54
55 // does a simple clipping and simply discarded the audio beyond the max duration.
56 bool clip_audio_length(audio_data_t& audio, double max_duration_second);
57
58private:
59 bool decode_audio(struct AVFormatContext* format_ctx, audio_data_t& out_audio, int target_sample_rate, MonoDownmixMode downmix);
60};
61
62
63

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected