kopia lustrzana https://github.com/jameshball/osci-render
Remove framerate cap for MUCH better performance
rodzic
edd49f9b56
commit
ca9cf4c97b
|
@ -5,7 +5,6 @@
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/lib" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/win32-x64" />
|
<excludeFolder url="file://$MODULE_DIR$/win32-x64" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
|
|
|
@ -11,10 +11,8 @@ import shapes.Shapes;
|
||||||
import shapes.Vector2;
|
import shapes.Vector2;
|
||||||
|
|
||||||
public class AudioClient {
|
public class AudioClient {
|
||||||
public static final double TARGET_FRAMERATE = 30;
|
|
||||||
|
|
||||||
private static final int SAMPLE_RATE = 192000;
|
private static final int SAMPLE_RATE = 192000;
|
||||||
private static final double OBJ_ROTATE = Math.PI / 100;
|
private static final double OBJ_ROTATE = Math.PI / 1000;
|
||||||
private static final float ROTATE_SPEED = 0;
|
private static final float ROTATE_SPEED = 0;
|
||||||
private static final float TRANSLATION_SPEED = 0;
|
private static final float TRANSLATION_SPEED = 0;
|
||||||
private static final Vector2 TRANSLATION = new Vector2(1, 1);
|
private static final Vector2 TRANSLATION = new Vector2(1, 1);
|
||||||
|
@ -28,7 +26,7 @@ public class AudioClient {
|
||||||
// Improve performance of line cleanup with a heuristic.
|
// Improve performance of line cleanup with a heuristic.
|
||||||
|
|
||||||
String objFilePath = args[0];
|
String objFilePath = args[0];
|
||||||
int numFrames = (int) (Float.parseFloat(args[1]) * TARGET_FRAMERATE);
|
int numFrames = Integer.parseInt(args[1]);
|
||||||
float focalLength = Float.parseFloat(args[2]);
|
float focalLength = Float.parseFloat(args[2]);
|
||||||
float cameraX = Float.parseFloat(args[3]);
|
float cameraX = Float.parseFloat(args[3]);
|
||||||
float cameraY = Float.parseFloat(args[4]);
|
float cameraY = Float.parseFloat(args[4]);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package audio;
|
package audio;
|
||||||
|
|
||||||
import com.xtaudio.xt.*;
|
import com.xtaudio.xt.*;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
import shapes.Shape;
|
import shapes.Shape;
|
||||||
import shapes.Vector2;
|
import shapes.Vector2;
|
||||||
|
|
||||||
|
@ -12,7 +14,6 @@ public class AudioPlayer extends Thread {
|
||||||
private final List<List<? extends Shape>> frames;
|
private final List<List<? extends Shape>> frames;
|
||||||
private int currentFrame = 0;
|
private int currentFrame = 0;
|
||||||
private int currentShape = 0;
|
private int currentShape = 0;
|
||||||
private long timeOfLastFrame;
|
|
||||||
private int audioFramesDrawn = 0;
|
private int audioFramesDrawn = 0;
|
||||||
|
|
||||||
private double translateSpeed = 0;
|
private double translateSpeed = 0;
|
||||||
|
@ -28,7 +29,6 @@ public class AudioPlayer extends Thread {
|
||||||
public AudioPlayer(int sampleRate, List<List<? extends Shape>> frames) {
|
public AudioPlayer(int sampleRate, List<List<? extends Shape>> frames) {
|
||||||
this.FORMAT = new XtFormat(new XtMix(sampleRate, XtSample.FLOAT32), 0, 0, 2, 0);
|
this.FORMAT = new XtFormat(new XtMix(sampleRate, XtSample.FLOAT32), 0, 0, 2, 0);
|
||||||
this.frames = frames;
|
this.frames = frames;
|
||||||
this.timeOfLastFrame = System.currentTimeMillis();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void render(XtStream stream, Object input, Object output, int audioFrames,
|
private void render(XtStream stream, Object input, Object output, int audioFrames,
|
||||||
|
@ -53,13 +53,12 @@ public class AudioPlayer extends Thread {
|
||||||
|
|
||||||
if (audioFramesDrawn > totalAudioFrames) {
|
if (audioFramesDrawn > totalAudioFrames) {
|
||||||
audioFramesDrawn = 0;
|
audioFramesDrawn = 0;
|
||||||
currentShape = ++currentShape % frames.get(currentFrame).size();
|
currentShape++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (System.currentTimeMillis() - timeOfLastFrame > (float) 1000 / AudioClient.TARGET_FRAMERATE) {
|
if (currentShape >= frames.get(currentFrame).size()) {
|
||||||
currentShape = 0;
|
currentShape = 0;
|
||||||
currentFrame = ++currentFrame % frames.size();
|
currentFrame = ++currentFrame % frames.size();
|
||||||
timeOfLastFrame = System.currentTimeMillis();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue