mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
Piano: Use Sample struct from LibDSP
Removes the Sample struct inside Piano and replaces it with the struct from LibDSP. It automatically scales the height of the wave depending on the maximum amplitude, as the Samples now contain floats and not integers.
This commit is contained in:
parent
0019b901a0
commit
885e35e92c
4 changed files with 30 additions and 16 deletions
|
@ -38,6 +38,19 @@ struct Sample {
|
|||
{
|
||||
}
|
||||
|
||||
// Returns the absolute maximum range (separate per channel) of the given sample buffer.
|
||||
// For example { 0.8, 0 } means that samples on the left channel occupy the range { -0.8, 0.8 },
|
||||
// while all samples on the right channel are 0.
|
||||
static Sample max_range(ReadonlySpan<Sample> span)
|
||||
{
|
||||
Sample result { NumericLimits<float>::min_normal(), NumericLimits<float>::min_normal() };
|
||||
for (Sample sample : span) {
|
||||
result.left = max(result.left, AK::fabs(sample.left));
|
||||
result.right = max(result.right, AK::fabs(sample.right));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void clip()
|
||||
{
|
||||
if (left > 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue