Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
b9270c324b | |||
d18a48bca1 | |||
4b04365f3f | |||
44911d3616 | |||
952e34a0b8 | |||
19956a6211 | |||
7f3ffb9a12 | |||
c76d433d50 | |||
d5c9a30189 | |||
33d621539b | |||
3a1721f6e1 | |||
a073d51f3d | |||
4a3ceff16b | |||
f2fae7b532 | |||
12bb701758 | |||
9cf23b59e9 | |||
eecf291eab | |||
5ee32982d4 | |||
10905293f7 |
373
LICENSE
Normal file
373
LICENSE
Normal file
@ -0,0 +1,373 @@
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
@ -1,4 +1,4 @@
|
||||
# audio-algo-speex
|
||||
(APACHE 2) speex dsp algo normalisation wrapper
|
||||
(MPL v2.0) speex dsp algo normalisation wrapper
|
||||
|
||||
[](https://travis-ci.org/musicdsp/audio-algo-speex)
|
||||
|
200
audio/algo/speex/Aec.cpp
Normal file
200
audio/algo/speex/Aec.cpp
Normal file
@ -0,0 +1,200 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#define speex_POSIX 1
|
||||
#include <audio/algo/speex/Aec.hpp>
|
||||
#include <audio/algo/speex/debug.hpp>
|
||||
#include <cmath>
|
||||
|
||||
#include <speex/speex_echo.h>
|
||||
#include <speex/speex_preprocess.h>
|
||||
|
||||
|
||||
namespace audio {
|
||||
namespace algo {
|
||||
namespace speex {
|
||||
class AecPrivate {
|
||||
private:
|
||||
SpeexEchoState* m_speexEchoState = null;
|
||||
SpeexPreprocessState* m_speexPreprocessState = null;
|
||||
enum audio::format m_format;
|
||||
float m_sampleRate;
|
||||
int8_t m_nbChannel;
|
||||
etk::Vector<float> m_tmpBufferIn;
|
||||
etk::Vector<float> m_tmpBufferOut;
|
||||
int32_t m_frameSize;
|
||||
uint32_t calculateBlockSize(uint32_t _sampleRate, uint32_t _sizeInMs) {
|
||||
uint32_t nframes = (_sampleRate * _sizeInMs) / 1000;
|
||||
uint32_t y = 1 << ((8 * sizeof(uint32_t)) - 2);
|
||||
if(_sampleRate < 4000) {
|
||||
AA_SPEEX_INFO("speex: request Sample rate < 4000: " << _sampleRate);
|
||||
return 32;
|
||||
}
|
||||
if(_sizeInMs < 1) {
|
||||
AA_SPEEX_INFO("speex: request size in ms < 1: " << _sizeInMs);
|
||||
return 32;
|
||||
}
|
||||
// calculate power of 2:
|
||||
while (y > nframes) {
|
||||
y >>= 1;
|
||||
}
|
||||
return y;
|
||||
}
|
||||
public:
|
||||
AecPrivate(int8_t _nbChannel, float _sampleRate, enum audio::format _format) :
|
||||
m_format(_format),
|
||||
m_sampleRate(_sampleRate),
|
||||
m_nbChannel(_nbChannel) {
|
||||
bool paramAGC = false;
|
||||
bool paramDenoise = false;
|
||||
bool paramEchoSuppress = true;
|
||||
int32_t paramEchoSuppressAttenuation = -40;
|
||||
int32_t paramEchoSuppressAttenuationActive = -15;
|
||||
uint32_t filterSizeMs = 200; // Buffer size in ms [100-500]
|
||||
uint32_t frameSizeMs = 20; // Frame size in ms [10..20]
|
||||
m_frameSize = calculateBlockSize(m_sampleRate, frameSizeMs);
|
||||
AA_SPEEX_INFO("Using framesize: " << m_frameSize);
|
||||
/*
|
||||
m_speexEchoState = speex_echo_state_init_mc(m_frameSize,
|
||||
(m_sampleRate * filterSizeMs) / 1000,
|
||||
m_nbChannel, // n microphone channel ...
|
||||
1 // 1 speaker
|
||||
);
|
||||
*/
|
||||
m_speexEchoState = speex_echo_state_init(m_frameSize, calculateBlockSize(m_sampleRate,filterSizeMs));//(m_sampleRate*filterSizeMs)/1000);
|
||||
if (m_speexEchoState == null) {
|
||||
AA_SPEEX_ERROR("Can not intanciate speex handle");
|
||||
return;
|
||||
}
|
||||
int sampleRateToInject = _sampleRate;
|
||||
speex_echo_ctl(m_speexEchoState, SPEEX_ECHO_SET_SAMPLING_RATE, &sampleRateToInject);
|
||||
|
||||
if ( paramAGC == true
|
||||
|| paramDenoise == true
|
||||
|| paramEchoSuppress == true) {
|
||||
spx_int32_t tmp;
|
||||
if (_nbChannel != 1) {
|
||||
AA_SPEEX_ERROR("support only one channel ... ==> need to create multiple channel instance ...");
|
||||
return;
|
||||
}
|
||||
m_speexPreprocessState = speex_preprocess_state_init(m_frameSize, m_sampleRate);
|
||||
AA_SPEEX_INFO("Set speex preprocessor AGC=" << paramAGC);
|
||||
tmp = paramAGC;
|
||||
speex_preprocess_ctl(m_speexPreprocessState, SPEEX_PREPROCESS_SET_AGC, &tmp);
|
||||
AA_SPEEX_INFO("Set speex preprocessor DENOISE=" << paramDenoise);
|
||||
tmp = paramDenoise;
|
||||
speex_preprocess_ctl(m_speexPreprocessState, SPEEX_PREPROCESS_SET_DENOISE, &tmp);
|
||||
|
||||
if (paramEchoSuppress) {
|
||||
if (paramEchoSuppressAttenuation) {
|
||||
int32_t tmpEchoSuppressAttenuation;
|
||||
speex_preprocess_ctl(m_speexPreprocessState, SPEEX_PREPROCESS_GET_ECHO_SUPPRESS, &tmpEchoSuppressAttenuation);
|
||||
AA_SPEEX_INFO("Set speex preprocessor AEC attenuation=" << paramEchoSuppressAttenuation << " base=" << tmpEchoSuppressAttenuation);
|
||||
speex_preprocess_ctl(m_speexPreprocessState, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS, ¶mEchoSuppressAttenuation);
|
||||
}
|
||||
if (paramEchoSuppressAttenuationActive) {
|
||||
int32_t tmpEchoSuppressAttenuationActive;
|
||||
speex_preprocess_ctl(m_speexPreprocessState, SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE, &tmpEchoSuppressAttenuationActive);
|
||||
AA_SPEEX_INFO("Set speex preprocessor AEC attenuation enable=" << paramEchoSuppressAttenuationActive << " base=" << tmpEchoSuppressAttenuationActive);
|
||||
speex_preprocess_ctl(m_speexPreprocessState, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE, ¶mEchoSuppressAttenuationActive);
|
||||
}
|
||||
speex_preprocess_ctl(m_speexPreprocessState, SPEEX_PREPROCESS_SET_ECHO_STATE, m_speexEchoState);
|
||||
}
|
||||
} else {
|
||||
AA_SPEEX_ERROR("request speex with no algorithm");
|
||||
}
|
||||
}
|
||||
|
||||
~AecPrivate() {
|
||||
/* TODO : Check this leak ...
|
||||
if (m_speexPreprocessState) {
|
||||
speex_preprocess_state_destroy(m_speexPreprocessState);
|
||||
m_speexPreprocessState = null;
|
||||
}
|
||||
if (m_speexEchoState) {
|
||||
speex_echo_state_destroy(m_speexEchoState);
|
||||
m_speexEchoState = null;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Main input algo process.
|
||||
* @param[in,out] _output Output data.
|
||||
* @param[in] _input Input data.
|
||||
* @param[in] _inputFeedback Input feedback data (all time MONO).
|
||||
* @param[in] _nbChunk Number of chunk in the input buffer.
|
||||
* @param[in] _nbChannel Number of channel in the stream.
|
||||
*/
|
||||
void process(void* _output, const void* _input, const void* _inputFeedback, size_t _nbChunk) {
|
||||
if (m_speexEchoState == null) {
|
||||
AA_SPEEX_ERROR("speex handle is not initialize ==> can not process");
|
||||
return;
|
||||
}
|
||||
switch (m_format) {
|
||||
case audio::format_int16:
|
||||
// process APC
|
||||
speex_echo_cancellation(m_speexEchoState, (const spx_int16_t*)_input, (const spx_int16_t*)_inputFeedback, (spx_int16_t*)_output);
|
||||
// apply NR after AEC
|
||||
if (m_speexPreprocessState != null) {
|
||||
speex_preprocess_run(m_speexPreprocessState, (spx_int16_t*) _output);
|
||||
}
|
||||
return;
|
||||
default:
|
||||
AA_SPEEX_ERROR("Can not Limit with unsupported format : " << m_format);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t getOptimalFrameSize() {
|
||||
return m_frameSize;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void audio::algo::speex::Aec::init(int8_t _nbChannel, float _sampleRate, enum audio::format _format) {
|
||||
m_private.reset();
|
||||
m_private = ememory::makeShared<audio::algo::speex::AecPrivate>(_nbChannel, _sampleRate, _format);
|
||||
}
|
||||
|
||||
etk::Vector<float> audio::algo::speex::Aec::getSupportedSampleRate() {
|
||||
etk::Vector<float> out;
|
||||
out.pushBack(4000);
|
||||
out.pushBack(8000);
|
||||
out.pushBack(16000);
|
||||
out.pushBack(32000);
|
||||
out.pushBack(48000);
|
||||
return out;
|
||||
}
|
||||
etk::Vector<enum audio::format> audio::algo::speex::Aec::getSupportedFormat() {
|
||||
return getNativeSupportedFormat();
|
||||
}
|
||||
|
||||
etk::Vector<enum audio::format> audio::algo::speex::Aec::getNativeSupportedFormat() {
|
||||
etk::Vector<enum audio::format> out;
|
||||
//out.pushBack(audio::format_float);
|
||||
out.pushBack(audio::format_int16);
|
||||
return out;
|
||||
}
|
||||
|
||||
void audio::algo::speex::Aec::process(void* _output, const void* _input, const void* _inputFeedback, size_t _nbChunk) {
|
||||
if (m_private == null) {
|
||||
AA_SPEEX_ERROR("Algo is not initialized...");
|
||||
}
|
||||
m_private->process(_output, _input, _inputFeedback, _nbChunk);
|
||||
}
|
||||
|
||||
int32_t audio::algo::speex::Aec::getOptimalFrameSize() {
|
||||
if (m_private == null) {
|
||||
AA_SPEEX_ERROR("Algo is not initialized...");
|
||||
return 32;
|
||||
}
|
||||
return m_private->getOptimalFrameSize();
|
||||
}
|
||||
|
61
audio/algo/speex/Aec.hpp
Normal file
61
audio/algo/speex/Aec.hpp
Normal file
@ -0,0 +1,61 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <audio/format.hpp>
|
||||
#include <chrono>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace audio {
|
||||
namespace algo {
|
||||
namespace speex {
|
||||
class AecPrivate;
|
||||
class Aec {
|
||||
public:
|
||||
Aec() = default;
|
||||
virtual ~Aec() = default;
|
||||
public:
|
||||
/**
|
||||
* @brief Initialize the Algorithm
|
||||
* @param[in] _nbChannel Number of channel in the stream.
|
||||
* @param[in] _sampleRate Sample rate.
|
||||
* @param[in] _format Input/output data format.
|
||||
*/
|
||||
virtual void init(int8_t _nbChannel, float _sampleRate, enum audio::format _format = audio::format_float);
|
||||
/**
|
||||
* @brief Get list of samplerate suported.
|
||||
* @return list of supported samplerate
|
||||
*/
|
||||
virtual etk::Vector<float> getSupportedSampleRate();
|
||||
/**
|
||||
* @brief Get list of format suported in input.
|
||||
* @return list of supported format
|
||||
*/
|
||||
virtual etk::Vector<enum audio::format> getSupportedFormat();
|
||||
/**
|
||||
* @brief Get list of algorithm format suported. No format convertion.
|
||||
* @return list of supported format
|
||||
*/
|
||||
virtual etk::Vector<enum audio::format> getNativeSupportedFormat();
|
||||
/**
|
||||
* @brief Main input algo process.
|
||||
* @param[in,out] _output Output data.
|
||||
* @param[in] _input Input data.
|
||||
* @param[in] _inputFeedback Input feedback data (all time MONO).
|
||||
* @param[in] _nbChunk Number of chunk in the input buffer.
|
||||
* @param[in] _nbChannel Number of channel in the stream.
|
||||
*/
|
||||
virtual void process(void* _output, const void* _input, const void* _inputFeedback, size_t _nbChunk);
|
||||
int32_t getOptimalFrameSize();
|
||||
protected:
|
||||
ememory::SharedPtr<AecPrivate> m_private; //!< private data.
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <audio/algo/speex/Resampler.h>
|
||||
#include <audio/algo/speex/debug.h>
|
||||
#include <audio/algo/speex/Resampler.hpp>
|
||||
#include <audio/algo/speex/debug.hpp>
|
||||
#include <cmath>
|
||||
#ifdef HAVE_SPEEX_DSP
|
||||
#include <speex/speex_resampler.h>
|
||||
@ -24,13 +24,13 @@ namespace audio {
|
||||
public:
|
||||
ResamplerPrivate(int8_t _nbChannel, float _inputSampleRate, float _outputSampleRate, int8_t _quality, enum audio::format _format) :
|
||||
#ifdef HAVE_SPEEX_DSP
|
||||
m_speexResampler(nullptr),
|
||||
m_speexResampler(null),
|
||||
#endif
|
||||
m_format(_format) {
|
||||
#ifdef HAVE_SPEEX_DSP
|
||||
if (m_speexResampler != nullptr) {
|
||||
if (m_speexResampler != null) {
|
||||
speex_resampler_destroy(m_speexResampler);
|
||||
m_speexResampler = nullptr;
|
||||
m_speexResampler = null;
|
||||
}
|
||||
AA_SPEEX_DEBUG("Create resampler for : " << _inputSampleRate << " to " << _outputSampleRate);
|
||||
int err = 0;
|
||||
@ -45,9 +45,9 @@ namespace audio {
|
||||
|
||||
~ResamplerPrivate() {
|
||||
#ifdef HAVE_SPEEX_DSP
|
||||
if (m_speexResampler != nullptr) {
|
||||
if (m_speexResampler != null) {
|
||||
speex_resampler_destroy(m_speexResampler);
|
||||
m_speexResampler = nullptr;
|
||||
m_speexResampler = null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -78,6 +78,7 @@ namespace audio {
|
||||
break;
|
||||
case audio::format_float:
|
||||
{
|
||||
AA_SPEEX_ERROR("RESAMPLE: " << _nbChunk << " ==> " << _nbChunkOut);
|
||||
uint32_t nbChunkInput = _nbChunk;
|
||||
uint32_t nbChunkOutput = _nbChunkOut;
|
||||
int ret = speex_resampler_process_interleaved_float(m_speexResampler,
|
||||
@ -85,6 +86,7 @@ namespace audio {
|
||||
&nbChunkInput,
|
||||
reinterpret_cast<float*>(_output),
|
||||
&nbChunkOutput);
|
||||
AA_SPEEX_ERROR("RESAMPLE: " << nbChunkInput << " ==> " << nbChunkOutput << " DONE");
|
||||
// Check all input and output ...
|
||||
if (nbChunkInput != _nbChunk) {
|
||||
AA_SPEEX_ERROR("inputSize (not all read ...) proceed=" << nbChunkInput << " requested=" << _nbChunk);
|
||||
@ -125,20 +127,20 @@ void audio::algo::speex::Resampler::init(int8_t _nbChannel, float _inputSampleRa
|
||||
m_private = ememory::makeShared<audio::algo::speex::ResamplerPrivate>(_nbChannel, _inputSampleRate, _outputSampleRate, _quality, _format);
|
||||
}
|
||||
|
||||
std::vector<enum audio::format> audio::algo::speex::Resampler::getSupportedFormat() {
|
||||
std::vector<enum audio::format> out = getNativeSupportedFormat();
|
||||
etk::Vector<enum audio::format> audio::algo::speex::Resampler::getSupportedFormat() {
|
||||
etk::Vector<enum audio::format> out = getNativeSupportedFormat();
|
||||
return out;
|
||||
}
|
||||
|
||||
std::vector<enum audio::format> audio::algo::speex::Resampler::getNativeSupportedFormat() {
|
||||
std::vector<enum audio::format> out;
|
||||
out.push_back(audio::format_float);
|
||||
out.push_back(audio::format_int16);
|
||||
etk::Vector<enum audio::format> audio::algo::speex::Resampler::getNativeSupportedFormat() {
|
||||
etk::Vector<enum audio::format> out;
|
||||
//out.pushBack(audio::format_float); ==> sppex dsp only compille in fixpoint, of float ... not at the same time ...
|
||||
out.pushBack(audio::format_int16);
|
||||
return out;
|
||||
}
|
||||
|
||||
void audio::algo::speex::Resampler::process(void* _output, size_t& _nbChunkOut, const void* _input, size_t _nbChunk) {
|
||||
if (m_private == nullptr) {
|
||||
if (m_private == null) {
|
||||
AA_SPEEX_ERROR("Algo is not initialized...");
|
||||
}
|
||||
m_private->process(_output, _nbChunkOut, _input, _nbChunk);
|
||||
|
@ -1,15 +1,15 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <audio/format.h>
|
||||
#include <chrono>
|
||||
#include <ememory/memory.h>
|
||||
#include <vector>
|
||||
#include <etk/types.hpp>
|
||||
#include <audio/format.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace algo {
|
||||
@ -33,12 +33,12 @@ namespace audio {
|
||||
* @brief Get list of format suported in input.
|
||||
* @return list of supported format
|
||||
*/
|
||||
virtual std::vector<enum audio::format> getSupportedFormat();
|
||||
virtual etk::Vector<enum audio::format> getSupportedFormat();
|
||||
/**
|
||||
* @brief Get list of algorithm format suported. No format convertion.
|
||||
* @return list of supported format
|
||||
*/
|
||||
virtual std::vector<enum audio::format> getNativeSupportedFormat();
|
||||
virtual etk::Vector<enum audio::format> getNativeSupportedFormat();
|
||||
/**
|
||||
* @brief Main input algo process.
|
||||
* @param[in,out] _output Output data.
|
114
audio/algo/speex/Vad.cpp
Normal file
114
audio/algo/speex/Vad.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#define speex_POSIX 1
|
||||
#include <audio/algo/speex/Vad.hpp>
|
||||
#include <audio/algo/speex/debug.hpp>
|
||||
#include <cmath>
|
||||
|
||||
#include <webrtc/common_audio/vad/include/webrtc_vad.h>
|
||||
|
||||
namespace audio {
|
||||
namespace algo {
|
||||
namespace speex {
|
||||
class VadPrivate {
|
||||
private:
|
||||
VadInst *m_vad = null;
|
||||
bool m_voiceDetected = false;
|
||||
uint32_t calculateBlockSize(uint32_t _sampleRate, uint32_t _sizeInMs) {
|
||||
return 0;
|
||||
}
|
||||
public:
|
||||
VadPrivate() {
|
||||
WebRtcVad_Create(&m_vad);
|
||||
WebRtcVad_Init(m_vad);
|
||||
}
|
||||
|
||||
~VadPrivate() {
|
||||
/* TODO : Check this leak ...
|
||||
if (m_speexPreprocessState) {
|
||||
speex_preprocess_state_destroy(m_speexPreprocessState);
|
||||
m_speexPreprocessState = null;
|
||||
}
|
||||
if (m_speexEchoState) {
|
||||
speex_echo_state_destroy(m_speexEchoState);
|
||||
m_speexEchoState = null;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Main input algo process.
|
||||
* @param[in,out] _output Output data.
|
||||
* @param[in] _input Input data.
|
||||
* @param[in] _inputFeedback Input feedback data (all time MONO).
|
||||
* @param[in] _nbChunk Number of chunk in the input buffer.
|
||||
* @param[in] _nbChannel Number of channel in the stream.
|
||||
*/
|
||||
void process(const void* _input, size_t _nbChunk) {
|
||||
if (m_vad == null) {
|
||||
AA_SPEEX_ERROR("speex handle is not initialize ==> can not process");
|
||||
return;
|
||||
}
|
||||
m_voiceDetected = WebRtcVad_Process(m_vad, 16000, (const int16_t*)_input, _nbChunk);
|
||||
}
|
||||
|
||||
int32_t getOptimalFrameSize() {
|
||||
return 160;
|
||||
}
|
||||
|
||||
bool getVoiceDetected() {
|
||||
return m_voiceDetected;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void audio::algo::speex::Vad::init(int8_t _nbChannel, float _sampleRate, enum audio::format _format) {
|
||||
m_private.reset();
|
||||
m_private = ememory::makeShared<audio::algo::speex::VadPrivate>();
|
||||
}
|
||||
|
||||
etk::Vector<float> audio::algo::speex::Vad::getSupportedSampleRate() {
|
||||
etk::Vector<float> out;
|
||||
out.pushBack(16000);
|
||||
return out;
|
||||
}
|
||||
etk::Vector<enum audio::format> audio::algo::speex::Vad::getSupportedFormat() {
|
||||
return getNativeSupportedFormat();
|
||||
}
|
||||
|
||||
etk::Vector<enum audio::format> audio::algo::speex::Vad::getNativeSupportedFormat() {
|
||||
etk::Vector<enum audio::format> out;
|
||||
out.pushBack(audio::format_int16);
|
||||
return out;
|
||||
}
|
||||
/// set 10 ms ==> 160 sample
|
||||
void audio::algo::speex::Vad::process(const void* _input, size_t _nbChunk) {
|
||||
if (m_private == null) {
|
||||
AA_SPEEX_ERROR("Algo is not initialized...");
|
||||
}
|
||||
m_private->process(_input, _nbChunk);
|
||||
}
|
||||
|
||||
int32_t audio::algo::speex::Vad::getOptimalFrameSize() {
|
||||
if (m_private == null) {
|
||||
AA_SPEEX_ERROR("Algo is not initialized...");
|
||||
return 32;
|
||||
}
|
||||
return m_private->getOptimalFrameSize();
|
||||
}
|
||||
|
||||
|
||||
bool audio::algo::speex::Vad::getVoiceDetected() {
|
||||
if (m_private == null) {
|
||||
AA_SPEEX_ERROR("Algo is not initialized...");
|
||||
return 32;
|
||||
}
|
||||
return m_private->getVoiceDetected();
|
||||
}
|
64
audio/algo/speex/Vad.hpp
Normal file
64
audio/algo/speex/Vad.hpp
Normal file
@ -0,0 +1,64 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <audio/format.hpp>
|
||||
#include <chrono>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace audio {
|
||||
namespace algo {
|
||||
namespace speex {
|
||||
class VadPrivate;
|
||||
class Vad {
|
||||
public:
|
||||
Vad() = default;
|
||||
virtual ~Vad() = default;
|
||||
public:
|
||||
/**
|
||||
* @brief Initialize the Algorithm
|
||||
* @param[in] _nbChannel Number of channel in the stream.
|
||||
* @param[in] _sampleRate Sample rate.
|
||||
* @param[in] _format Input/output data format.
|
||||
*/
|
||||
virtual void init(int8_t _nbChannel, float _sampleRate, enum audio::format _format = audio::format_float);
|
||||
/**
|
||||
* @brief Get list of samplerate suported.
|
||||
* @return list of supported samplerate
|
||||
*/
|
||||
virtual etk::Vector<float> getSupportedSampleRate();
|
||||
/**
|
||||
* @brief Get list of format suported in input.
|
||||
* @return list of supported format
|
||||
*/
|
||||
virtual etk::Vector<enum audio::format> getSupportedFormat();
|
||||
/**
|
||||
* @brief Get list of algorithm format suported. No format convertion.
|
||||
* @return list of supported format
|
||||
*/
|
||||
virtual etk::Vector<enum audio::format> getNativeSupportedFormat();
|
||||
/**
|
||||
* @brief Main input algo process.
|
||||
* @param[in,out] _output Output data.
|
||||
* @param[in] _input Input data.
|
||||
* @param[in] _inputFeedback Input feedback data (all time MONO).
|
||||
* @param[in] _nbChunk Number of chunk in the input buffer.
|
||||
* @param[in] _nbChannel Number of channel in the stream.
|
||||
*/
|
||||
virtual void process(const void* _input, size_t _nbChunk);
|
||||
|
||||
bool getVoiceDetected();
|
||||
|
||||
int32_t getOptimalFrameSize();
|
||||
protected:
|
||||
ememory::SharedPtr<VadPrivate> m_private; //!< private data.
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "debug.hpp"
|
||||
|
||||
|
||||
int32_t audio::algo::speex::getLogId() {
|
||||
|
@ -1,11 +1,11 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <elog/log.h>
|
||||
#include <elog/log.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace algo {
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.module as module
|
||||
import realog.debug as debug
|
||||
import lutin.tools as tools
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ def get_desc():
|
||||
return "test for speex ALGO"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
@ -24,13 +24,15 @@ def get_compagny_name():
|
||||
def get_maintainer():
|
||||
return "authors.txt"
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
def configure(target, my_module):
|
||||
my_module.add_src_file([
|
||||
'test/main.cpp'
|
||||
])
|
||||
my_module.add_depend(['audio-algo-speex', 'test-debug'])
|
||||
return my_module
|
||||
my_module.add_depend([
|
||||
'audio-algo-speex',
|
||||
'test-debug'
|
||||
])
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.module as module
|
||||
import realog.debug as debug
|
||||
import lutin.tools as tools
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ def get_desc():
|
||||
return "speex algos wrapper"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
@ -24,19 +24,26 @@ def get_maintainer():
|
||||
def get_version():
|
||||
return "version.txt"
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
def configure(target, my_module):
|
||||
my_module.add_src_file([
|
||||
'audio/algo/speex/debug.cpp',
|
||||
'audio/algo/speex/Resampler.cpp'
|
||||
'audio/algo/speex/Resampler.cpp',
|
||||
'audio/algo/speex/Aec.cpp',
|
||||
'audio/algo/speex/Vad.cpp',
|
||||
])
|
||||
my_module.add_header_file([
|
||||
'audio/algo/speex/Resampler.h'
|
||||
'audio/algo/speex/Resampler.hpp',
|
||||
'audio/algo/speex/Aec.hpp',
|
||||
'audio/algo/speex/Vad.hpp',
|
||||
])
|
||||
my_module.add_depend([
|
||||
'etk',
|
||||
'audio',
|
||||
'webrtc',
|
||||
])
|
||||
my_module.add_depend(['etk', 'audio'])
|
||||
my_module.add_optionnal_depend('speex-dsp', ["c++", "-DHAVE_SPEEX_DSP"])
|
||||
my_module.add_path(tools.get_current_path(__file__))
|
||||
return my_module
|
||||
my_module.add_path(".")
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
321
test/main.cpp
321
test/main.cpp
@ -1,53 +1,57 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <test-debug/debug.h>
|
||||
#include <etk/etk.h>
|
||||
#include <audio/algo/speex/Resampler.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <chrono>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
#include <audio/algo/speex/Resampler.hpp>
|
||||
#include <audio/algo/speex/Aec.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <ethread/Thread.hpp>
|
||||
|
||||
#include <ethread/tools.hpp>
|
||||
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
class Performance {
|
||||
private:
|
||||
std::chrono::steady_clock::time_point m_timeStart;
|
||||
std::chrono::steady_clock::time_point m_timeStop;
|
||||
std::chrono::nanoseconds m_totalTimeProcessing;
|
||||
std::chrono::nanoseconds m_minProcessing;
|
||||
std::chrono::nanoseconds m_maxProcessing;
|
||||
echrono::Steady m_timeStart;
|
||||
echrono::Steady m_timeStop;
|
||||
echrono::Duration m_totalTimeProcessing;
|
||||
echrono::Duration m_minProcessing;
|
||||
echrono::Duration m_maxProcessing;
|
||||
int32_t m_totalIteration;
|
||||
public:
|
||||
Performance() :
|
||||
m_totalTimeProcessing(0),
|
||||
m_minProcessing(99999999999999LL),
|
||||
m_minProcessing(int64_t(99999999999999LL)),
|
||||
m_maxProcessing(0),
|
||||
m_totalIteration(0) {
|
||||
|
||||
}
|
||||
void tic() {
|
||||
m_timeStart = std::chrono::steady_clock::now();
|
||||
m_timeStart = echrono::Steady::now();
|
||||
}
|
||||
void toc() {
|
||||
m_timeStop = std::chrono::steady_clock::now();
|
||||
std::chrono::nanoseconds time = m_timeStop - m_timeStart;
|
||||
m_minProcessing = std::min(m_minProcessing, time);
|
||||
m_maxProcessing = std::max(m_maxProcessing, time);
|
||||
m_timeStop = echrono::Steady::now();
|
||||
echrono::Duration time = m_timeStop - m_timeStart;
|
||||
m_minProcessing = etk::min(m_minProcessing, time);
|
||||
m_maxProcessing = etk::max(m_maxProcessing, time);
|
||||
m_totalTimeProcessing += time;
|
||||
m_totalIteration++;
|
||||
|
||||
}
|
||||
|
||||
std::chrono::nanoseconds getTotalTimeProcessing() {
|
||||
echrono::Duration getTotalTimeProcessing() {
|
||||
return m_totalTimeProcessing;
|
||||
}
|
||||
std::chrono::nanoseconds getMinProcessing() {
|
||||
echrono::Duration getMinProcessing() {
|
||||
return m_minProcessing;
|
||||
}
|
||||
std::chrono::nanoseconds getMaxProcessing() {
|
||||
echrono::Duration getMaxProcessing() {
|
||||
return m_maxProcessing;
|
||||
}
|
||||
int32_t getTotalIteration() {
|
||||
@ -57,9 +61,9 @@ class Performance {
|
||||
};
|
||||
|
||||
float performanceResamplerStepFloat(float _sampleRateIn, float _sampleRateOut, int8_t _quality) {
|
||||
std::vector<float> input;
|
||||
etk::Vector<float> input;
|
||||
input.resize(1024, 0);
|
||||
std::vector<float> output;
|
||||
etk::Vector<float> output;
|
||||
output.resize(input.size()*10, 0);
|
||||
double sampleRate = _sampleRateIn;
|
||||
{
|
||||
@ -82,24 +86,24 @@ float performanceResamplerStepFloat(float _sampleRateIn, float _sampleRateOut, i
|
||||
size_t sizeOut = output.size();
|
||||
algo.process(&output[0], sizeOut, &input[0], input.size());
|
||||
perfo.toc();
|
||||
usleep(1000);
|
||||
ethread::sleepMilliSeconds((1));
|
||||
}
|
||||
TEST_INFO(" blockSize=" << input.size() << " sample");
|
||||
TEST_INFO(" min < avg < max =" << perfo.getMinProcessing().count() << "ns < "
|
||||
<< perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration() << "ns < "
|
||||
<< perfo.getMaxProcessing().count() << "ns ");
|
||||
float avg = (float(((perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration())*sampleRate)/double(input.size()))/1000000000.0)*100.0;
|
||||
TEST_INFO(" min < avg < max= " << (float((perfo.getMinProcessing().count()*sampleRate)/double(input.size()))/1000000000.0)*100.0 << "% < "
|
||||
TEST_INFO(" min < avg < max =" << perfo.getMinProcessing() << " < "
|
||||
<< perfo.getTotalTimeProcessing().get()/perfo.getTotalIteration() << "ns < "
|
||||
<< perfo.getMaxProcessing());
|
||||
float avg = (float(((perfo.getTotalTimeProcessing().get()/perfo.getTotalIteration())*sampleRate)/double(input.size()))/1000000000.0)*100.0;
|
||||
TEST_INFO(" min < avg < max= " << (float((perfo.getMinProcessing().get()*sampleRate)/double(input.size()))/1000000000.0)*100.0 << "% < "
|
||||
<< avg << "% < "
|
||||
<< (float((perfo.getMaxProcessing().count()*sampleRate)/double(input.size()))/1000000000.0)*100.0 << "%");
|
||||
<< (float((perfo.getMaxProcessing().get()*sampleRate)/double(input.size()))/1000000000.0)*100.0 << "%");
|
||||
TEST_PRINT("float : " << _sampleRateIn << " -> " << _sampleRateOut << " quality=" << int32_t(_quality) << " : " << avg << "%");
|
||||
return avg;
|
||||
}
|
||||
|
||||
float performanceResamplerStepI16(float _sampleRateIn, float _sampleRateOut, int8_t _quality) {
|
||||
std::vector<int16_t> input;
|
||||
etk::Vector<int16_t> input;
|
||||
input.resize(1024, 0);
|
||||
std::vector<int16_t> output;
|
||||
etk::Vector<int16_t> output;
|
||||
output.resize(input.size()*10, 0);
|
||||
double sampleRate = _sampleRateIn;
|
||||
{
|
||||
@ -122,16 +126,16 @@ float performanceResamplerStepI16(float _sampleRateIn, float _sampleRateOut, int
|
||||
size_t sizeOut = output.size();
|
||||
algo.process(&output[0], sizeOut, &input[0], input.size());
|
||||
perfo.toc();
|
||||
usleep(1000);
|
||||
ethread::sleepMilliSeconds((1));
|
||||
}
|
||||
TEST_INFO(" blockSize=" << input.size() << " sample");
|
||||
TEST_INFO(" min < avg < max =" << perfo.getMinProcessing().count() << "ns < "
|
||||
<< perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration() << "ns < "
|
||||
<< perfo.getMaxProcessing().count() << "ns ");
|
||||
float avg = (float(((perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration())*sampleRate)/double(input.size()))/1000000000.0)*100.0;
|
||||
TEST_INFO(" min < avg < max= " << (float((perfo.getMinProcessing().count()*sampleRate)/double(input.size()))/1000000000.0)*100.0 << "% < "
|
||||
TEST_INFO(" min < avg < max =" << perfo.getMinProcessing() << " < "
|
||||
<< perfo.getTotalTimeProcessing().get()/perfo.getTotalIteration() << "ns < "
|
||||
<< perfo.getMaxProcessing());
|
||||
float avg = (float(((perfo.getTotalTimeProcessing().get()/perfo.getTotalIteration())*sampleRate)/double(input.size()))/1000000000.0)*100.0;
|
||||
TEST_INFO(" min < avg < max= " << (float((perfo.getMinProcessing().get()*sampleRate)/double(input.size()))/1000000000.0)*100.0 << "% < "
|
||||
<< avg << "% < "
|
||||
<< (float((perfo.getMaxProcessing().count()*sampleRate)/double(input.size()))/1000000000.0)*100.0 << "%");
|
||||
<< (float((perfo.getMaxProcessing().get()*sampleRate)/double(input.size()))/1000000000.0)*100.0 << "%");
|
||||
TEST_PRINT("int16_t : " << _sampleRateIn << " -> " << _sampleRateOut << " quality=" << int32_t(_quality) << " : " << avg << "%");
|
||||
return avg;
|
||||
}
|
||||
@ -163,24 +167,99 @@ void performanceResampler() {
|
||||
modeFloat = performanceResamplerStepFloat(48000, 8000, iii);
|
||||
modeI16 = performanceResamplerStepI16(48000, 8000, iii);
|
||||
}
|
||||
}
|
||||
|
||||
etk::Vector<int16_t> loadDataI16(etk::Uri _uri, int32_t _nbChannel, int32_t _selectChannel, bool _formatFileInteger16, int32_t _delaySample = 0) {
|
||||
TEST_INFO("Read : '" << _uri << "'");
|
||||
etk::Vector<int16_t> out;
|
||||
for (int32_t iii=0; iii<_delaySample; ++iii) {
|
||||
out.pushBack(0);
|
||||
}
|
||||
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(_uri);
|
||||
if (fileIO->open(etk::io::OpenMode::Read) == false) {
|
||||
return out;
|
||||
}
|
||||
if (_uri.getPath().getExtention() == "wav") {
|
||||
// remove the first 44 bytes
|
||||
fileIO->seek(44, etk::io::SeekMode::Start);
|
||||
}
|
||||
if (_formatFileInteger16 == true) {
|
||||
etk::Vector<int16_t> tmpData = fileIO->readAll<int16_t>();
|
||||
for (int32_t iii=0; iii<tmpData.size(); iii+=_nbChannel) {
|
||||
out.pushBack(tmpData[iii+_selectChannel]);
|
||||
}
|
||||
} else {
|
||||
etk::Vector<float> tmpData = fileIO->readAll<float>();
|
||||
for (int32_t iii=0; iii<tmpData.size(); iii+=_nbChannel) {
|
||||
double val = double(tmpData[iii+_selectChannel])*32768.0;
|
||||
if (val >= 32767.0) {
|
||||
out.pushBack(32767);
|
||||
} else if (val <= -32768.0) {
|
||||
out.pushBack(-32768);
|
||||
} else {
|
||||
out.pushBack(int16_t(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
fileIO->close();
|
||||
TEST_INFO(" " << out.size() << " samples");
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
etk::Vector<float> loadDataFloat(etk::Uri _uri, int32_t _nbChannel, int32_t _selectChannel, bool _formatFileInteger16, int32_t _delaySample = 0) {
|
||||
TEST_INFO("Read : '" << _uri << "'");
|
||||
etk::Vector<float> out;
|
||||
for (int32_t iii=0; iii<_delaySample; ++iii) {
|
||||
out.pushBack(0.0);
|
||||
}
|
||||
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(_uri);
|
||||
if (fileIO->open(etk::io::OpenMode::Read) == false) {
|
||||
return out;
|
||||
}
|
||||
if (_uri.getPath().getExtention() == "wav") {
|
||||
// remove the first 44 bytes
|
||||
fileIO->seek(44, etk::io::SeekMode::Start);
|
||||
}
|
||||
if (_formatFileInteger16 == true) {
|
||||
etk::Vector<int16_t> tmpData = fileIO->readAll<int16_t>();
|
||||
for (int32_t iii=0; iii<tmpData.size(); iii+=_nbChannel) {
|
||||
out.pushBack(double(tmpData[iii+_selectChannel])/32768.0);
|
||||
}
|
||||
} else {
|
||||
etk::Vector<float> tmpData = fileIO->readAll<float>();
|
||||
for (int32_t iii=0; iii<tmpData.size(); iii+=_nbChannel) {
|
||||
out.pushBack(tmpData[iii+_selectChannel]);
|
||||
}
|
||||
}
|
||||
fileIO->close();
|
||||
TEST_INFO(" " << out.size() << " samples");
|
||||
return out;
|
||||
}
|
||||
|
||||
int main(int _argc, const char** _argv) {
|
||||
// the only one init for etk:
|
||||
etk::init(_argc, _argv);
|
||||
std::string inputName = "";
|
||||
std::string outputName = "output.raw";
|
||||
etk::Path inputName = "";
|
||||
etk::Path feedbackName = "";
|
||||
etk::Path outputName = "output.raw";
|
||||
bool performance = false;
|
||||
bool perf = false;
|
||||
int64_t sampleRateIn = 48000;
|
||||
int64_t sampleRateOut = 48000;
|
||||
int32_t nbChan = 1;
|
||||
int32_t quality = 4;
|
||||
std::string test = "";
|
||||
etk::String test = "";
|
||||
bool formatFileInteger16 = true;
|
||||
int32_t inputNumberChannel = 1;
|
||||
int32_t inputSelectChannel = 0;
|
||||
int32_t inputSampleDelay = 0;
|
||||
int32_t feedbackNumberChannel = 1;
|
||||
int32_t feedbackSelectChannel = 0;
|
||||
int32_t feedbackSampleDelay = 0;
|
||||
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
etk::String data = _argv[iii];
|
||||
if (etk::start_with(data,"--in=")) {
|
||||
inputName = &data[5];
|
||||
} else if (etk::start_with(data,"--out=")) {
|
||||
@ -192,34 +271,94 @@ int main(int _argc, const char** _argv) {
|
||||
} else if (etk::start_with(data,"--test=")) {
|
||||
data = &data[7];
|
||||
sampleRateIn = etk::string_to_int32_t(data);
|
||||
} else if (etk::start_with(data,"--format=")) {
|
||||
if (data == "--format=i16") {
|
||||
formatFileInteger16 = true;
|
||||
} else if (data == "--format=float") {
|
||||
formatFileInteger16 = false;
|
||||
} else {
|
||||
TEST_CRITICAL("unsuported format");
|
||||
}
|
||||
} else if (etk::start_with(data,"--in-filter=")) {
|
||||
etk::String tmpData = &data[12];
|
||||
inputNumberChannel = tmpData.size();
|
||||
for (int32_t iii = 0; iii< tmpData.size(); ++iii) {
|
||||
if (tmpData[iii] == '1') {
|
||||
inputSelectChannel = iii;
|
||||
TEST_INFO("SELECT input channel : " << inputNumberChannel+1 << " / " << tmpData.size());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (etk::start_with(data,"--sample-rate-in=")) {
|
||||
data = &data[17];
|
||||
sampleRateIn = etk::string_to_int32_t(data);
|
||||
} else if (etk::start_with(data,"--sample-rate-out=")) {
|
||||
// ****************************************************
|
||||
// ** RESAMPLING section
|
||||
// ****************************************************
|
||||
} else if ( test == "RESAMPLING"
|
||||
&& etk::start_with(data,"--sample-rate-out=")) {
|
||||
data = &data[18];
|
||||
sampleRateOut = etk::string_to_int32_t(data);
|
||||
} else if (etk::start_with(data,"--nb=")) {
|
||||
} else if ( test == "RESAMPLING"
|
||||
&& etk::start_with(data,"--nb=")) {
|
||||
data = &data[5];
|
||||
nbChan = etk::string_to_int32_t(data);
|
||||
} else if (etk::start_with(data,"--quality=")) {
|
||||
} else if ( test == "RESAMPLING"
|
||||
&& etk::start_with(data,"--quality=")) {
|
||||
data = &data[10];
|
||||
quality = etk::string_to_int32_t(data);
|
||||
// ****************************************************
|
||||
// ** AEC section
|
||||
// ****************************************************
|
||||
} else if ( test == "AEC"
|
||||
&& etk::start_with(data,"--fb-filter=")) {
|
||||
etk::String tmpData = &data[12];
|
||||
feedbackNumberChannel = tmpData.size();
|
||||
for (int32_t iii = 0; iii< tmpData.size(); ++iii) {
|
||||
if (tmpData[iii] == '1') {
|
||||
feedbackSelectChannel = iii;
|
||||
TEST_INFO("SELECT FB channel : " << feedbackSelectChannel+1 << " / " << tmpData.size());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if ( test == "AEC"
|
||||
&& etk::start_with(data,"--fb=")) {
|
||||
feedbackName = &data[5];
|
||||
} else if ( test == "AEC"
|
||||
&& etk::start_with(data,"--fb-delay=")) {
|
||||
data = &data[11];
|
||||
feedbackSampleDelay = etk::string_to_int32_t(data);
|
||||
} else if ( test == "AEC"
|
||||
&& etk::start_with(data,"--in-delay=")) {
|
||||
data = &data[11];
|
||||
inputSampleDelay = etk::string_to_int32_t(data);
|
||||
} else if ( data == "-h"
|
||||
|| data == "--help") {
|
||||
TEST_PRINT("Help : ");
|
||||
TEST_PRINT(" ./xxx --fb=file.raw --mic=file.raw");
|
||||
TEST_PRINT(" --in=YYY.raw input file");
|
||||
TEST_PRINT(" --in-filter=xxx Select the channel desired in the input stream (n*0 for each channel and 1 for the selected one. ex: 4 channel, secect the third==> 0010) [default 1]");
|
||||
TEST_PRINT(" --sample-rate-in=XXXX Input signal sample rate (default 48000)");
|
||||
TEST_PRINT(" --out=zzz.raw output file");
|
||||
TEST_PRINT(" --format=xxx file Format : i16/float (default i16)");
|
||||
TEST_PRINT(" --performance Generate signal to force algo to maximum process time");
|
||||
TEST_PRINT(" --perf Enable performence test (little slower but real performence test)");
|
||||
TEST_PRINT(" --test=XXXX some test availlable ...");
|
||||
TEST_PRINT(" RESAMPLING Test resampling data 16 bit mode");
|
||||
TEST_PRINT(" --sample-rate-in=XXXX Input signal sample rate (default 48000)");
|
||||
TEST_PRINT(" --sample-rate-out=XXXX Output signal sample rate (default 48000)");
|
||||
TEST_PRINT(" --quality=XX Resampling quality [0..10] (default 4)");
|
||||
TEST_PRINT(" --nb=XX Number of channel in the file (default 1)");
|
||||
TEST_PRINT(" AEC Test AEC (SPEEX AEC is in 16 bits)");
|
||||
TEST_PRINT(" --fb=XXXX.raw Input Feedback file");
|
||||
TEST_PRINT(" --fb-filter=xxx Select the chanel desired in the input stream (same as --in-filter)");
|
||||
TEST_PRINT(" --fb-delay=xxx dalay in sample in the signal feedback (default 0)");
|
||||
TEST_PRINT(" --in-delay=xxx dalay in sample in the signal input (default 0)");
|
||||
TEST_PRINT(" example: ");
|
||||
TEST_PRINT(" ./XXX --test=AEC --fb=aaa_input.wav --in=aaa_input.wav --in-sample-rate=16000 --fb-filter=01 --in-filter=10 --format=i16 --in-delay=64");
|
||||
|
||||
exit(0);
|
||||
} else {
|
||||
TEST_CRITICAL("unknow parameter : '" << data << "'");
|
||||
}
|
||||
}
|
||||
// PERFORMANCE test only ....
|
||||
@ -229,15 +368,15 @@ int main(int _argc, const char** _argv) {
|
||||
}
|
||||
if (test == "RESAMPLING") {
|
||||
TEST_INFO("Start resampling test ... ");
|
||||
if (inputName == "") {
|
||||
if (inputName.isEmpty() == true) {
|
||||
TEST_ERROR("Can not Process missing parameters...");
|
||||
exit(-1);
|
||||
}
|
||||
TEST_INFO("Read input:");
|
||||
std::vector<int16_t> inputData = etk::FSNodeReadAllDataType<int16_t>(inputName);
|
||||
etk::Vector<int16_t> inputData = loadDataI16(inputName, inputNumberChannel, inputSelectChannel, formatFileInteger16, inputSampleDelay);
|
||||
TEST_INFO(" " << inputData.size() << " samples");
|
||||
// resize output :
|
||||
std::vector<int16_t> output;
|
||||
etk::Vector<int16_t> output;
|
||||
output.resize(inputData.size()*sampleRateOut/sampleRateIn+5000, 0);
|
||||
// process in chunk of 256 samples
|
||||
int32_t blockSize = 256*nbChan;
|
||||
@ -259,23 +398,87 @@ int main(int _argc, const char** _argv) {
|
||||
algo.process(&output[outputPosition], availlableSize, &inputData[iii*blockSize], blockSize);
|
||||
if (perf == true) {
|
||||
perfo.toc();
|
||||
usleep(1000);
|
||||
ethread::sleepMilliSeconds(1);
|
||||
}
|
||||
outputPosition += availlableSize*nbChan;
|
||||
}
|
||||
if (perf == true) {
|
||||
TEST_INFO("Performance Result: ");
|
||||
TEST_INFO(" blockSize=" << blockSize << " sample");
|
||||
TEST_INFO(" min=" << perfo.getMinProcessing().count() << " ns");
|
||||
TEST_INFO(" max=" << perfo.getMaxProcessing().count() << " ns");
|
||||
TEST_INFO(" avg=" << perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration() << " ns");
|
||||
TEST_INFO(" min=" << perfo.getMinProcessing());
|
||||
TEST_INFO(" max=" << perfo.getMaxProcessing());
|
||||
TEST_INFO(" avg=" << perfo.getTotalTimeProcessing().get()/perfo.getTotalIteration() << " ns");
|
||||
|
||||
TEST_INFO(" min=" << (float((perfo.getMinProcessing().count()*sampleRateIn)/blockSize)/1000000000.0)*100.0 << " %");
|
||||
TEST_INFO(" max=" << (float((perfo.getMaxProcessing().count()*sampleRateIn)/blockSize)/1000000000.0)*100.0 << " %");
|
||||
TEST_INFO(" avg=" << (float(((perfo.getTotalTimeProcessing().count()/perfo.getTotalIteration())*sampleRateIn)/blockSize)/1000000000.0)*100.0 << " %");
|
||||
}
|
||||
etk::FSNodeWriteAllDataType<int16_t>(outputName, output);
|
||||
TEST_INFO(" min=" << (float((perfo.getMinProcessing().get()*sampleRateIn)/blockSize)/1000000000.0)*100.0 << " %");
|
||||
TEST_INFO(" max=" << (float((perfo.getMaxProcessing().get()*sampleRateIn)/blockSize)/1000000000.0)*100.0 << " %");
|
||||
TEST_INFO(" avg=" << (float(((perfo.getTotalTimeProcessing().get()/perfo.getTotalIteration())*sampleRateIn)/blockSize)/1000000000.0)*100.0 << " %");
|
||||
}
|
||||
TEST_PRINT("Store in file : '" << outputName << "' size = " << output.size());
|
||||
|
||||
|
||||
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(outputName);
|
||||
if (fileIO->open(etk::io::OpenMode::Write) == false) {
|
||||
return -1;
|
||||
}
|
||||
fileIO->writeAll<int16_t>(output);
|
||||
fileIO->close();
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
} else if (test == "AEC") {
|
||||
// process in chunk of XXX samples represent 10 ms of DATA ==> this is webRTC ...
|
||||
int32_t blockSize = 32;
|
||||
etk::Vector<int16_t> inputData = loadDataI16(inputName, inputNumberChannel, inputSelectChannel, formatFileInteger16, inputSampleDelay);
|
||||
etk::Vector<int16_t> feedbackData = loadDataI16(feedbackName, feedbackNumberChannel, feedbackSelectChannel, formatFileInteger16, feedbackSampleDelay);
|
||||
//etk::FSNodeWriteAllDataType<int16_t>("bbb_input_I16_1c.raw", inputData);
|
||||
//etk::FSNodeWriteAllDataType<int16_t>("bbb_feedback_I16_1c.raw", feedbackData);
|
||||
// resize output :
|
||||
etk::Vector<int16_t> output;
|
||||
output.resize(inputData.size(), 0);
|
||||
Performance perfo;
|
||||
{
|
||||
audio::algo::speex::Aec algo;
|
||||
algo.init(1, sampleRateIn, audio::format_int16);
|
||||
blockSize = algo.getOptimalFrameSize();
|
||||
|
||||
int32_t lastPourcent = -1;
|
||||
for (int32_t iii=0; iii<output.size()/blockSize; ++iii) {
|
||||
if (lastPourcent != 100*iii / (output.size()/blockSize)) {
|
||||
lastPourcent = 100*iii / (output.size()/blockSize);
|
||||
TEST_INFO("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize << " " << lastPourcent << "/100");
|
||||
} else {
|
||||
TEST_VERBOSE("Process : " << iii*blockSize << "/" << int32_t(output.size()/blockSize)*blockSize);
|
||||
}
|
||||
perfo.tic();
|
||||
algo.process(&output[iii*blockSize], &inputData[iii*blockSize], &feedbackData[iii*blockSize], blockSize);
|
||||
if (perf == true) {
|
||||
perfo.toc();
|
||||
ethread::sleepMilliSeconds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
TEST_PRINT("Process done");
|
||||
if (perf == true) {
|
||||
TEST_PRINT("Performance Result: ");
|
||||
TEST_INFO(" blockSize=" << blockSize << " sample");
|
||||
TEST_INFO(" min < avg < max =" << perfo.getMinProcessing().get() << "ns < "
|
||||
<< perfo.getTotalTimeProcessing().get()/perfo.getTotalIteration() << "ns < "
|
||||
<< perfo.getMaxProcessing().get() << "ns ");
|
||||
float avg = (float(((perfo.getTotalTimeProcessing().get()/perfo.getTotalIteration())*sampleRateIn)/double(blockSize))/1000000000.0)*100.0;
|
||||
TEST_INFO(" min < avg < max= " << (float((perfo.getMinProcessing().get()*sampleRateIn)/double(blockSize))/1000000000.0)*100.0 << "% < "
|
||||
<< avg << "% < "
|
||||
<< (float((perfo.getMaxProcessing().get()*sampleRateIn)/double(blockSize))/1000000000.0)*100.0 << "%");
|
||||
TEST_PRINT("float : " << sampleRateIn << " : " << avg << "%");
|
||||
}
|
||||
TEST_PRINT("Store in file : '" << outputName << "' size = " << output.size());
|
||||
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(outputName);
|
||||
if (fileIO->open(etk::io::OpenMode::Write) == false) {
|
||||
return -1;
|
||||
}
|
||||
fileIO->writeAll<int16_t>(output);
|
||||
fileIO->close();
|
||||
}
|
||||
TEST_PRINT(" ***************************************");
|
||||
TEST_PRINT(" ** APPLICATION FINISHED OK **");
|
||||
TEST_PRINT(" ***************************************");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
0.1.1
|
||||
1.0.0
|
Loading…
x
Reference in New Issue
Block a user