Skip to content

split audiotap, add LevelReader - #11937

Merged
dhalbert merged 1 commit into
adafruit:mainfrom
FoamyGuy:split_audiotap
Nov 21, 2026
Merged

dhalbert merged 1 commit into
adafruit:mainfrom
FoamyGuy:split_audiotap

Conversation

@FoamyGuy

Copy link
Copy Markdown
Collaborator

Based on recent discussion from discord. Split the audiotap.Tap class so that users who want readinto() don't have to spend CPU on calculating peak and rms.

A new LevelReader class accepts a Tap in its constructor to attach to. It calculates peak and rms values from audio in the Taps stream.

This is a breaking change for any code that was using Tap.peak or Tap.rms.

@dhalbert dhalbert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! This seems good. Can you think of anything else that this might implement that either might be:

  • not a level but some other statistic (like FFT or some other frequency-based thing??). If so maybe a more general name.
  • anything else that might be expensive and so you'd want to turn it on and off? If so maybe enabling and disabling, which we already discussed.

But maybe an FFT would be a separate audiotap class.

@FoamyGuy

Copy link
Copy Markdown
Collaborator Author

I had imagined FFT or other use cases getting new classes created.

Another alternative approach for general use cases would be if have a good API to hand this data off to C or viper modules compiled to .mpy. Then users could create custom handling for whatever case they need without additional core code. But if there are very commonly used ones it might be good to move them in to the core in new classes.

@dhalbert
dhalbert merged commit 35c8c2a into adafruit:main Nov 21, 2026
717 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants