From f82e40c99b0dc0fb18542d22878ed776ac197268 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Mon, 2 Dec 2024 22:04:36 +0900 Subject: [PATCH 1/2] make tests more effective --- .../vavi/sound/dx7/Dx7SynthesizerTest.java | 29 +++++++++++-------- src/test/java/vavi/sound/dx7/FilerTest.java | 6 ++-- .../java/vavi/sound/dx7/SawtoothTest.java | 1 - 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/test/java/vavi/sound/dx7/Dx7SynthesizerTest.java b/src/test/java/vavi/sound/dx7/Dx7SynthesizerTest.java index 6623c2f..8bf3fd1 100644 --- a/src/test/java/vavi/sound/dx7/Dx7SynthesizerTest.java +++ b/src/test/java/vavi/sound/dx7/Dx7SynthesizerTest.java @@ -66,7 +66,11 @@ static boolean localPropertiesExists() { return Files.exists(Paths.get("local.properties")); } - static final float volume = Float.parseFloat(System.getProperty("vavi.test.volume.midi", "0.2")); + @Property(name = "vavi.test.volume.midi") + float midiVolume = 0.2f; + + @Property(name = "vavi.test.volume") + double volume = 0.02; @BeforeEach void setup() throws IOException { @@ -76,7 +80,6 @@ void setup() throws IOException { } @Property(name = "test.midi") - final String midi = "src/test/resources/test.mid"; @Test @@ -98,17 +101,17 @@ void test() throws Exception { CountDownLatch countDownLatch = new CountDownLatch(1); MetaEventListener mel = meta -> { -//System.err.println("META: " + meta.getType()); +//Debug.println("META: " + meta.getType()); if (meta.getType() == 47) { countDownLatch.countDown(); } }; sequencer.setSequence(seq); sequencer.addMetaEventListener(mel); -System.err.println("START"); +Debug.println("START"); sequencer.start(); - volume(receiver, volume); // gervill volume works! + volume(receiver, midiVolume); // gervill volume works! if (!System.getProperty("vavi.test", "").equals("ide")) { Thread.sleep(10 * 1000); @@ -117,7 +120,7 @@ void test() throws Exception { } else { countDownLatch.await(); } -System.err.println("END"); +Debug.println("END"); sequencer.removeMetaEventListener(mel); sequencer.close(); @@ -130,7 +133,7 @@ void test2() throws Exception { synthesizer.open(); Debug.println("synthesizer: " + synthesizer); - volume(synthesizer.getReceiver(), volume); // gervill volume works! + volume(synthesizer.getReceiver(), midiVolume); // gervill volume works! MidiChannel channel = synthesizer.getChannels()[0]; for (int i = 0; i < 32; i++) { @@ -188,7 +191,7 @@ void test3() throws Exception { System.err.println("START"); sequencer.start(); - volume(receiver, volume); // gervill volume works! + volume(receiver, midiVolume); // gervill volume works! if (!System.getProperty("vavi.test", "").equals("ide")) { Thread.sleep(10 * 1000); @@ -207,11 +210,13 @@ void test3() throws Exception { /** */ public static void main(String[] args) throws Exception { - t3(args); + Dx7SynthesizerTest app = new Dx7SynthesizerTest(); + app.setup(); + app.t3(args); } /** */ - public static void t3(String[] args) throws Exception { + public void t3(String[] args) throws Exception { final int nSamples = 20 * 1024; final float sampleRate = 44100.0f; Instrument instrument = new Dx7Soundbank().getInstrument(new ModelPatch(0, 0, true)); @@ -264,7 +269,7 @@ public static void t3(String[] args) throws Exception { line.close(); } - public static void t2(String[] args) throws Exception { + public void t2(String[] args) throws Exception { final int nSamples = 20 * 1024; final float sampleRate = 44100.0f; Instrument[] instruments = new Dx7Soundbank().getInstruments(); @@ -317,7 +322,7 @@ public static void t2(String[] args) throws Exception { line.close(); } - public static void t1(String[] args) throws Exception { + public void t1(String[] args) throws Exception { final int nSamples = 10 * 1024; final float sampleRate = 44100.0f; diff --git a/src/test/java/vavi/sound/dx7/FilerTest.java b/src/test/java/vavi/sound/dx7/FilerTest.java index 4d0ae65..73e1113 100644 --- a/src/test/java/vavi/sound/dx7/FilerTest.java +++ b/src/test/java/vavi/sound/dx7/FilerTest.java @@ -184,7 +184,7 @@ void runfmbench() { double elapsed = System.currentTimeMillis() - start; double nsPerSample = 1e9 * elapsed / nBuf / niter; - Debug.printf("fm op kernel: %f ms/sample\n", nsPerSample); +Debug.printf("fm op kernel: %f ms/sample\n", nsPerSample); } @Test @@ -212,7 +212,7 @@ void runSawBench() { double elapsed = System.currentTimeMillis() - start; double nsPerSample = 1e9 * elapsed / nBuf / niter; - Debug.printf("sawtooth %gHz: %f ms/sample\n", f, nsPerSample); +Debug.printf("sawtooth %gHz: %f ms/sample\n", f, nsPerSample); } } @@ -250,7 +250,7 @@ void runLadderBench() { double elapsed = System.currentTimeMillis() - start; double nsPerSample = 1e9 * elapsed / nBuf / niter; - Debug.printf("ladder %s: %f ms/sample\n", nl != 0 ? "nonlinear" : "linear", nsPerSample); +Debug.printf("ladder %s: %f ms/sample\n", nl != 0 ? "nonlinear" : "linear", nsPerSample); } } } diff --git a/src/test/java/vavi/sound/dx7/SawtoothTest.java b/src/test/java/vavi/sound/dx7/SawtoothTest.java index 1113a65..abffd3a 100644 --- a/src/test/java/vavi/sound/dx7/SawtoothTest.java +++ b/src/test/java/vavi/sound/dx7/SawtoothTest.java @@ -37,7 +37,6 @@ static boolean localPropertiesExists() { } @Property(name = "vavi.test.volume") - final double volume = 0.2; @BeforeEach From b36acf5efa8e835289dae8eaa30b4f10b250f82e Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 3 Dec 2024 01:10:20 +0900 Subject: [PATCH 2/2] bump version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 411c407..14748b7 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ vavi vavi-sound-dx7 - 0.0.4 + 0.0.5 0.02