no reply?
On Apr 10, 10:14 am, Anil <[EMAIL PROTECTED]> wrote:
> *bump*
>
> On Apr 9, 8:40 pm, Anil <[EMAIL PROTECTED]> wrote:
>
> > can any of the google engineers assigned to the codecs help?
>
> > On Apr 9, 1:34 pm, Anil <[EMAIL PROTECTED]> wrote:
>
> > > *bump*
>
> > > On Apr 9, 9:43 am, Anil <[EMAIL PROTECTED]> wrote:
>
> > > > I am trying to figure out how to play a JSpeex encoded audio file on
> > > > android but am stuck.
>
> > > > Speex or JSpeex (the Java implementation) is royalty free and is well
> > > > suited to voice applications. It provides as much compression as mp3.
> > > > Apparently it will be implemented in
> > > > android:http://code.google.com/p/android/issues/detail?id=354&can=4&colspec=I...
>
> > > > the project page is
> > > > herehttp://sourceforge.net/project/showfiles.php?group_id=84548
>
> > > > I am trying to figure out how to fit it into the android calls
>
> > > > MediaPlayer mp = new android.media.MediaPlayer();
> > > > mp.setDataSource("/data/data/com.jo.blockpad/files/jo-russkelly_files/
> > > > 2-0.spx");
> > > > mp.prepare();
> > > > mp.start();
>
> > > > Any help appreciated.
> > > > thanks,
> > > > Anil
>
> > > > -------------------------------------------------
> > > > calling it from Java Sound example
> > > > --------------------------------------------------
>
> > > > import java.io.IOException;
> > > > import java.net.URL;
> > > > import java.util.Observable;
> > > > import java.util.Observer;
>
> > > > import javax.sound.sampled.AudioFormat;
> > > > import javax.sound.sampled.AudioInputStream;
> > > > import javax.sound.sampled.AudioSystem;
> > > > import javax.sound.sampled.DataLine;
> > > > import javax.sound.sampled.LineEvent;
> > > > import javax.sound.sampled.LineListener;
> > > > import javax.sound.sampled.LineUnavailableException;
> > > > import javax.sound.sampled.Mixer;
> > > > import javax.sound.sampled.SourceDataLine;
> > > > import javax.swing.JOptionPane;
>
> > > > /**
> > > > * Audio playing code has been adapted from Matthias Pfisterer's
> > > > * AudioPlayer.java
> > > > *
> > > > * Anil
> > > > */
>
> > > > private MyObservable observable = new MyObservable();
>
> > > > private static int DEFAULT_EXTERNAL_BUFFER_SIZE = 128000;
>
> > > > int nExternalBufferSize = DEFAULT_EXTERNAL_BUFFER_SIZE;
>
> > > > int nInternalBufferSize = AudioSystem.NOT_SPECIFIED;
>
> > > > boolean bForceConversion = false;
>
> > > > private static boolean DEBUG = false;
>
> > > > SourceDataLine line = null;
>
> > > > private Object snippet = null;
>
> > > > public void playClip(String urlStr) throws Exception {
> > > > // important - otherwise skim() will fail to move to
> > > > the next node
> > > > this.snippet = snippetRef;
>
> > > > /**
> > > > * Flag for forcing a conversion. If set to true, a
> > > > conversion of
> > > > the
> > > > * AudioInputStream
> > > > (AudioSystem.getAudioInputStream(...,
> > > > * AudioInputStream)) is done even if the format of the
> > > > original
> > > > * AudioInputStream would be supported for
> > > > SourceDataLines directly.
> > > > * This flag is set by the command line options "-E"
> > > > and "-S".
> > > > */
> > > > boolean bForceConversion = false;
>
> > > > /**
> > > > * Endianess value to use in conversion. If a
> > > > conversion of the
> > > > * AudioInputStream is done, this values is used as
> > > > endianess in the
> > > > * target AudioFormat. The default value can be altered
> > > > by the
> > > > command
> > > > * line option "-B".
> > > > */
> > > > boolean bBigEndian = false;
>
> > > > /**
> > > > * Sample size value to use in conversion. If a
> > > > conversion of the
> > > > * AudioInputStream is done, this values is used as
> > > > sample size in
> > > > the
> > > > * target AudioFormat. The default value can be altered
> > > > by the
> > > > command
> > > > * line option "-S".
> > > > */
> > > > int nSampleSizeInBits = 16;
>
> > > > String strMixerName = null;
>
> > > > int nExternalBufferSize = DEFAULT_EXTERNAL_BUFFER_SIZE;
>
> > > > int nInternalBufferSize = AudioSystem.NOT_SPECIFIED;
>
> > > > AudioInputStream audioInputStream = null;
> > > > URL url = new URL(urlStr);
> > > > audioInputStream = AudioSystem.getAudioInputStream(url);
> > > > if (DEBUG)
> > > > out("AudioPlayer.main(): primary AIS: " +
> > > > audioInputStream);
>
> > > > /*
> > > > * From the AudioInputStream, i.e. from the sound file,
> > > > we fetch
> > > > * information about the format of the audio data.
> > > > These information
> > > > * include the sampling frequency, the number of
> > > > linkSnippets and
> > > > the
> > > > * size of the samples. These information are needed to
> > > > ask Java
> > > > Sound
> > > > * for a suitable output line for this audio stream.
> > > > */
> > > > AudioFormat audioFormat = audioInputStream.getFormat();
> > > > if (DEBUG)
> > > > out("AudioPlayer.main(): primary format: " +
> > > > audioFormat);
> > > > DataLine.Info info = new
> > > > DataLine.Info(SourceDataLine.class,
> > > > audioFormat,
> > > > nInternalBufferSize);
> > > > boolean bIsSupportedDirectly =
> > > > AudioSystem.isLineSupported(info);
> > > > if (!bIsSupportedDirectly || bForceConversion) {
> > > > AudioFormat sourceFormat = audioFormat;
> > > > AudioFormat targetFormat = new
> > > > AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
> > > > sourceFormat.getSampleRate(),
> > > > nSampleSizeInBits, sourceFormat
> > > > .getChannels(),
> > > > sourceFormat.getChannels()
> > > > *
> > > > (nSampleSizeInBits / 8), sourceFormat.getSampleRate(),
> > > > bBigEndian);
> > > > if (DEBUG) {
> > > > out("AudioPlayer.main(): source format:
> > > > " + sourceFormat);
> > > > out("AudioPlayer.main(): target format:
> > > > " + targetFormat);
> > > > }
> > > > audioInputStream =
> > > > AudioSystem.getAudioInputStream(targetFormat,
> > > > audioInputStream);
> > > > audioFormat = audioInputStream.getFormat();
> > > > if (DEBUG)
> > > > out("AudioPlayer.main(): converted AIS:
> > > > " + audioInputStream);
> > > > if (DEBUG)
> > > > out("AudioPlayer.main(): converted
> > > > format: " + audioFormat);
> > > > }
>
> > > > line = getSourceDataLine(strMixerName, audioFormat,
> > > > nInternalBufferSize);
> > > > if (line == null) {
> > > > out("AudioPlayer: cannot get SourceDataLine for
> > > > format " +
> > > > audioFormat);
> > > > JOptionPane.showMessageDialog(null,
> > > > "AudioPlayer: cannot get
> > > > SourceDataLine for format", "Cannot
> > > > play",
> > > > JOptionPane.ERROR_MESSAGE);
> > > > return;
> > > > }
> > > > if (DEBUG)
> > > > out("AudioPlayer.main(): line: " + line);
> > > > if (DEBUG)
> > > > out("AudioPlayer.main(): line format: " +
> > > > line.getFormat());
> > > > // Anil
>
> > > > line.addLineListener(new LineListener() {
>
> > > > public void update(LineEvent event) {
> > > > System.out.println("update().
> > > > SpeechPlayer LineListener. " +
> > > > event.getLine() + " "
> > > > + event.getType());
> > > > // we want to notify only on the
> > > > events: when clip runs out, and
> > > > // when forcibly stopped.
> > > > // ie. the STOP event. Otherwise the
> > > > application will hang if
> > > > // the blocking array is full.
> > > > // Anil 01/24/2006
> > > > if (event.getType() ==
> > > > LineEvent.Type.STOP) {
> > > > observable.setChanged();
> > > >
> > > > System.out.println("SpeechPlayer. About to notify "
> > > > +
> > > > observable.countObservers()
> > > > + " observers
> > > > regarding line event STOP.");
> > > >
> > > > observable.notifyObservers(snippet);
> > > > }
> > > > }
>
> > > > });
>
> > > > /*
> > > > * Still not enough. The line now can receive data, but
> > > > will not
> > > > pass
> > > > * them on to the audio output device (which means to
> > > > your sound
> > > > card).
> > > > * This has to be activated.
> > > > */
> > > > line.start();
>
> > > > /*
> > > > * Ok, finally the line is prepared. Now comes the real
> > > > job: we have
> > > > to
> > > > * write data to the line. We do this in a loop. First,
> > > > we read data
> > > > * from the AudioInputStream to a buffer.
>
> ...
>
> read more ยป
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---