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

34
LINES

< > BotCompany Repo | #1006989 // Test AudioInputStream on speech .mp3 [dev.]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 455K of libraries. Click here for Pure Java version (2390L/16K/53K).

!7

lib 1001094 // JavaLayer 1.0.1
lib 1003620 // mp3spi1.9.4.jar
lib 1003621 // tritonus_share.jar

import javax.sound.sampled.*;

p {
  File file = william_silent("hello");
  print("MP3 size: " + file.length());
  fixContextClassLoader();

  AudioInputStream in = AudioSystem.getAudioInputStream(file);

  AudioFormat baseFormat = in.getFormat();
  AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 
    baseFormat.getSampleRate(),
    16,
    baseFormat.getChannels(),
    baseFormat.getChannels() * 2,
    baseFormat.getSampleRate(),
    false);
                                            
  AudioInputStream din = AudioSystem.getAudioInputStream(decodedFormat, in);
  int numBytes = din.available();
  System.out.println("numbytes: "+numBytes);
  byte[] buffer = new byte[numBytes];
  int count=0, n;
  while ((n = din.read(buffer, count, numBytes-count)) > 0) {
    count += n;
    print("Read " + count + " bytes");
  }
}

Author comment

Began life as a copy of #1006984

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

-
Snippet ID: #1006989
Snippet name: Test AudioInputStream on speech .mp3 [dev.]
Eternal ID of this version: #1006989/7
Text MD5: 6ef54ad141c8bb95837264894a029336
Transpilation MD5: ec1169e7a16b3ee25f334ee7d4efcf8d
Author: stefan
Category: javax / audio
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-02-24 13:51:15
Source code size: 989 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 443 / 526
Version history: 6 change(s)
Referenced in: