Re: High latency in PtII javasound library

2008-02-02 Thread Christopher Brooks
Hi JS,
Edward created ptolemy/actor/lib/javasound/ClipPlayer.java, which
plays a sound file.  This actor is in the CVS tree, it is not
yet released.  The DE demo RealTimeComposite uses ClipPlayer.
See http://chess.eecs.berkeley.edu/ptexternal for CVS access.

However, it sounds like you want to play audio data directly, not
files.

Ptolemy II does includes an interface to the Java Media Framework
(JMF), see ptolemy.actor.lib.jmf.  There is an AudioPlayer actor 
in the jmf file.

The C codegen interface also has an interface to SDL, so that can 
be used to generate sound.  You could also use the EmbeddedC actor
to call the C based SDL from Java.

One thing to look at with AudioPlayer is how large chunks of audio
data are that you are passing around.  Try changing the transferSize
of AudioPlayer and see how that works for you.

_Christopher



Hi,

I'm trying to build an application with PtII that can:
1- read audio files
2- extract raw information (ie. amplitude) to control something else 
(like, say, the intensity of a light or the saturation of a video)
3- play the file

I can do (1) and (2) pretty easily with the AudioReader actor BUT if I 
plug it into the AudioPlayer the sound output is really poor. Even with 
this very simple app (AudioReader - AudioPlayer) I can hear clicks 
indicating a poor latency (and unacceptable for a media application).

Christopher pointed out a long time ago that the C codegen facility had 
an interface to Simple DirectMedia Layer. Could that be a solution? What 
about JMF?

-- 
J. S. Senécal
http://drone.ws


---
   -
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]



Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]


Re: High latency in PtII javasound library

2008-02-02 Thread JS

Hi Christopher,

Thanks for the quick answer. Yes, as you say, I want to be able to do at 
least simple sound filtering (ie. have the sound pass through a set of 
filters and getting a good output).

I have tried changing the transfer size but it doesn't seem to help at all.

From earlier tests I had found out that even for a very straightforward 
script using Javasound, the required buffer size is pretty high (2048 on 
a Mac iBook G4) (see 
https://lethe.koumbit.net/trac/drone/wiki/DevNotes/SwitchingToJava#Lowlatencyissues). 
We were able to achieve a much more acceptable performance (buffer size 
= 64) using the JASS library (see http://www.cs.ubc.ca/~kvdoel/jass/). I 
think this is the key, so I'll try to reimplement using JASS instead.


++ js

Christopher Brooks wrote:

Hi JS,
Edward created ptolemy/actor/lib/javasound/ClipPlayer.java, which
plays a sound file.  This actor is in the CVS tree, it is not
yet released.  The DE demo RealTimeComposite uses ClipPlayer.
See http://chess.eecs.berkeley.edu/ptexternal for CVS access.

However, it sounds like you want to play audio data directly, not
files.

Ptolemy II does includes an interface to the Java Media Framework
(JMF), see ptolemy.actor.lib.jmf.  There is an AudioPlayer actor 
in the jmf file.


The C codegen interface also has an interface to SDL, so that can 
be used to generate sound.  You could also use the EmbeddedC actor

to call the C based SDL from Java.

One thing to look at with AudioPlayer is how large chunks of audio
data are that you are passing around.  Try changing the transferSize
of AudioPlayer and see how that works for you.

_Christopher



Hi,

I'm trying to build an application with PtII that can:

1- read audio files
2- extract raw information (ie. amplitude) to control something else 
(like, say, the intensity of a light or the saturation of a video)

3- play the file

I can do (1) and (2) pretty easily with the AudioReader actor BUT if I 
plug it into the AudioPlayer the sound output is really poor. Even with 
this very simple app (AudioReader - AudioPlayer) I can hear clicks 
indicating a poor latency (and unacceptable for a media application).

Christopher pointed out a long time ago that the C codegen facility had 
an interface to Simple DirectMedia Layer. Could that be a solution? What 
about JMF?

-- 
J. S. Senécal

http://drone.ws


---

   -
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]



Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]

  



--
J. S. Senécal
http://drone.ws



Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]


Re: High latency in PtII javasound library

2008-02-02 Thread JS

Hi,

I just ran through my emails and there are actually a few issues with 
JASS. First, it does not any longer uses the original native library 
that they developed...  it uses Javasound. So it just won't help. Also, 
they have a strange license, not FreeBSD, not GPL, so, doesn't look that 
good after all.


I'm not sure what you mean by C code generation. Are you referring to 
building a native library?


Thanks,

++ js

Edward A. Lee wrote:

Yes, I've been frustrated by this as well...
Unfortunately, Christopher's suggestion of changing the transferSize
of AudioPlayer hasn't ever solved the problem for me...

JASS looks promising... Please let us know if you make
progress here. However, I suspect that to get really
reliable performance, C code generation is probably the only
really effective way to do this effectively...

Edward

At 09:51 AM 2/2/2008, JS wrote:
  

Hi,

I'm trying to build an application with PtII that can:
1- read audio files
2- extract raw information (ie. amplitude) to control something else (like, 
say, the intensity of a light or the saturation of a video)
3- play the file

I can do (1) and (2) pretty easily with the AudioReader actor BUT if I plug it into the 
AudioPlayer the sound output is really poor. Even with this very simple app (AudioReader 
- AudioPlayer) I can hear clicks indicating a poor latency (and unacceptable 
for a media application).

Christopher pointed out a long time ago that the C codegen facility had an 
interface to Simple DirectMedia Layer. Could that be a solution? What about JMF?

--
J. S. Senécal
http://drone.ws



Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]



 
Edward A. Lee

Chair of EECS and Robert S. Pepper Distinguished Professor
231 Cory Hall, UC Berkeley, Berkeley, CA 94720-1770
phone: 510-642-0253, fax: 510-642-2845
[EMAIL PROTECTED], http://www.eecs.berkeley.edu/Faculty/Homepages/lee.html  



  



--
J. S. Senécal
http://drone.ws



Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]


Re: High latency in PtII javasound library

2008-02-02 Thread JS

Hi Christopher,

I am pretty confident that the basic issue at hand here is latency in 
the sound playback. I have had the same problem in the past with 
captured audio in fact. Java Sound clearly sucks when it comes to audio 
playback/latency. I have read that this was fixed in Java 5, but 
apparently not on Mac OS X from what I have read.


I have been successfully using the Portaudio library [1] in the past and 
I have just found out there is a java binding project on Google Code 
called JPAB [2]. I am pretty confident that this approach would work on 
any platform.


As for Metronome, this is another set of issues that go beyond audio 
only, it's the issue of real-time applications. And the main problem for 
now is that there are no open-source implementations of the RTSJ 
available yet.


[1] http://portaudio.com
[2] http://code.google.com/p/jpab/

Christopher Brooks wrote:

Hi JS,
Ptolemy can generate C code in various ways:
1) Take a regular Java model, generate C code for the entire model.
  This is what we usually do with code generation.

2) Take a regular Java model, generate C code for only certain actors.
  This is uses Gang Zhou's EmbeddedC actor.

3) Take a regular Java model, generate C code for the model (like #1),
  but call some Java code from the C code.  We do this for the Java
  Plotter.  We could try calling the SDL C code directly.

I think the problem with #3 is that we will face the same issues that
javasound faces.  It might be interesting to get the Java source and
see if we can see how the javasound interface works.  Perhaps there is
something in the javasound implementation that is optimized for large
files.

Another idea is to profile the model and see where the time is being
spent.  Looking at various real-time java implementations might be of
interest.

You might also look at David Bacon's work at IBM on Harmonicon:
http://domino.research.ibm.com/comm/research_projects.nsf/pages/metronome.harmonicon.html

Harmonicon uses Metronome, which is a real time GC:
http://domino.research.ibm.com/comm/research_projects.nsf/pages/metronome.index.html

We intend to do some work in the area of audio, as it is very easy
for a human to tell when something is wrong.

_Christopher





Hi,

I just ran through my emails and there are actually a few issues with 
JASS. First, it does not any longer uses the original native library 
that they developed...  it uses Javasound. So it just won't help. Also, 
they have a strange license, not FreeBSD, not GPL, so, doesn't look that 
good after all.

I'm not sure what you mean by C code generation. Are you referring to 
building a native library?

Thanks,

++ js

Edward A. Lee wrote:

 Yes, I've been frustrated by this as well...
 Unfortunately, Christopher's suggestion of changing the transferSize
 of AudioPlayer hasn't ever solved the problem for me...

 JASS looks promising... Please let us know if you make
 progress here. However, I suspect that to get really
 reliable performance, C code generation is probably the only
 really effective way to do this effectively...

 Edward

 At 09:51 AM 2/2/2008, JS wrote:
   
 Hi,


 I'm trying to build an application with PtII that can:
 1- read audio files
 2- extract raw information (ie. amplitude) to control something else (li
   ke, say, the intensity of a light or the saturation of a video)
 3- play the file

 I can do (1) and (2) pretty easily with the AudioReader actor BUT if I p
   lug it into the AudioPlayer the sound output is really poor. Even with this 
   very simple app (AudioReader - AudioPlayer) I can hear clicks indicating 
   a poor latency (and unacceptable for a media application).


 Christopher pointed out a long time ago that the C codegen facility had 
   an interface to Simple DirectMedia Layer. Could that be a solution? What abo

   ut JMF?

 -- 
 J. S. Senécal

 http://drone.ws


 
   
 Posted to the ptolemy-hackers mailing list.  Please send administrative
 mail for this list to: [EMAIL PROTECTED]
 

  
 Edward A. Lee

 Chair of EECS and Robert S. Pepper Distinguished Professor
 231 Cory Hall, UC Berkeley, Berkeley, CA 94720-1770
 phone: 510-642-0253, fax: 510-642-2845
 [EMAIL PROTECTED], http://www.eecs.berkeley.edu/Faculty/Homepages/lee
   .html  



   


-- 
J. S. Senécal

http://drone.ws


---

   -
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]


  



--
J. S. Senécal
http://drone.ws