本文整理汇总了Java中javax.media.format.AudioFormat.LINEAR属性的典型用法代码示例。如果您正苦于以下问题:Java AudioFormat.LINEAR属性的具体用法?Java AudioFormat.LINEAR怎么用?Java AudioFormat.LINEAR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.media.format.AudioFormat
的用法示例。
在下文中一共展示了AudioFormat.LINEAR属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PowerMeter
public PowerMeter(int nPowersPerSec) {
this.nPowersPerSec = nPowersPerSec;
timeStamps = new long[nPowersPerSec * NUM_SECONDS];
powers = new float[nPowersPerSec * NUM_SECONDS];
inputFormats = new Format[] {new AudioFormat(AudioFormat.LINEAR,
Format.NOT_SPECIFIED,
16,
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED,
Format.byteArray)};
outputFormats = new Format[] {new AudioFormat(AudioFormat.LINEAR,
Format.NOT_SPECIFIED,
16,
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED,
Format.byteArray)};
}
示例2: PcmDepacketizer
public PcmDepacketizer() {
supportedInputFormats = new AudioFormat[] {
new AudioFormat(
CUSTOM_PCM
)
};
// We have to assume some defaults for the output
// format. Otherwise, the data flow graph cannot
// be initialized.
supportedOutputFormats = new AudioFormat[] {
new AudioFormat(
AudioFormat.LINEAR,
DEFAULT_RATE,
DEFAULT_SIZE,
DEFAULT_CHNLS
)
};
}
示例3: 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
};
}
示例4: PcmPacketizer
public PcmPacketizer() {
supportedInputFormats = new AudioFormat[] {
new AudioFormat(
AudioFormat.LINEAR
)
};
supportedOutputFormats = new AudioFormat[] {
new AudioFormat(
CUSTOM_PCM
)
};
}
示例5: initializeSound
private void initializeSound() {
Format input1 = new AudioFormat(AudioFormat.MPEGLAYER3);
Format input2 = new AudioFormat(AudioFormat.MPEG);
Format output = new AudioFormat(AudioFormat.LINEAR);
PlugInManager.addPlugIn(
"com.sun.media.codec.audio.mp3.JavaDecoder",
new Format[]{input1, input2},
new Format[]{output},
PlugInManager.CODEC
);
}
示例6: LiveStream
public LiveStream() {
if (videoData) {
int x, y, pos, revpos;
size = new Dimension(320, 240);
maxDataLength = size.width * size.height * 3;
rgbFormat = new RGBFormat(size, maxDataLength,
Format.byteArray,
frameRate,
24,
3, 2, 1,
3, size.width * 3,
VideoFormat.FALSE,
Format.NOT_SPECIFIED);
// generate the data
data = new byte[maxDataLength];
pos = 0;
revpos = (size.height - 1) * size.width * 3;
for (y = 0; y < size.height / 2; y++) {
for (x = 0; x < size.width; x++) {
byte value = (byte) ((y*2) & 0xFF);
data[pos++] = value;
data[pos++] = 0;
data[pos++] = 0;
data[revpos++] = value;
data[revpos++] = 0;
data[revpos++] = 0;
}
revpos -= size.width * 6;
}
} else { // audio data
audioFormat = new AudioFormat(AudioFormat.LINEAR,
8000.0,
8,
1,
Format.NOT_SPECIFIED,
AudioFormat.SIGNED,
8,
Format.NOT_SPECIFIED,
Format.byteArray);
maxDataLength = 1000;
}
thread = new Thread(this);
}
示例7: 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;
}
示例8: getSupportedInputFormats
@Override
public Format[] getSupportedInputFormats()
{
// TODO: query AudioSystem
return new Format[] { new AudioFormat(AudioFormat.LINEAR) };
}
示例9: detectDirectAudio
private void detectDirectAudio() {
Class<?> cls;
int plType = PlugInManager.RENDERER;
String dar = "com.sun.media.renderer.audio.DirectAudioRenderer";
try {
// Check if this is the Windows Performance Pack - hack
cls = Class.forName("VFWAuto");
// Check if DS capture is supported, otherwise fail DS renderer
// since NT doesn't have capture
cls = Class.forName("com.sun.media.protocol.dsound.DSound");
// Find the renderer class and instantiate it.
cls = Class.forName(dar);
Renderer rend = (Renderer) cls.newInstance();
try {
// Set the format and open the device
AudioFormat af = new AudioFormat(AudioFormat.LINEAR, 44100, 16,
2);
rend.setInputFormat(af);
rend.open();
Format[] inputFormats = rend.getSupportedInputFormats();
// Register the device
PlugInManager.addPlugIn(dar, inputFormats, new Format[0],
plType);
// Move it to the top of the list
Vector<String> rendList = PlugInManager.getPlugInList(null, null,
plType);
int listSize = rendList.size();
if (rendList.elementAt(listSize - 1).equals(dar)) {
rendList.removeElementAt(listSize - 1);
rendList.insertElementAt(dar, 0);
PlugInManager.setPlugInList(rendList, plType);
PlugInManager.commit();
// Log.debug("registered");
}
rend.close();
}
catch (Throwable t) {
// Log.debug("Error " + t);
}
}
catch (Throwable tt) {
//Do nothing
}
}
示例10: getSupportedInputFormats
/**
* Implements {@link Renderer#getSupportedInputFormats()}. Gets the list of
* input <tt>Format</tt>s supported by this <tt>Renderer</tt>.
*
* @return the list of input <tt>Format</tt>s supported by this
* <tt>Renderer</tt>
* @see Renderer#getSupportedInputFormats()
*/
public Format[] getSupportedInputFormats()
{
if (supportedInputFormats == null)
{
double[] supportedInputSampleRates
= new double[1 + Constants.AUDIO_SAMPLE_RATES.length];
int supportedInputSampleRateCount = 0;
supportedInputSampleRates[supportedInputSampleRateCount]
= AudioTrack.getNativeOutputSampleRate(getStreamType());
supportedInputSampleRateCount++;
System.arraycopy(
Constants.AUDIO_SAMPLE_RATES, 0,
supportedInputSampleRates, supportedInputSampleRateCount,
Constants.AUDIO_SAMPLE_RATES.length);
supportedInputSampleRateCount
+= Constants.AUDIO_SAMPLE_RATES.length;
supportedInputFormats
= new Format[2 * supportedInputSampleRateCount];
for (int i = 0; i < supportedInputSampleRateCount; i++)
{
double sampleRate = supportedInputSampleRates[i];
supportedInputFormats[2 * i]
= new AudioFormat(
AudioFormat.LINEAR,
sampleRate,
16 /* sampleSizeInBits */,
Format.NOT_SPECIFIED /* channels */,
AudioFormat.LITTLE_ENDIAN,
AudioFormat.SIGNED,
Format.NOT_SPECIFIED /* frameSizeInBits */,
Format.NOT_SPECIFIED /* frameRate */,
Format.byteArray);
supportedInputFormats[2 * i + 1]
= new AudioFormat(
AudioFormat.LINEAR,
sampleRate,
8 /* sampleSizeInBits */,
Format.NOT_SPECIFIED /* channels */,
AudioFormat.LITTLE_ENDIAN,
AudioFormat.SIGNED,
Format.NOT_SPECIFIED /* frameSizeInBits */,
Format.NOT_SPECIFIED /* frameRate */,
Format.byteArray);
}
}
return supportedInputFormats.clone();
}
示例11: detectDirectAudio
private void detectDirectAudio() {
Class<?> cls;
int plType = PlugInManager.RENDERER;
String dar = "com.sun.media.renderer.audio.DirectAudioRenderer";
try {
// Check if this is the Windows Performance Pack - hack
Class.forName("VFWAuto");
// Check if DS capture is supported, otherwise fail DS renderer
// since NT doesn't have capture
Class.forName("com.sun.media.protocol.dsound.DSound");
// Find the renderer class and instantiate it.
cls = Class.forName(dar);
Renderer rend = (Renderer)cls.newInstance();
try {
// Set the format and open the device
AudioFormat af = new AudioFormat(AudioFormat.LINEAR, 44100, 16,
2);
rend.setInputFormat(af);
rend.open();
Format[] inputFormats = rend.getSupportedInputFormats();
// Register the device
PlugInManager.addPlugIn(dar, inputFormats, new Format[0],
plType);
// Move it to the top of the list
Vector<String> rendList = PlugInManager.getPlugInList(null, null, plType);
int listSize = rendList.size();
if (rendList.elementAt(listSize - 1).equals(dar)) {
rendList.removeElementAt(listSize - 1);
rendList.insertElementAt(dar, 0);
PlugInManager.setPlugInList(rendList, plType);
PlugInManager.commit();
// Log.debug("registered");
}
rend.close();
}
catch (Throwable t) {
// Log.debug("Error " + t);
}
}
catch (Throwable tt) {
// Nothing to do
}
}