how to play pcm raw data?
803751Oct 7 2010 — edited Oct 18 2010i want to play audio which is .amr format file
Java sound API do not support to decode amr file
so i find amr decoder to decode .amr file , the output of decoder is PCM format
(The decoder output information : 16-bit pulse code modulation (PCM) speech data sampled at 8 kHz.)
and then i save the pcm data in a byte array
this is my play pcm audio code :
float sampleRate = 8000;
int sampleSizeInBits = 16;
int channel = 1;
boolean signed = true;
boolean bigEndian = true;
byte[] data = getBytesFromFile(audioFile); // the byte[] data retrieve pcm format data
InputStream audio = new ByteArrayInputStream(data);
AudioFormat pcm = new AudioFormat(sampleRate, sampleSizeInBits,channel, signed, bigEndian);
ain = new AudioInputStream(audio, pcm, data.length / pcm.getFrameSize());
DataLine.Info info = new DataLine.Info(SourceDataLine.class, pcm);
line = (SourceDataLine) AudioSystem.getLine(info);
line.open(pcm);
line.start();
......
and then i execute the player
but the result is noise
i have no idea about that.....
help me ,plz....
sorry for my poor English :)
Edited by: 800748 on 2010/10/7 上午 5:53