jjdh API

dh.javax.sound
Class SoundFacade

java.lang.Object
  extended by dh.javax.sound.SoundFacade
Direct Known Subclasses:
StandardSoundFacade

public class SoundFacade
extends Object


Field Summary
protected static AudioProxy dummyAudioProxy
           
protected  Map<String,BufferStrategy> map
           
protected  BufferStrategyChooser strategyChooser
           
protected  ExecutorService threadPool
           
 
Constructor Summary
SoundFacade()
          Creates a new SoundFacade with can play maximal eight sounds simultaneously.
SoundFacade(int maxSimultaneousSounds)
          Creates a new SoundFacade with the specified maximum number of simultaneous playable sounds.
 
Method Summary
static AudioInputStream asAudioInputStream(InputStream is)
          Create a audio stream from the given input stream.
static SourceDataLine getLine(AudioFormat audioFormat)
          Open a data line to play the given type of sampled audio.
protected static int getMaxSimultaneousSounds(AudioFormat playbackFormat)
          Gets the maximum number of simultaneous sounds with the specified AudioFormat that the default mixer can play.
protected  BufferStrategy getStrategy(String name)
          Returrns the saved strategy for the given key ( null, if no mapping exists).
 AudioProxy play(InputStream is, String name)
          Will try to play the given input stream.
protected  StandardAudioProxy playAudioStream(AudioInputStream audioInputStream)
          Plays audio from the given uncompressed audio input stream.
protected  AudioProxy playAudioStream(BufferStrategy factory)
          Plays the audio from the given audio stream factory.
 AudioProxy playByName(String name)
          Will try to play the sound with the given Name (works only if the sound was olready one time played).
 void shutdown()
          Shutdown this SoundFacade.
 AudioProxy stream(InputStream is)
          Will try to stream the given input stream as audio.
 String toString()
          Returns s textual description of this SoundFacace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dummyAudioProxy

protected static final AudioProxy dummyAudioProxy

strategyChooser

protected BufferStrategyChooser strategyChooser

map

protected Map<String,BufferStrategy> map

threadPool

protected ExecutorService threadPool
Constructor Detail

SoundFacade

public SoundFacade()
Creates a new SoundFacade with can play maximal eight sounds simultaneously.


SoundFacade

public SoundFacade(int maxSimultaneousSounds)
Creates a new SoundFacade with the specified maximum number of simultaneous playable sounds.

Method Detail

getStrategy

protected BufferStrategy getStrategy(String name)
Returrns the saved strategy for the given key ( null, if no mapping exists).


stream

public AudioProxy stream(InputStream is)
Will try to stream the given input stream as audio.


playByName

public AudioProxy playByName(String name)
Will try to play the sound with the given Name (works only if the sound was olready one time played).


play

public AudioProxy play(InputStream is,
                       String name)
Will try to play the given input stream.


playAudioStream

protected AudioProxy playAudioStream(BufferStrategy factory)
Plays the audio from the given audio stream factory. This method creates a proxy, delegates the playing to the internal thread pool and returns the proxy immediately.

Returns:
a suitable proxy
Throws:
ExecutionException
InterruptedException

playAudioStream

protected StandardAudioProxy playAudioStream(AudioInputStream audioInputStream)
Plays audio from the given uncompressed audio input stream.


asAudioInputStream

public static AudioInputStream asAudioInputStream(InputStream is)
Create a audio stream from the given input stream.


getLine

public static SourceDataLine getLine(AudioFormat audioFormat)
Open a data line to play the given type of sampled audio.

Parameters:
audioFormat -

getMaxSimultaneousSounds

protected static int getMaxSimultaneousSounds(AudioFormat playbackFormat)
Gets the maximum number of simultaneous sounds with the specified AudioFormat that the default mixer can play.


shutdown

public void shutdown()
Shutdown this SoundFacade.


toString

public String toString()
Returns s textual description of this SoundFacace.

Overrides:
toString in class Object

jjdh API

Copyright © 2006 Jonas Jacobi and Dennis Heidsiek. All Rights Reserved.