本文整理汇总了Java中javax.media.format.AudioFormat类的典型用法代码示例。如果您正苦于以下问题:Java AudioFormat类的具体用法?Java AudioFormat怎么用?Java AudioFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AudioFormat类属于javax.media.format包,在下文中一共展示了AudioFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFormat
import javax.media.format.AudioFormat; //导入依赖的package包/类
public Format setFormat(Format format)
{
setJMFAudioFormat((javax.media.format.AudioFormat) format);
// TODO: return specific format if passed in format is partially
// unspecified
// format changed, change targetDataLine format ( this will also
// recalc buflen )
if (connected)
{
disconnect();
try
{
connect();
} catch (IOException e)
{
logger.log(Level.WARNING, "" + e, e);
return null;
}
}
return jmfAudioFormat;
}
示例2: getTracks
import javax.media.format.AudioFormat; //导入依赖的package包/类
public Track[] getTracks() throws IOException, BadHeaderException {
if (tracks[0] != null)
return tracks;
stream = (PullSourceStream) streams[0];
readHeader();
bufferSize = bytesPerSecond;
tracks[0] = new GsmTrack((AudioFormat) format,
/*enabled=*/ true,
new Time(0),
numBuffers,
bufferSize,
minLocation,
maxLocation
);
return tracks;
}
示例3: 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());
}
}
示例4: PowerMeter
import javax.media.format.AudioFormat; //导入依赖的package包/类
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)};
}
示例5: PcmDepacketizer
import javax.media.format.AudioFormat; //导入依赖的package包/类
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
)
};
}
示例6: getSupportedInputFormats
import javax.media.format.AudioFormat; //导入依赖的package包/类
@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
};
}
示例7: getMyTracks
import javax.media.format.AudioFormat; //导入依赖的package包/类
private void getMyTracks() {
Format format;
TrackControl[] track = p.getTrackControls();
track_amount = track.length;
trackInfos = new String[track_amount];
Time t = p.getDuration();
trackTime = t.getSeconds();
for (int i = 0; i < track_amount; i++) {
format = track[i].getFormat();
trackInfos[i] = format.toString();
if (format instanceof VideoFormat) {
videoTrack = true;
}
if (format instanceof AudioFormat) {
audioTrack = true;
}
}
read = true;
}
示例8: setclockrates
import javax.media.format.AudioFormat; //导入依赖的package包/类
void setclockrates()
{
for (int i = 0; i < 16; i++)
clockrate[i] = 8000;
clockrate[6] = 16000;
clockrate[10] = 44100;
clockrate[11] = 44100;
clockrate[14] = 0x15f90;
clockrate[16] = 11025;
clockrate[17] = 22050;
clockrate[18] = 44100;
for (int i = 24; i < 34; i++)
clockrate[i] = 0x15f90;
for (int i = 96; i < 128; i++)
{
javax.media.Format fmt = sm.formatinfo.get(i);
if (fmt != null && (fmt instanceof AudioFormat))
clockrate[i] = (int) ((AudioFormat) fmt).getSampleRate();
else
clockrate[i] = 0x15f90;
}
}
示例9: setHandlers
import javax.media.format.AudioFormat; //导入依赖的package包/类
/**
* Set appropriate handlers for the audio and video tracks.
* We create our own handlers, which in turn will call the
* handlers provided to us in the constructor of this class.
*/
private void setHandlers()
{
TrackControl controls[] = processor.getTrackControls();
int nControls = controls.length;
int i;
for (i=0;i<nControls;i++) {
Format format = controls[i].getFormat();
try {
if (format instanceof VideoFormat) {
videoRenderer = new VideoRenderer(videoHandler);
controls[i].setRenderer(videoRenderer);
} else if (format instanceof AudioFormat) {
controls[i].setRenderer(new AudioRenderer());
} else {
System.err.println("Unknown track type");
}
} catch (UnsupportedPlugInException e) {
System.err.println("Got exception "+e);
}
}
}
示例10: getPreferredFormat
import javax.media.format.AudioFormat; //导入依赖的package包/类
/**
* reads the codec-order from the user-preferences
*
* @return
*/
//TODO REMOVE
@SuppressWarnings("unused")
private AudioFormat getPreferredFormat(ArrayList<String> formate){
LocalPreferences localPreferences = SettingsManager.getLocalPreferences();
// gets the selected order from preferences
String[] codecs = localPreferences.getSelectedCodecs().split("\\^");
for(String codec: codecs) {
for(String format : formate) {
if(format != null
&& format.toLowerCase().equals(codec.toLowerCase()))
return new AudioFormat(format);
}
}
// this return shouldn't be executed, but if no codec was found, then use the first
return new AudioFormat(formate.get(0));
}
示例11: getSelectedFormats
import javax.media.format.AudioFormat; //导入依赖的package包/类
private List<AudioFormat> getSelectedFormats(){
List<AudioFormat> format = new ArrayList<AudioFormat>();
List<AudioFormat> all = getAudioFormats();
LocalPreferences localPreferences = SettingsManager.getLocalPreferences();
// gets the selected order from preferences
String[] codecs = localPreferences.getSelectedCodecs().split("\\^");
for(AudioFormat form : all) {
for(String codec: codecs) {
if(form.getEncoding().toLowerCase().equals(codec.toLowerCase())){
format.add(form);
}
}
}
System.out.println("FORMATE NEU: " + format);
return format;
}
示例12: readHeader
import javax.media.format.AudioFormat; //导入依赖的package包/类
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);
}
示例13: PcmPacketizer
import javax.media.format.AudioFormat; //导入依赖的package包/类
public PcmPacketizer() {
supportedInputFormats = new AudioFormat[] {
new AudioFormat(
AudioFormat.LINEAR
)
};
supportedOutputFormats = new AudioFormat[] {
new AudioFormat(
CUSTOM_PCM
)
};
}
示例14: doAudioEffect
import javax.media.format.AudioFormat; //导入依赖的package包/类
void doAudioEffect(byte [] dest, byte [] src,
int destOffset, int srcOffset,
int count, int endian) {
short sDest, sSrc, result;
if (audioEffectDiff == 0)
audioEffectDiff = 4.0f / audioEffectDurationInSamples;
if (endian == AudioFormat.LITTLE_ENDIAN) {
for (int i = 0; i < count; i+=4) {
sDest = (short) ((dest[i+destOffset] & 0xFF) | ((dest[i+destOffset+1] & 0xFF) << 8));
sSrc = (short) ((src[i+srcOffset] & 0xFF) | ((src[i+srcOffset+1] & 0xFF) << 8));
result = (short) (sDest * (1 - audioEffectCurrent) + sSrc * audioEffectCurrent);
dest[i+destOffset] = (byte) (result & 0xFF);
dest[i+destOffset+1] = (byte) ((result >> 8) & 0xFF);
sDest = (short) ((dest[i+destOffset+2] & 0xFF) | ((dest[i+destOffset+3] & 0xFF) << 8));
sSrc = (short) ((src[i+srcOffset+2] & 0xFF) | ((src[i+srcOffset+3] & 0xFF) << 8));
result = (short) (sDest * (1 - audioEffectCurrent) + sSrc * audioEffectCurrent);
dest[i+destOffset+2] = (byte) (result & 0xFF);
dest[i+destOffset+3] = (byte) ((result >> 8) & 0xFF);
audioEffectCurrent += audioEffectDiff;
}
} else {
for (int i = 0; i < count; i+=4) {
sDest = (short) ((dest[i+destOffset+1] & 0xFF) | ((dest[i+destOffset+0] & 0xFF) << 8));
sSrc = (short) ((src[i+srcOffset+1] & 0xFF) | ((src[i+srcOffset+0] & 0xFF) << 8));
result = (short) (sDest * (1 - audioEffectCurrent) + sSrc * audioEffectCurrent);
dest[i+destOffset+1] = (byte) (result & 0xFF);
dest[i+destOffset+0] = (byte) ((result >> 8) & 0xFF);
sDest = (short) ((dest[i+destOffset+3] & 0xFF) | ((dest[i+destOffset+2] & 0xFF) << 8));
sSrc = (short) ((src[i+srcOffset+3] & 0xFF) | ((src[i+srcOffset+2] & 0xFF) << 8));
result = (short) (sDest * (1 - audioEffectCurrent) + sSrc * audioEffectCurrent);
dest[i+destOffset+3] = (byte) (result & 0xFF);
dest[i+destOffset+2] = (byte) ((result >> 8) & 0xFF);
audioEffectCurrent += audioEffectDiff;
}
}
}
示例15: printDataInfo
import javax.media.format.AudioFormat; //导入依赖的package包/类
void printDataInfo(Buffer buffer) {
//System.err.println("Read from stream: " + stream);
if (buffer.getFormat() instanceof AudioFormat)
System.err.println("Read audio data:");
else
System.err.println("Read video data:");
System.err.println(" Time stamp: " + buffer.getTimeStamp());
System.err.println(" Sequence #: " + buffer.getSequenceNumber());
System.err.println(" Data length: " + buffer.getLength());
if (buffer.isEOM())
System.err.println(" Got EOM!");
}