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
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind
Accepted Solution

OpenAl, stopping sound

Hey all, I used the cowbell sample as a base for getting sounds to work in my application and while that is fine, I was wondering how to stop a sound on command. My attempt to do this used the same framework as starting the sound, but replacing the alSourcePlay(source) command with alSourceStop(source), under the naive impression it could be that easy. Is there any good documentation for doing this or if anyone knows the solution that would be terrific.

 

I would have included my code but there are several snippets across different files and it is essentially the same as the way the alSourcePlay(source) was initiated just with that change. As always, look forward to a response.

Please use plain text.
BlackBerry Development Advisor (Retired)
rmadhavan
Posts: 29
Registered: ‎03-19-2012
My Device: Z10
My Carrier: BELL

Re: OpenAl, stopping sound

Hi,

 

I believe it IS as simple as calling alSourceStop(source) with a valid source ID :smileyhappy:

The best place to start with is OpenAL Spec which has all the information you would need.

 

Thanks for posting!

 

Ram

Please use plain text.
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Re: OpenAl, stopping sound

Took a bit of tweaking but got it working, thanks for getting back to me :smileyhappy:.

 

Please use plain text.
Developer
bbquincar
Posts: 304
Registered: ‎08-14-2012
My Device: PlayBook, Z10, Dev C
My Carrier: Rogers

Re: OpenAl, stopping sound

where you able to get the sound to work just by using qml code

BlackBerry 10 game reviews for the unknown, small and indie developers. Little games with big dreams. VeryBerryGames.com | Follow @VeryBerryGames | TwoCasualCoders.com | never casual on quality
Please use plain text.
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Re: OpenAl, stopping sound

No, it requires C++ work, I modeled mine after the cowbell sample from here:

https://developer.blackberry.com/cascades/sampleapps/

 

It was perfect for getting a grasp of incorporating wav sounds into my application. It only works with wav's however,  there are other samples available that handle other types. Good luck!

Please use plain text.
Developer
bcs925
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30
My Carrier: T-Mobile

Re: OpenAl, stopping sound

vingilot, mind posting your functions that control the stop feature? 

 

I tried essentially replicating the "play" function in the soundmanager.cpp except changing "alSourcePlay(source);" to "alSourceStop(source);" (as well as having the correct calls in the header file)... but no stopping the sound.

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Please use plain text.
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Re: OpenAl, stopping sound

[ Edited ]

Hmm, if I recall correctly I ran into the same problem as you, it seemed as though just using the stop command was failing and that is why I posted the thread in the first place. I tried a variety of things but found that using:

 

alSourceStopv(SOUNDMANAGER_MAX_NBR_OF_SOURCES, mSoundSources);

 

this stops a group of sources, of which there are 32 on the dev alpha and mSoundSources is the set of sources. Make sure that your stop command is telling it to stop the right source otherwise it won't work. I know the cowbell is built in to rotate through sources each time a note is played so that could cause it to not work. By using the above code, that ensures that all sources are stopped, which was good enough for me as my sounds run in a linear fashion, not concurrently. 

 

It should be a catchall for your situation and tell me if it works. I am now working on another issue, if you get passed this problem I would appreciate discussing more about using openAL later on. Best of luck.

Please use plain text.