diff --git a/sflphone-common/src/audio/Makefile.am b/sflphone-common/src/audio/Makefile.am index 4e86ba6f5350dea43a11f00c62afb3845674b8e8..d6ad9388a83014b2bae79ce21cb6b44cc0897864 100644 --- a/sflphone-common/src/audio/Makefile.am +++ b/sflphone-common/src/audio/Makefile.am @@ -12,6 +12,8 @@ libaudio_la_SOURCES = \ audiolayer.cpp \ audiodevice.cpp \ samplerateconverter.cpp \ + echocancel.cpp \ + audioprocessing.cpp \ dcblocker.cpp \ $(SPEEX_SOURCES_CPP) @@ -23,6 +25,9 @@ noinst_HEADERS = \ audiodevice.h \ mainbuffer.h \ recordable.h \ + algorithm.h \ + echocancel.h \ + audioprocessing.h \ dcblocker.h \ samplerateconverter.h diff --git a/sflphone-common/src/audio/algorithm.h b/sflphone-common/src/audio/algorithm.h new file mode 100644 index 0000000000000000000000000000000000000000..09d4faebf664449c9d9935665348549a261019b8 --- /dev/null +++ b/sflphone-common/src/audio/algorithm.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2008 2009 Savoir-Faire Linux inc. + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "global.h" + +/** + * \class Algorithm + * + * Abstract interface used to implement audio processing algorithm + */ +class Algorithm { + + public: + + /** + * Constructor for this class + */ + Algorithm(); + + /** + * Class implementing this interface must define this function + * \param micData + */ + virtual void process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData) = 0; + +}; diff --git a/sflphone-common/src/audio/audioprocessing.cpp b/sflphone-common/src/audio/audioprocessing.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9a325065ce33d51f39076514d45b25411e12cce8 --- /dev/null +++ b/sflphone-common/src/audio/audioprocessing.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2008 2009 Savoir-Faire Linux inc. + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "audioprocessing.h" + + + +AudioProcessing::AudioProcessing(Algorithm *_algo) : _algorithm(_algo){} + + +AudioProcessing::~AudioProcessing(void){} + + +void AudioProcessing::processAudio(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData) { + + _algorithm->process(micData, spkrData, outputData); +} diff --git a/sflphone-common/src/audio/audioprocessing.h b/sflphone-common/src/audio/audioprocessing.h new file mode 100644 index 0000000000000000000000000000000000000000..13a89aa9cadd545d729671ef1efb425a911a69cd --- /dev/null +++ b/sflphone-common/src/audio/audioprocessing.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2008 2009 Savoir-Faire Linux inc. + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "algorithm.h" + +/** + * Process audio buffers using specified at instantiation which may be + * changed dynamically at runtime. + */ +class AudioProcessing { + +public: + + /** + * The constructor for this class + */ + AudioProcessing(Algorithm *_algo); + + ~AudioProcessing(void); + + /** + * Set a new algorithm to process audio. Algorithm must be a subclass of abstract class Algorithm + */ + void setAlgorithm(Algorithm *_algo) { _algorithm = _algo; } + + /** + * Process some audio data. + */ + void processAudio(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData); + +private: + + Algorithm *_algorithm; + +}; diff --git a/sflphone-common/src/audio/echocancel.cpp b/sflphone-common/src/audio/echocancel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a1a2974514c992cd379e5e25afdd2ef57896015b --- /dev/null +++ b/sflphone-common/src/audio/echocancel.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2008 2009 Savoir-Faire Linux inc. + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "echocancel.h" + + +EchoCancel::EchoCancel() {} + +EchoCancel::~EchoCancel() {} + +void EchoCancel::process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData) { + + +} diff --git a/sflphone-common/src/audio/echocancel.h b/sflphone-common/src/audio/echocancel.h new file mode 100644 index 0000000000000000000000000000000000000000..3e0e0b7a6fa3b8c02821074a52e57c06bf6a10d3 --- /dev/null +++ b/sflphone-common/src/audio/echocancel.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2008 2009 Savoir-Faire Linux inc. + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "audioprocessing.h" +#include <speex/speex_echo.h> + +class EchoCancel : Algorithm { + + EchoCancel(); + + ~EchoCancel(); + + /** + * Perform echo cancellation + * \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 + */ + virtual void process(SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData); +};