示例#1
0
  /**
   * Constructs an <code>AudioSource</code> that will subscribe to the samples in <code>stream
   * </code>. It is expected that the stream is using a <code>DataLine</code> for playback. If it is
   * not, calls to <code>Controller</code>'s methods will result in a <code>NullPointerException
   * </code>.
   *
   * @param istream the <code>AudioStream</code> to subscribe to and wrap
   */
  public AudioSource(AudioStream istream) {
    super(istream.getControls());
    stream = istream;

    // we gots a buffer for users to poll
    buffer = new StereoBuffer(stream.getFormat().getChannels(), stream.bufferSize(), this);
    left = buffer.left;
    right = buffer.right;
    mix = buffer.mix;

    // we gots a signal splitter that we'll add any listeners the user wants
    splitter = new SignalSplitter(stream.getFormat(), stream.bufferSize());
    // we stick our buffer in the signal splitter because we can only set one
    // listener on the stream
    splitter.addListener(buffer);
    // and there it goes.
    stream.setAudioListener(splitter);

    // we got an effects chain that we'll add user effects to
    effects = new EffectsChain();
    // we set it as the effect on the stream
    stream.setAudioEffect(effects);

    stream.open();
  }
示例#2
0
 /** Closes the <code>AudioStream</code> this was constructed with. */
 public void close() {
   stream.close();
 }
示例#3
0
 @Override
 public float sampleRate() {
   return stream.getFormat().getSampleRate();
 }
示例#4
0
 @Override
 public int type() {
   return stream.getFormat().getChannels();
 }
示例#5
0
 @Override
 public AudioFormat getFormat() {
   return stream.getFormat();
 }
示例#6
0
 @Override
 public int bufferSize() {
   return stream.bufferSize();
 }