--- Utility: Load OGG file bytes from disk ---
| 53 | |
| 54 | // --- Utility: Load OGG file bytes from disk --- |
| 55 | static 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 --- |
| 77 | static fl::vector<fl::i16> decodeOggToPcm(const char* path, fl::u32* outSampleRate = nullptr) { |