MCPcopy Create free account
hub / github.com/FastLED/FastLED / loadOggFile

Function loadOggFile

tests/fl/audio/detector/vocal_real_audio.hpp:55–74  ·  view source on GitHub ↗

--- Utility: Load OGG file bytes from disk ---

Source from the content-addressed store, hash-verified

53
54// --- Utility: Load OGG file bytes from disk ---
55static fl::vector<fl::u8> loadOggFile(const char* path) {
56 fl::FILE* f = fl::fopen(path, "rb");
57 if (!f) {
58 return fl::vector<fl::u8>();
59 }
60 fl::fseek(f, 0, fl::io::seek_end);
61 long fileSize = fl::ftell(f);
62 fl::fseek(f, 0, fl::io::seek_set);
63 if (fileSize <= 0) {
64 fl::fclose(f);
65 return fl::vector<fl::u8>();
66 }
67 fl::vector<fl::u8> data(static_cast<fl::size>(fileSize));
68 fl::size bytesRead = fl::fread(data.data(), 1, static_cast<fl::size>(fileSize), f);
69 fl::fclose(f);
70 if (bytesRead != static_cast<fl::size>(fileSize)) {
71 return fl::vector<fl::u8>();
72 }
73 return data;
74}
75
76// --- Utility: Decode OGG to flat PCM i16 vector ---
77static fl::vector<fl::i16> decodeOggToPcm(const char* path, fl::u32* outSampleRate = nullptr) {

Callers 2

decodeOggToPcmFunction · 0.85
fixturesAvailableFunction · 0.85

Calls 6

fopenFunction · 0.85
fseekFunction · 0.85
ftellFunction · 0.85
fcloseFunction · 0.85
freadFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected