Jump to content
  • Advertisement
Sign in to follow this  
Voices

Sound with Nokia UI

This topic is 5449 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I'm just starting to convert games to the Nokia Series 40 phones and have been managing okay so far but there's just one thing I can't crack and that's sound! I can play a single note but can't actually getting any music on the go and the Nokia documentation isn't exactly the most helpful. Can anyone help me out or point in the direction of some good examples? Thanks, David.

Share this post


Link to post
Share on other sites
Advertisement
Ah, yes, sound on Nokia phones. I hope you like pain and agony!

Basically, check what sound formats the phone supports: the Sound.getSupportedFormats () method does this. There's two basic types: WAV and MIDI. The MIDI must be in Smart Messaging Ringtone format and the WAV should be in, well, it doesn't actually say anywhere which isn't really useful - probably a PCM format but who knows.

Oh, and don't assume the sound implementation is any good either. My 3650 occasionally makes random attempts at playing MIDI format stuff.

Skizz

Share this post


Link to post
Share on other sites
Series 60 phones support MMAPI (although there are lots of issues with the implementation), so you might want to look into that too.

The non-WAV sounds played by the Nokia UI are not really MIDI to my understanding, but a proprietary bytecode. You can create bytecode melodies/convert other data to them using the Nokia SDK.

Share this post


Link to post
Share on other sites
Cheers for the advice. Is there a way of getting the program to just play a midi file (ie like loading a ready made image)?

If not, how do I turn my little midi melody into bytecode?

Cheers,
David.

Share this post


Link to post
Share on other sites
Cheers for the advice. Is there a way of getting the program to just play a midi file (ie like loading a ready made image)?

If not, how do I turn my little midi melody into bytecode?

Cheers,
David.

Share this post


Link to post
Share on other sites
Quote:
Original post by Voices
Cheers for the advice. Is there a way of getting the program to just play a midi file (ie like loading a ready made image)?


Only on Series 60. See here for more info on making that work (the phones have particular quirks and don't let you do all the things that the MMAPI docs suggest should be possible).

On Series 40 you are SOL and will have to use bytecode:
Quote:

If not, how do I turn my little midi melody into bytecode?


Like I said, with the Nokia SDK. Load up Nokia Developer's Suite for J2ME, and use the "Audio Converter" tool.

Share this post


Link to post
Share on other sites
You can load and play an OTT file with the S40(no wavs or midis). Also about the S60, you should use Nokias own sound api, although MMAPI is supported, it's better.

Here's the code to play an OTT file:


protected void playMusic( String szFileName, int iTimes )
{

System.out.println("[ISOCANVAS::playMusic] Loading Ott File: "+szFileName);

try
{
InputStream stream = this.getClass().getResourceAsStream(szFileName);

byte[] byBuffer = new byte[1000];
stream.read(byBuffer, 0, byBuffer.length);
m_cSound = new Sound(byBuffer, Sound.FORMAT_TONE);
m_cSound.init(byBuffer, Sound.FORMAT_TONE);
m_cSound.play(iTimes);
} catch (Exception e) {}

System.out.println("[ISOCANVAS::playMusic] Playing Ott File");
}

[/quote]

You should probably store the size of the file somewhere, in that piece of code it just allocates a big chunck of memeory(that's is bigger then the file size)

/MindWipe

Share this post


Link to post
Share on other sites
Quote:
Original post by MindWipe
You can load and play an OTT file with the S40(no wavs or midis). Also about the S60, you should use Nokias own sound api, although MMAPI is supported, it's better.


If you're playing WAV or OTT, sure; but I can't find any evidence that their API will support any other sound file types... ? o_O

Quote:

Here's the code to play an OTT file:

*** Source Snippet Removed ***


The .init() call is redundant as initialization is implied by the constructor; that will throw away the sound data (as per .release() and load it again). The only real reason to use .init(), as far as I can tell, is to cut down on the total number of Sound objects you have... (e.g. have a single static Sound initialized with some dummy value at the beginning of the program, and .init() it and .play() each time you want to play a sound) I don't know how much heap that would save, but I'm not entirely convinced it would be worthwhile for most projects :
One other thing to note is that playing an OTT sound will pre-empt any already-playing OTT sound (cut it off and stop it). The behaviour is the other way around for MMAPI stuff IIRC; if the phone is busy playing something, the play request for the new sound fails.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
If you're playing WAV or OTT, sure; but I can't find any evidence that their API will support any other sound file types... ? o_O

...

The only real reason to use .init(), as far as I can tell, is to cut down on the total number of Sound objects you have... (e.g. have a single static Sound initialized with some dummy value at the beginning of the program, and .init() it and .play() each time you want to play a sound) I don't know how much heap that would save, but I'm not entirely convinced it would be worthwhile for most projects


True, I remembered that nokia's sound api supported MIDIs too. Anyway, it is recommended for ingame sound (wavs in this case) as it is faster.

And about the code, I do only have one a single Sound object.

/MindWipe

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!