1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 18:27:39 +00:00

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>
This commit is contained in:
David Isaksson 2021-09-23 21:16:03 +02:00 committed by Brian Gianforcaro
parent fa4255bcf1
commit b6d075bb01
11 changed files with 179 additions and 165 deletions

View file

@ -45,7 +45,7 @@ i32 Buffer::allocate_id()
}
template<typename SampleReader>
static void read_samples_from_stream(InputMemoryStream& stream, SampleReader read_sample, Vector<Frame>& samples, int num_channels)
static void read_samples_from_stream(InputMemoryStream& stream, SampleReader read_sample, Vector<Sample>& samples, int num_channels)
{
double norm_l = 0;
double norm_r = 0;
@ -54,7 +54,7 @@ static void read_samples_from_stream(InputMemoryStream& stream, SampleReader rea
case 1:
for (;;) {
norm_l = read_sample(stream);
samples.append(Frame(norm_l));
samples.append(Sample(norm_l));
if (stream.handle_any_error()) {
break;
@ -65,7 +65,7 @@ static void read_samples_from_stream(InputMemoryStream& stream, SampleReader rea
for (;;) {
norm_l = read_sample(stream);
norm_r = read_sample(stream);
samples.append(Frame(norm_l, norm_r));
samples.append(Sample(norm_l, norm_r));
if (stream.handle_any_error()) {
break;
@ -130,7 +130,7 @@ RefPtr<Buffer> Buffer::from_pcm_data(ReadonlyBytes data, int num_channels, PcmSa
RefPtr<Buffer> Buffer::from_pcm_stream(InputMemoryStream& stream, int num_channels, PcmSampleFormat sample_format, int num_samples)
{
Vector<Frame> fdata;
Vector<Sample> fdata;
fdata.ensure_capacity(num_samples);
switch (sample_format) {
@ -189,7 +189,7 @@ template Vector<double> ResampleHelper<double>::resample(Vector<double>);
NonnullRefPtr<Buffer> resample_buffer(ResampleHelper<double>& resampler, Buffer const& to_resample)
{
Vector<Frame> resampled;
Vector<Sample> resampled;
resampled.ensure_capacity(to_resample.sample_count() * ceil_div(resampler.source(), resampler.target()));
for (size_t i = 0; i < static_cast<size_t>(to_resample.sample_count()); ++i) {
auto sample = to_resample.samples()[i];