if (audioFileFormatType.toString().equals("MP3")) { if (!MaryRuntimeUtils.canCreateMP3()) { throw new UnsupportedAudioFileException("Conversion to MP3 not supported."); throw new UnsupportedAudioFileException("Conversion to OGG Vorbis format not supported.");
public static void lsfAnalyzeWavFile(String wavFileIn, String lsfFileOut, LsfFileHeader params) throws IOException { double[][] lsfs = null; try { lsfs = lsfAnalyzeWavFile(wavFileIn, params); } catch (UnsupportedAudioFileException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (lsfs != null) { params.numfrm = lsfs.length; writeLsfFile(lsfs, lsfFileOut, params); } else params.numfrm = 0; }
System.out.println("FLAC file reader: no stream info found"); throw new UnsupportedAudioFileException("No StreamInfo found"); final UnsupportedAudioFileException unsupportedAudioFileException = new UnsupportedAudioFileException(ioe.getMessage()); unsupportedAudioFileException.initCause(ioe); throw unsupportedAudioFileException;
/** * @param name The name of the sound file (no extension) */ private static void play(String name) { Preconditions.checkState(allSounds.containsKey(name), "'" + name + "' must be present (did you initialise?)"); byte[] sound = allSounds.get(name); try { final Clip clip = AudioSystem.getClip(); clip.addLineListener(new LineListener() { @Override public void update(LineEvent event) { if (event.getType() == LineEvent.Type.STOP) clip.close(); } }); clip.open(AudioSystem.getAudioInputStream(new ByteArrayInputStream(sound))); clip.start(); } catch (UnsupportedAudioFileException e) { throw new IllegalStateException(e.getMessage()); } catch (IOException e) { throw new IllegalStateException(e.getMessage()); } catch (LineUnavailableException e) { throw new IllegalStateException(e.getMessage()); } }
private static byte[] readByte(String filename) { byte[] data = null; AudioInputStream ais = null; try { // try to read from file File file = new File(filename); if (file.exists()) { ais = AudioSystem.getAudioInputStream(file); data = new byte[ais.available()]; ais.read(data); } // try to read from URL else { URL url = StdAudio.class.getResource(filename); ais = AudioSystem.getAudioInputStream(url); data = new byte[ais.available()]; ais.read(data); } } catch (IOException e) { System.out.println(e.getMessage()); throw new RuntimeException("Could not read " + filename); } catch (UnsupportedAudioFileException e) { System.out.println(e.getMessage()); throw new RuntimeException(filename + " in unsupported audio format"); } return data; }
if (audioFileFormatType.toString().equals("MP3")) { if (!MaryRuntimeUtils.canCreateMP3()) { throw new UnsupportedAudioFileException("Conversion to MP3 not supported."); throw new UnsupportedAudioFileException("Conversion to OGG Vorbis format not supported.");
public static void lsfAnalyzeWavFile(String wavFileIn, String lsfFileOut, LsfFileHeader params) throws IOException { double[][] lsfs = null; try { lsfs = lsfAnalyzeWavFile(wavFileIn, params); } catch (UnsupportedAudioFileException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (lsfs != null) { params.numfrm = lsfs.length; writeLsfFile(lsfs, lsfFileOut, params); } else params.numfrm = 0; }
afos.setFormat(format.getFormat()); } catch (UnsupportedAudioFileException e) { throw new IOException(e.getMessage(), e);
private static void getDurationWithMp3Spi(File file) throws UnsupportedAudioFileException, IOException { AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(file); if (fileFormat instanceof TAudioFileFormat) { Map<?, ?> properties = ((TAudioFileFormat) fileFormat).properties(); String key = "duration"; Long microseconds = (Long) properties.get(key); int mili = (int) (microseconds / 1000); int sec = (mili / 1000) % 60; int min = (mili / 1000) / 60; System.out.println("time = " + min + ":" + sec); } else { throw new UnsupportedAudioFileException(); } }
} catch (UnsupportedAudioFileException e) { System.err.println("Audio file format not supported: " + e); e.printStackTrace(); } catch (IOException e) { e.printStackTrace();
+ e.getMessage());
throw new UnsupportedAudioFileException("Conversion from audio format " + ais.getFormat() + " to requested audio format " + targetFormat + " not supported.\n" + iae.getMessage());
public F0TrackerAutocorrelationHeuristic(String wavFile, String ptcFile) throws Exception { if (FileUtils.exists(wavFile)) { params = new PitchFileHeader(); init(); PitchReaderWriter f0 = null; try { f0 = pitchAnalyzeWavFile(wavFile, ptcFile); } catch (UnsupportedAudioFileException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else throw new Exception("Wav file not found!"); }
error("URL is in an unsupported audio file format: " + e.getMessage());
throw new UnsupportedAudioFileException("Conversion from audio format " + ais.getFormat() + " to requested audio format " + targetFormat + " not supported.\n" + iae.getMessage());
} catch (UnsupportedAudioFileException e) { e.printStackTrace(); } catch (IOException e) {
System.err.println(ex.getMessage()); return;
private static void getDurationWithMp3Spi(File file) throws UnsupportedAudioFileException, IOException { AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(file); if (fileFormat instanceof TAudioFileFormat) { Map<?, ?> properties = ((TAudioFileFormat) fileFormat).properties(); String key = "duration"; Long microseconds = (Long) properties.get(key); int mili = (int) (microseconds / 1000); int sec = (mili / 1000) % 60; int min = (mili / 1000) / 60; System.out.println("time = " + min + ":" + sec); } else { throw new UnsupportedAudioFileException(); }
public F0TrackerAutocorrelationHeuristic(String wavFile, String ptcFile) throws Exception { if (FileUtils.exists(wavFile)) { params = new PitchFileHeader(); init(); PitchReaderWriter f0 = null; try { f0 = pitchAnalyzeWavFile(wavFile, ptcFile); } catch (UnsupportedAudioFileException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else throw new Exception("Wav file not found!"); }
System.err.println(ex.getMessage()); return;