phstc
Junho 12, 2004, 1:57pm
#1
Pessoal estou usando uma api da Nokia(com.nokia.mid.sound.Sound), para o metodo init requer um array de byte com o arquivo a ser tocado como eu faço isso em J2ME???
public void init(byte[] data,
int type)
[quote]Parameters:
data - a byte array containing the data to be played
type - type of the audio [/quote]
phstc
Junho 15, 2004, 4:50pm
#2
Tentei o seguinte código que achei na net e nem rolou!!!
[code] void initItNokia() {
try
{
Sound soundWav;
InputStream tune = this.getClass().getResourceAsStream("loud.WAV");
byte[] buffer = new byte[1192];
tune.read(buffer, 0, buffer.length);
soundWav = new Sound(22, 1000L);
soundWav.init(buffer, Sound.FORMAT_WAV);
soundWav.setGain(255);
soundWav.play(25);
buffer = null;
} catch (Exception e) {
System.out.println(e.getMessage());
}
}[/code]
assim funciona:
[code]
private void initItNokia() {
byte[] soundData = {(byte) 0x02, (byte) 0x4A, (byte) 0x3A, (byte) 0x51,
(byte) 0xD1, (byte) 0x95, (byte) 0xCD, (byte) 0xD0,
(byte) 0x08, (byte) 0x00, (byte) 0x1B, (byte) 0x20, (byte) 0x55}; Sound sound = new Sound(soundData, Sound.FORMAT_TONE);
sound.setGain(255);
sound.play(1);
}[/code]
Vocês sabem o que pode ser? Ou pelo menos como converter meu arquivo WAV para hexadecimal???