summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibAudio/MP3Loader.h
AgeCommit message (Collapse)Author
2023-03-19LibAudio: Use new generic seek table for MP3kleines Filmröllchen
MP3 had the exact same data structure, except less readable and less efficient.
2023-03-13LibAudio: Move audio stream buffering into the loaderkleines Filmröllchen
Before, some loader plugins implemented their own buffering (FLAC&MP3), some didn't require any (WAV), and some didn't buffer at all (QOA). This meant that in practice, while you could load arbitrary amounts of samples from some loader plugins, you couldn't do that with some others. Also, it was ill-defined how many samples you would actually get back from a get_more_samples call. This commit fixes that by introducing a layer of abstraction between the loader and its plugins (because that's the whole point of having the extra class!). The plugins now only implement a load_chunks() function, which is much simpler to implement and allows plugins to play fast and loose with what they actually return. Basically, they can return many chunks of samples, where one chunk is simply a convenient block of samples to load. In fact, some loaders such as FLAC and QOA have separate internal functions for loading exactly one chunk. The loaders *should* load as many chunks as necessary for the sample count to be reached or surpassed (the latter simplifies loading loops in the implementations, since you don't need to know how large your next chunk is going to be; a problem for e.g. FLAC). If a plugin has no problems returning data of arbitrary size (currently WAV), it can return a single chunk that exactly (or roughly) matches the requested sample count. If a plugin is at the stream end, it can also return less samples than was requested! The loader can handle all of these cases and may call into load_chunk multiple times. If the plugin returns an empty chunk list (or only empty chunks; again, they can play fast and loose), the loader takes that as a stream end signal. Otherwise, the loader will always return exactly as many samples as the user requested. Buffering is handled by the loader, allowing any underlying plugin to deal with any weird sample count requirement the user throws at it (looking at you, SoundPlayer!). This (not accidentally!) makes QOA work in SoundPlayer.
2023-02-13LibCore: Remove `Stream.h`Tim Schumacher
2023-02-08Everywhere: Use ReadonlySpan<T> instead of Span<T const>MacDue
2023-01-29AK: Move memory streams from `LibCore`Tim Schumacher
2023-01-29AK: Move bit streams from `LibCore`Tim Schumacher
2023-01-29AK: Move `Stream` and `SeekableStream` from `LibCore`Tim Schumacher
`Stream` will be qualified as `AK::Stream` until we remove the `Core::Stream` namespace. `IODevice` now reuses the `SeekMode` that is defined by `SeekableStream`, since defining its own would require us to qualify it with `AK::SeekMode` everywhere.
2023-01-29AK: Deprecate the old `AK::Stream`Tim Schumacher
This also removes a few cases where the respective header wasn't actually required to be included.
2023-01-28LibAudio: Remove `try_` prefix from fallible LoaderPlugin methodsLinus Groh
2023-01-20LibAudio: Use `AllocatingMemoryStream` as the MP3 loader bit reservoirTim Schumacher
2023-01-19LibAudio: Skip MP3 frames if not enough historic data is availableTim Schumacher
2023-01-10LibCore: Rename InputBitStream.h to BitStream.hTim Schumacher
We won't just be defining readable streams here from now on, but also writable streams.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-12-05LibAudio: Use `NonnullOwnPtr` to keep track of LoaderPlugin streamsTim Schumacher
This doesn't have any immediate uses, but this adapts the code a bit more to `Core::Stream` conventions (as most functions there use NonnullOwnPtr to handle streams) and it makes it a bit clearer that this pointer isn't actually supposed to be null. In fact, MP3LoaderPlugin and FlacLoaderPlugin apparently forgot to check for that completely before starting to decode data.
2022-12-05LibAudio: Switch LoaderPlugin to a more traditional constructor patternTim Schumacher
This now prepares all the needed (fallible) components before actually constructing a LoaderPlugin object, so we are no longer filling them in at an arbitrary later point in time.
2022-10-14LibAudio: Factorize stream initialisation to base class `LoaderPlugin`Lucas CHOLLET
All actual plugins follow the same logic to initialize their stream, this commit factorizes all of this to their base class: `LoaderPlugin`.
2022-10-14LibAudio: Allow the MP3 plugin to be constructed from a byte bufferLucas CHOLLET
2022-10-14LibAudio: Port the MP3 plugin to `Core::Stream`Lucas CHOLLET
2022-10-14LibAudio: Get rid of unused method `Loader::file()`Lucas CHOLLET
`aplay` and two files of `SoundPlayer` were relying on the include of `LibCore/File.h` by `Loader.h`.
2022-07-19LibDSP: Rename library namespace to DSPkleines Filmröllchen
That's the standard naming convention, but I didn't follow it when originally creating LibDSP and nobody corrected me, so here I am one year later :^)
2022-05-07LibAudio+LibDSP: Switch samples to 32-bit float instead of 64-bit floatkleines Filmröllchen
This has been overkill from the start, and it has been bugging me for a long time. With this change, we're probably a bit slower on most platforms but save huge amounts of space with all in-memory sample datastructures.
2022-05-03LibAudio+Userland: Remove Audio::LegacyBufferkleines Filmröllchen
The file is now renamed to Queue.h, and the Resampler APIs with LegacyBuffer are also removed. These changes look large because nobody actually needs Buffer.h (or Queue.h). It was mostly transitive dependencies on the massive list of includes in that header, which are now almost all gone. Instead, we include common things like Sample.h directly, which should give faster compile times as very few files actually need Queue.h.
2022-02-26LibAudio: Add basic MP3 DecoderArne Elster
This is a basic MPEG-1 layer 3 audio decoder. It supports all sample rates and stereo modes except for freeformat.