Only start osci-render audio pipeline once a project has been opened, and increase min length increment

pull/98/head
James Ball 2022-07-08 13:48:02 +01:00 zatwierdzone przez James H Ball
rodzic 75e94233f7
commit 10ed91e3a1
5 zmienionych plików z 50 dodań i 42 usunięć

Wyświetl plik

@ -33,7 +33,7 @@ public class ShapeAudioPlayer implements AudioPlayer<List<Shape>> {
private static final int BUFFER_SIZE = 10;
private static final boolean BIG_ENDIAN = false;
private static final double MIN_LENGTH_INCREMENT = 0.0000000001;
private static final double MIN_LENGTH_INCREMENT = 0.000001;
// MIDI
private final short[][] keyTargetVolumes = new short[MidiNote.NUM_CHANNELS][128];

Wyświetl plik

@ -175,6 +175,7 @@ public class Gui extends Application {
public void launchMainApplication(MainController controller, String projectPath, Boolean muted) throws Exception {
scene.setRoot(root);
controller.initialiseAudioEngine();
controller.openProject(projectPath);
if (muted) {
controller.setVolume(0);

Wyświetl plik

@ -194,22 +194,8 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
@FXML
private ComboBox<AudioSample> audioSampleComboBox;
public MainController() {
FrameSource<List<Shape>> frames = new ShapeFrameSource(List.of(new Vector2()));
openFiles.add(new byte[0]);
frameSources.add(frames);
sampleParsers.add(null);
frameSourcePaths.add("Empty file");
currentFrameSource = 0;
this.producer = new FrameProducer<>(audioPlayer, frames);
if (defaultDevice == null) {
throw new RuntimeException("No default audio device found!");
}
this.sampleRate = defaultDevice.sampleRate();
}
// initialises midiButtonMap by mapping MIDI logo SVGs to the slider that they
// control if they are selected.
private Map<SVGPath, Slider> initializeMidiButtonMap() {
Map<SVGPath, Slider> midiMap = new HashMap<>();
subControllers().forEach(controller -> midiMap.putAll(controller.getMidiButtonMap()));
@ -349,7 +335,6 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
});
}
objController.setAudioProducer(producer);
generalController.setMainController(this);
luaController.setMainController(this);
@ -532,32 +517,6 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
});
brightnessSlider.valueProperty().addListener((e, old, brightness) -> audioPlayer.setBrightness(brightness.doubleValue()));
objController.updateObjectRotateSpeed();
executor.submit(producer);
Gui.midiCommunicator.addListener(this);
AudioInput audioInput = new JavaAudioInput();
if (audioInput.isAvailable()) {
audioInput.addListener(this);
new Thread(audioInput).start();
} else {
for (CheckBox checkBox : micCheckBoxes()) {
if (checkBox != null) {
checkBox.setDisable(true);
}
}
}
luaController.updateLuaVariables();
objectServer = new ObjectServer(this::enableObjectServerRendering, this::disableObjectServerRendering);
new Thread(objectServer).start();
webSocketServer = new ByteWebSocketServer();
webSocketServer.start();
this.buffer = new byte[FRAME_SIZE * SOSCI_NUM_VERTICES * SOSCI_VERTEX_SIZE];
new Thread(() -> sendAudioDataToWebSocket(webSocketServer)).start();
}
public void setLuaVariable(String variableName, Object value) {
@ -1459,6 +1418,48 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
effectsController.setVolume(volume);
}
public void initialiseAudioEngine() {
FrameSource<List<Shape>> frames = new ShapeFrameSource(List.of(new Vector2()));
openFiles.add(new byte[0]);
frameSources.add(frames);
sampleParsers.add(null);
frameSourcePaths.add("Empty file");
currentFrameSource = 0;
producer = new FrameProducer<>(audioPlayer, frames);
objController.setAudioProducer(producer);
if (defaultDevice == null) {
throw new RuntimeException("No default audio device found!");
}
sampleRate = defaultDevice.sampleRate();
objController.updateObjectRotateSpeed();
executor.submit(producer);
Gui.midiCommunicator.addListener(this);
AudioInput audioInput = new JavaAudioInput();
if (audioInput.isAvailable()) {
audioInput.addListener(this);
new Thread(audioInput).start();
} else {
for (CheckBox checkBox : micCheckBoxes()) {
if (checkBox != null) {
checkBox.setDisable(true);
}
}
}
luaController.updateLuaVariables();
objectServer = new ObjectServer(this::enableObjectServerRendering, this::disableObjectServerRendering);
new Thread(objectServer).start();
webSocketServer = new ByteWebSocketServer();
webSocketServer.start();
this.buffer = new byte[FRAME_SIZE * SOSCI_NUM_VERTICES * SOSCI_VERTEX_SIZE];
new Thread(() -> sendAudioDataToWebSocket(webSocketServer)).start();
}
private record PrintableSlider(Slider slider) {
@Override
public String toString() {

Wyświetl plik

@ -8,6 +8,9 @@ import java.net.InetSocketAddress;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import static sh.ball.gui.Gui.logger;
public class ByteWebSocketServer extends WebSocketServer {
@ -26,6 +29,7 @@ public class ByteWebSocketServer extends WebSocketServer {
sock.send(bytes);
} catch (Exception e) {
conns.remove(sock);
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
}

Wyświetl plik

@ -7,6 +7,8 @@
- Shows last 20 previously opened projects
- These can be clicked on to open a previous project
- Allow any font that has been installed on your machine to be used with text files
- Change font by selecting a font from the drop-down under View > Text File Font
- Change font style (i.e. plain, bold, italic) by selecting a font style from the drop-down under View > Text File Font Style
- 1.26.4