Posts Tagged ‘j2me’

Audio support in J2ME and J2SE

So I’d like to capture some audio using a Java program, and play it back using a different Java program. I don’t care what encoding I use. Easy, right?

No, unfortunately not. Because the recording is to be done using J2ME (and JSR-135) on a mobile phone… but played back with a J2SE application on my desktop PC.

And guess what? There isn’t a single common codec! My phone only supports AMR, but the Java Media Framework supports everything but.

FFS! :(

Tags: , , , , ,
Filed under tech : Comments (0) : Sep 14th, 2008

Extreme Tips for Unmaintainable MIDlets

I stumbled on a blog post containing “Extreme Tips for Lightning-Fast MIDlets“. Let’s look at some of these programming gems:

Avoid synchronization when possible

Mmm, okay. Don’t know about you, but I synchronize code only when I need it. Perhaps the author of this article likes to synchronize on a whim? Not me…

Array-spreading

Example:

// Before
int[][] table; // a 4×4 table

// After
int[] table; // a 1×16 table

WTF?! Let’s look at the pros and cons of this:

Pros:

  • marginally quicker

Cons:

  • extra computation needed to find the correct array element, if the data structure is supposed to model multi-dimensional data. Espcially relevant if the number of the items in the first dimension isn’t fixed at compile-time
  • yields code which is more difficult to maintain. Associated risk of introducing bugs

Read the rest of this entry »

Tags: ,
Filed under tech : Comments (0) : Aug 5th, 2008