Unified · Split
| @@ -149,6 +149,32 @@ lack ID3 tags, which allows us to decode the first frame and calculate all frame · 148 unmodified lines | |||
| 149 | positions as ``frame_bytes * N``. However, because of padding, frames can differ | 149 | positions as ``frame_bytes * N``. However, because of padding, frames can differ |
| 150 | in size even in this case. | 150 | in size even in this case. |
| 151 | 151 | ||
| 152 | ## High-level API | ||
| 153 | |||
| 154 | If you need only decode file/buffer, you can use optional high-level API. | ||
| 155 | Just ``#include`` ``minimp3_ex.h`` instead and use following additional functions: | ||
| 156 | |||
| 157 | ``` | ||
| 158 | typedef struct | ||
| 159 | { | ||
| 160 | int16_t *buffer; | ||
| 161 | size_t samples; /* channels included, byte size = samples*sizeof(int16_t) */ | ||
| 162 | int channels, hz, layer, avg_bitrate_kbps; | ||
| 163 | } mp3dec_file_info_t; | ||
| 164 | |||
| 165 | /* decode whole buffer block */ | ||
| 166 | void mp3dec_load_buf(mp3dec_t *dec, const uint8_t *buf, size_t buf_size, mp3dec_file_info_t *info); | ||
| 167 | /* iterate through frames with optional decoding */ | ||
| 168 | void mp3dec_iterate_buf(const uint8_t *buf, size_t buf_size, MP3D_ITERATE_CB callback, void *user_data); | ||
| 169 | #ifndef MINIMP3_NO_STDIO | ||
| 170 | /* stdio versions with file pre-load */ | ||
| 171 | int mp3dec_iterate(const char *file_name, MP3D_ITERATE_CB callback, void *user_data); | ||
| 172 | int mp3dec_load(mp3dec_t *dec, const char *file_name, mp3dec_file_info_t *info); | ||
| 173 | #endif | ||
| 174 | ``` | ||
| 175 | |||
| 176 | Use MINIMP3_NO_STDIO define to exclude STDIO functions. | ||
| 177 | |||
| 152 | ## Bindings | 178 | ## Bindings |
| 153 | 179 | ||
| 154 | * https://github.com/tosone/minimp3 - go bindings | 180 | * https://github.com/tosone/minimp3 - go bindings |