@Test public void ShouldConcatinateToCorrectLength() { try { int numOfFiles = 15; float concateItemLength = 7.53f; String concateItem = appConfigs.MOCK_AUDIO_PATH + "concateTestItem.wav"; String concateOutput = appConfigs.MOCK_AUDIO_PATH + "concateTestOutput.wav"; shimGenerator.generateSilence(concateItemLength, concateItem, 0); BaseRenderer baseRenderer = new BaseRenderer(); List<String> sourceFilesList = new ArrayList<String>(); for (int i = 0; i < numOfFiles; i++) { sourceFilesList.add(concateItem); } baseRenderer.concatenateFiles(sourceFilesList, concateOutput); float expectedLength = concateItemLength * 15.0f; float audioLength = audioUtils.getAudioLength(concateOutput); assertEquals(expectedLength, audioLength, 0.01f); } catch (Exception e) { fail("FAILED"); } }
public Boolean concatenateFiles(List<String> sourceFilesList, String destinationFileName) throws Exception { destinationFileName = correctFilePath(destinationFileName); try { Vector<AudioInputStream> inputStreams = new Vector<>(); AudioFormat audioFormat = null; long frameLength = 0; for (String source : sourceFilesList) { AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File(source)); inputStreams.add(inputStream); audioFormat = inputStream.getFormat(); frameLength = frameLength + inputStream.getFrameLength(); } Enumeration<AudioInputStream> enumeration = inputStreams.elements(); AudioInputStream appendedFiles = new AudioInputStream( new SequenceInputStream(enumeration), audioFormat, frameLength); Application.logger.debug("LOG: %%%%%%% RENDERED: " + destinationFileName); AudioSystem.write(appendedFiles, AudioFileFormat.Type.WAVE, new File(destinationFileName)); } catch (Exception e) { Application.logger.debug("LOG:",e); return false; } return true; }
BaseRenderer { public Boolean concatenateFiles(List<String> sourceFilesList, String destinationFileName) throws Exception { destinationFileName = correctFilePath(destinationFileName); try { Vector<AudioInputStream> inputStreams = new Vector<>(); AudioFormat audioFormat = null; long frameLength = 0; for (String source : sourceFilesList) { AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File(source)); inputStreams.add(inputStream); audioFormat = inputStream.getFormat(); frameLength = frameLength + inputStream.getFrameLength(); } Enumeration<AudioInputStream> enumeration = inputStreams.elements(); AudioInputStream appendedFiles = new AudioInputStream( new SequenceInputStream(enumeration), audioFormat, frameLength); Application.logger.debug("LOG: %%%%%%% RENDERED: " + destinationFileName); AudioSystem.write(appendedFiles, AudioFileFormat.Type.WAVE, new File(destinationFileName)); } catch (Exception e) { Application.logger.debug("LOG:",e); return false; } return true; } }
BaseRenderer { public Boolean concatenateFiles(List<String> sourceFilesList, String destinationFileName) throws Exception { destinationFileName = correctFilePath(destinationFileName); try { Vector<AudioInputStream> inputStreams = new Vector<>(); AudioFormat audioFormat = null; long frameLength = 0; for (String source : sourceFilesList) { AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File(source)); inputStreams.add(inputStream); audioFormat = inputStream.getFormat(); frameLength = frameLength + inputStream.getFrameLength(); } Enumeration<AudioInputStream> enumeration = inputStreams.elements(); AudioInputStream appendedFiles = new AudioInputStream( new SequenceInputStream(enumeration), audioFormat, frameLength); Application.logger.debug("LOG: %%%%%%% RENDERED: " + destinationFileName); AudioSystem.write(appendedFiles, AudioFileFormat.Type.WAVE, new File(destinationFileName)); } catch (Exception e) { Application.logger.debug("LOG:",e); return false; } return true; }  }
BaseRenderer { public Boolean concatenateFiles(List<String> sourceFilesList, String destinationFileName) throws Exception { destinationFileName = correctFilePath(destinationFileName); try { Vector<AudioInputStream> inputStreams = new Vector<>(); AudioFormat audioFormat = null; long frameLength = 0; for (String source : sourceFilesList) { AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File(source)); inputStreams.add(inputStream); audioFormat = inputStream.getFormat(); frameLength = frameLength + inputStream.getFrameLength(); } Enumeration<AudioInputStream> enumeration = inputStreams.elements(); AudioInputStream appendedFiles = new AudioInputStream( new SequenceInputStream(enumeration), audioFormat, frameLength); Application.logger.debug("LOG: %%%%%%% RENDERED: " + destinationFileName); AudioSystem.write(appendedFiles, AudioFileFormat.Type.WAVE, new File(destinationFileName)); } catch (Exception e) { Application.logger.debug("LOG:",e); return false; } return true; }  Boolean concatenateFiles(List<String> sourceFilesList, String destinationFileName); }
BaseRenderer { public Boolean concatenateFiles(List<String> sourceFilesList, String destinationFileName) throws Exception { destinationFileName = correctFilePath(destinationFileName); try { Vector<AudioInputStream> inputStreams = new Vector<>(); AudioFormat audioFormat = null; long frameLength = 0; for (String source : sourceFilesList) { AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File(source)); inputStreams.add(inputStream); audioFormat = inputStream.getFormat(); frameLength = frameLength + inputStream.getFrameLength(); } Enumeration<AudioInputStream> enumeration = inputStreams.elements(); AudioInputStream appendedFiles = new AudioInputStream( new SequenceInputStream(enumeration), audioFormat, frameLength); Application.logger.debug("LOG: %%%%%%% RENDERED: " + destinationFileName); AudioSystem.write(appendedFiles, AudioFileFormat.Type.WAVE, new File(destinationFileName)); } catch (Exception e) { Application.logger.debug("LOG:",e); return false; } return true; }  Boolean concatenateFiles(List<String> sourceFilesList, String destinationFileName);  }