Oliver Rettig | 1 Dec 2011 10:24
Picon

Re: [OT] java sound

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
(Continue reading)

Alan Wolfe | 1 Dec 2011 10:34
Picon

Re: [OT] java sound

A little off topic but Chrome has a way for you to run native code safely without the user needing to install a plugin or other hoop jumping.

It limits you to Chrome but its fast and cross platform and I'm pretty sure it has an audio api that let's you mess with things at a sample level.

Might be worth checking out!

On Dec 1, 2011 1:24 AM, "Oliver Rettig" <Oliver.Rettig <at> orat.de> 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 ...

_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Alan Wolfe | 1 Dec 2011 10:50
Picon

Re: [OT] java sound

Oh and by native code I literally mean c++ compiled into executable machine code (ie not interpreted bytecodes or anything like that!)

On Dec 1, 2011 1:34 AM, "Alan Wolfe" <alan.wolfe <at> gmail.com> wrote:

A little off topic but Chrome has a way for you to run native code safely without the user needing to install a plugin or other hoop jumping.

It limits you to Chrome but its fast and cross platform and I'm pretty sure it has an audio api that let's you mess with things at a sample level.

Might be worth checking out!


>
> On Dec 1, 2011 1:24 AM, "Oliver Rettig" <Oliver.Rettig <at> orat.de> wrote:
>
> Hi Victor,
>
> there...

>
>
> > Thanks, Phil, this is very useful. I had read that JSyn was using it, so

> that is why I decided ...

_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Victor Lazzarini | 1 Dec 2011 11:32
Picon
Favicon

Re: [OT] java sound

Are you talking about NaCl, http://code.google.com/chrome/nativeclient ? Yes,  that is also on my list, but it does not appear to be as mature a technology as java & Jaws. But definitely worth considering. I think eventually I will actually work with that.

Victor
On 1 Dec 2011, at 09:50, Alan Wolfe wrote:

Oh and by native code I literally mean c++ compiled into executable machine code (ie not interpreted bytecodes or anything like that!)

On Dec 1, 2011 1:34 AM, "Alan Wolfe" <alan.wolfe <at> gmail.com> wrote:

A little off topic but Chrome has a way for you to run native code safely without the user needing to install a plugin or other hoop jumping.

It limits you to Chrome but its fast and cross platform and I'm pretty sure it has an audio api that let's you mess with things at a sample level.

Might be worth checking out!



>
> On Dec 1, 2011 1:24 AM, "Oliver Rettig" <Oliver.Rettig <at> orat.de> wrote:
>
> Hi Victor,
>
> there...


>
>
> > Thanks, Phil, this is very useful. I had read that JSyn was using it, so

> that is why I decided ...



_______________________________________________
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
Victor Lazzarini | 1 Dec 2011 12:15
Picon
Favicon

Re: [OT] java sound


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



_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Oliver Rettig | 1 Dec 2011 17:18
Picon

Re: [OT] java sound

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
John Clements | 1 Dec 2011 18:20
Gravatar

Windows buffer sizes

I've done a bit of searching through the mailing list, but five minutes didn't turn up anything relevant,
and I'm hoping this is a simple answer.

I'm using Portaudio for cross-platform development, and I'm trying to understand the behavior of the
windows engine.  In particular, when I call Pa_OpenDefaultStream at 44.1KHz sample rate with a buffer
size of 0 (a.k.a. "dear system, pick what you want"), I'm seeing that it's pulling monster chunks of 4096
frames at a time.  That means 100-200ms of latency. If I set the buffer size smaller, it appears to be just
waiting longer and then hitting the callback repeatedly to simulate a buffer size of 4K frames again. 

System info: Windows 7 32-bit, portaudio compiled without ASIO support, version string "PortAudio
V19-devel (built Jun 29 2011 14:57:25)"

Possible responses:

1) Windows 7 (32-bit) just likes big buffers. There's nothing you can do about it.
2) You need to compile with ASIO; that will make a big difference.
3) Update to a newer version of Portaudio, we solved this problem.
4) None of the above, you must be doing something else wrong.

Can someone with some expertise pick 1-4 for me?

Many thanks in advance,

John Clements

Attachment (smime.p7s): application/pkcs7-signature, 4624 bytes
_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Phil Burk | 1 Dec 2011 20:09

Re: [OT] java sound

Hello Oliver,

On 12/1/11 8:18 AM, Oliver Rettig wrote:
> 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.

Do you actually call into the Java Virtual Machine from the 'C' 
PortAudio callback?! I've always been afraid to do that. I'm worried 
about having to synchronize with Java Threads and the garbage collector 
in the callback. I don't even call malloc() from 'C' in the PortAudio 
callback.

What has been your experience? Is it a fast switch?

Phil
Bjorn Roche | 1 Dec 2011 20:50
Favicon
Gravatar

Re: [OT] java sound


On Dec 1, 2011, at 2:09 PM, Phil Burk wrote:

Hello Oliver,

On 12/1/11 8:18 AM, Oliver Rettig wrote:
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.

Do you actually call into the Java Virtual Machine from the 'C' PortAudio callback?! I've always been afraid to do that. I'm worried about having to synchronize with Java Threads and the garbage collector in the callback. I don't even call malloc() from 'C' in the PortAudio callback.

What has been your experience? Is it a fast switch?


This is getting very off-topic, but JNI is rarely discussed on the java lists, so...

The length of time this takes depends on the "calling conventions" of the particular JVM (if I am remembering the right term), and is usually longer than a C or java call, sometimes much longer, but not a "blocking" type operation. IIRC, it is about 4x longer for sun's JVM than a regular java call, but I could be totally misremembering that. It's from a long time ago, anyway, so don't assume that's right.

In another app, I effectively launch an entire second app that runs inside the first from a JNI call. Complete with threads, callbacks, system calls, Quicktime, etc. I even embed native UI components in swing. It can be done, albeit with some amount of care.

On Dec 1, 2011, at 11:18 AM, Oliver Rettig wrote:

 One advantage is 
that I can use the callback mechanism.

If you prefer callbacks on principle, or want to use javasound but might switch to PA-based callbacks, you can simply write a wrapper around javasound that calls back into your app. I believe I did this for Mantis with the intent of prepping for switching to PA.

bjorn

-----------------------------
Bjorn Roche
Audio Collaboration

Catch us at NAMM booth #1000



_______________________________________________
Portaudio mailing list
Portaudio <at> music.columbia.edu
http://music.columbia.edu/mailman/listinfo/portaudio
Oliver Rettig | 1 Dec 2011 22:35
Picon

Re: [OT] java sound

Hallo Phil,

My java code starts recording and playing auf audio by invoking portaudio api 
via JNI.

My c-code implements a portaudio-callback by invoking a java-method. It works 
fine for me and has the advantage that because of high priority of the c-
callback also my java code is invoked with the same high priority. 

Before switched to Java 7 I had some problems with gc but it looks like this 
problem is gone now. But I am always interested ideas to make it faster for 
lower latency. Do you see any better ways?

best regards
Oliver

> Hello Oliver,
> 
> On 12/1/11 8:18 AM, Oliver Rettig wrote:
> > 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.
> 
> Do you actually call into the Java Virtual Machine from the 'C'
> PortAudio callback?! I've always been afraid to do that. I'm worried
> about having to synchronize with Java Threads and the garbage collector
> in the callback. I don't even call malloc() from 'C' in the PortAudio
> callback.
> 
> What has been your experience? Is it a fast switch?
> 
> Phil
> 
> 
> _______________________________________________
> Portaudio mailing list
> Portaudio <at> music.columbia.edu
> http://music.columbia.edu/mailman/listinfo/portaudio

Gmane