com.frinika.benchmark.audio
Class PJVoiceServer
java.lang.Object
com.frinika.voiceserver.VoiceServer
com.frinika.benchmark.audio.PJVoiceServer
- All Implemented Interfaces:
- java.lang.Runnable
public class PJVoiceServer
- extends VoiceServer
- implements java.lang.Runnable
An integration of the Voice server with the sound hardware interfaces of the java sound api.
Brief description of the latency schemes
Frinika latency schemes is more or less all about how to pause after data is processed and written to the audio output. A typical (buffer) cycle is this:
1. Process audio data
2. Write data to audioOut
3. Pause until time for processing new buffer
The pause time is the total buffer time (represented by number of samples in the buffer) minus the time used in step 1 and 2.
It's very important that the time used for all these three steps is as constant as possible, and that the total time equals the time represented by a buffer.
To obtain this constant time different "blocking" schemes are implemented, as alternative to the blocking provided by sourceDataLine.write. What scheme to use depends
on your system, try yourself and choose the scheme that is most stable. My experience is that the sdl.write blocking sometimes blocks too long, resulting in glitches.
The two main alternatives in Frinika makes sure that sd.write doesn't block at all (by setting a very large buffer size), and then takes care of the blocking manually.
- Standard latency cheme (no checkboxes checked in the audio device conf - this is the scheme that works best on most systems)
- Blocking is done using Thread.sleepNanos
- "UltraLowLatency"
- Blocking is done using a loop and Thread.yield() while measuring sdl.getLongFramePosition(), very CPU intensive, but very accurate on when it stops blocking
- "UltraLowLatency" with "Frinika estimated framepos"
- Same as above but instead of using sdl.getLongFramePosition(), Frinika calculates an ideal Frame position by measuring System.nanoTime()
- Author:
- Peter Johan Salomonsen
Field Summary |
protected boolean |
standardLatency
Use Java standard way of latency control (blocking on sdl.write) |
protected boolean |
ultraLowLatency
Ultra low latency mode can be used for small buffer sizes to obtain better latency -
BUT it eats all your CPU. |
Methods inherited from class com.frinika.voiceserver.VoiceServer |
addTransmitter, getBufferSize, getLatency, getLatencyAsFrames, getSampleRate, getTotalLatency, getTotalLatencyAsFrames, interruptTransmitter, processFinalOutput, read, read, readNonRealtime, realtimeOff, realtimeOn, removeTransmitter, setSampleRate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ultraLowLatency
protected boolean ultraLowLatency
- Ultra low latency mode can be used for small buffer sizes to obtain better latency -
BUT it eats all your CPU.
standardLatency
protected boolean standardLatency
- Use Java standard way of latency control (blocking on sdl.write)
PJVoiceServer
public PJVoiceServer(int bufferSize)
startAudioOutput
public void startAudioOutput()
stopAudioOutput
public void stopAudioOutput()
throws java.lang.Exception
- Throws:
java.lang.Exception
run
public void run()
- Specified by:
run
in interface java.lang.Runnable
configureAudioOutput
public void configureAudioOutput(javax.swing.JFrame frame)
- Specified by:
configureAudioOutput
in class VoiceServer
setBufferSize
public void setBufferSize(int len)
throws java.lang.Exception
- Throws:
java.lang.Exception
printStats
public void printStats()