mackron / miniaudio

Audio playback and capture library written in C, in a single source file.
https://miniaud.io
Other
4.07k stars 361 forks source link

Where is ma_decoder_init_mp3 in separate implement? #535

Closed SC-One closed 2 years ago

SC-One commented 2 years ago

I'm using latest commit of miniaudio(master branch). Thanks for creating the awesome crossplatform library. I wanna using ma_decoder_init_mp3 , but it was not ready in _extras/miniaudiosplit/miniaudio.h header. what's problem? I know it's exist in header only source (root project). but how about implementation way.?

mackron commented 2 years ago

Where are you seeing that function in the main file? I just looked now and there's no function with that name. I think that function used to exist, but that was removed a long time ago (over a year ago now). Are you sure you're looking at the right version? Can you take a screenshot of the function and post the line number so I can see what function you're talking about?

miniaudio will automatically detect the file type so you shouldn't need to explicitly specify the file type. However, if you do indeed want to give miniaudio a hint that the file is an MP3 file, you can set the encodingFormat member of ma_decoder_config to ma_encoding_format_mp3:

ma_decoder_config config = ma_decoder_config_init_default();
config.encodingFormat = ma_encoding_format_mp3;

ma_decoder_init(..., &config, &decoder);
SC-One commented 2 years ago

Thanks. I found it on documentation!( and I think your right it is older version , I will check again , sorry) And about auto detect , It has not more overhead on auto detecting? I'm not using file , I takling chunks from network And I will use call back so , how do it ? it can auto detect chunks too in callback?

mackron commented 2 years ago

Yes, there will be some overhead, and it needs to do seeking as well. It uses trial-and-error. I can't remember the order off the top of my head, but it will first try one format, and if that fails, it will seek back to the start of the file and then try the next format, then the next and so on until it finds one that works. If you know the format will always be MP3, specifying the encoding format like I mentioned in my comment above will be the most efficient way to do it.

SC-One commented 2 years ago

Thanks for explanation.