Win a copy of Java Challengers this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

RTP and Java 3D sounds

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to receive RTP audio and then play it using the Java 3D sound APIs. I am sucessfully receiving the audio, but cannot get it to play through the Java 3D PointSound class.
I created a PipedOutputStream and PipedInputStream and connected those. Then I created an AudioInputStream from the PipedInputStream and set that AudioInputStream as the source for the PointSound. Below is a code snipet showing how I set this up:
pout = new PipedOutputStream();
try
{
pin = new PipedInputStream(pout);
}
catch (Exception e)
{
System.out.println("Piped input error");
}

AudioFormat af = new AudioFormat (AudioFormat.Encoding.ULAW, 8000, 8, 1, 1, 8000, true);
astream = new AudioInputStream(pin, af, 8000);

sample = new MediaContainer(astream);

sound.setContinuousEnable(false);
sound.setReleaseEnable(false);
sound.setSoundData(sample);
sound.setInitialGain(2.0f);
Point3f soundPos = new Point3f(-30.0f, 0.0f, 0.0f);
sound.setPosition(soundPos);

Then I have a Thread that accepts the RTP packets, strips off the RTP header and writes the raw audio data into the PipedOutputStream and tells the sound to start playing. What I was expecting to happen was that I was writing to the PipedOutputStream, which was the source for the sound that I wanted to play, so the sound would be read out of the stream as it was written into the stream. What actually happened is that data was written into the PipedOutputStream until the buffer was full and no sound was played.
Does anyone have any ideas if this should work?
 
We can walk to school together. And we can both read this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic