@Test public void shouldExtractCorrectPitchesFromHarmonicLoops80_2bars() throws IOException, UnsupportedAudioFileException, InterruptedException { HarmonicLoop hlOneBarEightyBpm = new HarmonicLoop(); hlOneBarEightyBpm.setId(1); hlOneBarEightyBpm.setBarCount(2); hlOneBarEightyBpm.setAudioLength(6.0f); hlOneBarEightyBpm.setBpm(80); hlOneBarEightyBpm.setFileName(Paths.get(appConfigs.getApplicationRoot(),"TrebleMakerCore","src","main","java","com","treblemaker","tests","Mocks","pitchDetectionTest","pitch_test_2b_80.wav").toString()); List<PitchExtractions> extractedPitchs = pitchExtractionUtil.extractPitchs(hlOneBarEightyBpm, new File(hlOneBarEightyBpm.getFileName())); assertThat(extractedPitchs).hasSize(2); }
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; }