@Test public void shouldExtractCorrectPitchesFromHarmonicLoops120() throws IOException, UnsupportedAudioFileException, InterruptedException { HarmonicLoop hlOneBarEightyBpm = new HarmonicLoop(); hlOneBarEightyBpm.setId(1); hlOneBarEightyBpm.setBarCount(1); hlOneBarEightyBpm.setAudioLength(2.0f); hlOneBarEightyBpm.setBpm(120); hlOneBarEightyBpm.setFileName(Paths.get(appConfigs.getApplicationRoot(), "TrebleMakerCore", "src","main","java","com","treblemaker","tests","Mocks","pitchDetectionTest","pitch_test_1b_120.wav").toString()); List<PitchExtractions> extractedPitchs = pitchExtractionUtil.extractPitchs(hlOneBarEightyBpm, new File(hlOneBarEightyBpm.getFileName())); int score = 0; score = updateScore(score, extractedPitchs.get(0).getOneOne(), "c", ""); score = updateScore(score, extractedPitchs.get(0).getOneTwo(), "", ""); score = updateScore(score, extractedPitchs.get(0).getOneThree(), "c", ""); score = updateScore(score, extractedPitchs.get(0).getOneFour(), "c", ""); score = updateScore(score, extractedPitchs.get(0).getTwoOne(), "c", "d"); score = updateScore(score, extractedPitchs.get(0).getTwoTwo(), "", ""); score = updateScore(score, extractedPitchs.get(0).getTwoThree(), "c", ""); score = updateScore(score, extractedPitchs.get(0).getTwoFour(), "", ""); score = updateScore(score, extractedPitchs.get(0).getThreeOne(), "cs", "d"); score = updateScore(score, extractedPitchs.get(0).getThreeTwo(), "cs", ""); score = updateScore(score, extractedPitchs.get(0).getThreeThree(), "cs", "ds"); score = updateScore(score, extractedPitchs.get(0).getThreeFour(), "cs", ""); score = updateScore(score, extractedPitchs.get(0).getFourOne(), "f", "e"); score = updateScore(score, extractedPitchs.get(0).getFourTwo(), "fs", "e"); score = updateScore(score, extractedPitchs.get(0).getFourThree(), "", ""); score = updateScore(score, extractedPitchs.get(0).getFourFour(), "g", "gs"); System.out.println("FINAL SCORE *** " + score); System.out.println("FINAL SCORE *** " + score); System.out.println("FINAL SCORE *** " + score); System.out.println("FINAL SCORE *** " + score); assertThat(extractedPitchs).hasSize(1); assertThat(score).isGreaterThan(7); }
public List<PitchExtractions> extractPitchs(HarmonicLoop harmonicLoop, File audioFile) throws IOException, UnsupportedAudioFileException, InterruptedException { int bufferSize = 1024; int overlap = 768; AudioDispatcher dispatcher = AudioDispatcherFactory.fromFile(audioFile, bufferSize, overlap); PitchDetectionHandlerImp pitchDetectionHandler = new PitchDetectionHandlerImp(); dispatcher.addAudioProcessor(new PitchProcessor(PitchEstimationAlgorithm.MPM, dispatcher.getFormat().getSampleRate(), bufferSize, pitchDetectionHandler)); new Thread(dispatcher, "Audio dispatching").start(); Thread.sleep(10000); return pitchDetectionHandler.getPitchExtractions((double) LoopUtils.getSecondsInBar(harmonicLoop.getBpm()), harmonicLoop.getBarCount()); }
PitchExtractionUtil { public List<PitchExtractions> extractPitchs(HarmonicLoop harmonicLoop, File audioFile) throws IOException, UnsupportedAudioFileException, InterruptedException { int bufferSize = 1024; int overlap = 768; AudioDispatcher dispatcher = AudioDispatcherFactory.fromFile(audioFile, bufferSize, overlap); PitchDetectionHandlerImp pitchDetectionHandler = new PitchDetectionHandlerImp(); dispatcher.addAudioProcessor(new PitchProcessor(PitchEstimationAlgorithm.MPM, dispatcher.getFormat().getSampleRate(), bufferSize, pitchDetectionHandler)); new Thread(dispatcher, "Audio dispatching").start(); Thread.sleep(10000); return pitchDetectionHandler.getPitchExtractions((double) LoopUtils.getSecondsInBar(harmonicLoop.getBpm()), harmonicLoop.getBarCount()); } }
PitchExtractionUtil { public List<PitchExtractions> extractPitchs(HarmonicLoop harmonicLoop, File audioFile) throws IOException, UnsupportedAudioFileException, InterruptedException { int bufferSize = 1024; int overlap = 768; AudioDispatcher dispatcher = AudioDispatcherFactory.fromFile(audioFile, bufferSize, overlap); PitchDetectionHandlerImp pitchDetectionHandler = new PitchDetectionHandlerImp(); dispatcher.addAudioProcessor(new PitchProcessor(PitchEstimationAlgorithm.MPM, dispatcher.getFormat().getSampleRate(), bufferSize, pitchDetectionHandler)); new Thread(dispatcher, "Audio dispatching").start(); Thread.sleep(10000); return pitchDetectionHandler.getPitchExtractions((double) LoopUtils.getSecondsInBar(harmonicLoop.getBpm()), harmonicLoop.getBarCount()); } @Autowired  PitchExtractionUtil(IHarmonicLoopsDal harmonicLoopsDal); }
PitchExtractionUtil { public List<PitchExtractions> extractPitchs(HarmonicLoop harmonicLoop, File audioFile) throws IOException, UnsupportedAudioFileException, InterruptedException { int bufferSize = 1024; int overlap = 768; AudioDispatcher dispatcher = AudioDispatcherFactory.fromFile(audioFile, bufferSize, overlap); PitchDetectionHandlerImp pitchDetectionHandler = new PitchDetectionHandlerImp(); dispatcher.addAudioProcessor(new PitchProcessor(PitchEstimationAlgorithm.MPM, dispatcher.getFormat().getSampleRate(), bufferSize, pitchDetectionHandler)); new Thread(dispatcher, "Audio dispatching").start(); Thread.sleep(10000); return pitchDetectionHandler.getPitchExtractions((double) LoopUtils.getSecondsInBar(harmonicLoop.getBpm()), harmonicLoop.getBarCount()); } @Autowired  PitchExtractionUtil(IHarmonicLoopsDal harmonicLoopsDal); void extractPitchsAndUpdateDatabase(); List<HarmonicLoop> findLoopsWithoutPitchExtractions(List<HarmonicLoop> harmonicLoops); List<PitchExtractions> extractPitchs(HarmonicLoop harmonicLoop, File audioFile); }
PitchExtractionUtil { public List<PitchExtractions> extractPitchs(HarmonicLoop harmonicLoop, File audioFile) throws IOException, UnsupportedAudioFileException, InterruptedException { int bufferSize = 1024; int overlap = 768; AudioDispatcher dispatcher = AudioDispatcherFactory.fromFile(audioFile, bufferSize, overlap); PitchDetectionHandlerImp pitchDetectionHandler = new PitchDetectionHandlerImp(); dispatcher.addAudioProcessor(new PitchProcessor(PitchEstimationAlgorithm.MPM, dispatcher.getFormat().getSampleRate(), bufferSize, pitchDetectionHandler)); new Thread(dispatcher, "Audio dispatching").start(); Thread.sleep(10000); return pitchDetectionHandler.getPitchExtractions((double) LoopUtils.getSecondsInBar(harmonicLoop.getBpm()), harmonicLoop.getBarCount()); } @Autowired  PitchExtractionUtil(IHarmonicLoopsDal harmonicLoopsDal); void extractPitchsAndUpdateDatabase(); List<HarmonicLoop> findLoopsWithoutPitchExtractions(List<HarmonicLoop> harmonicLoops); List<PitchExtractions> extractPitchs(HarmonicLoop harmonicLoop, File audioFile); @Autowired
    public AppConfigs appConfigs; }