오디오 파일을 표준 형식으로 변환하고 바이트를 읽으려고합니다. 내가 할동일한 오디오 파일에서 다른 바이트 가져 오기
우선은 다음과 같습니다
static void main(String [] args)
{
File file = new File("/path/to/my/file.mp3");
AudioInputStream source = AudioSystem.getAudioInputStream(file);
AudioFormat sourceFormat = source.getFormat();
AudioFormat convertFormat = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
sourceFormat.getSampleRate(),
16,
sourceFormat.getChannels(),
sourceFormat.getChannels() * 2,
sourceFormat.getSampleRate(),
false);
AudioInputStream convert1AIS = AudioSystem.getAudioInputStream(convertFormat, source);
AudioFormat targetFormat = new AudioFormat(
44100,
8,
1,
true,
true);
AudioInputStream target = AudioSystem.getAudioInputStream(targetFormat, convert1AIS);
byte[] buffer = new byte[4096];
//Here come strange things
target.read(buffer,0, buffer.length);
}
내가 프로그램을 시작할 때마다, 버퍼 내가 같은 결코 디버거에서 볼 즉 서로 다른 바이트, 처음 10 바이트를 포함한다. 뭐가 잘못 되었 니? jl1.0.1.jar, jtransform-2.4.jar, mp3spi1.9.5.jar, tritonus_remaining-0.3.6.jar, tritonus_share.jar
OS :
나는 다음과 같은 라이브러리를 추가 한 . 우분투 14.04
자바 버전 "1.8.0_111" 자바 (TM) SE 런타임 환경 (빌드 1.8.0_111-B14) 자바 핫스팟 (TM) 64 비트 서버 VM (25.111-B14, 혼합 모드를 구축)
를
필자는이 API를 사용하지 않았지만 MP3를 PCM으로 읽으려는 것처럼 보입니다. 단지 작동하지 않을 것입니다. MP3 코덱을 사용하여 다른 것을하기 전에 MP3를 PCM으로 디코딩해야합니다. – Brad
모든 라이브러리를 추가했지만 어디에서 사용합니까? mp3는 특별히 audioinputstream을 읽지 않아도됩니다. 왜 isnt로 시작하는 라이브러리를 추가했는지 그 이유는 무엇입니까? 이 라이브러리를 사용하여 mp3를 읽는 다른 예제를 보거나 나중에 다시 올 것이다. – gpasch