Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
danielatgrayfin
Posts: 22
Registered: ‎08-10-2012
My Carrier: N/A

Re: how to set volume to mmrenderer audio


gbeukeboom wrote:

The code you provided for mmr worked for me, I just plugged it into the PlayAudio sample at line 150 of main.c:

 

    	strm_dict_t *dict = strm_dict_new();
    	dict = strm_dict_set(dict, "volume", "50");
    	if (dict) mmr_output_parameters(ctxt, audio_oid, dict);

 

This successfully resulted in the output audio volume being halved. I used the NDK 2.0 Beta 3.

 



I have tried this approach with the playbook 2.0.1 ndk ( i too need to set the mmr volume independantly of other audio) and while the volume is changing - it doesn't appear to be linear from 0->100. It ramps down quickly from "100", and a volume of "50" seems to be almost silent.

 

I couldn't really find any documentation on this - is this scale supposed to be linear? (ie 0 silent, 100 full) Is  there something else I might be missing? Thanks!

Please use plain text.
Contributor
danielatgrayfin
Posts: 22
Registered: ‎08-10-2012
My Carrier: N/A

Re: how to set volume to mmrenderer audio

OK, to answer my own question: based on trying a few things out, it does seem like the volume response is non-linear.

 

if you have a simple scalar volume from 0->1 then I beleive  the value you send to the mmr should be:

 

float db_vol = 100.f + (20.0f * log10f(vol));

 

ie. 100 is full volume and attenuation is in dB.

 

If this is not the intended behavior(perhaps a bug in the version  - 2.0.1 - of the sdk i am using?) then someone let me know!! If it is intended, then it would be nice for it to be documented somewhere :smileyhappy:

 

 

Please use plain text.
Contributor
danielatgrayfin
Posts: 22
Registered: ‎08-10-2012
My Carrier: N/A

Re: how to set volume to mmrenderer audio

oh, and don't forget (like i did) that log(0) is -infinity which causes a crash in release builds(but not debug), so probably worth checking first!
Please use plain text.