UM8AudioFormatConverter.java :  » Game » aetheria » micromod » output » converters » Java Open Source

Java Open Source » Game » aetheria 
aetheria » micromod » output » converters » UM8AudioFormatConverter.java

package micromod.output.converters;

/**
  Unsigned mono 8 bit cheesy output.
  This should allow anyone with an 8 bit soundcard (or just a half-arsed driver)
  to get at least some audio out of most of the output devices.
*/
public class UM8AudioFormatConverter implements AudioFormatConverter {
  public int getBytesPerFrame()    { return 1; }
  public int getNumberOfChannels() { return 1; }
  public boolean isSigned()        { return false; }
  public boolean isBigEndian()     { return false; }

  public void convert( short[] left, short[] right, int position, byte[] output, int length ) {
    int counter=0;
    length+=position;
    for ( int i=position; i<length; i++ ) {
      output[counter++] = (byte)( (left[i]+right[i]>>9)+128 );
    }
  }
}

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.