BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-01-2007, 04:44 PM   #1 (permalink)
New Member
 
Join Date: Jul 2007
Model: 7100
PIN: N/A
Carrier: rogers
Posts: 10
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default midlet sound

Please Login to Remove!

Hey. I'm looking to create a little metronome for my blackberry.. Learning guitar and all.
Anyone out here know how to 1 produce sound, 2 do so on a timer.
Heck while I'm at it. I'd like to be able to use my BB as a tooner too so if anyone out here knows how to listen through the mic that'd be great.
Well it be great if they happened to see this and enlighten me.

All hail captain duncel.
Offline  
Old 10-02-2007, 03:11 AM   #2 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

timing would go with a thread.sleep maybe, just no clue how long a play tune method would take, maybe take a second thread for that and just notify it.
how to play tunes is explained in the developers guide pdfs.

hth,
simon
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 10-02-2007, 03:07 PM   #3 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

you also can consider java.util.Timer and its method scheduleAtFixedRate()
Offline  
Old 10-02-2007, 04:41 PM   #4 (permalink)
New Member
 
Join Date: Jul 2007
Model: 7100
PIN: N/A
Carrier: rogers
Posts: 10
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default ou est developers guide pdfs.

ok found the rim developers guide.
not very helpfull as the word sound or play doesn't apear to be in it. Display shows up all over the place but no play.
tune isn't there. Nore is tone.
So while I can get a timer kinda of thing going I have no sound.
I miss the Beep of C++. Beep(freq, duration); easy peasy.

Last edited by baash05 : 10-02-2007 at 04:56 PM.
Offline  
Old 10-03-2007, 12:37 AM   #5 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think net.rim.device.api.system.Alert and its methods startAudio()/stopAudio() will help you.
There are examples for it in developers guide pdf and in JDE samplea - search for startAudio there.
Offline  
Old 10-03-2007, 08:24 PM   #6 (permalink)
New Member
 
Join Date: Jul 2007
Model: 7100
PIN: N/A
Carrier: rogers
Posts: 10
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default The sample was awesome

I ended up using the sample. It worked great.

C:\Program Files\Research In Motion\BlackBerry JDE 4.1.0\samples\com\rim\samples\device\notifications demo

So here's a smidge of a question as a follow up.
Do you know if this would work on a cell phone?
Offline  
Old 10-04-2007, 01:06 AM   #7 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

No, since net.rim.device.api.system.Alert - is blackberry-only API.

You need to use JSR-135 (MMAPI) there. Actually you can use MMAPI on blackberry too, but it seems to me that net.rim.device.api.system.Alert is simpler to use.

See javadoc for javax.microedition.media package for samples.
Offline  
Old 10-04-2007, 08:51 PM   #8 (permalink)
New Member
 
Join Date: Jul 2007
Model: 7100
PIN: N/A
Carrier: rogers
Posts: 10
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks all..
I own an 8830. when I ran the app something very odd happened.
The sound was infact produced, BUT...
It was as if it produced it through the "PC" speakers of the device. Like it uses a different audio driver. I was hoping to be able to have the app play the sound through the earphones. That and it played the sound crazy quitely. I had to hold the BB to my ear to hear anything. Not handy if I'm using it as a metronome and trying to play the guitar.
The tuner mic might not work. Though I'm not sure why.. But for now I'd be happy with an earphone-able metronome.

private int startSound()
{
double bpm = (double)(m_list.getCurSel() * 2 + START_TEMP);
bpm = (60/bpm)*1000;
bpm -= (float)dpause;//allow for the rest

for(int x = 0; x < COUNT; x+=4)
{
TUNE[x+0] = C;
TUNE[x+1] = dpause;
TUNE[x+2] = 0;//FOR THE REST
TUNE[x+3] = (short)bpm;
}

net.rim.device.api.system.Alert.startAudio(TUNE, VOLUME);

return (int)bpm;

}

Is there an sdk for the JSR-135 (MMAPI). A dev tool for these platforms?

Last edited by baash05 : 10-04-2007 at 09:09 PM.
Offline  
Old 10-05-2007, 12:36 AM   #9 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

no special sdk. JSR-135 is just javax.microedition.media package - it is part of MIDP 2.0 and is included in JDE. You can see samples either in its javadoc or in WTK.
Offline  
Old 10-05-2007, 03:58 PM   #10 (permalink)
New Member
 
Join Date: Jul 2007
Model: 7100
PIN: N/A
Carrier: rogers
Posts: 10
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Any thoughts on the "where's the sound comming from" issue?
I'm going to dig about the midlet samples and see how hard it's to make sound.
Any good books out there. I've got a few already but nothing seems to deal direclty with sound..
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.