pitch tracking working on some basic level

This commit is contained in:
Trent
2017-06-26 23:31:34 -04:00
parent 4681319591
commit 35aee551c0
7 changed files with 45 additions and 28 deletions

View File

@@ -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