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


Java Buffer.getOffset方法代码示例

本文整理汇总了Java中javax.media.Buffer.getOffset方法的典型用法代码示例。如果您正苦于以下问题:Java Buffer.getOffset方法的具体用法?Java Buffer.getOffset怎么用?Java Buffer.getOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.media.Buffer的用法示例。


在下文中一共展示了Buffer.getOffset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mute

import javax.media.Buffer; //导入方法依赖的package包/类
/**
 * Replaces the media data contained in a specific <tt>Buffer</tt> with a
 * compatible representation of silence.
 *
 * @param buffer the <tt>Buffer</tt> the data contained in which is to be
 * replaced with silence
 */
public static void mute(Buffer buffer)
{
    Object data = buffer.getData();

    if (data != null)
    {
        Class<?> dataClass = data.getClass();
        final int fromIndex = buffer.getOffset();
        final int toIndex = fromIndex + buffer.getLength();

        if (Format.byteArray.equals(dataClass))
            Arrays.fill((byte[]) data, fromIndex, toIndex, (byte) 0);
        else if (Format.intArray.equals(dataClass))
            Arrays.fill((int[]) data, fromIndex, toIndex, 0);
        else if (Format.shortArray.equals(dataClass))
            Arrays.fill((short[]) data, fromIndex, toIndex, (short) 0);

        buffer.setData(data);
    }
}
 
开发者ID:bejayoharen,项目名称:java-bells,代码行数:28,代码来源:RewritablePushBufferDataSource.java

示例2: process

import javax.media.Buffer; //导入方法依赖的package包/类
/**
 * Updates the image to be drawn on the graphics context.
 * 
 * @param buffer the RAW image data.
 * @param size the dimension of the image in the buffer.
 */
void process(Buffer buffer, Dimension size)
{
    if (mis == null || !this.size.equals(size))
    {
        this.size = size;
        mis =
            new MemoryImageSource(size.width, size.height,
                (int[]) buffer.getData(), buffer.getOffset(), size.width);
    }
    else
    {
        mis.newPixels((int[]) buffer.getData(), ColorModel.getRGBdefault(),
            buffer.getOffset(), size.width);
    }

    this.repaint();
}
 
开发者ID:jitsi,项目名称:libjitsi,代码行数:24,代码来源:Java2DRendererVideoComponent.java

示例3: printDataInfo

import javax.media.Buffer; //导入方法依赖的package包/类
void printDataInfo(Buffer buffer) {


		byte[] data = (byte[])buffer.getData(); 
		try {
			out.write (data, buffer.getOffset(), buffer.getLength());
		} catch (IOException e) {
			BrokerFactory.getLoggingBroker().logError(e);
		}
		for (int i = buffer.getOffset(); i < buffer.getLength(); i++) {
			int n = data[i];
			if (n < 0) n+=256;
			if (lastSample == -1) lastSample = n;

			boolean thisMove = Math.abs(n-lastSample) > minimumSilenceThreshold;
			lastSample = n;
			
			if (inSilence && thisMove) {
				if (inSilence) {
					inSilence = false;
					fireSilenceChange(inSilence);
				}
			}
			
			if ((!inSilence) && (thisMove)) {
				silenceLength = 0;
			}
			if ((!inSilence) && (!thisMove)) {
				silenceLength ++;
				if (silenceLength > minimumSilenceLength) {
					inSilence = true;
					fireSilenceChange(inSilence);
				}
			}
			
			currentIndex++;
		}
		if (buffer.isEOM())
			System.err.println("  Got EOM!");
	}
 
开发者ID:davidrudder23,项目名称:OpenNotification,代码行数:41,代码来源:SilenceDataSink.java

示例4: process

import javax.media.Buffer; //导入方法依赖的package包/类
public int process(Buffer inputBuffer, Buffer outputBuffer){
// == prolog
if (isEOM(inputBuffer) ) {
    propagateEOM(outputBuffer);
    return BUFFER_PROCESSED_OK;
}

byte [] inBuffer       = (byte[])inputBuffer.getData();
int     inLength       = inputBuffer.getLength();
int     inOffset       = inputBuffer.getOffset();
int     samplesNumber  = inLength;
AudioFormat af = (AudioFormat) inputBuffer.getFormat();


if (enabled) { 
    int shiftZero = 0;
    int shiftOne = 8;
    if (af.getEndian() == AudioFormat.BIG_ENDIAN) {
	shiftZero = 8;
	shiftOne = 0;
    }

    // == main
    int spa = ((int) af.getSampleRate() * af.getChannels()) / nPowersPerSec;
    long npa = 1000000000L / nPowersPerSec;
    long timeStamp = inputBuffer.getTimeStamp(); // in nanos
    float average = 0;
    long cspa = 0;
    for (int i = 0; i < inLength; i += 2) {
	short sample = (short)
	    (((0xFF & inBuffer[inOffset + i]) << shiftZero) |
	     ((0xFF & inBuffer[inOffset + i + 1]) << shiftOne));
	float normal = (float) sample;
	average = average + normal * normal;
	cspa++;
	if (cspa == spa) {
	    cspa = 0;
	    average = (float) Math.sqrt((average / spa)) / 32768;
	    push(timeStamp, average);
	    timeStamp += npa;
	    average = 0;
	}
    }
}

// == epilog
inputBuffer.setData(outputBuffer.getData());
outputBuffer.setFormat(af);
outputBuffer.setData(inBuffer);
outputBuffer.setLength(inLength);
outputBuffer.setOffset(inOffset);
outputBuffer.setTimeStamp(inputBuffer.getTimeStamp());
outputBuffer.setFlags(inputBuffer.getFlags());

return BUFFER_PROCESSED_OK;
   }
 
开发者ID:champtar,项目名称:fmj-sourceforge-mirror,代码行数:57,代码来源:PowerMeter.java


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