AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein [Java] Problem mit AudioInputStream
Thema durchsuchen
Ansicht
Themen-Optionen

[Java] Problem mit AudioInputStream

Ein Thema von 3_of_8 · begonnen am 1. Jul 2007
Antwort Antwort
Benutzerbild von 3_of_8
3_of_8

Registriert seit: 22. Mär 2005
Ort: Dingolfing
4.129 Beiträge
 
Turbo Delphi für Win32
 
#1

[Java] Problem mit AudioInputStream

  Alt 1. Jul 2007, 12:33
Morgen.

Ich spiel grad unter Java ein bisschen mit nem AudioInputStream herum und habe folgendes Problem:

Ich versuche, den Stream mit der Utility-Klasse AudioSystem in ein passendes Format zu verwandeln und dann die einzelnen Samplewerte auszulesen und in einen int[]-Buffer zu packen. Mein Code dazu sieht so aus:

Code:
    public int[] getIntBuffer()
            throws UnsupportedAudioFileException, IOException {
        AudioInputStream stream = getStream();      
        int[] buffer = null;
        try {
            AudioFormat tmpFormat =
                new AudioFormat(
                        Encoding.PCM_SIGNED,
                        stream.getFormat().getSampleRate(),
                        stream.getFormat().getSampleSizeInBits(),
                        1,
                        stream.getFormat().getFrameSize(),
                        stream.getFormat().getSampleRate(),
                        false);
            AudioInputStream tmpStream =
                AudioSystem.getAudioInputStream(tmpFormat, stream);
           
            byte[] buf = new byte[tmpFormat.getFrameSize()];
       
            buffer = new int[(int) tmpStream.getFrameLength()];
            if (tmpFormat.getFrameSize() > 1) {
                for (int i = 0; i < buffer.length; i++) {
                    tmpStream.read(buf);
                    buffer[i] = (int) (buf[0]) | (int) (buf[1])<<8;
                    System.out.println(buffer[i]);
                }
            } else {
                for (int i = 0; i < buffer.length; i++) {
                    tmpStream.read(buf);
                    buffer[i] = (int) (buf[0]);
                }               
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
       
        return buffer;
    }
Das Problem ist, dass mir der Stream Werte jenseits von Gut und Böse liefert, mit denen ich gar nichts anfangen kann.
Manuel Eberl
„The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.“
- Terry Pratchett
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:31 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz