Re: [OT] java sound
Oliver Rettig <Oliver.Rettig <at> orat.de>
2011-12-01 16:18:42 GMT
Hi Victor,
yes you can do that if you use portaudio between javasound and the hardware
and you can be sure that float representation as bytes is always the same. But
produces a lot of conversions and the intense of the javasound api is to use
explicit the bytes you get from your soundcard without conversion and that
your algorithm should work with different formats.
my workaround some years ago was that I configure portaudio that it converts
all formats to float, than that I can read it with bytebuffer as float with my
java code.
I think togehter with portmixer it should be possible to implement a complete
java sound service provider implementation. Javasound api is not too bad. But
the other possibility is to create an java api which is nearer on the
portaudio api. In my apps I use the last and it works fine. One advantage is
that I can use the callback mechanism.
best regards
Oliver
I
> Oliver,
>
> yes, that was one of my first misgivings, but I went past that when I saw
> this simple solution posted on the web:
>
> FloatBuffer floatbuffer;
>
> ByteBuffer byteBuffer = ByteBuffer.allocate(floatbuffer.capacity() * 4);
> byteBuffer.asFloatBuffer().put(floatbuffer);
> byte[] bytearray = byteBuffer.array();
>
> Victor
>
> On 1 Dec 2011, at 09:24, Oliver Rettig wrote:
> > Hi Victor,
> >
> > there are some parts of Javsound I really like, e.g. the possibility to
> > use controls works fine for me. Some years ago I have based my audioapps
> > on my own java sound impl based on portaudio via JNI. But a complete
> > implementation needs more than portaudio, e.g the portmixer lib.
> >
> > The main drawback of javasound for me is that it is based on byte[] and
> > not float[]. Thats why my audioapps now are based on a
> > portaudio-java-wrapper directly without integration as javasound service
> > provider implementation.
> >
> > best regards
> > Oliver
> >
> >> Thanks, Phil, this is very useful. I had read that JSyn was using it, so
> >> that is why I decided to consider it.
> >>
> >> Regards
> >>
> >> Victor
> >>
> >> On 30 Nov 2011, at 22:26, Phil Burk wrote:
> >>> Hello Victor,
> >>>
> >>> On 11/30/11 1:46 PM, Victor Lazzarini wrote:
> >>>> How usable is Java Sound for RT audio playback?
> >>>
> >>> JavaSound is not bad. I use it in JSyn. The JavaSound API is a bit odd
> >>> as Bjorn pointed out. For example you write output data to a
> >>> SourceDataLine and read input data from a TargetDataLine. But just
> >>> wrap the JavaSound oddness and forget about it.
> >>>
> >>> I am currently having a problem with recent versions of JavaSound on
> >>> Mac popping every few seconds. But the Windows version seems solid.
> >>>
> >>> Latency is not super low but you can adjust it. You may also need to
> >>> adjust the Java garbage collector algorithm for better real time
> >>> performance. That can be a source of glitches.
> >>>
> >>> You can play around with some JSyn examples here:
> >>> http://www.softsynth.com/jsyn/examples/
> >>>
> >>> You'll hear pops in the sine wave in the "SeeOsc" example.
> >>>
> >>> You can test latency on mouseUp in the PluckString example.
> >>>
> >>> Enjoy,
> >>> Phil Burk
> >>> _______________________________________________
> >>> Portaudio mailing list
> >>> Portaudio <at> music.columbia.edu
> >>> http://music.columbia.edu/mailman/listinfo/portaudio
> >>
> >> Dr Victor Lazzarini
> >> Senior Lecturer
> >> Dept. of Music
> >> NUI Maynooth Ireland
> >> tel.: +353 1 708 3545
> >> Victor dot Lazzarini AT nuim dot ie
> >>
> >>
> >>
> >> _______________________________________________
> >> Portaudio mailing list
> >> Portaudio <at> music.columbia.edu
> >> http://music.columbia.edu/mailman/listinfo/portaudio
> >
> > _______________________________________________
> > Portaudio mailing list
> > Portaudio <at> music.columbia.edu
> > http://music.columbia.edu/mailman/listinfo/portaudio
>
> Dr Victor Lazzarini
> Senior Lecturer
> Dept. of Music
> NUI Maynooth Ireland
> tel.: +353 1 708 3545
> Victor dot Lazzarini AT nuim dot ie