2022-01-23 17:21:56 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SampleFormats.h"
|
|
|
|
|
|
|
|
namespace Audio {
|
|
|
|
|
|
|
|
u16 pcm_bits_per_sample(PcmSampleFormat format)
|
|
|
|
{
|
|
|
|
switch (format) {
|
2022-03-17 23:38:24 +03:00
|
|
|
case PcmSampleFormat::Uint8:
|
2022-01-23 17:21:56 +03:00
|
|
|
return 8;
|
2022-03-17 23:38:24 +03:00
|
|
|
case PcmSampleFormat::Int16:
|
2022-01-23 17:21:56 +03:00
|
|
|
return 16;
|
2022-03-17 23:38:24 +03:00
|
|
|
case PcmSampleFormat::Int24:
|
2022-01-23 17:21:56 +03:00
|
|
|
return 24;
|
2022-03-17 23:38:24 +03:00
|
|
|
case PcmSampleFormat::Int32:
|
|
|
|
case PcmSampleFormat::Float32:
|
2022-01-23 17:21:56 +03:00
|
|
|
return 32;
|
2022-03-17 23:38:24 +03:00
|
|
|
case PcmSampleFormat::Float64:
|
2022-01-23 17:21:56 +03:00
|
|
|
return 64;
|
|
|
|
default:
|
|
|
|
VERIFY_NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-04 21:02:33 +03:00
|
|
|
DeprecatedString sample_format_name(PcmSampleFormat format)
|
2022-01-23 17:21:56 +03:00
|
|
|
{
|
2022-03-17 23:38:24 +03:00
|
|
|
bool is_float = format == PcmSampleFormat::Float32 || format == PcmSampleFormat::Float64;
|
2022-12-04 21:02:33 +03:00
|
|
|
return DeprecatedString::formatted("PCM {}bit {}", pcm_bits_per_sample(format), is_float ? "Float" : "LE");
|
2022-01-23 17:21:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|