[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kvm-interest
Subject:    Re: How to play audio data from a buffer
From:       Ivan Wong <Ivan.Wong () SUN ! COM>
Date:       2002-11-26 23:57:27
[Download RAW message or body]

Rick,

What you want is to use the Player API to continuously stream
audio data to the audio device.  That usage is not guaranteed
by the API.  Although it may look trivially similar to playing
back a self-contained audio file, there's additional contraints
placed on the device to being able to handle jitter buffering.
The expert group who designed the API was somewhat hesitant in
spec'ing that in.

If you like to experiment, you can try the following:

Play your continuous stream of audio as one long wav audio stream.
You'll need to implement a FIFO byte array buffer queue as an
InputStream.  Using that, you can pipe data continously into a
Player.  Next you'll need to generate a wav audio header for 8k,
8bit PCM with a long duration.  You can feed that header to your
pipe InputStream.  After that, you can directly feed the continuous
stream of PCM data to the player via the InputStream.  When it
reaches the end, return -1 from InputStream.read() to signal
end of media.

This should work with the MMAPI RI.  But again, it is not
guaranteed to work on an actual device.

Ivan Wong
Java Media Engineering
Sun Microsystems, Inc.



> Delivered-To: kvm-interest@swjscmail1.java.sun.com
> Delivered-To: kvm-interest@java.sun.com
> Date: Mon, 25 Nov 2002 20:45:31 -0700
> From: Rick Lee <hyliott@YAHOO.COM>
> Subject: Re: How to play audio data from a buffer
> To: KVM-INTEREST@JAVA.SUN.COM
>
> Sorry. The previous message is not complete and was sent out by accident. I
just repost it again:
>
> ------------------------------------
> Hi,
>   I would like to play continuous audio data from a byte array using MIDP2.0.
Assume the voice data segments are continuously read into a byte array
"audioData". The code is as following:
>
>   byte[] inBuf = new byte[256];
>   System.arraycopy(audioData, 0, inBuf, 0 128);
>   ByteArrayInputStream inStream = new ByteArrayInputStream(inBuf);
>   try {
>     Player p = Manager.creatPlayer((InputStream) inStream, "audio/x-wav");
>     p.start();
>   } catch...
>
>   My question is: How can I add new voice data segments to the inStream such
that the same player can play the voice data segments one after another?
>
> Thanks
>
> Rick
>
> --------------------------------------------------
>
>
> On Mon, 25 Nov 2002 20:04:54 -0700, Rick Lee <hyliott@YAHOO.COM> wrote:
>
> >Hi,
> >  I would like to play audio data from a byte array in MIDP2.0. The code is
as following:
> >
> >  byte[] inBuf = new byte[256];
> >  ByteArrayInputStream inStream = new ByteArrayInputStream(inBuf);
> >  try {
> >    Player p = Manager.creatPlayer((InputStream) inStream, "audio/x-wav");
> >
> > ==========================================================================
> >To unsubscribe, send email to listserv@java.sun.com and include in the body
> >of the message "signoff KVM-INTEREST".  For general help, send email to
> >listserv@java.sun.com and include in the body of the message "help".
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff KVM-INTEREST".  For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

 ==========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST".  For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic