@Test public void shouldRenderSynthBassAtCorrectLength() throws IOException, InterruptedException { int bpm = 80; int barCount = 32; String midiGeneratedTest = appConfigs.getApplicationRoot() + "lowMidiTest.wav"; String midiFilePath = appConfigs.getMockDataDir() + "midi\\" + "complow.mid"; File targetFile = new File(midiGeneratedTest); if(targetFile != null && targetFile.exists()){ deleteFolderAndContents(targetFile); } ObjectMapper mapper = new ObjectMapper(); SynthTemplate synthTemplate = mapper.readValue(new File(appConfigs.getMockDataDir() + "midi\\mockSynthTemplate.json"), SynthTemplate.class); Pattern pattern = new Pattern(); List<Chord> chords = new ArrayList<>(); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.add(new Chord("C")); chords.add(new Chord("E")); chords.forEach(c -> { Note rootNote = c.getRoot(); String bassNote = rootNote.toStringWithoutDuration() + 4 + "w"; pattern.add(bassNote); }); pattern.setTempo(bpm); try { MidiFileManager.save(new Player().getSequence(pattern), new File(midiFilePath)); } catch (IOException e1) { e1.printStackTrace(); } audioRender.renderPart(midiFilePath, midiGeneratedTest, AudioRender.Spectrum.LOW, synthTemplate, BPM); Thread.sleep(5000); float audioLengthInSeconds = audioUtils.getAudioLength(midiGeneratedTest); float targetTrackLengthInSeconds = LoopUtils.getSecondsInBar(bpm) * barCount; Assert.assertEquals(targetTrackLengthInSeconds,audioLengthInSeconds,0.05f); }
public void renderPart(String midiFilePath, String audioTargetPath, Spectrum spectrum, SynthTemplate template, Integer bpm) { midiFilePath = midiFilePath.replace(" audioTargetPath = audioTargetPath.replace(" String synthSetting = ""; if (spectrum == Spectrum.HI) { synthSetting = template.getHiSynthNameAlt() + "," + template.getHiPresetAlt(); }else if (spectrum == Spectrum.ALT_HI) { synthSetting = template.getHiSynthNameAlt() + "," + template.getHiPresetAlt(); }else if (spectrum == Spectrum.MID) { synthSetting = template.getMidSynthName() + "," + template.getMidPreset(); }else if (spectrum == Spectrum.ALT_MID) { synthSetting = template.getMidSynthName() + "," + template.getMidPresetAlt(); } else if (spectrum == Spectrum.LOW) { synthSetting = template.getLowSynthName() + "," + template.getLowPreset(); }else if (spectrum == Spectrum.ALT_LOW) { synthSetting = template.getLowSynthName() + "," + template.getLowPresetAlt(); } String debugProcess = appConfigs.getMrsWatsonLocation() + " " + "--midi-file" + " " + midiFilePath + " " + "--tempo" + " " + Integer.toString(bpm) + " " + "--output" + " " + audioTargetPath + " " + "--plugin" + " " + appConfigs.getVSTPluginDir() + synthSetting; Application.logger.debug("LOG: **********"); Application.logger.debug("LOG:" + debugProcess); Application.logger.debug("LOG: **********"); ProcessBuilder process = new ProcessBuilder(appConfigs.getMrsWatsonLocation(), "--midi-file", midiFilePath, "--tempo", Integer.toString(bpm), "--output", audioTargetPath, "--plugin", appConfigs.getVSTPluginDir() + synthSetting); StringBuilder strBuild = new StringBuilder(); Process processDuration = null; try { process.redirectErrorStream(true).start(); try (BufferedReader processOutputReader = new BufferedReader(new InputStreamReader(processDuration.getInputStream(), Charset.defaultCharset()))) { String line; while ((line = processOutputReader.readLine()) != null) { strBuild.append(line + System.lineSeparator()); } processDuration.waitFor(); } catch (InterruptedException e) { Application.logger.debug("LOG:", e); } System.out.print("renderPart " + spectrum + " COMPLETE"); } catch (IOException e) { Application.logger.debug("LOG:", e); } }
AudioRender implements IAudioRender { public void renderPart(String midiFilePath, String audioTargetPath, Spectrum spectrum, SynthTemplate template, Integer bpm) { midiFilePath = midiFilePath.replace(" audioTargetPath = audioTargetPath.replace(" String synthSetting = ""; if (spectrum == Spectrum.HI) { synthSetting = template.getHiSynthNameAlt() + "," + template.getHiPresetAlt(); }else if (spectrum == Spectrum.ALT_HI) { synthSetting = template.getHiSynthNameAlt() + "," + template.getHiPresetAlt(); }else if (spectrum == Spectrum.MID) { synthSetting = template.getMidSynthName() + "," + template.getMidPreset(); }else if (spectrum == Spectrum.ALT_MID) { synthSetting = template.getMidSynthName() + "," + template.getMidPresetAlt(); } else if (spectrum == Spectrum.LOW) { synthSetting = template.getLowSynthName() + "," + template.getLowPreset(); }else if (spectrum == Spectrum.ALT_LOW) { synthSetting = template.getLowSynthName() + "," + template.getLowPresetAlt(); } String debugProcess = appConfigs.getMrsWatsonLocation() + " " + "--midi-file" + " " + midiFilePath + " " + "--tempo" + " " + Integer.toString(bpm) + " " + "--output" + " " + audioTargetPath + " " + "--plugin" + " " + appConfigs.getVSTPluginDir() + synthSetting; Application.logger.debug("LOG: **********"); Application.logger.debug("LOG:" + debugProcess); Application.logger.debug("LOG: **********"); ProcessBuilder process = new ProcessBuilder(appConfigs.getMrsWatsonLocation(), "--midi-file", midiFilePath, "--tempo", Integer.toString(bpm), "--output", audioTargetPath, "--plugin", appConfigs.getVSTPluginDir() + synthSetting); StringBuilder strBuild = new StringBuilder(); Process processDuration = null; try { process.redirectErrorStream(true).start(); try (BufferedReader processOutputReader = new BufferedReader(new InputStreamReader(processDuration.getInputStream(), Charset.defaultCharset()))) { String line; while ((line = processOutputReader.readLine()) != null) { strBuild.append(line + System.lineSeparator()); } processDuration.waitFor(); } catch (InterruptedException e) { Application.logger.debug("LOG:", e); } System.out.print("renderPart " + spectrum + " COMPLETE"); } catch (IOException e) { Application.logger.debug("LOG:", e); } } }
AudioRender implements IAudioRender { public void renderPart(String midiFilePath, String audioTargetPath, Spectrum spectrum, SynthTemplate template, Integer bpm) { midiFilePath = midiFilePath.replace(" audioTargetPath = audioTargetPath.replace(" String synthSetting = ""; if (spectrum == Spectrum.HI) { synthSetting = template.getHiSynthNameAlt() + "," + template.getHiPresetAlt(); }else if (spectrum == Spectrum.ALT_HI) { synthSetting = template.getHiSynthNameAlt() + "," + template.getHiPresetAlt(); }else if (spectrum == Spectrum.MID) { synthSetting = template.getMidSynthName() + "," + template.getMidPreset(); }else if (spectrum == Spectrum.ALT_MID) { synthSetting = template.getMidSynthName() + "," + template.getMidPresetAlt(); } else if (spectrum == Spectrum.LOW) { synthSetting = template.getLowSynthName() + "," + template.getLowPreset(); }else if (spectrum == Spectrum.ALT_LOW) { synthSetting = template.getLowSynthName() + "," + template.getLowPresetAlt(); } String debugProcess = appConfigs.getMrsWatsonLocation() + " " + "--midi-file" + " " + midiFilePath + " " + "--tempo" + " " + Integer.toString(bpm) + " " + "--output" + " " + audioTargetPath + " " + "--plugin" + " " + appConfigs.getVSTPluginDir() + synthSetting; Application.logger.debug("LOG: **********"); Application.logger.debug("LOG:" + debugProcess); Application.logger.debug("LOG: **********"); ProcessBuilder process = new ProcessBuilder(appConfigs.getMrsWatsonLocation(), "--midi-file", midiFilePath, "--tempo", Integer.toString(bpm), "--output", audioTargetPath, "--plugin", appConfigs.getVSTPluginDir() + synthSetting); StringBuilder strBuild = new StringBuilder(); Process processDuration = null; try { process.redirectErrorStream(true).start(); try (BufferedReader processOutputReader = new BufferedReader(new InputStreamReader(processDuration.getInputStream(), Charset.defaultCharset()))) { String line; while ((line = processOutputReader.readLine()) != null) { strBuild.append(line + System.lineSeparator()); } processDuration.waitFor(); } catch (InterruptedException e) { Application.logger.debug("LOG:", e); } System.out.print("renderPart " + spectrum + " COMPLETE"); } catch (IOException e) { Application.logger.debug("LOG:", e); } }  }
AudioRender implements IAudioRender { public void renderPart(String midiFilePath, String audioTargetPath, Spectrum spectrum, SynthTemplate template, Integer bpm) { midiFilePath = midiFilePath.replace(" audioTargetPath = audioTargetPath.replace(" String synthSetting = ""; if (spectrum == Spectrum.HI) { synthSetting = template.getHiSynthNameAlt() + "," + template.getHiPresetAlt(); }else if (spectrum == Spectrum.ALT_HI) { synthSetting = template.getHiSynthNameAlt() + "," + template.getHiPresetAlt(); }else if (spectrum == Spectrum.MID) { synthSetting = template.getMidSynthName() + "," + template.getMidPreset(); }else if (spectrum == Spectrum.ALT_MID) { synthSetting = template.getMidSynthName() + "," + template.getMidPresetAlt(); } else if (spectrum == Spectrum.LOW) { synthSetting = template.getLowSynthName() + "," + template.getLowPreset(); }else if (spectrum == Spectrum.ALT_LOW) { synthSetting = template.getLowSynthName() + "," + template.getLowPresetAlt(); } String debugProcess = appConfigs.getMrsWatsonLocation() + " " + "--midi-file" + " " + midiFilePath + " " + "--tempo" + " " + Integer.toString(bpm) + " " + "--output" + " " + audioTargetPath + " " + "--plugin" + " " + appConfigs.getVSTPluginDir() + synthSetting; Application.logger.debug("LOG: **********"); Application.logger.debug("LOG:" + debugProcess); Application.logger.debug("LOG: **********"); ProcessBuilder process = new ProcessBuilder(appConfigs.getMrsWatsonLocation(), "--midi-file", midiFilePath, "--tempo", Integer.toString(bpm), "--output", audioTargetPath, "--plugin", appConfigs.getVSTPluginDir() + synthSetting); StringBuilder strBuild = new StringBuilder(); Process processDuration = null; try { process.redirectErrorStream(true).start(); try (BufferedReader processOutputReader = new BufferedReader(new InputStreamReader(processDuration.getInputStream(), Charset.defaultCharset()))) { String line; while ((line = processOutputReader.readLine()) != null) { strBuild.append(line + System.lineSeparator()); } processDuration.waitFor(); } catch (InterruptedException e) { Application.logger.debug("LOG:", e); } System.out.print("renderPart " + spectrum + " COMPLETE"); } catch (IOException e) { Application.logger.debug("LOG:", e); } }  String output(InputStream inputStream); void renderPart(String midiFilePath, String audioTargetPath, Spectrum spectrum, SynthTemplate template, Integer bpm); }
AudioRender implements IAudioRender { public void renderPart(String midiFilePath, String audioTargetPath, Spectrum spectrum, SynthTemplate template, Integer bpm) { midiFilePath = midiFilePath.replace(" audioTargetPath = audioTargetPath.replace(" String synthSetting = ""; if (spectrum == Spectrum.HI) { synthSetting = template.getHiSynthNameAlt() + "," + template.getHiPresetAlt(); }else if (spectrum == Spectrum.ALT_HI) { synthSetting = template.getHiSynthNameAlt() + "," + template.getHiPresetAlt(); }else if (spectrum == Spectrum.MID) { synthSetting = template.getMidSynthName() + "," + template.getMidPreset(); }else if (spectrum == Spectrum.ALT_MID) { synthSetting = template.getMidSynthName() + "," + template.getMidPresetAlt(); } else if (spectrum == Spectrum.LOW) { synthSetting = template.getLowSynthName() + "," + template.getLowPreset(); }else if (spectrum == Spectrum.ALT_LOW) { synthSetting = template.getLowSynthName() + "," + template.getLowPresetAlt(); } String debugProcess = appConfigs.getMrsWatsonLocation() + " " + "--midi-file" + " " + midiFilePath + " " + "--tempo" + " " + Integer.toString(bpm) + " " + "--output" + " " + audioTargetPath + " " + "--plugin" + " " + appConfigs.getVSTPluginDir() + synthSetting; Application.logger.debug("LOG: **********"); Application.logger.debug("LOG:" + debugProcess); Application.logger.debug("LOG: **********"); ProcessBuilder process = new ProcessBuilder(appConfigs.getMrsWatsonLocation(), "--midi-file", midiFilePath, "--tempo", Integer.toString(bpm), "--output", audioTargetPath, "--plugin", appConfigs.getVSTPluginDir() + synthSetting); StringBuilder strBuild = new StringBuilder(); Process processDuration = null; try { process.redirectErrorStream(true).start(); try (BufferedReader processOutputReader = new BufferedReader(new InputStreamReader(processDuration.getInputStream(), Charset.defaultCharset()))) { String line; while ((line = processOutputReader.readLine()) != null) { strBuild.append(line + System.lineSeparator()); } processDuration.waitFor(); } catch (InterruptedException e) { Application.logger.debug("LOG:", e); } System.out.print("renderPart " + spectrum + " COMPLETE"); } catch (IOException e) { Application.logger.debug("LOG:", e); } }  String output(InputStream inputStream); void renderPart(String midiFilePath, String audioTargetPath, Spectrum spectrum, SynthTemplate template, Integer bpm);  }