Como transformar WAV ou MID em um array de byte?

1 resposta
P

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)

Parameters:
data - a byte array containing the data to be played
type - type of the audio

1 Resposta

P

Tentei o seguinte código que achei na net e nem rolou!!!

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());
		}
		
		
		}
assim funciona:
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);
	}

Vocês sabem o que pode ser? Ou pelo menos como converter meu arquivo WAV para hexadecimal???

Criado 15 de junho de 2004
Ultima resposta 15 de jun. de 2004
Respostas 1
Participantes 1