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


Java AudioFormat.LINEAR属性代码示例

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

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

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

示例4: PcmPacketizer

public PcmPacketizer() {
   	supportedInputFormats = new AudioFormat[] {
     new AudioFormat(
  AudioFormat.LINEAR
            )
    };
    supportedOutputFormats  = new AudioFormat[] {
     new AudioFormat(
                CUSTOM_PCM
            )
    };
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:12,代码来源:PcmPacketizer.java

示例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
    );
}
 
开发者ID:kelzan,项目名称:HanziHelper,代码行数:11,代码来源:FlashcardDeck.java

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

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

示例8: getSupportedInputFormats

@Override
public Format[] getSupportedInputFormats()
{
    // TODO: query AudioSystem
    return new Format[] { new AudioFormat(AudioFormat.LINEAR) };
}
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:6,代码来源:JavaSoundMux.java

示例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
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:45,代码来源:JMFInit.java

示例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();
}
 
开发者ID:zhaozw,项目名称:android-1,代码行数:58,代码来源:AudioTrackRenderer.java

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


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