How to Build Audio Environment of Android App with AudioKit of HMS Core — 2 — Audio Effects
Hello everyone,
In the last article, we created the main class for the audio kit implementation and built our application’s audio environment. In this article, we will add the effect feature of the audio kit into the application.
Effects
Audio Kit included effect capabilities with the version of 1.3.0.300 at 2021–04–27. In that update, 11 standard sound effects and 5 featured sound effects are provided in the audio kit.
If you remember that we had an init method in AudioHelper class and set audio manager, player-manager, queue-manager and config-manager. Now, we will get the effect manager object too. Now, we can add just this line in the init function after config manager;
...
mHwAudioEffectManager= hwAudioManager.effectManager
Now, we can reach the manager object anytime we want. So, we are going to add the effect we created into any audio item. To create an effect may require some basic knowledge about audio, sound technology. Or, you can just try the numbers and effect types :)
Firstly, we are going to create the effect item. What does it mean? It means that we will have a custom effect that we can apply for any audio item. That effect item object is generated from HwAudioEffectItem class. You can see in the official guide; https://developer.huawei.com/consumer/en/doc/development/HMSCore-References-V5/hwaudioeffectitem-0000001098354856-V5.
In the effect manager class, there is an effect creator method. It takes the name which can be anything string as a parameter and returns the effect item. Then, we will add some custom changes to it. Now, we only add a few sound effect parameters.
setType: Type of sound effect. 203 featured sound effects and 205 standard sound effects. (20501 for custom sound effect)
Changing frequency in the analyzer by setting decibel of the band methods; Eq31, Eq62, Eq125, Eq250, Eq500, Eq1k, Eq2k, Eq4k, Eq8k, Eq16k. Of course, we have setter and getter methods for each of them. (In kotlin, you can use only “item.eq31 = 300” for setter and “item.eq31” for the getter. In java, you should use “item.setEq31 = 400” and “item.getEq31”) Set method of Each of them takes integer parameters between -10 and +10. It refers to Decibel, in dB.
Additionally, there are some other data changer methods;
EqUltraLowStress: set/get booster data of the equalizer. The set method takes integer parameters ranging from 0 to 10. 0 means the bass booster is disabled.
EqSuperEnvironmentalSoundEffect: set/get surround sound. The set method takes integer parameters ranging from 0 to 10. 0 means the surround effect is disabled.
EqSuperChannelBalance: set/get to adjust audio balance (right and left). The set method takes an integer parameter which refers to the position (between -5 and +5). If the value is negative, the left audio channel is louder. If the value is positive, the right channel is louder. 0 means balanced.
Now, we applied the related effect to our effect manager. When any audio item is played, you will see that effect is applied. You can change and customize equalizer parameters and other changes. If you want to
These are all from the effects of the audio kit for now. Later, we can see more features that we can customize effects or adding manipulation to audios. Thank you for reading.
If you have any questions about the audio kit, please comment below.