本文整理汇总了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());
}
}
示例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);
}
示例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;
}
}
}
}
示例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;
}
}
}
}