DoubleDataSource audioSource = new DatagramDoubleDataSource(datagrams); return (new DDSAudioInputStream(new BufferedDoubleDataSource(audioSource), aft.getFormat()));
AudioSystem.write(outputAudio, AudioFileFormat.Type.WAVE, new File(outFileName)); long endTime = System.currentTimeMillis(); int audioDuration = (int) (AudioSystem.getAudioFileFormat(new File(file1)).getFrameLength() / (double) samplingRate * 1000); System.out.println("LSF-based interpolatin took " + (endTime - startTime) + " ms for " + audioDuration + " ms of audio");
if (audioFileFormat == null) throw new NullPointerException("audio file format is needed for output type AUDIO"); this.appendableAudioStream = new AppendableSequenceAudioInputStream(audioFileFormat.getFormat(), null); } else { this.appendableAudioStream = null; info.append("\", style \"" + this.defaultStyle); if (audioFileFormat != null) info.append("\", audio \"" + audioFileFormat.getType().toString() + "\""); if (streamAudio) info.append(", streaming");
audioFormat = Voice.AF16000; AudioFileFormat audioFileFormat = new AudioFileFormat(audioFileFormatType, audioFormat, AudioSystem.NOT_SPECIFIED); AudioFileFormat.Type audioType = maryRequest.getAudioFileFormat().getType(); AudioStreamNHttpEntity entity = new AudioStreamNHttpEntity(maryRequest); new Thread(entity, "HTTPWriter " + maryRequest.getId()).start(); else contentType = MaryHttpServerUtils.getMimeType(maryRequest.getAudioFileFormat().getType()); MaryHttpServerUtils.toHttpResponse(outputStream.toByteArray(), response, contentType); } catch (Exception e) {
@Override public AudioInputStream getAudioInputStream(InputStream in) throws UnsupportedAudioFileException, IOException { try { if(!in.markSupported()) in = new BufferedInputStream(in); in.mark(1000); final AudioFileFormat aff = getAudioFileFormat(in, AudioSystem.NOT_SPECIFIED); in.reset(); return new MP4AudioInputStream(in, aff.getFormat(), aff.getFrameLength()); } catch(UnsupportedAudioFileException e) { in.reset(); throw e; } catch(IOException e) { in.reset(); throw e; } }
try { AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(stream); Type type = fileFormat.getType(); if (type == Type.AIFC || type == Type.AIFF) { metadata.set(Metadata.CONTENT_TYPE, "audio/x-aiff"); AudioFormat audioFormat = fileFormat.getFormat(); int channels = audioFormat.getChannels(); if (channels != AudioSystem.NOT_SPECIFIED) { addMetadata(metadata, fileFormat.properties()); addMetadata(metadata, audioFormat.properties()); } catch (UnsupportedAudioFileException e) {
public Track readSingle(Track track) { TrackData trackData = track.getTrackData(); File file = trackData.getFile(); String title = Util.removeExt(file.getName()); trackData.setTagFieldValues(FieldKey.TITLE, title); try { AudioFileFormat format = AudioSystem.getAudioFileFormat(file); trackData.setStartPosition(0); AudioFormat audioFormat = format.getFormat(); trackData.setSampleRate((int) audioFormat.getSampleRate()); trackData.setTotalSamples(format.getFrameLength()); trackData.setChannels(audioFormat.getChannels()); trackData.setCodec(Util.getFileExt(file).toUpperCase()); if (format.getFrameLength() > 0) trackData.setBitrate((int) (format.getByteLength() / format.getFrameLength() * audioFormat.getSampleRate() / 100)); } catch (Exception e) { System.out.println("Couldn't read file: " + trackData.getFile()); } return track; }
public void run() { try { AudioSystem.write(request.getAudio(), request.getAudioFileFormat().getType(), output); output.flush(); output.close(); logger.info("Finished writing output"); } catch (IOException ioe) { logger.info("Cannot write output, client seems to have disconnected. ", ioe); request.abort(); } } }
private void setAudioFileFormatForVoice() { if (voice != null) { AudioFormat af = voice.dbAudioFormat(); audioFileFormat = new AudioFileFormat(AudioFileFormat.Type.WAVE, af, AudioSystem.NOT_SPECIFIED); } else { audioFileFormat = null; } }
File file = new File("filename.mp3"); AudioFileFormat baseFileFormat = new MpegAudioFileReader().getAudioFileFormat(file); Map properties = baseFileFormat.properties(); Long duration = (Long) properties.get("duration");
@Override public AudioInputStream getAudioInputStream(InputStream in) throws UnsupportedAudioFileException, IOException { try { if(!in.markSupported()) in = new BufferedInputStream(in); in.mark(1000); final AudioFileFormat aff = getAudioFileFormat(in, AudioSystem.NOT_SPECIFIED); in.reset(); return new MP4AudioInputStream(in, aff.getFormat(), aff.getFrameLength()); } catch(UnsupportedAudioFileException e) { in.reset(); throw e; } catch(IOException e) { in.reset(); throw e; } }
Type type = fileFormat.getType(); if (type == Type.AIFC || type == Type.AIFF) { metadata.set(Metadata.CONTENT_TYPE, "audio/x-aiff"); AudioFormat audioFormat = fileFormat.getFormat(); int channels = audioFormat.getChannels(); if (channels != AudioSystem.NOT_SPECIFIED) { addMetadata(metadata, fileFormat.properties()); addMetadata(metadata, audioFormat.properties()); } catch (UnsupportedAudioFileException e) {
public void run() { try { AudioSystem.write(request.getAudio(), request.getAudioFileFormat().getType(), output); output.flush(); output.close(); logger.info("Finished writing output"); } catch (IOException ioe) { logger.info("Cannot write output, client seems to have disconnected. ", ioe); request.abort(); } } }
private void setAudioFileFormatForVoice() { if (voice != null) { AudioFormat af = voice.dbAudioFormat(); audioFileFormat = new AudioFileFormat(AudioFileFormat.Type.WAVE, af, AudioSystem.NOT_SPECIFIED); } else { audioFileFormat = null; } }
audioFormat = Voice.AF16000; AudioFileFormat audioFileFormat = new AudioFileFormat(audioFileFormatType, audioFormat, AudioSystem.NOT_SPECIFIED); AudioFileFormat.Type audioType = maryRequest.getAudioFileFormat().getType(); AudioStreamNHttpEntity entity = new AudioStreamNHttpEntity(maryRequest); new Thread(entity, "HTTPWriter " + maryRequest.getId()).start(); else contentType = MaryHttpServerUtils.getMimeType(maryRequest.getAudioFileFormat().getType()); MaryHttpServerUtils.toHttpResponse(outputStream.toByteArray(), response, contentType); } catch (Exception e) {
@Nullable public Duration getDuration() { if (infoFormat.properties().containsKey("duration")) { long microDuration = (long) infoFormat.properties().get("duration"); return Duration.ofMillis(TimeUnit.MICROSECONDS.toMillis(microDuration)); } return null; }
/** * Return the AudioInputStream from the given InputStream. */ public AudioInputStream getAudioInputStream(InputStream inputStream, int medialength, int totalms) throws UnsupportedAudioFileException, IOException { if (TDebug.TraceAudioFileReader) TDebug.out("getAudioInputStream(InputStream inputStreamint medialength, int totalms)"); try { if (!inputStream.markSupported()) inputStream = new BufferedInputStream(inputStream); inputStream.mark(MARK_LIMIT); AudioFileFormat audioFileFormat = getAudioFileFormat(inputStream, medialength, totalms); inputStream.reset(); return new AudioInputStream(inputStream, audioFileFormat.getFormat(), audioFileFormat.getFrameLength()); } catch (UnsupportedAudioFileException e) { inputStream.reset(); throw e; } catch (IOException e) { inputStream.reset(); throw e; } }
DoubleDataSource audioSource = new DatagramDoubleDataSource(datagrams); return (new DDSAudioInputStream(new BufferedDoubleDataSource(audioSource), aft.getFormat()));
if (audioFileFormat == null) throw new NullPointerException("audio file format is needed for output type AUDIO"); this.appendableAudioStream = new AppendableSequenceAudioInputStream(audioFileFormat.getFormat(), null); } else { this.appendableAudioStream = null; info.append("\", style \"" + this.defaultStyle); if (audioFileFormat != null) info.append("\", audio \"" + audioFileFormat.getType().toString() + "\""); if (streamAudio) info.append(", streaming");
try { AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(stream); Type type = fileFormat.getType(); if (type == Type.AIFC || type == Type.AIFF) { metadata.set(Metadata.CONTENT_TYPE, "audio/x-aiff"); AudioFormat audioFormat = fileFormat.getFormat(); int channels = audioFormat.getChannels(); if (channels != AudioSystem.NOT_SPECIFIED) { addMetadata(metadata, fileFormat.properties()); addMetadata(metadata, audioFormat.properties()); } catch (UnsupportedAudioFileException e) {