本文整理汇总了Java中be.tarsos.dsp.AudioEvent类的典型用法代码示例。如果您正苦于以下问题:Java AudioEvent类的具体用法?Java AudioEvent怎么用?Java AudioEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AudioEvent类属于be.tarsos.dsp包,在下文中一共展示了AudioEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handlePitch
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
public void handlePitch(PitchDetectionResult pitchDetectionResult, AudioEvent audioEvent) {
if (pitchDetectionResult.getPitch() != -1) {
double timeStamp = audioEvent.getTimeStamp();
float pitch = pitchDetectionResult.getPitch();
float probability = pitchDetectionResult.getProbability();
double rms = audioEvent.getRMS() * 100;
String message = String.format("Pitch detected at %.2fs: %.2fHz ( %.2f probability, RMS: %.5f )\n",
timeStamp, pitch, probability, rms);
System.out.println(message);
String addMe1;
if (probability < 0.5 && Pitch.pitches.getItemCount() > 2) {
addMe1 = Pitch.pitches.getItem(Pitch.pitches.getItemCount() - 1);
} else {
addMe1 = String.valueOf(pitch);
}
String addMe2 = String.valueOf(timeStamp);
Pitch.pitches.add(addMe1);
Pitch.time.add(addMe2);
}
}
开发者ID:Scoutdrago3,项目名称:MusicToGraph,代码行数:23,代码来源:MyPitchDetector.java
示例2: process
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
float[] currentMagnitudes = eventPointProcessor.getMagnitudes().clone();
//for visualization purposes:
//store the new max value or, decay the running max
float currentMaxValue = max(currentMagnitudes);
if(currentMaxValue > runningMaxMagnitude){
runningMaxMagnitude = currentMaxValue;
}else{
runningMaxMagnitude = 0.9999f * runningMaxMagnitude;
}
normalize(currentMagnitudes);
magnitudes.put((float)audioEvent.getTimeStamp(),currentMagnitudes);
return true;
}
开发者ID:JorenSix,项目名称:Panako,代码行数:19,代码来源:QIFFTAudioFileInfo.java
示例3: process
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent) {
float[] fftData = audioEvent.getFloatBuffer().clone();
Arrays.fill(zeroPaddedData, 0);
System.arraycopy(fftData, 0, zeroPaddedData, fftData.length/2, fftData.length);
fft.forwardTransform(zeroPaddedData);
fft.multiply(zeroPaddedData, zeroPaddedInvesedQuery);
fft.backwardsTransform(zeroPaddedData);
float maxVal = -100000;
int maxIndex = 0;
for(int i = 0 ; i<zeroPaddedData.length ; i++){
if(zeroPaddedData[i]> maxVal){
maxVal = zeroPaddedData[i];
maxIndex=i;
}
}
float time = (float) (audioEvent.getTimeStamp() - audioEvent.getBufferSize()/audioEvent.getSampleRate() + maxIndex/2 /audioEvent.getSampleRate() + 0.005);
handler.handleCrossCorrelation((float)audioEvent.getTimeStamp(), time, maxVal);
return true;
}
开发者ID:JorenSix,项目名称:Panako,代码行数:25,代码来源:CrossCorrelation.java
示例4: monitor
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
@Override
public void monitor(String query, final int maxNumberOfReqults,Set<Integer> avoid,
final QueryResultHandler handler) {
int samplerate = Config.getInt(Key.NCTEQ_SAMPLE_RATE);
int size = Config.getInt(Key.MONITOR_STEP_SIZE) * samplerate;
int overlap = Config.getInt(Key.MONITOR_OVERLAP) * samplerate;
final ConstantQ constanQ = createConstantQ();
AudioDispatcher d = AudioDispatcherFactory.fromPipe(query, samplerate, size, overlap);
d.addAudioProcessor(new AudioProcessor() {
@Override
public boolean process(AudioEvent audioEvent) {
double timeStamp = audioEvent.getTimeStamp() - Config.getInt(Key.MONITOR_OVERLAP);
processMonitorQuery(audioEvent.getFloatBuffer().clone(), maxNumberOfReqults, handler,timeStamp,constanQ);
return true;
}
@Override
public void processingFinished() {
}
});
d.run();
}
开发者ID:JorenSix,项目名称:Panako,代码行数:26,代码来源:NCteQStrategy.java
示例5: process
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent)
{
// Don't do anything before the beginning of Fade Out
if(isFadeOut==true)
{
if(firstTime==-1)
firstTime=audioEvent.getTimeStamp();
// Decrease the gain according to time since the beginning of the Fade Out
time=audioEvent.getTimeStamp()-firstTime;
gp.setGain(1-time/duration);
gp.process(audioEvent);
}
return true;
}
开发者ID:gstraube,项目名称:cythara,代码行数:17,代码来源:FadeOut.java
示例6: process
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
@Override
public boolean process(AudioEvent audioEvent)
{
// Don't do anything after the end of the Fade In
if(fadingIn)
{
if(firstTime==-1)
firstTime=audioEvent.getTimeStamp();
// Increase the gain according to time since the beginning of the Fade In
time=audioEvent.getTimeStamp()-firstTime;
gp.setGain(time/duration);
gp.process(audioEvent);
if(time > duration){
fadingIn = false;
}
}
return true;
}
开发者ID:gstraube,项目名称:cythara,代码行数:21,代码来源:FadeIn.java
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例11: startDispatch
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
private void startDispatch() {
dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(22050, 1024, 0);
uiThread = new Handler();
PitchDetectionHandler pdh = (PitchDetectionResult result, AudioEvent audioEven) -> uiThread.post(() -> {
final float pitchInHz = result.getPitch();
int pitch = pitchInHz > 0 ? (int) pitchInHz : 1;
if(pitch > 1 && mConnected) {
if((pitch - lastPitch) >= sensitive * 10) {
Random random = new Random();
byte[] rgb = getLedBytes(random.nextInt(600000000) + 50000);
controlLed(rgb);
}
if(minPitch > pitch)
minPitch = pitch;
}
lastPitch = pitch;
});
processor = new PitchProcessor(PitchProcessor.PitchEstimationAlgorithm.FFT_YIN, 22050, 1024, pdh);
dispatcher.addAudioProcessor(processor);
listeningThread = new Thread(dispatcher);
listeningThread.start();
}
开发者ID:skydoves,项目名称:MagicLight-Controller,代码行数:27,代码来源:MainActivity.java
示例12: checkMicrophone
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
private void checkMicrophone() {
AudioDispatcher dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(22050, 1024, 0);
PitchDetectionHandler pdh = new PitchDetectionHandler() {
@Override
public void handlePitch(PitchDetectionResult result,AudioEvent e) {
final float pitchInHz = result.getPitch();
runOnUiThread(new Runnable() {
@Override
public void run() {
if (pitchInHz != -1) {
System.out.println(pitchInHz);
}
if (pitchInHz <= 18500 && pitchInHz >= 17500) {
System.err.println("Pitch Richtig");
}
}
});
}
};
AudioProcessor p = new PitchProcessor(PitchProcessor.PitchEstimationAlgorithm.FFT_YIN, 22050, 1024, pdh);
dispatcher.addAudioProcessor(p);
new Thread(dispatcher,"Audio Dispatcher").start();
}
开发者ID:AndroidMusicSync,项目名称:AndroidMusicSync,代码行数:25,代码来源:ServantActivity.java
示例13: 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
示例14: newPitchDetectionHandler
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
/**
* A pitch detection storing {@link SoundEvent}
*/
protected VoiceDetection newPitchDetectionHandler() {
VoiceDetection prs = new VoiceDetection(settings.format.getSampleRate(), settings) {
@Override
public void handlePitch(PitchDetectionResult pitchDetectionResult, AudioEvent audioEvent) {
// Process
float frequency = (float) computeFrequency(pitchDetectionResult);
float amplitude = computeAmplitude(audioEvent);
double timestamp = audioEvent.getTimeStamp();
// pitch
SoundEvent pitch = SoundEvent.pitch((float) timestamp, frequency);
pitch.confidence = pitchDetectionResult.getProbability();
pitchEvents.add(pitch);
// amplitude
ampliEvents.add(SoundEvent.amplitude((float) timestamp, amplitude));
}
};
return prs;
}
开发者ID:vocobox,项目名称:vocobox,代码行数:24,代码来源:VoiceFileRead.java
示例15: extractInfoFromAudio
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
public void extractInfoFromAudio(final Component componentToRepaint){
int samplerate = Config.getInt(Key.NFFT_SAMPLE_RATE);
int size = Config.getInt(Key.NFFT_SIZE);
int overlap = size - Config.getInt(Key.NFFT_STEP_SIZE);
StopWatch w = new StopWatch();
w.start();
d = AudioDispatcherFactory.fromPipe(audioFile.getAbsolutePath(), samplerate, size, overlap);
eventPointProcessor = new QIFFTEventPointProcessor(size,overlap,samplerate,4);
d.addAudioProcessor(eventPointProcessor);
d.addAudioProcessor(this);
d.addAudioProcessor(new AudioProcessor() {
@Override
public void processingFinished() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
componentToRepaint.repaint();
}
});
if(referenceFileInfo!=null)
referenceFileInfo.setMatchingFingerprints(matchingPrints);
}
@Override
public boolean process(AudioEvent audioEvent) {
return true;
}
});
new Thread(d).start();
}
开发者ID:JorenSix,项目名称:Panako,代码行数:31,代码来源:QIFFTAudioFileInfo.java
示例16: extractInfoFromAudio
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
public void extractInfoFromAudio(final Component componentToRepaint){
int samplerate = Config.getInt(Key.NFFT_SAMPLE_RATE);
int size = Config.getInt(Key.NFFT_SIZE);
int overlap = size - Config.getInt(Key.NFFT_STEP_SIZE);
StopWatch w = new StopWatch();
w.start();
d = AudioDispatcherFactory.fromPipe(audioFile.getAbsolutePath(), samplerate, size, overlap);
eventPointProcessor = new NFFTEventPointProcessor(size,overlap,samplerate);
d.addAudioProcessor(eventPointProcessor);
d.addAudioProcessor(this);
d.addAudioProcessor(new AudioProcessor() {
@Override
public void processingFinished() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
componentToRepaint.repaint();
}
});
if(referenceAudioFileInfo!=null)
referenceAudioFileInfo.setMatchingFingerprints(matchingPrints);
}
@Override
public boolean process(AudioEvent audioEvent) {
return true;
}
});
new Thread(d).start();
}
开发者ID:JorenSix,项目名称:Panako,代码行数:31,代码来源:NFFTAudioFileInfo.java
示例17: monitor
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
@Override
public void monitor(String query, int maxNumberOfReqults, Set<Integer> avoid, QueryResultHandler handler) {
int samplerate = Config.getInt(Key.RAFS_SAMPLE_RATE);
int size = Config.getInt(Key.MONITOR_STEP_SIZE) * samplerate;
int overlap = Config.getInt(Key.MONITOR_OVERLAP) * samplerate;
AudioDispatcher d ;
if (query.equals(Panako.DEFAULT_MICROPHONE)){
try {
d = AudioDispatcherFactory.fromDefaultMicrophone(samplerate,size, overlap);
} catch (LineUnavailableException e) {
LOG.warning("Could not connect to default microphone!" + e.getMessage());
e.printStackTrace();
d = null;
}
}else{
d = AudioDispatcherFactory.fromPipe(query, samplerate, size, overlap);
}
d.setZeroPadFirstBuffer(true);
d.addAudioProcessor(new AudioProcessor() {
@Override
public boolean process(AudioEvent audioEvent) {
double timeStamp = audioEvent.getTimeStamp() - Config.getInt(Key.MONITOR_OVERLAP);
processMonitorQuery(audioEvent.getFloatBuffer().clone(), handler,timeStamp,avoid);
return true;
}
@Override
public void processingFinished() {
}
});
d.run();
}
开发者ID:JorenSix,项目名称:Panako,代码行数:33,代码来源:RafsRepStrategy.java
示例18: monitor
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
public void monitor(String query,final SerializedFingerprintsHandler handler){
int samplerate = Config.getInt(Key.NFFT_SAMPLE_RATE);
int size = Config.getInt(Key.MONITOR_STEP_SIZE) * samplerate;
int overlap = Config.getInt(Key.MONITOR_OVERLAP) * samplerate;
AudioDispatcher d ;
if (query.equals(Panako.DEFAULT_MICROPHONE)){
try {
d = AudioDispatcherFactory.fromDefaultMicrophone(samplerate,size, overlap);
} catch (LineUnavailableException e) {
LOG.warning("Could not connect to default microphone!" + e.getMessage());
e.printStackTrace();
d = null;
}
}else{
d = AudioDispatcherFactory.fromPipe(query, samplerate, size, overlap);
}
d.addAudioProcessor(new AudioProcessor() {
@Override
public boolean process(AudioEvent audioEvent) {
double timeStamp = audioEvent.getTimeStamp() - Config.getInt(Key.MONITOR_OVERLAP);
processMonitorQueryToSerializeFingerprints(audioEvent.getFloatBuffer().clone(), handler,timeStamp);
return true;
}
@Override
public void processingFinished() {
}
});
d.run();
}
开发者ID:JorenSix,项目名称:Panako,代码行数:32,代码来源:NFFTStrategy.java
示例19: testPipeDecoder
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
@Test
public void testPipeDecoder(){
File reference = TestUtilities.getResource("dataset/61198.wav");
File referenceFile = TestUtilities.getResource("dataset/61198.wav");
final float[] referenceBuffer = TestUtilities.getAudioBuffer(reference,1.0,1.5);
AudioDispatcher d = AudioDispatcherFactory.fromPipe(referenceFile.getAbsolutePath(), 44100, 22050, 0,1.0,0.5);
d.addAudioProcessor(new AudioProcessor() {
boolean ran = false;
@Override
public void processingFinished() {
}
@Override
public boolean process(AudioEvent audioEvent) {
if(!ran){
float[] otherBuffer = audioEvent.getFloatBuffer();
assertEquals("Buffers should be equal in length", referenceBuffer.length, otherBuffer.length);
for(int i = 0 ; i < otherBuffer.length; i++){
assertEquals("Buffers should have the same content", referenceBuffer[i], otherBuffer[i],0.0000001);
}
}
ran = true;
return true;
}
});
d.run();
}
开发者ID:JorenSix,项目名称:Panako,代码行数:29,代码来源:SyncSinkTests.java
示例20: getAudioBuffer
import be.tarsos.dsp.AudioEvent; //导入依赖的package包/类
public static float[] getAudioBuffer(File file,double start,double stop){
double sampleRate = 44100;
int sampleStart = (int) Math.round(sampleRate * start);
int sampleStop = (int) Math.round(sampleRate * stop);
int diff = sampleStop - sampleStart;
final float[] audioBuffer = new float[diff];
AudioDispatcher d;
d = AudioDispatcherFactory.fromPipe(file.getAbsolutePath(), 44100,diff, 0);
d.skip(start);
d.addAudioProcessor(new AudioProcessor() {
boolean filled = false;
@Override
public void processingFinished() {
}
@Override
public boolean process(AudioEvent audioEvent) {
if(!filled){
for (int i = 0; i < audioEvent.getFloatBuffer().length; i++) {
audioBuffer[i] = audioEvent.getFloatBuffer()[i];
}
filled = true;
}
return false;
}
});
d.run();
return audioBuffer;
}
开发者ID:JorenSix,项目名称:Panako,代码行数:36,代码来源:TestUtilities.java
注:本文中的be.tarsos.dsp.AudioEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论