56 lines · 1.8 KB · C
RawDownload
/*
  ==============================================================================

    Yin.h
    Created: 17 Jan 2017 1:20:23pm
    Author:  Michael R Mulshine

  ==============================================================================
*/

#ifndef YIN_H_INCLUDED
#define YIN_H_INCLUDED #include <stdint.h> #define YIN_SAMPLING_RATE 44100#define YIN_DEFAULT_THRESHOLD 0.15 /** * @struct  Yin * @breif	Object to encapsulate the parameters for the Yin pitch detection algorithm  */typedef struct _Yin {	int16_t bufferSize;			/**< Size of the audio buffer to be analysed */	int16_t halfBufferSize;		/**< Half the buffer length */	float* yinBuffer;		/**< Buffer that stores the results of the intermediate processing steps of the algorithm */	float probability;		/**< Probability that the pitch found is correct as a decimal (i.e 0.85 is 85%) */	float threshold;		/**< Allowed uncertainty in the result as a decimal (i.e 0.15 is 15%) */} Yin; /** * Initialise the Yin pitch detection object * @param yin        Yin pitch detection object to initialise * @param bufferSize Length of the audio buffer to analyse * @param threshold  Allowed uncertainty (e.g 0.05 will return a pitch with ~95% probability) */void Yin_init(Yin *yin, int16_t bufferSize, float threshold); /** * Runs the Yin pitch detection algortihm * @param  yin    Initialised Yin object * @param  buffer Buffer of samples to analyse * @return        Fundamental frequency of the signal in Hz. Returns -1 if pitch can't be found */float Yin_getPitch(Yin *yin, int16_t* buffer); /** * Certainty of the pitch found  * @param  yin Yin object that has been run over a buffer * @return     Returns the certainty of the note found as a decimal (i.e 0.3 is 30%) */float Yin_getProbability(Yin *yin);	

#endif  // YIN_H_INCLUDED

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t