Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audio: Add AAC decoding #16526

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

torokati44
Copy link
Member

@torokati44 torokati44 commented May 29, 2024

WIP, mostly pushing for visibility.

Will fix the audio part of #8891.

TODO:

  • Parse "sequence headers", and configure the decoder accordingly.
    • Symphonia does this for us, as M4AInfo
  • Split into reasonable, smaller commits.
    • Done.
  • Make sure no build errors whether the new aac feature is enabled or not...
    • Done.
  • Add some kind of test with different channel counts and sample rates.
    • Done.

@torokati44 torokati44 added the audio Issues relating to audio playback label May 30, 2024
@torokati44 torokati44 force-pushed the aac-decoding branch 7 times, most recently from d7ad389 to eb83b74 Compare June 3, 2024 00:59
@torokati44 torokati44 force-pushed the aac-decoding branch 3 times, most recently from a5d0e04 to d82f98d Compare June 13, 2024 09:25
@torokati44 torokati44 force-pushed the aac-decoding branch 2 times, most recently from 05e536a to b3db352 Compare June 22, 2024 10:49
@torokati44 torokati44 marked this pull request as ready for review June 22, 2024 12:03
@torokati44
Copy link
Member Author

I marked this as ready for review. The only thing I'm unsure about is whether the test needs more explanation.

@torokati44 torokati44 added the waiting-on-review Waiting on review from a Ruffle team member label Jun 22, 2024
Comment on lines +1 to +7

ffmpeg -f lavfi -i "sine=frequency=444:duration=1:sample_rate=44100" -af "volume=5" -ac 2 -c:a aac tone_stereo_44100hz.flv
ffmpeg -f lavfi -i "sine=frequency=444:duration=1:sample_rate=48000" -af "volume=5" -ac 2 -c:a aac tone_stereo_48000hz.flv
ffmpeg -f lavfi -i "sine=frequency=444:duration=1:sample_rate=22050" -af "volume=5" -ac 2 -c:a aac tone_stereo_22050hz.flv
ffmpeg -f lavfi -i "sine=frequency=444:duration=1:sample_rate=44100" -af "volume=5" -ac 1 -c:a aac tone_mono_44100hz.flv
ffmpeg -f lavfi -i "sine=frequency=444:duration=1:sample_rate=48000" -af "volume=5" -ac 1 -c:a aac tone_mono_48000hz.flv
ffmpeg -f lavfi -i "sine=frequency=444:duration=1:sample_rate=22050" -af "volume=5" -ac 1 -c:a aac tone_mono_22050hz.flv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put it in generate_test_sounds.sh?

Comment on lines +39 to +41
for (var j:uint=0; j<256; j++) {
var sp = ba.readFloat();
var arg = j * coeff;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some mixed spaces and tabs in this file

Comment on lines +700 to +707
if self.sample_buf.capacity() < decoded.capacity() {
// Ensure our buffer has enough space for the decoded samples.
self.sample_buf = audio::SampleBuffer::new(
decoded.capacity() as core::units::Duration,
*decoded.spec(),
);
}
self.sample_buf.copy_interleaved_ref(decoded);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some code duplication with mp3, maybe we should add some utility method or SampleBuffer wrapper?

Comment on lines +608 to +609
#[cfg(feature = "aac")]
mod aac {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other decoders have their own files, maybe we should also move it to aac.rs for consistency?

@torokati44 torokati44 removed the waiting-on-review Waiting on review from a Ruffle team member label Jun 29, 2024
@torokati44 torokati44 added the waiting-on-author Waiting on the PR author to make the requested changes label Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio Issues relating to audio playback waiting-on-author Waiting on the PR author to make the requested changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants