gordonfreeman
gordonfreeman

Reputation: 49

Real time audio analysis on java me with mmapi

I'm trying to write an app that uses the mmapi protocol do analyse the volume of sound coming from the microphone, all it needs to do is detect the audio level coming in from the microphone and display this in real time.

I'm using RecordControl and it seems you have to stopthe stream before any data is written to the buffer. I've tried creating a thread which records very short bursts of audio of 20-40 ms but it is far too slow. There is way to much overhead when starting and stopping the stream for this to be a viable solution.

 Player recordPlayer = Manager.createPlayer("capture://audio");
            recordPlayer.realize();
            RecordControl recordControl = (RecordControl) recordPlayer.getControl("RecordControl");
            output = new ByteArrayOutputStream();
            recordControl.setRecordStream(output);
            recordPlayer.start();
            recordControl.startRecord();

            while(running)
            {

                if (recordPlayer != null) 
                {
                    Thread.sleep(25);

                    // Nothing here??
                    byte []data = output.toByteArray();
                }
            }

            recordPlayer.stop();
            recordControl.stopRecord();
            recordControl.commit();

Upvotes: 1

Views: 111

Answers (0)

Related Questions