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
ImperialPenguin
Posts: 20
Registered: ‎07-15-2012
My Device: Developer
Accepted Solution

MMR Problems

I'm having a number of problems getting my audio code to work correctly. I'll go one by one to simply things. The first problem is that I can't get looping to work. I think I've done everything correctly, but apparently not. Here is all of the relevant code:
char cwd[FILENAME_MAX];
memset(cwd, FILENAME_MAX, 0);
getcwd(cwd, PATH_MAX);

char path[PATH_MAX];
snprintf(path, PATH_MAX, "file://%s/%s", cwd, pszFilePath);

s_mmrConnection = mmr_connect(mmrname);

if (!s_mmrConnection)
{
	perror("mmr_connect");
	s_hasMMRError = true;
	return;
}

s_mmrContext = mmr_context_create(s_mmrConnection, ctxtname, 0, mode);
if (!s_mmrContext)
{
	perror(ctxtname);
	s_hasMMRError = true;
	return;
}

if ((s_audioOid = mmr_output_attach(s_mmrContext, "audio:default", "audio")) < 0)
{
	mmrerror(s_mmrContext, "audio:default");
	return;
}

if (mmr_input_attach(s_mmrContext, path, "autolist") < 0)
{
	fprintf(stderr, "unable to load %s\n", path);
	mmrerror(s_mmrContext, path);
	return;
}

strm_dict_t *dictionary = strm_dict_new();
s_repeatDictionary = strm_dict_set(dictionary, "repeat", "all");

if (mmr_input_parameters(s_mmrContext, s_repeatDictionary) != 0)
{
	mmrerror(s_mmrContext, "input parameters (loop)");
	return;
}

if (mmr_play(s_mmrContext) < 0)
{
	mmrerror(s_mmrContext, "mmr_play");
	s_hasMMRError = true;
}
The audio plays, but it only plays once. I'm not getting an error from mmr_input_parameters, so I'm guessing they are getting set correctly. What am I doing wrong?
BlackBerry Development Advisor (Retired)
mgoulet
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha

Re: MMR Problems

Hi there,

 

It has been a while since you posted this - are you stil lhaving issues?

 

Martin

 

Contributor
ImperialPenguin
Posts: 20
Registered: ‎07-15-2012
My Device: Developer

Re: MMR Problems

Yes I am. I'm actually writing this code as part of a cross-platform development solution so when I hit the roadblock I was able to just keep working on other parts of the software. This is the last stumbling block, but unfortunately if Blackberry can't use the same sound formats as the other platforms then I can't include support for it.  Which is a shame because I don't want just another iOS, Android only solution.

Any help would be greatly appreciated. 

 

BlackBerry Development Advisor (Retired)
mgoulet
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha

Re: MMR Problems

[ Edited ]

I've seem several threads about MMR on these forums - have you taken a peek at this one dealinn with looping specifically? (see highlighted post)

http://supportforums.blackberry.com/t5/Native-Development/Multimedia-renderer-REPEAT-LOOP-Audio/m-p/...

 

A quote from smcveigh:

"repeat" input parameter can only be applied to playlists or autolists -- not to individual tracks."

 

Let me know if this helps pointing you in the correct direction;

 

Martin

Contributor
ImperialPenguin
Posts: 20
Registered: ‎07-15-2012
My Device: Developer

Re: MMR Problems

I saw that, but doesn't the line below properly set my track as an autolist and not an individual track? If not, how can I go about makes a single track a list?

 

mmr_input_attach(s_mmrContext, path, "autolist")

 

Contributor
ImperialPenguin
Posts: 20
Registered: ‎07-15-2012
My Device: Developer

Re: MMR Problems

I've narrowed down my problem. I can get it to loop if I put the play code in a separate function, which is fine because that's what I want anyhow. However, the volume appears to be an issue. According to the manual, the volume ranges from 0-100. However, if I set the volume to 50, which should be half volume, I have to turn the volume on the simulator all the way up, turn the volume on my mac all the way up, turn off everything else in the room that makes any noise, and put my ear up to the speaker to hear anything. 

By contrast, OpenAL sound played at half volume is loud enough that I can hear it without doing any of those things. Is 0-100 not the correct values for MMR volume? The code I use to set the volume is below.

 

strm_dict_t *dictionary = strm_dict_new();
s_volumeDictionary = strm_dict_set(dictionary, "volume", "50");
mmr_output_parameters(s_mmrContext, s_audioOid, s_volumeDictionary)

 

I can hear it okay if I set the volume to 100, but should half volume really be that inaudible?

BlackBerry Development Advisor (Retired)
mgoulet
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha

Re: MMR Problems

That's great news!

 

I am not sure how the values are gauged for volume, however; How does it sound like at 75% volume, is there an ecxponential change or does it sound linear between values?

 

Martin

Contributor
danielatgrayfin
Posts: 22
Registered: ‎08-10-2012
My Device: Playbook

Re: MMR Problems

huh - somehow i missed this post when searching for a similar problem, even though it was right here on the first page! I just answered my own (same) question about mmr volume in this thread: http://supportforums.blackberry.com/t5/Native-Development/how-to-set-volume-to-mmrenderer-audio/td-p...

 

It appears that the volume attenuation is logarithmic with 100 being "full".

 

 

Contributor
ImperialPenguin
Posts: 20
Registered: ‎07-15-2012
My Device: Developer

Re: MMR Problems

Thanks danielatgrayfin, that seems to have worked. But like you said, it would be really nice if RIM documented it. Or if they just used a normal value like everyone else. My experience with Blackberry development vs iOS, Android, WebOS, and even Series40 has been abyssmal. I'm halfway under the impression that they don't actually want people developing for them. This issue is just one of many that makes things far more difficult than they need to be.

Contributor
danielatgrayfin
Posts: 22
Registered: ‎08-10-2012
My Device: Playbook

Re: MMR Problems

For audio specificially, i've actually found the BB NDK to have far fewer issues than Android, where I've found audio to be a complete mess (if you're bored... http://www.grayfinstudios.com/post?id=ag1ncmF5Zmlud2ViYXBwcgwLEgRQb3N0GJS5Bww ) . This volume thing was the only stumbling block i came across, and would've been fine if documented. (Android's OpenSL ES uses a similar scale - where 0.0dB is full volume)

 

Generally, I've found BB development support to be very helpful, and the bps libaries to be great, but  maybe thats just me :smileywink:

 

My main struggles at this point (going off topic!) are the interation time from Momentics, where slow builds, and slow launch times make testing/debugging pretty painful.