TarsosDSP Pitch Analysis for Dummies

I wake up on a program that analyzes the pitch of a sound file. I came across a very nice API called "TarsosDSP", which offers a variety of tone analysis. However, I am having a lot of setup problems. Can someone show me some quick pointers on how to use this API (espically PitchProcessor class), please? Some code snippets will be greatly appreciated because I am really new to sound analysis.

thanks

EDIT: I found some kind of document at http://husk.eecs.berkeley.edu/courses/cs160-sp14/index.php/Sound_Programming , where there is an example code that shows how to configure PitchProcessor, ...

int bufferReadResult = mRecorder.read(mBuffer, 0, mBufferSize); // (note: this is NOT android.media.AudioFormat) be.hogent.tarsos.dsp.AudioFormat mTarsosFormat = new be.hogent.tarsos.dsp.AudioFormat(SAMPLE_RATE, 16, 1, true, false); AudioEvent audioEvent = new AudioEvent(mTarsosFormat, bufferReadResult); audioEvent.setFloatBufferWithByteBuffer(mBuffer); pitchProcessor.process(audioEvent); 

... I'm completely lost, what are mBuffer and mBufferSize? How to find these values? And where can I enter my audio files?

+5
source share
1 answer

The main audio stream in the TarsosDSP structure is as follows: the incoming audio stream coming from an audio file or microphone is read and interrupted in the form of frames, for example. 1024 samples. Each frame moves through a pipeline that modifies or analyzes (for example, pitch analysis).

At TarsosDSP, AudioDispatcher is responsible for chopping audio into frames. It also wraps the audio frame in an AudioEvent object. This AudioEvent object AudioEvent dispatched through the AudioProcessors chain.

So, in the code you specified, mBuffer is the audio frame, mBufferSize is the size of the buffer in the samples. You can choose the size of the buffer yourself, but to determine the pitch of 2048 samples is reasonable.

To determine the pitch, you can do something similar with the TarsosDSP library:

  PitchDetectionHandler handler = new PitchDetectionHandler() { @Override public void handlePitch(PitchDetectionResult pitchDetectionResult, AudioEvent audioEvent) { System.out.println(audioEvent.getTimeStamp() + " " pitchDetectionResult.getPitch()); } }; AudioDispatcher adp = AudioDispatcherFactory.fromDefaultMicrophone(2048, 0); adp.addAudioProcessor(new PitchProcessor(PitchEstimationAlgorithm.YIN, 44100, 2048, handler)); adp.run(); 

In this code, a handler is first created that simply prints the detected step. AudioDispatcher connects to the microphone by default and has AudioDispatcher buffering. The sound processor that determines the pitch is added to AudioDispatcher . A handler is also used there.

The last line starts the process.

+7
source

All Articles