pitch tracking working on some basic level
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "PluginProcessor.h"
|
||||
#include "PluginEditor.h"
|
||||
#include <math.h>
|
||||
|
||||
LampshadeAudioProcessor::LampshadeAudioProcessor()
|
||||
#ifndef JucePlugin_PreferredChannelConfigurations
|
||||
@@ -93,6 +94,7 @@ bool LampshadeAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts
|
||||
|
||||
void LampshadeAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
|
||||
{
|
||||
static float incrementer;
|
||||
const int totalNumInputChannels = getTotalNumInputChannels();
|
||||
const int totalNumOutputChannels = getTotalNumOutputChannels();
|
||||
|
||||
@@ -106,12 +108,17 @@ void LampshadeAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffe
|
||||
buffer.clear(i, 0, buffer.getNumSamples());
|
||||
|
||||
float pitch = myYin.getPitch(buffer.getWritePointer (0)); // returns Pitch in Hertz
|
||||
printf("pitch: %f", pitch);
|
||||
static float myPitch;
|
||||
if(pitch > 0) { myPitch = pitch; }
|
||||
|
||||
for (int channel = 0; channel < totalNumInputChannels; ++channel) {
|
||||
//float* channelData = buffer.getWritePointer (channel);
|
||||
|
||||
float* channel1Data = buffer.getWritePointer (0);
|
||||
float* channel2Data = buffer.getWritePointer (1);
|
||||
for(int i=0; i < buffer.getNumSamples(); i++){
|
||||
incrementer += (myPitch / 4000);
|
||||
channel1Data[i] = sin(incrementer) * 0.1;
|
||||
channel2Data[i] = channel1Data[i];
|
||||
}
|
||||
printf("%f\n",channel1Data[0]);
|
||||
}
|
||||
|
||||
bool LampshadeAudioProcessor::hasEditor() const
|
||||
|
@@ -1,12 +1,13 @@
|
||||
#include "Yin.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
//#include "WProgram.h"
|
||||
|
||||
void Yin::initialize(float yinSampleRate,int yinBufferSize){
|
||||
bufferSize = yinBufferSize;
|
||||
sampleRate = yinSampleRate;
|
||||
halfBufferSize = bufferSize / 2;
|
||||
threshold = 0.15;
|
||||
threshold = 0.01;
|
||||
probability = 0.0;
|
||||
//initialize array and set it to zero
|
||||
yinBuffer = (float *) malloc(sizeof(float)* halfBufferSize);
|
||||
@@ -137,6 +138,7 @@ int Yin::absoluteThreshold(){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if no pitch found, tau => -1
|
||||
if (tau == halfBufferSize || yinBuffer[tau] >= threshold) {
|
||||
tau = -1;
|
||||
|
Reference in New Issue
Block a user