setting latency in JSyn to avoid glitches

View: New views
9 Messages — Rating Filter:   Alert me  

setting latency in JSyn to avoid glitches

by music.columbia.edu - JSyn mailing list :: Rate this Message:

| View Threaded | Show Only this Message

Nick found that the new Pure Java JSyn was using a latency value that
was too optimistic. We both had glitching on Windows 7 under Eclipse.

I changed the default output latency for Windows from 30 to 80 msec.

You can tune the latency for your application. Use a low latency value
for highly interactive applications like drums. But if latency is too
low you will hear glitching.  For non-interactive apps or apps with slow
controls use a higher latency to avoid glitching. Windows will require
higher latency than Mac or Linux.

Suggested output latency:
Mac Linux:  20 - 50
Windows: 70 - 150

It is hard to predict the proper latency for any given situation. Use
whatever works for you.

The device drivers may not allow you to set an exact latency. But you
can "suggest" a latency value. To set the suggestedOutputLatency with
the new API with Pure Java JSyn use:

// Create a context for the synthesizer.
synth = JSyn.createSynthesizer();

// Set output latency to 123 msec.
synth.getAudioDeviceManager().setSuggestedOutputLatency( 0.123 );

// Start the synthesiser using the suggested latency.
synth.start();


In the old API use:

synthContext = new SynthContext();
synthContext.initialize();
synthContext.setSuggestedOutputLatency( 0.123 );

Phil Burk
---------------------------------------
SoftSynth, Audio Research and Development
http://www.softsynth.com/
75 Pleasant Lane, San Rafael, CA, 94901 USA
Office/Fax: +1-415-453-4320
Mobile: +1-415-846-4370
---------------------------------------
_______________________________________________
JSyn mailing list
JSyn@...
To change digest mode or to make other administrative changes visit:
http://music.columbia.edu/mailman/listinfo/jsyn

Re: setting latency in JSyn to avoid glitches

by music.columbia.edu - JSyn mailing list :: Rate this Message:

| View Threaded | Show Only this Message

Thanks Phil

I can report that the following test gets rid of the glitching when run
from Eclipse! For me, Output Latency threshold is about 0.70. Anything
below this gives be a glitchy sine tone

But is there any way to do this using the global Synth.startEngine()?
None of my existing codebase uses SynthContext, so using this solution
will require a pretty big rewrite.

Thanks
Nick Didkovsky

public class TestJSyn extends java.applet.Applet {

     SineOscillator osc;
     LineOut out;
     SynthContext synthContext;

     public void start() {
//        Synth.startEngine(0);

         synthContext = new SynthContext();
         synthContext.initialize();
         synthContext.setSuggestedOutputLatency( 0.070 ); // clean !!!
         synthContext.startEngine(0);

         osc = new SineOscillator(synthContext);
         osc.start();
         out = new LineOut(synthContext);
         out.start();
         osc.output.connect(out.input);
     }

     public void stop() {
         synthContext.stopEngine();
     }
}

On 6/20/2011 3:14 PM, jsyn@... wrote:

> Nick found that the new Pure Java JSyn was using a latency value that
> was too optimistic. We both had glitching on Windows 7 under Eclipse.
>
> I changed the default output latency for Windows from 30 to 80 msec.
>
> You can tune the latency for your application. Use a low latency value
> for highly interactive applications like drums. But if latency is too
> low you will hear glitching.  For non-interactive apps or apps with slow
> controls use a higher latency to avoid glitching. Windows will require
> higher latency than Mac or Linux.
>
> Suggested output latency:
> Mac Linux:  20 - 50
> Windows: 70 - 150
>
> It is hard to predict the proper latency for any given situation. Use
> whatever works for you.
>
> The device drivers may not allow you to set an exact latency. But you
> can "suggest" a latency value. To set the suggestedOutputLatency with
> the new API with Pure Java JSyn use:
>
> // Create a context for the synthesizer.
> synth = JSyn.createSynthesizer();
>
> // Set output latency to 123 msec.
> synth.getAudioDeviceManager().setSuggestedOutputLatency( 0.123 );
>
> // Start the synthesiser using the suggested latency.
> synth.start();
>
>
> In the old API use:
>
> synthContext = new SynthContext();
> synthContext.initialize();
> synthContext.setSuggestedOutputLatency( 0.123 );
>
> Phil Burk
> ---------------------------------------
> SoftSynth, Audio Research and Development
> http://www.softsynth.com/
> 75 Pleasant Lane, San Rafael, CA, 94901 USA
> Office/Fax: +1-415-453-4320
> Mobile: +1-415-846-4370
> ---------------------------------------
> _______________________________________________
> JSyn mailing list
> JSyn@...
> To change digest mode or to make other administrative changes visit:
> http://music.columbia.edu/mailman/listinfo/jsyn
_______________________________________________
JSyn mailing list
JSyn@...
To change digest mode or to make other administrative changes visit:
http://music.columbia.edu/mailman/listinfo/jsyn

Re: setting latency in JSyn to avoid glitches

by music.columbia.edu - JSyn mailing list :: Rate this Message:

| View Threaded | Show Only this Message


 > But is there any way to do this using the global Synth.startEngine()?

Yes. Try this:

Synth.initialize(); // create a shared context

Synth.getSharedContext().setSuggestedOutputLatency( 0.070 );

Synth.start( 0, 44100 );



Phil Burk
_______________________________________________
JSyn mailing list
JSyn@...
To change digest mode or to make other administrative changes visit:
http://music.columbia.edu/mailman/listinfo/jsyn

JSyn beta 16.4.3 posted

by music.columbia.edu - JSyn mailing list :: Rate this Message:

| View Threaded | Show Only this Message

I just posted a new JSyn Beta with:

* default output latency of 80 msec for Windows

* improved AudioScope with autoScaling

* JAR file is now a double-clickable "About JSyn" app that shows the
version #.

http://www.jsyn.com/jsyn/beta/

Phil Burk

_______________________________________________
JSyn mailing list
JSyn@...
To change digest mode or to make other administrative changes visit:
http://music.columbia.edu/mailman/listinfo/jsyn

Re: setting latency in JSyn to avoid glitches

by music.columbia.edu - JSyn mailing list :: Rate this Message:

| View Threaded | Show Only this Message

Thanks!  Tried it and it works great
nick

On 6/20/2011 4:49 PM, jsyn@... wrote:

>   >  But is there any way to do this using the global Synth.startEngine()?
>
> Yes. Try this:
>
> Synth.initialize(); // create a shared context
>
> Synth.getSharedContext().setSuggestedOutputLatency( 0.070 );
>
> Synth.start( 0, 44100 );
>
>
>
> Phil Burk
> _______________________________________________
> JSyn mailing list
> JSyn@...
> To change digest mode or to make other administrative changes visit:
> http://music.columbia.edu/mailman/listinfo/jsyn
_______________________________________________
JSyn mailing list
JSyn@...
To change digest mode or to make other administrative changes visit:
http://music.columbia.edu/mailman/listinfo/jsyn

Re: JSyn beta 16.4.3 posted

by music.columbia.edu - JSyn mailing list :: Rate this Message:

| View Threaded | Show Only this Message

Phil

Big question.
Does it work on Android?

Hope you are well!

Patrick Pagano
University of Florida


On 6/20/11 5:19 PM, "jsyn@..." <jsyn@...>
wrote:

>I just posted a new JSyn Beta with:
>
>* default output latency of 80 msec for Windows
>
>* improved AudioScope with autoScaling
>
>* JAR file is now a double-clickable "About JSyn" app that shows the
>version #.
>
>http://www.jsyn.com/jsyn/beta/
>
>Phil Burk
>
>_______________________________________________
>JSyn mailing list
>JSyn@...
>To change digest mode or to make other administrative changes visit:
>http://music.columbia.edu/mailman/listinfo/jsyn
>


_______________________________________________
JSyn mailing list
JSyn@...
To change digest mode or to make other administrative changes visit:
http://music.columbia.edu/mailman/listinfo/jsyn

Re: JSyn beta 16.4.3 posted

by music.columbia.edu - JSyn mailing list :: Rate this Message:

| View Threaded | Show Only this Message



On 6/20/11 2:26 PM, jsyn@... wrote:
> Does it work on Android?

Sorry. No.

My JSyn ToDo list, in order of priority is:

1) Implement Java wrapper for PortAudio. Implement a JSyn AudioDevice
that calls JPortAudio as an alternative to JavaSound.

2) Document new JSyn API, with tutorial. Document audio device interface.

3) Implement JSyn AudioDevice on Android as an alternative to JavaSound.

4) Implement Envelope Editor in Swing for new API.


Step (1) will pave the way for ANdroid by refining the AudioDevice
interface.

Step (2) is needed if anyone is going to make sense of the new JSyn API.

Unfortunately I am juggling several projects so it may take awhile.

Phil Burk



_______________________________________________
JSyn mailing list
JSyn@...
To change digest mode or to make other administrative changes visit:
http://music.columbia.edu/mailman/listinfo/jsyn

Re: JSyn beta 16.4.3 posted

by music.columbia.edu - JSyn mailing list :: Rate this Message:

| View Threaded | Show Only this Message

Phil,

Working great!

Regards,

Edward

On Mon, Jun 20, 2011 at 5:19 PM, jsyn@... <
jsyn@...> wrote:

> I just posted a new JSyn Beta with:
>
> * default output latency of 80 msec for Windows
>
> * improved AudioScope with autoScaling
>
> * JAR file is now a double-clickable "About JSyn" app that shows the
> version #.
>
> http://www.jsyn.com/jsyn/beta/
>
> Phil Burk
>
> ______________________________**_________________
> JSyn mailing list
> JSyn@...
> To change digest mode or to make other administrative changes visit:
> http://music.columbia.edu/**mailman/listinfo/jsyn<http://music.columbia.edu/mailman/listinfo/jsyn>
>



--
Edward Childs
+1 802 794-3589 (Best: Google Voice)
+1 603 892 9377 (Cell)
+1 508 955 9051 (Massachusetts Home)
+1 802 955 9030  (Fax)
http://blog.edwardchilds.com
_______________________________________________
JSyn mailing list
JSyn@...
To change digest mode or to make other administrative changes visit:
http://music.columbia.edu/mailman/listinfo/jsyn

Re: JSyn beta 16.4.3 posted

by music.columbia.edu - JSyn mailing list :: Rate this Message:

| View Threaded | Show Only this Message

Beta 16.4.3 works great with my tests so far.
I am also adding suggested output latency as a parameter the user can
pass the JMSL's JSynMusicDevice.
Pieces that were glitching earlier this week are now playing smoothly
with Windows 7 latency at 0.70
Thanks Phil!
Nick

On 6/20/2011 5:19 PM, jsyn@... wrote:

> I just posted a new JSyn Beta with:
>
> * default output latency of 80 msec for Windows
>
> * improved AudioScope with autoScaling
>
> * JAR file is now a double-clickable "About JSyn" app that shows the
> version #.
>
> http://www.jsyn.com/jsyn/beta/
>
> Phil Burk
>
> _______________________________________________
> JSyn mailing list
> JSyn@...
> To change digest mode or to make other administrative changes visit:
> http://music.columbia.edu/mailman/listinfo/jsyn
_______________________________________________
JSyn mailing list
JSyn@...
To change digest mode or to make other administrative changes visit:
http://music.columbia.edu/mailman/listinfo/jsyn