Skip to content

Commit

Permalink
testing easier output note method
Browse files Browse the repository at this point in the history
  • Loading branch information
N0AHt committed Apr 20, 2020
1 parent 44be794 commit 97efc12
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Code/classfiles/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tester: fulltest.cpp
g++ -c fulltest.cpp fft.cpp vocoder.cpp dispatch.cpp -I/usr/include/rtaudio
g++ -c fulltest.cpp fft.cpp vocoder.cpp dispatch.cpp -I/usr/local/include/rtaudio
g++ -o tester fulltest.o vocoder.o fft.o dispatch.o -lrtaudio -lfftw3
Binary file added Code/classfiles/tester
Binary file not shown.
10 changes: 4 additions & 6 deletions Code/fft_object_copy/audioStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ void audioStreamer::run()
unsigned int bufferFrames = 512; // samples/Fs = bufferTime
RtAudio::StreamParameters iParams, oParams;
iParams.deviceId = 0; // first available device
iParams.nChannels = 2;
iParams.nChannels = 1;
oParams.deviceId = 0; // first available device
oParams.nChannels = 2;
oParams.nChannels = 1;
int samplingRate = 44100;

//Instantiate Classes
int signed_bufferFrames = (int) bufferFrames;
fft fourier(signed_bufferFrames, samplingRate);
vocoder vocode = vocoder(samplingRate, signed_bufferFrames, cMajor);
vocoder vocode(samplingRate, signed_bufferFrames, cMajor);
dispatch dispatcher(&fourier, &vocode);
try {
adac.openStream( &oParams, &iParams, RTAUDIO_FLOAT64, samplingRate, &bufferFrames, &dispatch::caller, (void *)&dispatcher );
Expand All @@ -50,9 +50,7 @@ void audioStreamer::run()
std::cout << "\nRunning ... press <enter> to quit.\n";
inputData = fourier.in;
outputData = fourier.out;
currentNote = vocode.binDifference;
cout << "Note Difference: " << currentNote << '\n';
// inverseOut = fourier.inverse_out;
currentNote = cMajor[(vocode.baseSample)+(vocode.binDifference)];
std::cin.get(input);
// Stop the stream.
if (!running) adac.stopStream();
Expand Down
2 changes: 1 addition & 1 deletion Code/fft_object_copy/audioStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class audioStreamer : public QThread
double *inputData;
fftw_complex *outputData;
double *inverseOut;
double currentNote;
char* currentNote;

private:
bool running;
Expand Down
7 changes: 7 additions & 0 deletions Code/fft_object_copy/fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ fft::fft(int nBufferFrames, int samplingRate) {
this->nBufferFrames = nBufferFrames; //need to set as object variable or it wont exist outwith this function!
};

// void fft::setFourierSpectrum(fftw_complex* fftSpectrum){
// for (int i=0; i<nBufferFrames; ++i) {
// fourierSpectrum[i][0] = fftSpectrum[i][0];
// fourierSpectrum[i][1] = fftSpectrum[i][1];
// }
// }

void fft::executefft(double *inputBuffer) {
memcpy(in, inputBuffer, sizeof(double)*nBufferFrames );
fftw_execute(my_plan);
Expand Down
11 changes: 5 additions & 6 deletions Code/fft_object_copy/window.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "window.h"
#include "audioStreamer.h"
#include <iostream>
#include <string>
#include <iostream>
#include <string>
#include <cmath> // for sine stuff


Expand All @@ -15,7 +15,7 @@ Window::Window() : gain(5), count(0)
// every time the knob is moved, the setGain function will be called
// connect( knob, SIGNAL(valueChanged(double)), SLOT(setGain(double)) );


//thermo->setRange(0, 20);
int Fs = 44100;

Expand All @@ -27,7 +27,7 @@ Window::Window() : gain(5), count(0)
}
for( int index=0; index<fftPlotDataSize; ++index )
{
xData2[index] = index;
xData2[index] = index;
yData2[index] = 0;
}

Expand Down Expand Up @@ -112,8 +112,7 @@ void Window::timerEvent( QTimerEvent * )
++count;
std::string hi ("Hello");
dial->setValue(count);
std::cout << aStreamer->currentNote << '\n';
currentNoteText->setText(std::to_string(aStreamer->currentNote).c_str());
currentNoteText->setText(aStreamer->currentNote);

// currentNoteText->setText(std::to_string(count).c_str());
// add the new input to the plot
Expand Down

0 comments on commit 97efc12

Please sign in to comment.