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


Java AudioFormat.getSampleSizeInBits方法代码示例

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


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

示例1: GsmTrack

import javax.media.format.AudioFormat; //导入方法依赖的package包/类
GsmTrack(AudioFormat format, boolean enabled, Time startTime,
         int numBuffers, int bufferSize,
         long minLocation, long maxLocation) {
    super(GsmParser.this, 
          format, enabled, GsmParser.this.duration,
          startTime, numBuffers, bufferSize,
          GsmParser.this.stream, minLocation, maxLocation);

    double sampleRate = format.getSampleRate();
    int channels = format.getChannels();
    int sampleSizeInBits = format.getSampleSizeInBits();

    float bytesPerSecond;
    float bytesPerFrame;
    float samplesPerFrame;

    long durationNano = this.duration.getNanoseconds();
    if (!( (durationNano ==
          Duration.DURATION_UNKNOWN.getNanoseconds()) ||
           (durationNano == 
           Duration.DURATION_UNBOUNDED.getNanoseconds()) )) {
        maxFrame = mapTimeToFrame(this.duration.getSeconds());
    }
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:25,代码来源:GsmParser.java

示例2: setInputFormat

import javax.media.format.AudioFormat; //导入方法依赖的package包/类
@Override
public Format setInputFormat(Format format, int trackID)
{
    final AudioFormat af = (AudioFormat) format;
    if (af.getSampleSizeInBits() == 8
            && af.getSigned() == AudioFormat.SIGNED)
        return null; // 8-bit is always unsigned for Wav.

    if (af.getSampleSizeInBits() == 16
            && af.getSigned() == AudioFormat.UNSIGNED)
        return null; // 16-bit is always signed for Wav.

    return super.setInputFormat(format, trackID);
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:15,代码来源:WAVMux.java

示例3: processData

import javax.media.format.AudioFormat; //导入方法依赖的package包/类
public void processData(Buffer buf)
{
    if (getMute() || buf.isDiscard() || (buf.getLength() <= 0))
    {
        return;
    }

    AudioFormat af = (AudioFormat) buf.getFormat();

    byte[] data = (byte[]) buf.getData();

    if (af.getEncoding().equalsIgnoreCase("LINEAR"))
    {
        if (af.getSampleSizeInBits() == 16)
        {
            int msb = 0;
            int lsb = 1;

            if (af.getEndian() == AudioFormat.LITTLE_ENDIAN)
            {
                msb = 1;
                lsb = 0;
            }

            if (af.getSigned() == AudioFormat.SIGNED)
            {
                int peak = 0;
                int samples = data.length / 2;
                for (int i = 0; i < samples; i++)
                {
                    int value = (data[(i * 2) + msb] << 8)
                            + (data[(i * 2) + lsb] & 0xff);
                    if (value < 0)
                    {
                        value = -value;
                    }

                    if (value > peak)
                    {
                        peak = value;
                    }
                }

                peakLevel = peak / 32768.0f;
            }
        }
    }
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:49,代码来源:DataSource.java

示例4: processData

import javax.media.format.AudioFormat; //导入方法依赖的package包/类
public void processData(Buffer buf)
{
    if (getMute() || buf.isDiscard() || (buf.getLength() <= 0))
    {
        return;
    }

    AudioFormat af = (AudioFormat) buf.getFormat();
    byte[] data = (byte[]) buf.getData();

    if (af.getEncoding().equalsIgnoreCase("LINEAR"))
    {
        if (af.getSampleSizeInBits() == 16)
        {
            int msb = 0;
            int lsb = 1;

            if (af.getEndian() == AudioFormat.LITTLE_ENDIAN)
            {
                msb = 1;
                lsb = 0;
            }

            if (af.getSigned() == AudioFormat.SIGNED)
            {
                int peak = 0;
                int samples = data.length / 2;
                for (int i = 0; i < samples; i++)
                {
                    int value = (data[(i * 2) + msb] << 8)
                            + (data[(i * 2) + lsb] & 0xff);
                    if (value < 0)
                    {
                        value = -value;
                    }

                    if (value > peak)
                    {
                        peak = value;
                    }
                }

                peakLevel = peak / 32768.0f;
            }
        }
    }
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:48,代码来源:JavaSoundRenderer.java


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