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


Java AudioFormat类代码示例

本文整理汇总了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;
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:25,代码来源:DataSource.java

示例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;
    }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:18,代码来源:GsmParser.java

示例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());
    }
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:25,代码来源:GsmParser.java

示例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)};
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:25,代码来源:PowerMeter.java

示例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
)
 };
 }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:20,代码来源:PcmDepacketizer.java

示例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
    };
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:18,代码来源:JavaSoundAUMux.java

示例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;
}
 
开发者ID:mloobo,项目名称:Dolphin-Streaming-Server,代码行数:21,代码来源:InfoArchivo.java

示例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;
    }

}
 
开发者ID:Metaswitch,项目名称:fmj,代码行数:26,代码来源:SSRCCache.java

示例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);
        }
    }
}
 
开发者ID:Norkart,项目名称:NK-VirtualGlobe,代码行数:27,代码来源:MovieDecoder.java

示例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));
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:23,代码来源:JmfMediaManager.java

示例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;
   }
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:17,代码来源:JmfMediaManager.java

示例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);
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:32,代码来源:GsmParser.java

示例13: PcmPacketizer

import javax.media.format.AudioFormat; //导入依赖的package包/类
public PcmPacketizer() {
   	supportedInputFormats = new AudioFormat[] {
     new AudioFormat(
  AudioFormat.LINEAR
            )
    };
    supportedOutputFormats  = new AudioFormat[] {
     new AudioFormat(
                CUSTOM_PCM
            )
    };
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:13,代码来源:PcmPacketizer.java

示例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;
    }
}
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:38,代码来源:SuperGlueDataSource.java

示例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!");
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:14,代码来源:DataSourceReader.java


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