本文整理汇总了Java中be.tarsos.dsp.pitch.PitchProcessor类的典型用法代码示例。如果您正苦于以下问题:Java PitchProcessor类的具体用法?Java PitchProcessor怎么用?Java PitchProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PitchProcessor类属于be.tarsos.dsp.pitch包,在下文中一共展示了PitchProcessor类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startDispatch
import be.tarsos.dsp.pitch.PitchProcessor; //导入依赖的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
示例2: checkMicrophone
import be.tarsos.dsp.pitch.PitchProcessor; //导入依赖的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
示例3: configure
import be.tarsos.dsp.pitch.PitchProcessor; //导入依赖的package包/类
@Override
public VoiceDetection configure() throws LineUnavailableException {
pitchDetectionHandler = newPitchDetectionHandler(settings.format.getSampleRate());
audioStream = newJVMAudioInputStream(currentMixer, settings.format);
dispatcher = newAudioDispatcher(audioStream);
dispatcher.addAudioProcessor(new PitchProcessor(newPitchDetectAlgo(settings.pitchDetectAlgo), settings.format.getSampleRate(), settings.bufferSize, pitchDetectionHandler));
return pitchDetectionHandler;
}
开发者ID:vocobox,项目名称:vocobox,代码行数:9,代码来源:VoiceInputStreamListen.java
示例4: doInBackground
import be.tarsos.dsp.pitch.PitchProcessor; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... params) {
PitchDetectionHandler pitchDetectionHandler = new PitchDetectionHandler() {
@Override
public void handlePitch(PitchDetectionResult pitchDetectionResult,
AudioEvent audioEvent) {
if (isCancelled()) {
stopAudioDispatcher();
return;
}
if (!IS_RECORDING) {
IS_RECORDING = true;
publishProgress();
}
float pitch = pitchDetectionResult.getPitch();
if (pitch != -1) {
PitchDifference pitchDifference = PitchComparator.retrieveNote(pitch);
pitchDifferences.add(pitchDifference);
if (pitchDifferences.size() >= MIN_ITEMS_COUNT) {
PitchDifference average =
Sampler.calculateAverageDifference(pitchDifferences);
publishProgress(average);
pitchDifferences.clear();
}
}
}
};
PitchProcessor pitchProcessor = new PitchProcessor(FFT_YIN, SAMPLE_RATE,
BUFFER_SIZE, pitchDetectionHandler);
audioDispatcher = fromDefaultMicrophone(SAMPLE_RATE,
BUFFER_SIZE, OVERLAP);
audioDispatcher.addAudioProcessor(pitchProcessor);
audioDispatcher.run();
return null;
}
开发者ID:gstraube,项目名称:cythara,代码行数:50,代码来源:ListenerFragment.java
示例5: addPitchDetection
import be.tarsos.dsp.pitch.PitchProcessor; //导入依赖的package包/类
public VoiceDetection addPitchDetection() {
VoiceDetection pitchDetectionHandler = newPitchDetectionHandler();
dispatcher.addAudioProcessor(new PitchProcessor(newPitchDetectAlgo(settings.pitchDetectAlgo), settings.format.getSampleRate(), settings.bufferSize, pitchDetectionHandler));
return pitchDetectionHandler;
}
开发者ID:vocobox,项目名称:vocobox,代码行数:6,代码来源:VoiceFileRead.java
示例6: newPitchProcessor
import be.tarsos.dsp.pitch.PitchProcessor; //导入依赖的package包/类
protected PitchProcessor newPitchProcessor(AudioFormat format, VoiceDetectionSynthController pitchDetectionHandler) {
return new PitchProcessor(newPitchDetectAlgo(settings.pitchDetectAlgo), format.getSampleRate(), settings.bufferSize, pitchDetectionHandler);
}
开发者ID:vocobox,项目名称:vocobox,代码行数:4,代码来源:VoiceAnalyser.java
示例7: startPitchDetection
import be.tarsos.dsp.pitch.PitchProcessor; //导入依赖的package包/类
public void startPitchDetection()
{
Log.d(TAG, "startPitchDetection");
//algorithm, sampleRate, bufferSize, handler
dispatcher.addAudioProcessor(new PitchProcessor(PitchEstimationAlgorithm.FFT_YIN, 16000, 1024, new PitchDetectionHandler() {
@Override
public void handlePitch(PitchDetectionResult pitchDetectionResult, AudioEvent audioEvent) {
//-1 means no sound
final float pitchInHz = pitchDetectionResult.getPitch();
//Log.i("Pitch", String.valueOf(pitchInHz));
if(pitchInHz == -1)
sendResult("Silent");
else
sendResult("Speaking");
//call showPitchOnUI(pitchInHz)
/*runOnUiThread(new Runnable() {
@Override
public void run() {
if(pitchInHz == -1)
uiMessage = "Silent";
else
uiMessage = "Speaking";
}
});
*/
}
}));
}
开发者ID:wahibhaq,项目名称:android-speaker-audioanalysis,代码行数:43,代码来源:RecordingMfccService.java
注:本文中的be.tarsos.dsp.pitch.PitchProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论