androidthings / sample-googleassistant

Google Assistant API sample for Android Things
Apache License 2.0
467 stars 147 forks source link

Low volume on 100% #54

Closed majo551 closed 6 years ago

majo551 commented 6 years ago

After testing the original implementation of the Voice AIY project I am wondering why the volume is so low even with 100 volume set in this project

It is about 50% weaker when compared to the Voice Hat driver implementation in the original project. Is this the Audio manager or the VoiceHat driver issue in this Android Things implementation? I tried to change the stream volume but it did not help.

 AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

  int amStreamMusicMaxVol = (int) (am.getStreamMaxVolume(am.STREAM_MUSIC) * (volume / 100f));

  am.setStreamVolume(am.STREAM_MUSIC, amStreamMusicMaxVol, 0);
ashdavies commented 6 years ago

Related to #43 and/or https://github.com/googlecodelabs/androidthings-googleassistant/issues/3 ?

majo551 commented 6 years ago

looks like though original was related to crackling. My issue is only low volume. No cracling or distortion.

Dňa 27. 1. 2018 9:38 používateľ "Ash Davies" notifications@github.com napísal:

Related to #43 https://github.com/androidthings/sample-googleassistant/issues/43 and googlecodelabs/androidthings-googleassistant#3 https://github.com/googlecodelabs/androidthings-googleassistant/issues/3 ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/androidthings/sample-googleassistant/issues/54#issuecomment-360970062, or mute the thread https://github.com/notifications/unsubscribe-auth/AMurCJW2yAGdSYgP4Y3YL02JeSpyhSBkks5tOuBngaJpZM4RvNda .

ashdavies commented 6 years ago

I have the same low volume issue with the other (codelabs) version, but crackling/popping in this version 😞

pflammertsma commented 6 years ago

I'm experiencing the same problem: low volume (even with stream volume set to the maximum value of 15) and crackling/pop.

To make sure it's not the hardware or wiring, I've also build the whole Raspbian variant and ran the sample, and the speaker is very, very loud indeed. The difference is night and day!

To also make sure it's not the audio playback, I wrote a simple Android app that plays a generated tone that reaches maximum amplitude (at 16 bits, -32768 to 32767), and I'm afraid it's very quiet. It seems like the amplifier is simply not powered.

In that regard, I was thinking perhaps the Max98357A's gain pin needs to be defined? I tried the following:

voiceHatDac.setGainSlot(Max98357A.GAIN_SLOT_ENABLE)

But the gain pin is not defined in VoiceHat.openDac() (the second parameter is null). Any thoughts or insights would be very helpful!

pflammertsma commented 6 years ago

It seems my hypothesis is incorrect; this comment in VoiceHat.openDac() specifically states:

On the VoiceHat, the GAIN_SLOT pin on the DAC is not connected.

Fleker commented 6 years ago

I've been talking with some other engineers about a potential fix based on the way that audio is handled in Android. I'll be taking a look at this again, as well as a potential fix, today or tomorrow.

Fleker commented 6 years ago

This should be fixed in b31a2cc6dd943113fe08ee9de53cfd3357fa99ad.

elizacamber commented 6 years ago

Still experiencing the same issues after the fix. The volume is so quite you can barely hear it

pflammertsma commented 5 years ago

I'm almost confident that this issue has nothing to do with the MAX 98357A SD mode. Effectively this fix is setting the GPIO attached to the SD pin to up, which gives it 5V. According to the MAX 98357A:

If the voltage on SD is higher than 1.4V then the output is the Left channel.

This is consistent with the patch; enabling the GPIO uses a constant accurately named SD_MODE_LEFT.

Nevertheless, the volume remains incredibly low. I believe this has something to do with Android Things itself instead of code, as even using a USB sound card produces very low volume.

pflammertsma commented 5 years ago

Unfortunately, it appears that the output volume on Android Things is determined at a low level and is outputting at roughly half of what it should.

I've tested with three different RPi 3 Bs, using the analog line out, two separate USB sound cards and the Adafruit MAX 98357A amplifier (using I2S bus output), and all produce sound at an incorrect level. I'm comparing this against booting those same devices into Raspbian or attaching the USB or amp to a different machine.

I'm testing the output volume while setting both the system volume and the media player's volume to max. Furthermore, the sound level of system sounds such as the volume pop or key press are also very quiet.

After having invested quite heavily into various speaker amplifiers and speakers, my conclusion is that there must be a low-level issue in Android Things itself.

crysxd commented 5 years ago

Is there any update on this topic? I'm running Android things 1.0.9 and the latest master code but still experience this issue

pflammertsma commented 5 years ago

Android Things is being shut down for general development; see the blog post: https://android-developers.googleblog.com/2019/02/an-update-on-android-things.html

It will only be available for OEM partners for the specific purpose of implementing Google Assistant into smart speakers and smart frames.

If you are looking to leverage the platform for anything beyond tinkering on personal projects, I suggest looking at alternatives, such as Microsoft's Windows 10 IoT platform.