当前位置: 首页>>代码示例>>Java>>正文


Java AudioFormat.BIG_ENDIAN属性代码示例

本文整理汇总了Java中javax.media.format.AudioFormat.BIG_ENDIAN属性的典型用法代码示例。如果您正苦于以下问题:Java AudioFormat.BIG_ENDIAN属性的具体用法?Java AudioFormat.BIG_ENDIAN怎么用?Java AudioFormat.BIG_ENDIAN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.media.format.AudioFormat的用法示例。


在下文中一共展示了AudioFormat.BIG_ENDIAN属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSupportedInputFormats

@Override
public Format[] getSupportedInputFormats()
{
    // TODO: query AudioSystem
    return new Format[] {
            new AudioFormat(AudioFormat.LINEAR, -1, 8, -1, -1,
                    AudioFormat.SIGNED),
            new AudioFormat(AudioFormat.LINEAR, -1, 16, -1,
                    AudioFormat.BIG_ENDIAN, AudioFormat.SIGNED),
            new AudioFormat(AudioFormat.LINEAR, -1, 24, -1,
                    AudioFormat.BIG_ENDIAN, AudioFormat.SIGNED),
            new AudioFormat(AudioFormat.LINEAR, -1, 32, -1,
                    AudioFormat.BIG_ENDIAN, AudioFormat.SIGNED),
            new AudioFormat(AudioFormat.ULAW), // TODO: narrow down
            new AudioFormat(AudioFormat.ALAW) // TODO: narrow down
    };
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:17,代码来源:JavaSoundAUMux.java

示例2: readHeader

private void /* for now void */ readHeader()
    throws IOException, BadHeaderException {

    minLocation = getLocation(stream); // Should be zero

    long contentLength = stream.getContentLength();
    if ( contentLength != SourceStream.LENGTH_UNKNOWN ) {
        double durationSeconds = contentLength / bytesPerSecond;


        duration = new Time(durationSeconds);
        maxLocation = contentLength;

    } else {
        maxLocation = Long.MAX_VALUE;
    }

    boolean signed = true;
    boolean bigEndian = false;
    format = new AudioFormat(AudioFormat.GSM,
                             8000,  // sampleRate,
                             16,    // sampleSizeInBits,
                             1,     // channels,
                             bigEndian ? AudioFormat.BIG_ENDIAN : 
                            AudioFormat.LITTLE_ENDIAN,
                             signed ? AudioFormat.SIGNED : 
                            AudioFormat.UNSIGNED,
                             (blockSize * 8), // frameSizeInBits
                             Format.NOT_SPECIFIED,  
                             Format.byteArray);
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:31,代码来源:GsmParser.java

示例3: process

public int process(Buffer inputBuffer, Buffer outputBuffer){
// == prolog
if (isEOM(inputBuffer) ) {
    propagateEOM(outputBuffer);
    return BUFFER_PROCESSED_OK;
}

byte [] inBuffer       = (byte[])inputBuffer.getData();
int     inLength       = inputBuffer.getLength();
int     inOffset       = inputBuffer.getOffset();
int     samplesNumber  = inLength;
AudioFormat af = (AudioFormat) inputBuffer.getFormat();


if (enabled) { 
    int shiftZero = 0;
    int shiftOne = 8;
    if (af.getEndian() == AudioFormat.BIG_ENDIAN) {
	shiftZero = 8;
	shiftOne = 0;
    }

    // == main
    int spa = ((int) af.getSampleRate() * af.getChannels()) / nPowersPerSec;
    long npa = 1000000000L / nPowersPerSec;
    long timeStamp = inputBuffer.getTimeStamp(); // in nanos
    float average = 0;
    long cspa = 0;
    for (int i = 0; i < inLength; i += 2) {
	short sample = (short)
	    (((0xFF & inBuffer[inOffset + i]) << shiftZero) |
	     ((0xFF & inBuffer[inOffset + i + 1]) << shiftOne));
	float normal = (float) sample;
	average = average + normal * normal;
	cspa++;
	if (cspa == spa) {
	    cspa = 0;
	    average = (float) Math.sqrt((average / spa)) / 32768;
	    push(timeStamp, average);
	    timeStamp += npa;
	    average = 0;
	}
    }
}

// == epilog
inputBuffer.setData(outputBuffer.getData());
outputBuffer.setFormat(af);
outputBuffer.setData(inBuffer);
outputBuffer.setLength(inLength);
outputBuffer.setOffset(inOffset);
outputBuffer.setTimeStamp(inputBuffer.getTimeStamp());
outputBuffer.setFlags(inputBuffer.getFlags());

return BUFFER_PROCESSED_OK;
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:56,代码来源:PowerMeter.java

示例4: convertFormat

/**
 * Convert javax.sound.sampled.AudioFormat to
 * javax.media.format.AudioFormat.
 */
public static AudioFormat convertFormat(
        javax.sound.sampled.AudioFormat format)
{
    Encoding encoding = format.getEncoding();
    int channels = format.getChannels();
    float frameRate = format.getFrameRate();
    int frameSize = format.getFrameSize() < 0 ? format.getFrameSize()
            : (format.getFrameSize() * 8);
    float sampleRate = format.getSampleRate();
    int sampleSize = format.getSampleSizeInBits();

    int endian = format.isBigEndian() ? AudioFormat.BIG_ENDIAN
            : AudioFormat.LITTLE_ENDIAN;

    int signed = Format.NOT_SPECIFIED;
    String encodingString = AudioFormat.LINEAR;

    if (encoding == Encoding.PCM_SIGNED)
    {
        signed = AudioFormat.SIGNED;
        encodingString = AudioFormat.LINEAR;
    } else if (encoding == Encoding.PCM_UNSIGNED)
    {
        signed = AudioFormat.UNSIGNED;
        encodingString = AudioFormat.LINEAR;
    } else if (encoding == Encoding.ALAW)
    {
        encodingString = AudioFormat.ALAW;
    } else if (encoding == Encoding.ULAW)
    {
        encodingString = AudioFormat.ULAW;
    } else
    {
        encodingString = encoding.toString();

    }

    AudioFormat jmfFormat = new AudioFormat(encodingString, sampleRate,
            sampleSize, channels, endian, signed, frameSize, frameRate,
            Format.byteArray);

    return jmfFormat;
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:47,代码来源:JavaSoundUtils.java


注:本文中的javax.media.format.AudioFormat.BIG_ENDIAN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。