-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from LancerMar/haotian
Haotian
- Loading branch information
Showing
33 changed files
with
765 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "App.h" | ||
#include "window.h" | ||
#include <array> | ||
|
||
App::App() { | ||
fft = new FftClass(); | ||
lp = new Lp(SAMPLE_RATE); | ||
window = new Window(fft->array); | ||
window->show(); | ||
} | ||
|
||
/* | ||
* lowpass process data | ||
*/ | ||
int* App::lpData(int *buffer_tmp){ | ||
for(int i = 0; i < FFT_BUFFER_SIZE;i++){ | ||
data[i] = lp->filter((*buffer_tmp)); | ||
buffer_tmp++; | ||
} | ||
return data; | ||
} | ||
|
||
/* | ||
* fft process data(why frame?) | ||
*/ | ||
void App::fftData(int32_t* buffer, int frames) { | ||
fft->fill_buffer(buffer); | ||
fft->update(); | ||
} | ||
|
||
/* | ||
* plot frequency buffer data | ||
* | ||
void App::plotBuffer(double *arr) { | ||
window->updateBuffer(arr); | ||
} | ||
*/ | ||
/* | ||
* setup driver params | ||
*/ | ||
void App::setup(){ | ||
mic.registercallback(this); | ||
mic.open_pcm(); | ||
mic.set_params(); | ||
} | ||
|
||
/* | ||
* start data acquistion | ||
*/ | ||
void App::run(){ | ||
mic.run(); | ||
} | ||
|
||
App::~App(){ | ||
delete fft; | ||
delete lp; | ||
delete window; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef APP_H | ||
#define APP_H | ||
|
||
#include "DriverCallback.h" | ||
#include "i2s_mems_mic.h" | ||
#include "FftClass.h" | ||
#include "lp.h" | ||
#include "window.h" | ||
#include <array> | ||
|
||
|
||
class App : public DriverCallback{ | ||
|
||
public: | ||
/* constructor */ | ||
App(); | ||
|
||
/* implement fft process function */ | ||
void fftData(int32_t*, int) override; | ||
|
||
/* implement lowpass data function*/ | ||
int* lpData(int *) override; | ||
|
||
/* setup application */ | ||
void setup(); | ||
|
||
/* start application */ | ||
void run(); | ||
|
||
/* destructor */ | ||
~App(); | ||
|
||
private: | ||
FftClass *fft; | ||
I2Smic mic; //default-initialise object | ||
Lp *lp; | ||
Window *window; | ||
|
||
int data[FFT_BUFFER_SIZE]; | ||
}; | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#ifndef __CPP_THREAD_H_ | ||
#define __CPP_THREAD_H_ | ||
|
||
/** | ||
* GNU GENERAL PUBLIC LICENSE | ||
* Version 3, 29 June 2007 | ||
* | ||
* (C) 2020-2022, Bernd Porr <[email protected]> | ||
**/ | ||
|
||
#include <thread> | ||
|
||
/** | ||
* A thin wrapper around the C++ thread model to avoid | ||
* a static callback. Instead just inherit this class | ||
* and overload run() which then runs in this thread. | ||
* This is header-only so that it can be performed | ||
* inline for max performance. | ||
**/ | ||
class CppThread { | ||
|
||
public: | ||
/** | ||
* Starts the thread. | ||
**/ | ||
inline void start() { | ||
if (nullptr == uthread) { | ||
uthread = new std::thread(CppThread::exec, this); | ||
} | ||
} | ||
|
||
/** | ||
* Waits for the thread to terminate. | ||
**/ | ||
inline void join() { | ||
if (nullptr != uthread) { | ||
uthread->join(); | ||
delete uthread; | ||
uthread = nullptr; | ||
} | ||
} | ||
|
||
protected: | ||
/** | ||
* This method does all the work of this thread. | ||
* Overload this abstract function with | ||
* a real one doing the actual work of this thread. | ||
**/ | ||
virtual void run() = 0; | ||
|
||
private: | ||
// pointer to the thread | ||
std::thread* uthread = nullptr; | ||
// static function which points back to the instance | ||
static void exec(CppThread* cppThread) { | ||
cppThread->run(); | ||
} | ||
}; | ||
|
||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef DRIVERCALLBACK_H | ||
#define DRIVERCALLBACK_H | ||
|
||
|
||
class DriverCallback { | ||
public: | ||
//virtual functions to be overriden | ||
virtual void fftData(int *, int) = 0;//fft process | ||
virtual int* lpData(int *) = 0;// low pass data | ||
|
||
}; | ||
|
||
#endif |
Oops, something went wrong.