hi
I am N.chandrasekaran from India, I am a Pockect Pc application developer. Now i started developing j2me games for nokia 60 series . I developed a side scrolling game but couldn’t able to add sound to my game if i add the .wav or .mid files using conventional
methods of “getClass().getResourceAsStream(”/hai.wav");" and using input streamreader it takes a delay to play the sound even if i put this code in a seperate thread. and also takes memory for every call which ultimately let my emulator to hang. so please help me
Did you look at Forum Nokia’s MIDP 2.0 game programming example, the Sheepdog game? It uses WAVs, and seems to run fine. You can download it for free from Forum Nokia (including source code and a tutorial document).
thanks for your replay i downloaded the sheep dog example even this example keep on taking the memory for every sound call watch it in the memory monitor of sun java mobility studio 6 q3.
I don’t have Sun Java Mobility Studio. But I modified Sheepdog to display Runtime.getRuntime().freeMemory() at the top of the game screen, and it was continuously decreasing all the time, whether or not the sound effects were being played. My Series 60 phone did a garbage-collection every 20 seconds or so; my PC emulator had so much memory that it didn’t need to.
I think that creating a small number of garbage-objects is typical of Java. Even if your own code doesn’t, you’ll find that the implementation of the MIDP APIs does. As long as the phone’s garbage-collector can cope, there’s no problem. It’s not good that your emulator hangs, but have you tried your application on a real phone?
thanks for your interest but i thing there are some more problems to be realised.
I already used the System.gc(); to call the garbage collecter but amazingly it doesn’t have any effect on the memory occupied by the sound(but it works fine for the memory occupied by images and all). to day i tried your code Runtime.getRuntime().freeMemory() but it too have the same effect. since i am a beginer i may not know some other problems but if you can see that memory moniter of sun java MObility Studio you will surly realise the problem that hides in using sounds.
[quote]hi
I am N.chandrasekaran from India, I am a Pockect Pc application developer. Now i started developing j2me games for nokia 60 series . I developed a side scrolling game but couldn’t able to add sound to my game if i add the .wav or .mid files using conventional
methods of “getClass().getResourceAsStream(”/hai.wav");" and using input streamreader it takes a delay to play the sound even if i put this code in a seperate thread. and also takes memory for every call which ultimately let my emulator to hang. so please help me
[/quote]
You arn’t recreating the player each time you want to play the sound are you?
That will certainly be slow, and will likely leak memory (due to the buggy implementation of InputStreams on most series 60 phones)
did any one show me a sample code for accessing dictionary of nokia phones ???
The only dictionary in a Nokia phone would be the T9 text prediction dictionary. This is not accessible in any way from standard MIDP, and Nokia provides no proprietary API for accessing it.
If you want to use T9 in your MIDlet’s text input, you’ll have to use the standard MIDP LCDUI ‘high-level’ text controls: TextField and TextArea. If you’re creating your own, prettier text input controls using Canvas or CustomItem, I’m afraid you won’t have T9.