Commit 75be06bd authored by Alexandre Savard's avatar Alexandre Savard

[#1966] Add putData and process methods in Algorithm class

parent 08d97c38
......@@ -32,8 +32,22 @@ class Algorithm {
public:
/**
* Class implementing this interface must define this function
* \param micData
* Put data to be processed
*/
virtual void putData(SFLDataFormat *inputData) = 0;
/**
* Class implementing this interface must define this function
* for audio processing that require synchronization between spkrdata and
*/
virtual void process(SFLDataFormat *inputData, SFLDataFormat *outputData) = 0;
/**
* Class implementing this interface must define this function
* for audio processing that require synchronization between spkr and mic
* \param micData
* \param spkrData
* \param outputData
*/
virtual void process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData) = 0;
......
......@@ -23,15 +23,29 @@
#define FRAME_SIZE 160
#define FILTER_LENGTH 2000
EchoCancel::EchoCancel() {
EchoCancel::EchoCancel()
{
_echoState = speex_echo_state_init(FRAME_SIZE, FILTER_LENGTH);
}
EchoCancel::~EchoCancel() {
EchoCancel::~EchoCancel()
{
speex_echo_state_destroy(_echoState);
_echoState = NULL;
}
void EchoCancel::process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData) {
void EchoCancel::putData(SFLDataFormat *inputData)
{
speex_echo_playback(_echoState, inputData);
}
void EchoCancel::process(SFLDataFormat *inputData, SFLDataFormat *outputData)
{
speex_echo_capture(_echoState, inputData, outputData);
}
void EchoCancel::process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData){
speex_echo_cancellation(_echoState, micData, spkrData, outputData);
}
......@@ -32,7 +32,20 @@ class EchoCancel : public Algorithm {
~EchoCancel();
/**
* Perform echo cancellation
* Add speaker data into internal buffer
* \param inputData containing far-end voice data to be sent to speakers
*/
virtual void putData(SFLDataFormat *inputData);
/**
* Perform echo cancellation using internal buffers
* \param inputData containing mixed echo and voice data
* \param outputData containing
*/
virtual void process(SFLDataFormat *inputData, SFLDataFormat *outputData);
/**
* Perform echo cancellation, application must provide its own buffer
* \param micData containing mixed echo and voice data
* \param spkrData containing far-end voice data to be sent to speakers
* \param outputData containing the processed data
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment