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


Java AudioEvent.getFloatBuffer方法代码示例

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


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

示例1: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
	float[] audioFloatBuffer = audioEvent.getFloatBuffer();
	int overlap = audioEvent.getOverlap();
		
	for(int i = overlap ; i < audioFloatBuffer.length ; i++){
		if(position >= echoBuffer.length){
			position = 0;
		}
		
		//output is the input added with the decayed echo 		
		audioFloatBuffer[i] = audioFloatBuffer[i] + echoBuffer[position] * decay;
		//store the sample in the buffer;
		echoBuffer[position] = audioFloatBuffer[i];
		
		position++;
	}
	
	applyNewEchoLength();
	
	return true;
}
 
开发者ID:gstraube,项目名称:cythara,代码行数:23,代码来源:DelayEffect.java

示例2: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {

	float[] audioBuffer = audioEvent.getFloatBuffer();
	float[] sortBuffer = new float[audioBuffer.length];

	transform.forwardTrans(audioBuffer);

	for (int i = 0; i < sortBuffer.length; i++) {
		sortBuffer[i] = Math.abs(audioBuffer[i]);
	}
	Arrays.sort(sortBuffer);

	double threshold = sortBuffer[compression];

	for (int i = 0; i < audioBuffer.length; i++) {
		if (Math.abs(audioBuffer[i]) <= threshold) {
			audioBuffer[i] = 0;
		}
	}
	return true;
}
 
开发者ID:gstraube,项目名称:cythara,代码行数:23,代码来源:Daubechies4WaveletCoder.java

示例3: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {

	float[] audioBuffer = audioEvent.getFloatBuffer();
	float[] sortBuffer = new float[audioBuffer.length];
	transform.transform(audioEvent.getFloatBuffer());

	for (int i = 0; i < sortBuffer.length; i++) {
		sortBuffer[i] = Math.abs(audioBuffer[i]);
	}
	Arrays.sort(sortBuffer);

	double threshold = sortBuffer[compression];

	for (int i = 0; i < audioBuffer.length; i++) {
		if (Math.abs(audioBuffer[i]) <= threshold) {
			audioBuffer[i] = 0;
		}
	}

	return true;
}
 
开发者ID:gstraube,项目名称:cythara,代码行数:23,代码来源:HaarWaveletCoder.java

示例4: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
	float[] audioFloatBuffer = audioEvent.getFloatBuffer();
	
	for (int i = audioEvent.getOverlap(); i < audioFloatBuffer.length; i++) {
		//shift the in array
		System.arraycopy(in, 0, in, 1, in.length - 1);
		in[0] = audioFloatBuffer[i];

		//calculate y based on a and b coefficients
		//and in and out.
		float y = 0;
		for(int j = 0 ; j < a.length ; j++){
			y += a[j] * in[j];
		}			
		for(int j = 0 ; j < b.length ; j++){
			y += b[j] * out[j];
		}
		//shift the out array
		System.arraycopy(out, 0, out, 1, out.length - 1);
		out[0] = y;
		
		audioFloatBuffer[i] = y;
	} 
	return true;
}
 
开发者ID:gstraube,项目名称:cythara,代码行数:27,代码来源:IIRFilter.java

示例5: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
	float[][] input = {audioEvent.getFloatBuffer()};
	rbs.process(input, false);
	
	int availableSamples = rbs.available();
	while(availableSamples ==0){
		try {
			Thread.sleep(1);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		availableSamples = rbs.available();
	}
	float[][] output = {new float[availableSamples]};
	rbs.retrieve(output);
	audioEvent.setFloatBuffer(output[0]);
	return true;
}
 
开发者ID:JorenSix,项目名称:RubberBandJNI,代码行数:20,代码来源:RubberBandAudioProcessor.java

示例6: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
	float[] buffer = audioEvent.getFloatBuffer();
	for(int i = 0 ; i < buffer.length ; i++){
		buffer[i] += (float) (Math.random() * gain);
	}
	return true;
}
 
开发者ID:gstraube,项目名称:cythara,代码行数:9,代码来源:NoiseGenerator.java

示例7: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
	float[] buffer = audioEvent.getFloatBuffer();
	double sampleRate = audioEvent.getSampleRate();
	double twoPiF = 2 * Math.PI * frequency;
	double time = 0;
	for(int i = 0 ; i < buffer.length ; i++){
		time = i / sampleRate;
		buffer[i] += (float) (gain * Math.sin(twoPiF * time + phase));
	}
	phase = twoPiF * buffer.length / sampleRate + phase;
	return true;
}
 
开发者ID:gstraube,项目名称:cythara,代码行数:14,代码来源:SineGenerator.java

示例8: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
	float[] buffer = audioEvent.getFloatBuffer();
	double sampleRate = audioEvent.getSampleRate();
	double twoPiF = 2 * Math.PI * frequency;
	double time = 0;
	for(int i = 0 ; i < buffer.length ; i++){
		time = i / sampleRate;
		float gain =  (float) (scaleParameter * Math.sin(twoPiF * time + phase));
		buffer[i] = gain * buffer[i];
	}
	phase = twoPiF * buffer.length / sampleRate + phase;
	return true;
}
 
开发者ID:gstraube,项目名称:cythara,代码行数:15,代码来源:AmplitudeLFO.java

示例9: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
	float[] audioFloatBuffer = audioEvent.getFloatBuffer();
	double skn0, skn1, skn2;
	int numberOfDetectedFrequencies = 0;
	for (int j = 0; j < frequenciesToDetect.length; j++) {
		skn0 = skn1 = skn2 = 0;
		for (int i = 0; i < audioFloatBuffer.length; i++) {
			skn2 = skn1;
			skn1 = skn0;
			skn0 = precalculatedCosines[j] * skn1 - skn2
					+ audioFloatBuffer[i];
		}
		double wnk = precalculatedWnk[j];
		calculatedPowers[j] = 20 * Math.log10(Math.abs(skn0 - wnk * skn1));
		if (calculatedPowers[j] > POWER_THRESHOLD) {
			numberOfDetectedFrequencies++;
		}
	}

	if (numberOfDetectedFrequencies > 0) {
		double[] frequencies = new double[numberOfDetectedFrequencies];
		double[] powers = new double[numberOfDetectedFrequencies];
		int index = 0;
		for (int j = 0; j < frequenciesToDetect.length; j++) {
			if (calculatedPowers[j] > POWER_THRESHOLD) {
				frequencies[index] = frequenciesToDetect[j];
				powers[index] = calculatedPowers[j];
				index++;
			}
		}
		handler.handleDetectedFrequencies(audioEvent.getTimeStamp(),frequencies, powers,
				frequenciesToDetect.clone(), calculatedPowers.clone());
	}

	return true;
}
 
开发者ID:gstraube,项目名称:cythara,代码行数:38,代码来源:Goertzel.java

示例10: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
	
	float[] x = audioEvent.getFloatBuffer();
	WindowFunction f  = new HammingWindow();
	f.apply(x);
	for (int j = 0; j < frequenciesToDetect.length; j++) {
		double pik_term = 2 * Math.PI * indvec[j]/(float) audioEvent.getBufferSize(); 
		double cos_pik_term2 = Math.cos(pik_term) * 2;
		Complex cc = new Complex(0,-1*pik_term).exp();
		double s0=0;
		double s1=0;
		double s2=0;
		
		for(int i = 0 ; i < audioEvent.getBufferSize() ; i++ ){
			s0 = x[i]+cos_pik_term2*s1-s2;
			s2=s1;
			s1=s0;
		}
		s0 = cos_pik_term2 * s1 - s2;
		calculatedComplex[j] = cc.times(new Complex(-s1,0)).plus(new Complex(s0,0));
		calculatedPowers[j] = calculatedComplex[j].mod();
	}
	
	handler.handleDetectedFrequencies(audioEvent.getTimeStamp(),frequenciesToDetect.clone(), calculatedPowers.clone(),
			frequenciesToDetect.clone(), calculatedPowers.clone());
	
	return true;
}
 
开发者ID:gstraube,项目名称:cythara,代码行数:30,代码来源:GeneralizedGoertzel.java

示例11: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
	float[] audioFloatBuffer = audioEvent.getFloatBuffer();
	this.processedSamples += audioFloatBuffer.length;
	this.processedSamples -= audioEvent.getOverlap();

	fft.forwardTransform(audioFloatBuffer);
	fft.modulus(audioFloatBuffer, currentMagnitudes);
	int binsOverThreshold = 0;
	for (int i = 0; i < currentMagnitudes.length; i++) {
		if (priorMagnitudes[i] > 0.f) {
			double diff = 10 * Math.log10(currentMagnitudes[i]
					/ priorMagnitudes[i]);
			if (diff >= threshold) {
				binsOverThreshold++;
			}
		}
		priorMagnitudes[i] = currentMagnitudes[i];
	}

	if (dfMinus2 < dfMinus1
			&& dfMinus1 >= binsOverThreshold
			&& dfMinus1 > ((100 - sensitivity) * audioFloatBuffer.length) / 200) {
		float timeStamp = processedSamples / sampleRate;
		handler.handleOnset(timeStamp,-1);
	}

	dfMinus2 = dfMinus1;
	dfMinus1 = binsOverThreshold;

	return true;
}
 
开发者ID:gstraube,项目名称:cythara,代码行数:33,代码来源:PercussionOnsetDetector.java

示例12: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
	int i, used;
	float[] src = audioEvent.getFloatBuffer();
	float[] dest = new float[(int) Math.round(audioEvent.getBufferSize() / rate)];
    used = 0;
    i = 0;

    // Process the last sample saved from the previous call first...
    while (slopeCount <= 1.0f) {
        dest[i] = (float)((1.0f - slopeCount) * prevSample + slopeCount * src[0]);
        i++;
        slopeCount += rate;
    }
    slopeCount -= 1.0f;
    end:
       while(true){
           while (slopeCount > 1.0f) {
               slopeCount -= 1.0f;
               used++;
               if (used >= src.length - 1) 
               	break end;
           }
           if(i < dest.length){
           	dest[i] = (float)((1.0f - slopeCount) * src[used] + slopeCount * src[used + 1]);
           }
           i++;
           slopeCount += rate;
       }
    
    //Store the last sample for the next round
    prevSample = src[src.length - 1];
    dispatcher.setStepSizeAndOverlap(dest.length, 0);
    audioEvent.setFloatBuffer(dest);
	return true;
}
 
开发者ID:gstraube,项目名称:cythara,代码行数:37,代码来源:SoundTouchRateTransposer.java

示例13: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
	float[] src = audioEvent.getFloatBuffer();
	//Creation of float array in loop could be prevented if src.length is known beforehand...
	//Possible optimization is to instantiate it outside the loop and get a pointer to the 
	//array here, in the process method method.
	float[] out = new float[(int) (src.length * factor)];
	r.process(factor, src, 0, src.length, false, out, 0, out.length);
	//The size of the output buffer changes (according to factor). 
	audioEvent.setFloatBuffer(out);
	return true;
}
 
开发者ID:gstraube,项目名称:cythara,代码行数:13,代码来源:RateTransposer.java

示例14: applyDetectionToSelfOscillo

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
protected void applyDetectionToSelfOscillo(PitchDetectionResult pitchDetectionResult, AudioEvent audioEvent) {
    double frequency = computeFrequency(pitchDetectionResult);
    final float[] audioBuffer = audioEvent.getFloatBuffer();
    final double twoPiF = 2 * Math.PI * frequency;
    double timefactor = twoPiF * audioBuffer.length / sampleRate;
    computeEnvelopeAndApplyToBuffer(audioBuffer, twoPiF);
    computePhase(timefactor);
}
 
开发者ID:vocobox,项目名称:vocobox,代码行数:9,代码来源:VoiceDetection.java

示例15: process

import be.tarsos.dsp.AudioEvent; //导入方法依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
	//clone since the buffer is reused to slide
	float[] buffer = audioEvent.getFloatBuffer();
	float[] zeroPaddedData = new float[zeropaddingFactor*512];
	int offset = (buffer.length * zeropaddingFactor - buffer.length)/2;
	for(int i = offset ; i < offset + buffer.length ;i ++){
		zeroPaddedData[i] = buffer[i-offset];
	}
	
	//calculate the fft
	fft.forwardTransform(zeroPaddedData);
	
	//store the magnitudes (moduli) in magnitudes
	fft.modulus(zeroPaddedData, magnitudes[magnitudesIndex]);
			
	//calculate the natural logarithm
	//It is not really needed, and skipped since it is very computationally expensive
	//log();
	
	//run a maximum filter on the frame
	maxFilterVertical.filter(magnitudes[magnitudesIndex]);
	previousMaxMagnitudes.put(analysisFrameIndex,maxFilterVertical.getMaxVal());

	//run a minimum filter on the frame
	minFilterVertical.filter(magnitudes[magnitudesIndex]);
	previousMinMagnitudes.put(analysisFrameIndex,minFilterVertical.getMinVal());
	
			
	//store the frame magnitudes
	previousMagintudes.put(analysisFrameIndex, magnitudes[magnitudesIndex]);
	
	//find the horziontal minima and maxima
	if(previousMaxMagnitudes.size()==longestFilterWindowSize){
		horizontalFilter();
		//Remove analysis frames that are not needed any more:
		//previousMaxFrames.removeFirst();
		previousMaxMagnitudes.remove(analysisFrameIndex-longestFilterWindowSize+1);
		previousMinMagnitudes.remove(analysisFrameIndex-longestFilterWindowSize+1);
		previousMagintudes.remove(analysisFrameIndex-longestFilterWindowSize+1);
	}
			
	//magnitude index counter
	magnitudesIndex++;
	if(magnitudesIndex == magnitudes.length){
		magnitudesIndex=0;
	}
	
	//Increment analysis frame counter
	analysisFrameIndex++;
	
	return true;
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:54,代码来源:QIFFTEventPointProcessor.java


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