Commit Graph

6 Commits

Author SHA1 Message Date
David Isaksson
b6d075bb01 LibAudio: Rename Audio::Frame -> Audio::Sample
"Frame" is an MPEG term, which is not only unintuitive but also
overloaded with different meaning by other codecs (e.g. FLAC).
Therefore, use the standard term Sample for the central audio structure.

The class is also extracted to its own file, because it's becoming quite
large. Bundling these two changes means not distributing similar
modifications (changing names and paths) across commits.

Co-authored-by: kleines Filmröllchen <malu.bertsch@gmail.com>
2021-11-08 16:29:25 -08:00
kleines Filmröllchen
d049626f40 Userland+LibAudio: Make audio applications support dynamic sample rate
All audio applications (aplay, Piano, Sound Player) respect the ability
of the system to have theoretically any sample rate. Therefore, they
resample their own audio into the system sample rate.

LibAudio previously had its loaders resample their own audio, even
though they expose their sample rate. This is now changed. The loaders
output audio data in their file's sample rate, which the user has to
query and resample appropriately. Resampling code from Buffer, WavLoader
and FlacLoader is removed.

Note that these applications only check the sample rate at startup,
which is reasonable (the user has to restart applications when changing
the sample rate). Fully dynamic adaptation could both lead to errors and
will require another IPC interface. This seems to be enough for now.
2021-08-27 23:35:27 +04:30
kleines Filmröllchen
195d6d006f LibAudio: Resample FLAC audio data
FlacLoader initialized, but never used its resampler; this is now fixed
and all subframes are resampled before decorrelation occurs. FLAC files
with non-44100-Hz sample rates now play properly.
2021-08-18 18:16:48 +02:00
Andrew Kaster
845d403b8c LibAudio: Handle stream errors in FlacLoader
The FlacLoader already has numerous checks for invalid data reads and
for invalid stream states, but it never actually handles the stream
errors on the stream object. By handling them properly we can actually
run FuzzFlacLoader for longer than a few seconds before it hits the
first assertion :^).
2021-08-02 09:05:28 +02:00
Karol Kosek
8c2be4b3dc LibAudio: Implement loaded_samples() in the FLAC Loader
This makes aplay show current playback position.
2021-07-22 22:57:05 +02:00
kleines Filmröllchen
22d7e57955 LibAudio: Implement a basic FLAC loader
This commit adds a loader for the FLAC audio codec, the Free Lossless
Audio codec by the Xiph.Org foundation. LibAudio will automatically
read and parse FLAC files, so users do not need to adjust.

This implementation is bare-bones and needs to be improved upon.
There are many bugs, verbatim subframes and any kind of seeking is
not supported. However, stereo files exported by libavcodec on
highest compression setting seem to work well.
2021-06-25 20:48:14 +04:30