mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:17:35 +00:00
Piano+LibDSP: Move Track to LibDSP
This is a tangly commit and it fixes all the bugs that a plain move would have caused (i.e. we need to touch other logic which had wrong assumptions).
This commit is contained in:
parent
125122a9ab
commit
4941cffdd0
29 changed files with 322 additions and 413 deletions
|
@ -40,10 +40,18 @@ void WavWriter::set_file(StringView path)
|
|||
m_finalized = false;
|
||||
}
|
||||
|
||||
void WavWriter::write_samples(u8 const* samples, size_t size)
|
||||
void WavWriter::write_samples(Span<Sample> samples)
|
||||
{
|
||||
m_data_sz += size;
|
||||
m_file->write(samples, size);
|
||||
m_data_sz += samples.size() * sizeof(Sample);
|
||||
|
||||
for (auto const& sample : samples) {
|
||||
// FIXME: This only really works for 16-bit samples.
|
||||
u16 left = static_cast<i16>(sample.left * static_cast<float>(1 << m_bits_per_sample));
|
||||
u16 right = static_cast<i16>(sample.right * static_cast<float>(1 << m_bits_per_sample));
|
||||
// FIXME: This ignores endianness.
|
||||
m_file->write(bit_cast<u8 const*>(&left), sizeof(u16));
|
||||
m_file->write(bit_cast<u8 const*>(&right), sizeof(u16));
|
||||
}
|
||||
}
|
||||
|
||||
void WavWriter::finalize()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue