public TimedAudioRecorder(TargetDataLine line, AudioFileFormat.Type targetType, File file, long timeout) { m_line = line; m_audioInputStream = new AudioInputStream(line); m_targetType = targetType; m_outputFile = file; this.timeout = timeout; }
public SimpleAudioRecorder(TargetDataLine line, AudioFileFormat.Type targetType, File file) { m_line = line; m_audioInputStream = new AudioInputStream(line); m_targetType = targetType; m_outputFile = file; }
public SimpleAudioRecorder(TargetDataLine line, AudioFileFormat.Type targetType, File file) { m_line = line; m_audioInputStream = new AudioInputStream(line); m_targetType = targetType; m_outputFile = file; }
public TimedAudioRecorder(TargetDataLine line, AudioFileFormat.Type targetType, File file, long timeout) { m_line = line; m_audioInputStream = new AudioInputStream(line); m_targetType = targetType; m_outputFile = file; this.timeout = timeout; }
public TimedAudioRecorder(TargetDataLine line, AudioFileFormat.Type targetType, File file, long timeout) { m_line = line; m_audioInputStream = new AudioInputStream(line); m_targetType = targetType; m_outputFile = file; this.timeout = timeout; }
public SimpleAudioRecorder(TargetDataLine line, AudioFileFormat.Type targetType, File file) { m_line = line; m_audioInputStream = new AudioInputStream(line); m_targetType = targetType; m_outputFile = file; }
public SimpleAudioRecorder(TargetDataLine line, AudioFileFormat.Type targetType, File file) { m_line = line; m_audioInputStream = new AudioInputStream(line); m_targetType = targetType; m_outputFile = file; }
public TimedAudioRecorder(TargetDataLine line, AudioFileFormat.Type targetType, File file, long timeout) { m_line = line; m_audioInputStream = new AudioInputStream(line); m_targetType = targetType; m_outputFile = file; this.timeout = timeout; }
public DirectRecorder(TargetDataLine line, AudioFileFormat.Type targetType, File file) { super(line, targetType, file); m_audioInputStream = new AudioInputStream(line); }
public DirectRecorder(TargetDataLine line, AudioFileFormat.Type targetType, File file) { super(line, targetType, file); m_audioInputStream = new AudioInputStream(line); }
public DirectRecorder(TargetDataLine line, AudioFileFormat.Type targetType, File file) { super(line, targetType, file); m_audioInputStream = new AudioInputStream(line); }
public DirectRecorder(TargetDataLine line, AudioFileFormat.Type targetType, File file) { super(line, targetType, file); m_audioInputStream = new AudioInputStream(line); }
/** * Writes the temporary file with the generated audio. * * @param inputStream input stream with the waveform * @param length length of the waveform * @return name of the generated temporary file * @throws IOException */ private static String writeWav(InputStream inputStream, int length) throws IOException { AudioFormat format = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, SAMPLE_RATE, 8, 1, 1, SAMPLE_RATE, false); File file = File.createTempFile("wav", "."); AudioSystem.write(new AudioInputStream(inputStream, format, length), AudioFileFormat.Type.WAVE, file); return file.getAbsolutePath(); } }
/** * Convert the audio data into an AudioInputStream of the proper AudioFormat. * * @param audioFormat * the format of the audio data. * @return an AudioInputStream from which the synthesised audio data can be read. * @throws IOException * if a problem occurred with the temporary file (only applies when using files as temporary storage). */ public AudioInputStream convertToAudioInputStream(AudioFormat audioFormat) throws IOException { if (ram) { assert os instanceof ByteArrayOutputStream; assert f == null; byte[] audioData = ((ByteArrayOutputStream) os).toByteArray(); // logger.debug("Total of " + audioData.length + " bytes of audio data for this section."); return new AudioInputStream(new ByteArrayInputStream(audioData), audioFormat, audioData.length / audioFormat.getFrameSize()); } else { assert os instanceof FileOutputStream; assert f != null; os.close(); long byteLength = f.length(); return new AudioInputStream(new FileInputStream(f), audioFormat, byteLength / audioFormat.getFrameSize()); } }
AudioInputStream ais = new AudioInputStream(bais, format, samples.length); if (filename.endsWith(".wav") || filename.endsWith(".WAV")) { AudioSystem.write(ais, AudioFileFormat.Type.WAVE, new File(filename));
/** * Save the audio as a WAV file in the given file. * * @param fileName the name of the audio file * @param fileFormat the audio file format * @throws java.io.IOException if IO went wrong */ public void save(String fileName, AudioFileFormat.Type fileFormat) throws IOException { File file = new File(fileName); byte[] audio = getAudio(); AudioInputStream ais = new AudioInputStream ((new ByteArrayInputStream(audio)), getAudioFormat(), audio.length); AudioSystem.write(ais, fileFormat, file); } }
public Microphone( float sampleRate, int sampleSize, boolean signed, boolean bigEndian) { AudioFormat format = new AudioFormat(sampleRate, sampleSize, 1, signed, bigEndian); try { line = AudioSystem.getTargetDataLine(format); line.open(); } catch (LineUnavailableException e) { throw new IllegalStateException(e); } inputStream = new AudioInputStream(line); }
/** * Writes the current stream to disc; override this method if you want to take * additional action on file writes * * @param wavName name of the file to be written */ protected void writeFile(String wavName) { AudioFormat wavFormat = new AudioFormat(sampleRate, bitsPerSample, 1, isSigned, true); AudioFileFormat.Type outputType = getTargetType("wav"); byte[] abAudioData = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(abAudioData); AudioInputStream ais = new AudioInputStream(bais, wavFormat, abAudioData.length / wavFormat.getFrameSize()); File outWavFile = new File(wavName); if (AudioSystem.isFileTypeSupported(outputType, ais)) { try { AudioSystem.write(ais, outputType, outWavFile); } catch (IOException e) { e.printStackTrace(); } } } }
new AudioInputStream( new SequenceInputStream(clip1, clip2), clip1.getFormat(),
private static void dumpStreamChunk(File file, String dstPath, long offset, long length) throws UnsupportedAudioFileException, IOException { AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(file); AudioInputStream inputStream = AudioSystem.getAudioInputStream(file); AudioFormat audioFormat = fileFormat.getFormat(); int bitrate = Math.round(audioFormat.getFrameSize() * audioFormat.getFrameRate() / 1000); inputStream.skip(offset * bitrate); AudioInputStream chunkStream = new AudioInputStream(inputStream, audioFormat, length * bitrate); AudioSystem.write(chunkStream, fileFormat.getType(), new File(dstPath)); inputStream.close(); chunkStream.close(); } }