ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
330
330
EMPFEHLEN
-
Hallo miteinander!
Derzeit bin ich dabei ein Spiel zu programmieren, welches mir aus einer .wav Datei eine Welle zeichnet, auf dem ein kleiner Surfer dann surfen kann.
Hierfür habe ich die Klasse, welches mir eine .wav Datei schon mal abspielt:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
import java.io.File; import java.io.IOException; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.FloatControl; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.SourceDataLine; import javax.sound.sampled.UnsupportedAudioFileException; public class AePlayWave extends Thread { private String filename; private Position curPosition; private final int EXTERNAL_BUFFER_SIZE = 524288; // 128Kb enum Position { LEFT, RIGHT, NORMAL }; public AePlayWave(String wavfile) { filename = wavfile; curPosition = Position.NORMAL; } public AePlayWave(String wavfile, Position p) { filename = wavfile; curPosition = p; } public void run() { File soundFile = new File(filename); if (!soundFile.exists()) { System.err.println("Wave file not found: " + filename); return; } AudioInputStream audioInputStream = null; try { audioInputStream = AudioSystem.getAudioInputStream(soundFile); } catch (UnsupportedAudioFileException e1) { e1.printStackTrace(); return; } catch (IOException e1) { e1.printStackTrace(); return; } AudioFormat format = audioInputStream.getFormat(); SourceDataLine auline = null; DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); try { auline = (SourceDataLine) AudioSystem.getLine(info); auline.open(format); } catch (LineUnavailableException e) { e.printStackTrace(); return; } catch (Exception e) { e.printStackTrace(); return; } if (auline.isControlSupported(FloatControl.Type.PAN)) { FloatControl pan = (FloatControl) auline .getControl(FloatControl.Type.PAN); if (curPosition == Position.RIGHT) pan.setValue(1.0f); else if (curPosition == Position.LEFT) pan.setValue(-1.0f); } auline.start(); int nBytesRead = 0; byte[] abData = new byte[EXTERNAL_BUFFER_SIZE]; try { while (nBytesRead != -1) { nBytesRead = audioInputStream.read(abData, 0, abData.length); if (nBytesRead >= 0) auline.write(abData, 0, nBytesRead); } } catch (IOException e) { e.printStackTrace(); return; } finally { auline.drain(); auline.close(); } } }
Zu meiner Frage:
Der Bytecode bzw. das Lied wird ja in den Zeilen
abgespielt.Code :1 2 3 4 5 6
try { while (nBytesRead != -1) { nBytesRead = audioInputStream.read(abData, 0, abData.length); if (nBytesRead >= 0) auline.write(abData, 0, nBytesRead); }
Ist es möglich genau herauszufinden, welches Byte zu welcher Zeit(sek oder ms) gerade meine Boxen verlässt?
Oder anders gefragt: Wie weiß ich, wann welches Byte in die DataSourceLine geschrieben wird?
Danke im Voraus !
Ähnliche Themen
-
Bildwechsel mit Zeitangabe
Von MJRENNER im Forum Relationale DatenbanksystemeAntworten: 9Letzter Beitrag: 30.09.09, 19:00 -
INSERT: Zeitangabe
Von Hattrix im Forum Relationale DatenbanksystemeAntworten: 9Letzter Beitrag: 14.03.07, 16:41 -
[C] größeren Bytestrom erzeugen und übergeben
Von rohrbold im Forum C/C++Antworten: 0Letzter Beitrag: 28.02.06, 18:12 -
Problem mit Zeitangabe
Von xtraMen im Forum PHPAntworten: 1Letzter Beitrag: 25.04.05, 15:21 -
zeitangabe mit nullen füllen!
Von redback79 im Forum PHPAntworten: 10Letzter Beitrag: 15.03.02, 23:21





Zitieren
Login





