Link to home
Start Free TrialLog in
Avatar of Rashimus
Rashimus

asked on

Convert WAV to MP3 in J2ME or other compressed format!!!

Hi all,

I have created an audio capture player within my MIDlet using:

player = Manager.createPlayer("capture://audio");

I am then recording using the RecordControl object that is obtainable from the player. As default it is recording using a sample rate of 44khz. This creates very large *.wav files. (is itr possible to change this sample rate?)

These files are too large and i need them to be smaller, therefore i need to compress them, possibly into MP3.

(Average wav size = 2meg, required file size less than 400k)

Either that or something smaller, which i can then make back into a WAVE at my ASP Side.

Has anybody solved this problem before.

Help will be very greatfully appreciated.

Thanks

Rashel
Avatar of schalow
schalow

Should your OEM device *always* default to a high format rate use this function:

private RateControl getRateControl()
{
   return (RateControl) player.getControl("RateControl");
}

then try and set the rate against the capture player...

RateControl rtc = getRateControl();
rtc.setRate(int rate);


Works well with my large-scale TTS/Reco implementation processing many-to-many formats for devices that support WAV, AU, GSM, MP3 in conjunction w/back-end services.  (Also works via JMF and applets for J2SE/JDK1.1.)  For more on this, here's an article (incl. function models) for a media brokering approach I wrote published at the Australian Developer's Magazine this year (should be in the U.S. at WDJ soon):

http://developer.net.au/features/articles/article+j2me+media+for+the+enterprise1.asp

Hope this helps.

Dale Schalow
AMN Corporation (USA)
+1 301.496.5120
dale@a-m-n.com
http://a-m-n.com


Avatar of Rashimus

ASKER

Hi,

As i am using "capture://audio" as the player type, when i try and get a RateControl from it, it is null.

Will i be able to get this RateControl a different way or will i be able to set the rate via my RecordControl.

Thanks.
From an audio engineering perspective, you can do some interesting things with rate control in general.  For the JSR's MIDP spec. work RateControl (interface) was probably viewed more as a precise way to toggle "player rate" of a stream.  For that matter, pitch control (I believe the PitchControl interface class) can also bend frequencies for audio samples & MIDI as such (Hey, it sounds like Mickey Mouse -or- Hey, it sounds like it's in slow-motion).  More like adjusting "player speed"... In any event, setting a rate can also shape sound based from its sample rate.

Nothing *documented* for RecordControl indicates an easy approach for setting a capture sampling rate (but hey, it's an interface so anything's possible, right?).

My tests have revealed mostly 22kHz in emulation and below for OEM devices. Since I'm assuming you're using an Emulator (or maybe not) here's some recent MIDP 2.0 info regarding emulation support for all audio formats (ref. <WTK 2.0 home>\docs\BasicCustomizationGuide_HTML\ch_creating-property-files.html):

=============

The Emulator supports all sound file formats currently supported by JDK1.4:

Audio file formats: AIFF, AU and WAV
Music file formats: MIDI Type 0, MIDI Type 1, and Rich Music Format (RMF)
Sound formats: 8-bit and 16-bit audio data, in mono and stereo, with sample rates from 8 kHz to 48 kHz
Linear, A-law, and mu-law encoded data in any of the supported audio file formats

=============

To incorporate MP3 you'll need to address at a codec level (i.e. covert from PCM/Wav).  I seem to recall a WTK I looked at a couple months ago that delivered JMF with it most likely for these purposes (among others).  JMFRegistry can give you more info on this.

Dale

Dale Schalow
AMN Corporation (USA)
+1 301.496.5120
dale@a-m-n.com
http://a-m-n.com
ASKER CERTIFIED SOLUTION
Avatar of schalow
schalow

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial