Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

14
LINES

< > BotCompany Repo | #1007036 // pcmToWAVE

JavaX fragment (include)

import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;

// format is for both the PCM and the output file
static void pcmToWAVE(byte[] pcm, AudioFormat format, File outputFile) ctex {
  AudioInputStream sourceStream = new AudioInputStream(new ByteArrayInputStream(pcm), format, l(pcm)); // TODO: last parameter should be length in frames?
  AudioInputStream stream = AudioSystem.getAudioInputStream(format, sourceStream);
  AudioSystem.write(stream, AudioFileFormat.Type.WAVE, outputFile);
  sourceStream.close();
  stream.close();
}

Author comment

Began life as a copy of #1004799

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007036
Snippet name: pcmToWAVE
Eternal ID of this version: #1007036/3
Text MD5: 3929a8d73b1db2933a8cd04bd2c49935
Author: stefan
Category: javax / speech
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-07 16:19:22
Source code size: 720 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 582 / 598
Version history: 2 change(s)
Referenced in: [show references]