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


Java AudioDispatcher.run方法代码示例

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


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

示例1: processMonitorQuery

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
private void processMonitorQuery(float[] audioData,QueryResultHandler handler, double timeStamp,Set<Integer> avoid){
	int samplerate = Config.getInt(Key.RAFS_SAMPLE_RATE);
	int size = Config.getInt(Key.RAFS_FFT_SIZE);
	int overlap = size - Config.getInt(Key.RAFS_FFT_STEP_SIZE);
	
	AudioDispatcher d;
	try {
		d = AudioDispatcherFactory.fromFloatArray(audioData, samplerate, size, overlap);
		d.setZeroPadFirstBuffer(true);
		final RafsExtractor processor = new RafsExtractor(null,true);
		d.addAudioProcessor(processor);
		d.run();
		queryForMonitor(processor.fingerprints, processor.fingerprintProbabilities, 10 , avoid, handler);
	} catch (UnsupportedAudioFileException e) {
		LOG.severe("Unsupported audio");
	}
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:18,代码来源:RafsRepStrategy.java

示例2: extractPacker

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
private static RafsPacker extractPacker(File f, int fileIndex, boolean trackProbabilities){
	final int sampleRate = Config.getInt(Key.RAFS_SAMPLE_RATE);//2250Hz Nyquist frequency
	final int size = Config.getInt(Key.RAFS_FFT_SIZE);
	final int overlap =  size - Config.getInt(Key.RAFS_FFT_STEP_SIZE); //about an fft every 11.6ms (64/5500)
	String file = f.getAbsolutePath();
	AudioDispatcher d = AudioDispatcherFactory.fromPipe(file, sampleRate, size, overlap);
	d.setZeroPadFirstBuffer(true);
	RafsExtractor ex = new RafsExtractor(file, trackProbabilities);
	RafsPacker packer = new RafsPacker(ex,trackProbabilities);
	//String baseName = f.getName();
	d.setZeroPadFirstBuffer(true);
	d.addAudioProcessor(ex);
	d.addAudioProcessor(packer);
	d.run();
	return packer;
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:17,代码来源:RafsStrategy.java

示例3: extractPackedPrints

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
private static List<BitSetWithID> extractPackedPrints(File f,int fileIndex){		
	final int sampleRate = Config.getInt(Key.RAFS_SAMPLE_RATE);//2250Hz Nyquist frequency
	final int size = Config.getInt(Key.RAFS_FFT_SIZE);
	final int overlap =  size - Config.getInt(Key.RAFS_FFT_STEP_SIZE); 
	String file = f.getAbsolutePath();
	AudioDispatcher d = AudioDispatcherFactory.fromPipe(file, sampleRate, size, overlap);
	RafsExtractor ex = new RafsExtractor(file, true);
	RafsPacker packer = new RafsPacker(ex,true);
	//String baseName = f.getName();
	d.setZeroPadFirstBuffer(true);
	d.addAudioProcessor(ex);
	d.addAudioProcessor(packer);
	d.run();
	List<BitSetWithID> prints = new ArrayList<>();
	
	for (Map.Entry<Float, BitSet> frameEntry : packer.packedFingerprints.entrySet()) {
		int offset = (int) (frameEntry.getKey() * 1000);
		prints.add(new BitSetWithID(fileIndex * (1L<<32)  + offset, frameEntry.getValue()));
	}
	return prints;		
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:22,代码来源:RafsCliTest.java

示例4: processMonitorQueryToSerializeFingerprints

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
private void processMonitorQueryToSerializeFingerprints(float[] audioBuffer,SerializedFingerprintsHandler handler,double queryOffset){
	int samplerate = Config.getInt(Key.NFFT_SAMPLE_RATE);
	int size = Config.getInt(Key.NFFT_SIZE);
	int overlap = size - Config.getInt(Key.NFFT_STEP_SIZE);
	
	AudioDispatcher d;
	try {
		d = AudioDispatcherFactory.fromFloatArray(audioBuffer, samplerate, size, overlap);
		final NFFTEventPointProcessor minMaxProcessor = new NFFTEventPointProcessor(size,overlap,samplerate);
		d.addAudioProcessor(minMaxProcessor);
		d.run();
		double queryDuration = d.secondsProcessed();
		List<NFFTFingerprint> fingerprints = new ArrayList<NFFTFingerprint>(minMaxProcessor.getFingerprints());
		handler.handleSerializedFingerprints(PanakoWebserviceClient.serializeFingerprintsToJson(fingerprints),queryDuration,queryOffset);
	} catch (UnsupportedAudioFileException e) {
		LOG.severe("Unsupported audio");
	}
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:19,代码来源:NFFTStrategy.java

示例5: run

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
@Override
public void run(String... args) {
	String inputResource = AudioResourceUtils.sanitizeResource(args[0]);
	AudioDispatcher d;
	try {
		d = AudioDispatcherFactory.fromPipe(inputResource, TARGET_SAMPLE_RATE, 2028, 0);
		d.addAudioProcessor(new AudioPlayer(JVMAudioInputStream.toAudioFormat(d.getFormat())));
		d.run();
	}  catch (LineUnavailableException e) {
		e.printStackTrace();
		System.err.print(e.getLocalizedMessage());
	}
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:14,代码来源:Play.java

示例6: monitor

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的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

示例7: extractExtractor

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
private static RafsExtractor extractExtractor(File f, int fileIndex, boolean trackProbabilities){
	final int sampleRate = Config.getInt(Key.RAFS_SAMPLE_RATE);//2250Hz Nyquist frequency
	final int size = Config.getInt(Key.RAFS_FFT_SIZE);
	final int overlap = size -  Config.getInt(Key.RAFS_FFT_STEP_SIZE); //about an fft every 11.6ms (64/5500)
	String file = f.getAbsolutePath();
	AudioDispatcher d = AudioDispatcherFactory.fromPipe(file, sampleRate, size, overlap);
	d.setZeroPadFirstBuffer(true);
	RafsExtractor ex = new RafsExtractor(file, trackProbabilities);
	//String baseName = f.getName();
	d.addAudioProcessor(ex);
	d.run();
	return ex;
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:14,代码来源:RafsRepStrategy.java

示例8: starExtraction

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
public void starExtraction(){
	AudioDispatcher d = AudioDispatcherFactory.fromPipe(file, sampleRate, size, overlap);
	//every buffer has the same length
	d.setZeroPadFirstBuffer(true);
	d.addAudioProcessor(this);
	d.run();
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:8,代码来源:RafsExtractor.java

示例9: extractPackedPrints

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
private static TreeMap<Float, BitSet> extractPackedPrints(File f,boolean trackProbabilities){		
	final int sampleRate = Config.getInt(Key.RAFS_SAMPLE_RATE);//2250Hz Nyquist frequency
	final int size = Config.getInt(Key.RAFS_FFT_SIZE);
	final int overlap = size - Config.getInt(Key.RAFS_FFT_STEP_SIZE);
	String file = f.getAbsolutePath();
	AudioDispatcher d = AudioDispatcherFactory.fromPipe(file, sampleRate, size, overlap);
	d.setZeroPadFirstBuffer(true);
	RafsExtractor ex = new RafsExtractor(file, trackProbabilities);
	//String baseName = f.getName();
	d.addAudioProcessor(ex);
	d.run();
	return ex.fingerprints;
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:14,代码来源:RafsCompStats.java

示例10: extractFingerprints

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
private List<NFFTFingerprint> extractFingerprints(String resource) {
	int samplerate = Config.getInt(Key.NFFT_SAMPLE_RATE);
	int size = Config.getInt(Key.NFFT_SIZE);
	int overlap = size - Config.getInt(Key.NFFT_STEP_SIZE);

	AudioDispatcher d = AudioDispatcherFactory.fromPipe(resource, samplerate, size, overlap);
	final NFFTEventPointProcessor minMaxProcessor = new NFFTEventPointProcessor(size, overlap, samplerate);
	d.addAudioProcessor(minMaxProcessor);
	d.run();
	return new ArrayList<NFFTFingerprint>(minMaxProcessor.getFingerprints());
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:12,代码来源:NFFTStreamSync.java

示例11: store

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
@Override
public double store(String resource, String description) {
	int samplerate = Config.getInt(Key.NFFT_SAMPLE_RATE);
	int size = Config.getInt(Key.NFFT_SIZE);
	int overlap = size - Config.getInt(Key.NFFT_STEP_SIZE);
	
	AudioDispatcher d = AudioDispatcherFactory.fromPipe(resource, samplerate, size, overlap);
	final NFFTEventPointProcessor minMaxProcessor = new NFFTEventPointProcessor(size,overlap,samplerate);
	d.addAudioProcessor(minMaxProcessor);
	d.run();
	Set<NFFTFingerprint> fingerprints = new HashSet<NFFTFingerprint>(minMaxProcessor.getFingerprints());
	
	int identifier = FileUtils.getIdentifier(resource);
	
	
	for(NFFTFingerprint fingerprint: fingerprints){
		storage.addFingerprint(identifier, fingerprint.t1, fingerprint.hash());
	}
	
	// Store the meta data.
	storage.addAudio(identifier, description);
	
	// Commit the changes to store the fingerprints
	double durationInSeconds = d.secondsProcessed();
	storage.audioObjectAdded((int) Math.round(durationInSeconds));
	
	LOG.info(String.format("Stored %d fingerprints bundeled from %d event points for %s.",fingerprints.size(),minMaxProcessor.getEventPoints().size(),resource));
	return durationInSeconds;
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:30,代码来源:NFFTStrategy.java

示例12: extractFingerprintsFromQuery

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
public List<NFFTFingerprint> extractFingerprintsFromQuery(String query){
	int samplerate = Config.getInt(Key.NFFT_SAMPLE_RATE);
	int size = Config.getInt(Key.NFFT_SIZE);
	int overlap = size - Config.getInt(Key.NFFT_STEP_SIZE);
	AudioDispatcher d = AudioDispatcherFactory.fromPipe(query, samplerate, size, overlap);
	final NFFTEventPointProcessor minMaxProcessor = new NFFTEventPointProcessor(size,overlap,samplerate);
	d.addAudioProcessor(minMaxProcessor);
	d.run();
	List<NFFTFingerprint> fingerprints = new ArrayList<NFFTFingerprint>(minMaxProcessor.getFingerprints());
	return fingerprints;
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:12,代码来源:NFFTStrategy.java

示例13: monitor

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的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

示例14: processMonitorQuery

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
private void processMonitorQuery(float[] audioBuffer,int maxNumberOfResults,
		QueryResultHandler handler,double queryOffset,Set<Integer> avoid){
	int samplerate = Config.getInt(Key.NFFT_SAMPLE_RATE);
	int size = Config.getInt(Key.NFFT_SIZE);
	int overlap = size - Config.getInt(Key.NFFT_STEP_SIZE);
	
	AudioDispatcher d;
	try {
		d = AudioDispatcherFactory.fromFloatArray(audioBuffer, samplerate, size, overlap);
		final NFFTEventPointProcessor minMaxProcessor = new NFFTEventPointProcessor(size,overlap,samplerate);
		d.addAudioProcessor(minMaxProcessor);
		d.run();
		List<NFFTFingerprint> fingerprints = new ArrayList<NFFTFingerprint>(minMaxProcessor.getFingerprints());
		
		final List<NFFTFingerprintQueryMatch> queryMatches = new ArrayList<NFFTFingerprintQueryMatch>();
		
		queryMatches.addAll(storage.getMatches(fingerprints, maxNumberOfResults));
		
		double queryDuration = d.secondsProcessed();
		
		if(queryMatches.isEmpty()){
			QueryResult result = QueryResult.emptyQueryResult(queryOffset,queryOffset+queryDuration);
			handler.handleEmptyResult(result);
		}else{
			for(NFFTFingerprintQueryMatch match : queryMatches){
				//avoid the results in the avoid hash set
				if(!avoid.contains(match.identifier)){
					String description = storage.getAudioDescription(match.identifier);
					handler.handleQueryResult(new QueryResult(queryOffset,queryOffset+queryDuration,String.valueOf(match.identifier), description, match.score, match.getStartTime(),100.0,100.0));
				}
			}
		}
		
	} catch (UnsupportedAudioFileException e) {
		LOG.severe("Unsupported audio");
	}
	
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:39,代码来源:NFFTStrategy.java

示例15: store

import be.tarsos.dsp.AudioDispatcher; //导入方法依赖的package包/类
@Override
public double store(String resource, String description) {
	
	ConstantQ constantQ = createConstantQ();
	NCteQMapDBStorage storage = NCteQMapDBStorage.getInstance();
	
	int sampleRate = Config.getInt(Key.NCTEQ_SAMPLE_RATE);
	int size = constantQ.getFFTlength();
	int overlap = size - Config.getInt(Key.NCTEQ_STEP_SIZE);
	NCteQEventPointProcessor eventPointProcessor = new NCteQEventPointProcessor(constantQ,sampleRate,Config.getInt(Key.NCTEQ_STEP_SIZE));
	
	AudioDispatcher d = AudioDispatcherFactory.fromPipe(resource, sampleRate, size , overlap);
	d.addAudioProcessor(eventPointProcessor);
	d.run();
	
	int identifier = FileUtils.getIdentifier(resource);
	int hashesAdded = 0;
	
	float bucketFillFactorSum = 0.0f;
	for(NCteQFingerprint fingerprint : eventPointProcessor.getFingerprints()){
		float fillFactor = storage.addFingerprint(identifier, fingerprint.t1, fingerprint.hash(),fingerprint.timeDelta(),fingerprint.f1);
		bucketFillFactorSum += fillFactor;
		if(fillFactor != 1.0){
			hashesAdded++;
		}
	}
	LOG.info(String.format("Average hash bucket fill factor for %d hashes %.2f %%", hashesAdded, 100 * bucketFillFactorSum / (float)hashesAdded ) );
	float secondsProcessed = d.secondsProcessed();
	
	storage.addAudio(identifier, description);
	storage.audioObjectAdded(hashesAdded, Math.round(secondsProcessed));
	
	return secondsProcessed;
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:35,代码来源:NCteQStrategy.java


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