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

Current audio recording sounds a bit quiet #215

Open
microbit-carlos opened this issue Aug 8, 2024 · 4 comments
Open

Current audio recording sounds a bit quiet #215

microbit-carlos opened this issue Aug 8, 2024 · 4 comments
Assignees
Milestone

Comments

@microbit-carlos
Copy link
Contributor

In comparison the recording in MakeCode is a bit louder, the background noise is also increased, but it makes voice recordings a bit easier to understand.

I've created this hex file for comparison using a test version of MakeCode with the latest CODAL tag v0.2.67: makecode-test-record.hex.zip

Button A records, button b plays recording (logo touch changes the playback speed between normal [n], fast [f] and slow [s]).
Code can be seen here: https://makecode.microbit.org/_6x6Hq9EC8i6R

The MakeCode pipeline configuration code can be seen here: https://github.com/microsoft/pxt-microbit/blob/1049fc5ac641da9df65b2be174cbcec0cdfca017/libs/audio-recording/recording.cpp#L44-L56

Maybe it's the creation of a mixer channel with the StreamRecording and the volume configuration below that?

@microbit-carlos microbit-carlos added this to the 2.2.0-beta.1 milestone Aug 8, 2024
@dpgeorge dpgeorge self-assigned this Sep 10, 2024
@dpgeorge
Copy link
Collaborator

Possibly try channel->setVolume(75.0).

@dpgeorge
Copy link
Collaborator

MakeCode uses a sample range of 1023, yet MicroPython uses 255, so the corresponding volume increase would be channel->setVolume(18.7). I tried that setting but it makes the background noise very loud, much louder than the MakeCode example above.

I'm not sure what MakeCode is doing that it can keep the noise down while still amplifying the volume of the recording.

Also, because MicroPython uses the same audio output channel for all audio sources, if the volume is increased for recordings then it's increased for everything (because you can't tell if you're playing a recording or some other sample, eg loaded from a file). Sound expressions have their volume increased as well.

So we might need to come up with a better way for MicroPython to make the recordings louder. Maybe the samples coming out of the microphone can be automatically amplified (instead of amplifying the playback)?

@microbit-carlos
Copy link
Contributor Author

Also, because MicroPython uses the same audio output channel for all audio sources, if the volume is increased for recordings then it's increased for everything (because you can't tell if you're playing a recording or some other sample, eg loaded from a file). Sound expressions have their volume increased as well.

But that would only be the case if we set the mixer global volume (uBit.audio.mixer.setVolume()) right?
I thought creating a mixer channel and changing the volume in the channel itself (raw_source.channel->setVolume()) would only affect that channel, no?

Since there are some differences between the MakeCode & MicroPython pipeline configuration I think it's fine to play with the numbers until it sounds around the same volume-ish. Had a quick play around and setting ``raw_source.channel->setVolume()` to around 4.0 sounds close enough. Does that also affect other channels like the Sound Expressions?

@dpgeorge
Copy link
Collaborator

I thought creating a mixer channel and changing the volume in the channel itself (raw_source.channel->setVolume()) would only affect that channel, no?

You are right that sound expressions will not be affected. Also speech is on a different channel.

So it's only the AudioFrame/AudioRecording/AudioTrack sound level that will be changed.

Had a quick play around and setting ``raw_source.channel->setVolume()` to around 4.0 sounds close enough. Does that also affect other channels like the Sound Expressions?

No, that should not affect sound expressions, nor speech.

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

No branches or pull requests

2 participants