1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:37:35 +00:00

LibAudio: Allow loading sounds from memory

The Loader and WavLoaderPlugin classes now have methods for loading
from a ByteBuffer, in addition to streaming from disk.
This commit is contained in:
Julian Offenhäuser 2020-12-02 15:44:45 +01:00 committed by Andreas Kling
parent dff5983706
commit 21977a2188
5 changed files with 110 additions and 154 deletions

View file

@ -97,14 +97,14 @@ static double read_norm_sample_8(InputMemoryStream& stream)
stream >> sample;
return double(sample) / NumericLimits<u8>::max();
}
RefPtr<Buffer> Buffer::from_pcm_data(ReadonlyBytes data, ResampleHelper& resampler, int num_channels, int bits_per_sample)
{
InputMemoryStream stream { data };
return from_pcm_stream(stream, resampler, num_channels, bits_per_sample, data.size() / (bits_per_sample / 8));
}
RefPtr<Buffer> Buffer::from_pcm_stream(InputMemoryStream &stream, ResampleHelper& resampler, int num_channels, int bits_per_sample, int num_samples)
RefPtr<Buffer> Buffer::from_pcm_stream(InputMemoryStream& stream, ResampleHelper& resampler, int num_channels, int bits_per_sample, int num_samples)
{
Vector<Sample> fdata;
fdata.ensure_capacity(num_samples);