从阵列到扬声器的输出(CreatePlayer,J2ME)

时间:2013-12-08 12:14:53

标签: java-me

我无法找到通过J2ME平台上的扬声器从阵列输出声音的简单代码(我知道Create Player类需要带参数的WAV头)。

int[] wav_hdr = {0x52,0x49,0x46,0x46,
                 0xC6,0x0F,0x00,0x00,
                 0x57,0x41,0x56,0x45,
                 0x66,0x6D,0x74,0x20,
                 0x12,0‌x00,0x00,0x00,
                 0x01,0x00,0x01,0x00,
                 0x40,0x1F,0x00,0x00,
                 0x40,0x1F,0x00,0x00,
                 0x01,0x00,0x08,0x00,
                 0x00,0x00,0x64,0x61,
                 0x74,0x61,0xA0,0x0‌​F,
                 0x00,0x00};\\ wav header

byte[] adata = new byte[wav_hdr.length+4000];

for(int i=0; i<wav_hdr.length; i++) {
  adata[i] = (byte)wav_hdr[i];
}

Player player = Manager.createPlayer(new ByteArrayInputStream(adata), "audio/x-wav"); 
player.start();

0 个答案:

没有答案