Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f7a565017c | |||
| 9408e2590c | |||
| 9f8b23080b | |||
| fccbf4953e | |||
| 1863974f8f | |||
| 746a6413f2 | |||
| 09889ba745 | |||
| 3e2ef8ce59 | |||
| 57adfb43c8 | |||
| 567bdd6a86 | |||
| 2bd207471f | |||
| e1b155410a | |||
| afc8b186c7 | |||
| 2483530165 | |||
| 3df9a989d8 | |||
| 2b64dbf401 | |||
| 77c9b99c7a | |||
| 7a217bfbd2 | |||
| 185bc5a21c | |||
| dbba4af26d | |||
| 73d7141574 | |||
| 2cd03d30e4 | |||
| 1401d1dea6 | |||
| 8f0ce824b9 | |||
| 65af248eab | |||
| 80f8d2d7d2 | |||
| 4ed5d9a905 | |||
| 87345b84a7 | |||
| 6f6ee330ac | |||
| a4a021277a | |||
| c638b01ff0 | |||
| 57952d4060 | |||
| 0ba0243081 |
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.
|
||||
18
README.md
18
README.md
@@ -1,4 +1,20 @@
|
||||
# audio-drain
|
||||
(APACHE v2.0) audio: processing pipe for simple agorithms (resampling, change format, reorder channel, volume ...) 1 flow
|
||||
(MPL v2.0) audio: processing pipe for simple agorithms (resampling, change format, reorder channel, volume ...) 1 flow
|
||||
|
||||
[](https://travis-ci.org/musicdsp/audio-drain)
|
||||
|
||||
License (MPL v2.0)
|
||||
=====================
|
||||
Copyright audio Edouard DUPIN
|
||||
|
||||
Licensed under the Mozilla Public License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.mozilla.org/MPL/2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
@@ -1,15 +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)
|
||||
*/
|
||||
#include <audio/drain/Algo.h>
|
||||
#include <functional>
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Algo"
|
||||
#include <audio/drain/Algo.hpp>
|
||||
#include <etk/Function.hpp>
|
||||
#include "debug.hpp"
|
||||
|
||||
audio::drain::Algo::Algo() :
|
||||
m_temporary(false),
|
||||
@@ -21,8 +17,8 @@ audio::drain::Algo::Algo() :
|
||||
|
||||
void audio::drain::Algo::init() {
|
||||
// set notification callback :
|
||||
m_input.setCallback(std11::bind(&audio::drain::Algo::configurationChangeLocal, this));
|
||||
m_output.setCallback(std11::bind(&audio::drain::Algo::configurationChangeLocal, this));
|
||||
m_input.setCallback([=](){audio::drain::Algo::configurationChangeLocal();});
|
||||
m_output.setCallback([=](){audio::drain::Algo::configurationChangeLocal();});
|
||||
// first configure ==> update the internal parameters
|
||||
configurationChange();
|
||||
}
|
||||
@@ -63,6 +59,20 @@ void audio::drain::Algo::configurationChange() {
|
||||
}
|
||||
}
|
||||
|
||||
etk::String audio::drain::Algo::getDotDesc() {
|
||||
etk::String out;
|
||||
if (m_input.getFormat() != m_output.getFormat()) {
|
||||
out += "\\nformat: " + etk::toString(m_input.getFormat()) + "->" + etk::toString(m_output.getFormat());
|
||||
}
|
||||
if (m_input.getMap() != m_output.getMap()) {
|
||||
out += "\\nmap: " + etk::toString(m_input.getMap()) + "->" + etk::toString(m_output.getMap());
|
||||
}
|
||||
if (m_input.getFrequency() != m_output.getFrequency()) {
|
||||
out += "\\nsamplerate: " + etk::toString(m_input.getFrequency()) + "->" + etk::toString(m_output.getFrequency());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
size_t audio::drain::Algo::needInputData(size_t _output) {
|
||||
size_t input = _output;
|
||||
/* NOT good at all ...
|
||||
@@ -106,12 +116,12 @@ void audio::drain::Algo::setStatusFunction(algoStatusFunction _newFunction) {
|
||||
m_statusFunction = _newFunction;
|
||||
}
|
||||
|
||||
void audio::drain::Algo::generateStatus(const std::string& _status) {
|
||||
if (m_statusFunction != nullptr) {
|
||||
void audio::drain::Algo::generateStatus(const etk::String& _status) {
|
||||
if (m_statusFunction != null) {
|
||||
if (m_name.size() == 0) {
|
||||
m_statusFunction(m_type, _status);
|
||||
} else {
|
||||
m_statusFunction(m_name, _status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,53 @@
|
||||
/** @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/String.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <audio/format.hpp>
|
||||
#include <audio/channel.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <etk/Function.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include "AutoLogInOut.hpp"
|
||||
#include "IOFormatInterface.hpp"
|
||||
#include <audio/Time.hpp>
|
||||
#include <audio/Duration.hpp>
|
||||
#include "debug.hpp"
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_CORE_ALGO_H__
|
||||
#define __AUDIO_DRAIN_ALGO_CORE_ALGO_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include <audio/format.h>
|
||||
#include <audio/channel.h>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include "AutoLogInOut.h"
|
||||
#include "IOFormatInterface.h"
|
||||
#include <audio/Time.h>
|
||||
#include <audio/Duration.h>
|
||||
#include "debug.h"
|
||||
|
||||
/**
|
||||
* @brief Audio library namespace
|
||||
*/
|
||||
namespace audio {
|
||||
/**
|
||||
* @brief audio-algo library namespace
|
||||
*/
|
||||
namespace drain{
|
||||
typedef std11::function<void (const std::string& _origin, const std::string& _status)> algoStatusFunction;
|
||||
class Algo : public std11::enable_shared_from_this<Algo> {
|
||||
typedef etk::Function<void (const etk::String& _origin, const etk::String& _status)> algoStatusFunction;
|
||||
class Algo : public ememory::EnableSharedFromThis<Algo> {
|
||||
private:
|
||||
std::string m_name;
|
||||
etk::String m_name;
|
||||
public:
|
||||
const std::string& getName() const {
|
||||
const etk::String& getName() const {
|
||||
return m_name;
|
||||
}
|
||||
void setName(const std::string& _name) {
|
||||
void setName(const etk::String& _name) {
|
||||
m_name = _name;
|
||||
}
|
||||
protected:
|
||||
std::string m_type;
|
||||
etk::String m_type;
|
||||
public:
|
||||
const std::string& getType() const {
|
||||
const etk::String& getType() const {
|
||||
return m_type;
|
||||
}
|
||||
void setType(const std::string& _type) {
|
||||
void setType(const etk::String& _type) {
|
||||
m_type = _type;
|
||||
}
|
||||
public:
|
||||
virtual etk::String getDotDesc();
|
||||
private:
|
||||
bool m_temporary;
|
||||
public:
|
||||
@@ -58,9 +62,9 @@ namespace audio {
|
||||
public:
|
||||
void setStatusFunction(algoStatusFunction _newFunction);
|
||||
protected:
|
||||
void generateStatus(const std::string& _status);
|
||||
void generateStatus(const etk::String& _status);
|
||||
protected:
|
||||
std::vector<int8_t> m_outputData;
|
||||
etk::Vector<int8_t> m_outputData;
|
||||
int8_t m_formatSize; //!< sample size
|
||||
/**
|
||||
* @brief Constructor
|
||||
@@ -133,58 +137,58 @@ namespace audio {
|
||||
// TODO : Manage the change of the timestamp ...
|
||||
virtual size_t needInputData(size_t _output);
|
||||
protected: // note when nothing ==> support all type
|
||||
std::vector<audio::format> m_supportedFormat;
|
||||
etk::Vector<audio::format> m_supportedFormat;
|
||||
public:
|
||||
virtual std::vector<audio::format> getFormatSupportedInput() {
|
||||
virtual etk::Vector<audio::format> getFormatSupportedInput() {
|
||||
if (m_output.getConfigured() == true) {
|
||||
std::vector<audio::format> out;
|
||||
out.push_back(m_output.getFormat());
|
||||
etk::Vector<audio::format> out;
|
||||
out.pushBack(m_output.getFormat());
|
||||
return out;
|
||||
}
|
||||
return m_supportedFormat;
|
||||
};
|
||||
virtual std::vector<audio::format> getFormatSupportedOutput() {
|
||||
virtual etk::Vector<audio::format> getFormatSupportedOutput() {
|
||||
if (m_input.getConfigured() == true) {
|
||||
std::vector<audio::format> out;
|
||||
out.push_back(m_input.getFormat());
|
||||
etk::Vector<audio::format> out;
|
||||
out.pushBack(m_input.getFormat());
|
||||
return out;
|
||||
}
|
||||
return m_supportedFormat;
|
||||
};
|
||||
protected: // note when nothing ==> support all type
|
||||
std::vector<std::vector<audio::channel> > m_supportedMap;
|
||||
etk::Vector<etk::Vector<audio::channel> > m_supportedMap;
|
||||
public:
|
||||
virtual std::vector<std::vector<audio::channel> > getMapSupportedInput() {
|
||||
virtual etk::Vector<etk::Vector<audio::channel> > getMapSupportedInput() {
|
||||
if (m_output.getConfigured() == true) {
|
||||
std::vector<std::vector<audio::channel> > out;
|
||||
out.push_back(m_output.getMap());
|
||||
etk::Vector<etk::Vector<audio::channel> > out;
|
||||
out.pushBack(m_output.getMap());
|
||||
return out;
|
||||
}
|
||||
return m_supportedMap;
|
||||
};
|
||||
virtual std::vector<std::vector<audio::channel> > getMapSupportedOutput() {
|
||||
virtual etk::Vector<etk::Vector<audio::channel> > getMapSupportedOutput() {
|
||||
if (m_input.getConfigured() == true) {
|
||||
std::vector<std::vector<audio::channel> > out;
|
||||
out.push_back(m_input.getMap());
|
||||
etk::Vector<etk::Vector<audio::channel> > out;
|
||||
out.pushBack(m_input.getMap());
|
||||
return out;
|
||||
}
|
||||
return m_supportedMap;
|
||||
};
|
||||
protected: // note when nothing ==> support all type
|
||||
std::vector<float> m_supportedFrequency;
|
||||
etk::Vector<float> m_supportedFrequency;
|
||||
public:
|
||||
virtual std::vector<float> getFrequencySupportedInput() {
|
||||
virtual etk::Vector<float> getFrequencySupportedInput() {
|
||||
if (m_output.getConfigured() == true) {
|
||||
std::vector<float> out;
|
||||
out.push_back(m_output.getFrequency());
|
||||
etk::Vector<float> out;
|
||||
out.pushBack(m_output.getFrequency());
|
||||
return out;
|
||||
}
|
||||
return m_supportedFrequency;
|
||||
};
|
||||
virtual std::vector<float> getFrequencySupportedOutput() {
|
||||
virtual etk::Vector<float> getFrequencySupportedOutput() {
|
||||
if (m_input.getConfigured() == true) {
|
||||
std::vector<float> out;
|
||||
out.push_back(m_input.getFrequency());
|
||||
etk::Vector<float> out;
|
||||
out.pushBack(m_input.getFrequency());
|
||||
return out;
|
||||
}
|
||||
return m_supportedFrequency;
|
||||
@@ -197,22 +201,21 @@ namespace audio {
|
||||
* @return true set done
|
||||
* @return false An error occured
|
||||
*/
|
||||
virtual bool setParameter(const std::string& _parameter, const std::string& _value) { return false; }
|
||||
virtual bool setParameter(const etk::String& _parameter, const etk::String& _value) { return false; }
|
||||
/**
|
||||
* @brief Get a parameter value
|
||||
* @param[in] _parameter Parameter name.
|
||||
* @return The requested value.
|
||||
*/
|
||||
virtual std::string getParameter(const std::string& _parameter) const { return "[ERROR]"; }
|
||||
virtual etk::String getParameter(const etk::String& _parameter) const { return "[ERROR]"; }
|
||||
/**
|
||||
* @brief Get a parameter value
|
||||
* @param[in] _parameter Parameter name.
|
||||
* @return The requested value.
|
||||
*/
|
||||
virtual std::string getParameterProperty(const std::string& _parameter) const { return "[ERROR]"; };
|
||||
virtual etk::String getParameterProperty(const etk::String& _parameter) const { return "[ERROR]"; };
|
||||
};
|
||||
}
|
||||
}
|
||||
#include "debugRemove.h"
|
||||
#include "debugRemove.hpp"
|
||||
|
||||
#endif
|
||||
@@ -1,13 +1,13 @@
|
||||
/** @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 "AutoLogInOut.h"
|
||||
#include "debug.h"
|
||||
#include "AutoLogInOut.hpp"
|
||||
#include "debug.hpp"
|
||||
|
||||
audio::drain::AutoLogInOut::AutoLogInOut(const std::string& _value) :
|
||||
audio::drain::AutoLogInOut::AutoLogInOut(const etk::String& _value) :
|
||||
m_value(_value) {
|
||||
DRAIN_VERBOSE(" '" << m_value << "' [START]");
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_AUTO_LOG_IN_OUT_H__
|
||||
#define __AUDIO_DRAIN_ALGO_AUTO_LOG_IN_OUT_H__
|
||||
|
||||
#include <string>
|
||||
#include "debug.h"
|
||||
|
||||
namespace audio {
|
||||
namespace drain{
|
||||
class AutoLogInOut {
|
||||
private:
|
||||
std::string m_value;
|
||||
public:
|
||||
AutoLogInOut(const std::string& _value);
|
||||
~AutoLogInOut();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include "debugRemove.h"
|
||||
|
||||
#endif
|
||||
|
||||
24
audio/drain/AutoLogInOut.hpp
Normal file
24
audio/drain/AutoLogInOut.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/String.hpp>
|
||||
#include "debug.hpp"
|
||||
|
||||
namespace audio {
|
||||
namespace drain{
|
||||
class AutoLogInOut {
|
||||
private:
|
||||
etk::String m_value;
|
||||
public:
|
||||
AutoLogInOut(const etk::String& _value);
|
||||
~AutoLogInOut();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include "debugRemove.hpp"
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
/** @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/drain/ChannelReorder.h>
|
||||
#include <iostream>
|
||||
#include "debug.h"
|
||||
#include "debug.h"
|
||||
#include <audio/drain/ChannelReorder.hpp>
|
||||
#include "debug.hpp"
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ChannelReorder"
|
||||
|
||||
audio::drain::ChannelReorder::ChannelReorder() {
|
||||
|
||||
}
|
||||
@@ -23,8 +18,8 @@ void audio::drain::ChannelReorder::init() {
|
||||
m_type = "ChannelReorder";
|
||||
}
|
||||
|
||||
std11::shared_ptr<audio::drain::ChannelReorder> audio::drain::ChannelReorder::create() {
|
||||
std11::shared_ptr<audio::drain::ChannelReorder> tmp(new audio::drain::ChannelReorder());
|
||||
ememory::SharedPtr<audio::drain::ChannelReorder> audio::drain::ChannelReorder::create() {
|
||||
ememory::SharedPtr<audio::drain::ChannelReorder> tmp(ETK_NEW(audio::drain::ChannelReorder));
|
||||
tmp->init();
|
||||
return tmp;
|
||||
}
|
||||
@@ -61,7 +56,7 @@ bool audio::drain::ChannelReorder::process(audio::Time& _time,
|
||||
_output = _input;
|
||||
return true;
|
||||
}
|
||||
if (_input == nullptr) {
|
||||
if (_input == null) {
|
||||
_output = &(m_outputData[0]);
|
||||
_outputNbChunk = 0;
|
||||
DRAIN_ERROR("null pointer input ... ");
|
||||
|
||||
@@ -1,13 +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
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_CHANNEL_REORDER_H__
|
||||
#define __AUDIO_DRAIN_ALGO_CHANNEL_REORDER_H__
|
||||
|
||||
#include <audio/drain/Algo.h>
|
||||
#include <audio/drain/Algo.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain{
|
||||
@@ -19,7 +17,7 @@ namespace audio {
|
||||
ChannelReorder();
|
||||
void init();
|
||||
public:
|
||||
static std11::shared_ptr<audio::drain::ChannelReorder> create();
|
||||
static ememory::SharedPtr<audio::drain::ChannelReorder> create();
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
@@ -36,4 +34,3 @@ namespace audio {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,16 +1,16 @@
|
||||
/** @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/drain/CircularBuffer.h>
|
||||
#include <audio/drain/debug.h>
|
||||
#include <audio/drain/CircularBuffer.hpp>
|
||||
#include <audio/drain/debug.hpp>
|
||||
|
||||
audio::drain::CircularBuffer::CircularBuffer(const audio::drain::CircularBuffer& _obj) :
|
||||
m_data(),
|
||||
m_write(nullptr),
|
||||
m_read(nullptr),
|
||||
m_write(null),
|
||||
m_read(null),
|
||||
m_timeRead(),
|
||||
m_capacity(0),
|
||||
m_sizeChunk(0),
|
||||
@@ -27,8 +27,8 @@ audio::drain::CircularBuffer& audio::drain::CircularBuffer::operator=(const audi
|
||||
|
||||
audio::drain::CircularBuffer::CircularBuffer() :
|
||||
m_data(),
|
||||
m_write(nullptr),
|
||||
m_read(nullptr),
|
||||
m_write(null),
|
||||
m_read(null),
|
||||
m_timeRead(),
|
||||
m_capacity(0),
|
||||
m_sizeChunk(0),
|
||||
@@ -38,8 +38,8 @@ audio::drain::CircularBuffer::CircularBuffer() :
|
||||
|
||||
audio::drain::CircularBuffer::~CircularBuffer() {
|
||||
m_data.clear();
|
||||
m_read = nullptr;
|
||||
m_write = nullptr;
|
||||
m_read = null;
|
||||
m_write = null;
|
||||
}
|
||||
|
||||
void audio::drain::CircularBuffer::setCapacity(size_t _capacity, size_t _chunkSize, uint32_t _frequency) {
|
||||
@@ -58,8 +58,8 @@ void audio::drain::CircularBuffer::setCapacity(size_t _capacity, size_t _chunkSi
|
||||
_chunkSize = 8;
|
||||
}
|
||||
m_data.clear();
|
||||
m_write = nullptr;
|
||||
m_read = nullptr;
|
||||
m_write = null;
|
||||
m_read = null;
|
||||
m_frequency = _frequency;
|
||||
m_capacity = _capacity;
|
||||
m_sizeChunk = _chunkSize;
|
||||
@@ -75,9 +75,9 @@ void audio::drain::CircularBuffer::setCapacity(size_t _capacity, size_t _chunkSi
|
||||
m_write = &m_data[0];
|
||||
}
|
||||
|
||||
void audio::drain::CircularBuffer::setCapacity(std11::chrono::milliseconds _capacity, size_t _chunkSize, uint32_t _frequency) {
|
||||
uint32_t nbSampleNeeded = _frequency*_capacity.count()/1000;
|
||||
DRAIN_DEBUG("buffer setCapacity(" << _capacity.count() << "ms ," << _chunkSize << ")");
|
||||
void audio::drain::CircularBuffer::setCapacity(echrono::Duration _capacity, size_t _chunkSize, uint32_t _frequency) {
|
||||
uint32_t nbSampleNeeded = _frequency*_capacity.get()/1000000000LL;
|
||||
DRAIN_DEBUG("buffer setCapacity(" << _capacity << " ," << _chunkSize << ")");
|
||||
setCapacity(nbSampleNeeded, _chunkSize, _frequency);
|
||||
}
|
||||
|
||||
@@ -191,12 +191,12 @@ size_t audio::drain::CircularBuffer::read(void* _data, size_t _nbChunk, const au
|
||||
if (0 < m_size) {
|
||||
// check the time of the read :
|
||||
audio::Duration deltaTime = m_timeRead - _time;
|
||||
if (deltaTime.count() == 0) {
|
||||
if (deltaTime.get() == 0) {
|
||||
// nothing to do ==> just copy data ...
|
||||
} else if (deltaTime.count() > 0) {
|
||||
} else if (deltaTime.get() > 0) {
|
||||
// Add empty sample in the output buffer ...
|
||||
size_t nbSampleEmpty = m_frequency*deltaTime.count()/100000000;
|
||||
nbSampleEmpty = std::min(nbSampleEmpty, _nbChunk);
|
||||
size_t nbSampleEmpty = m_frequency*deltaTime.get()/1000000000LL;
|
||||
nbSampleEmpty = etk::min(nbSampleEmpty, _nbChunk);
|
||||
DRAIN_WARNING("add Empty sample in the output buffer " << nbSampleEmpty << " / " << _nbChunk);
|
||||
memset(_data, 0, nbSampleEmpty * m_sizeChunk);
|
||||
if (nbSampleEmpty == _nbChunk) {
|
||||
@@ -212,7 +212,7 @@ size_t audio::drain::CircularBuffer::read(void* _data, size_t _nbChunk, const au
|
||||
DRAIN_VERBOSE("crop nb sample : m_size=" << m_size << " _nbChunk=" << _nbChunk);
|
||||
_nbChunk = m_size;
|
||||
}
|
||||
m_timeRead += std11::chrono::microseconds(_nbChunk*1000000/m_frequency);
|
||||
m_timeRead += echrono::microseconds(_nbChunk*1000000/m_frequency);
|
||||
if (usedSizeBeforeEnd >= _nbChunk) {
|
||||
// all Data will be copy
|
||||
memcpy(_data, m_read, _nbChunk * m_sizeChunk);
|
||||
@@ -257,11 +257,11 @@ void audio::drain::CircularBuffer::setReadPosition(const audio::Time& _time) {
|
||||
if (0 < m_size) {
|
||||
// check the time of the read :
|
||||
audio::Duration deltaTime = _time - m_timeRead;
|
||||
size_t nbSampleToRemove = int64_t(m_frequency)*int64_t(deltaTime.count())/1000000000LL;
|
||||
nbSampleToRemove = std::min(nbSampleToRemove, m_size);
|
||||
size_t nbSampleToRemove = int64_t(m_frequency)*int64_t(deltaTime.get())/1000000000LL;
|
||||
nbSampleToRemove = etk::min(nbSampleToRemove, m_size);
|
||||
DRAIN_VERBOSE("Remove sample in the buffer " << nbSampleToRemove << " / " << m_size);
|
||||
audio::Duration updateTime(0,(int64_t(nbSampleToRemove)*1000000000LL)/int64_t(m_frequency));
|
||||
DRAIN_VERBOSE(" add time : " << updateTime.count() << "ns / " << deltaTime.count() << "ns");
|
||||
DRAIN_VERBOSE(" add time : " << updateTime << " / " << deltaTime);
|
||||
if (usedSizeBeforeEnd >= nbSampleToRemove) {
|
||||
usedSizeBeforeEnd -= nbSampleToRemove;
|
||||
m_size -= nbSampleToRemove;
|
||||
|
||||
@@ -1,18 +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
|
||||
|
||||
|
||||
#ifndef __AUDIO_DRAIN_CIRCULAR_BUFFER_H__
|
||||
#define __AUDIO_DRAIN_CIRCULAR_BUFFER_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
#include <audio/Time.h>
|
||||
#include <audio/Duration.h>
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <audio/Time.hpp>
|
||||
#include <audio/Duration.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain {
|
||||
@@ -43,7 +40,7 @@ namespace audio {
|
||||
*/
|
||||
class CircularBuffer {
|
||||
private:
|
||||
std::vector<uint8_t> m_data; //!< data pointer
|
||||
etk::Vector<uint8_t> m_data; //!< data pointer
|
||||
void* m_write; //!< write pointer
|
||||
void* m_read; //!< read pointer
|
||||
audio::Time m_timeRead; //!< current read time
|
||||
@@ -74,14 +71,11 @@ namespace audio {
|
||||
void setCapacity(size_t _capacity, size_t _chunkSize, uint32_t _frequency);
|
||||
/**
|
||||
* @brief set the capacity of the circular buffer.
|
||||
* @param[in] _capacity time in millisecond stored in the buffer.
|
||||
* @param[in] _capacity Duration stored in the buffer.
|
||||
* @param[in] _chunkSize Size of one chunk.
|
||||
* @param[in] _frequency Frequency of the buffer
|
||||
*/
|
||||
void setCapacity(std11::chrono::milliseconds _capacity, size_t _chunkSize, uint32_t _frequency);
|
||||
void setCapacity(std11::chrono::microseconds _capacity, size_t _chunkSize, uint32_t _frequency) {
|
||||
setCapacity(std11::chrono::milliseconds(_capacity.count()/1000), _chunkSize, _frequency);
|
||||
}
|
||||
void setCapacity(echrono::Duration _capacity, size_t _chunkSize, uint32_t _frequency);
|
||||
/**
|
||||
* @brief get free size of the buffer.
|
||||
* @return Number of free chunk.
|
||||
@@ -144,4 +138,3 @@ namespace audio {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,13 +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
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_END_POINT_H__
|
||||
#define __AUDIO_DRAIN_ALGO_END_POINT_H__
|
||||
|
||||
#include <audio/drain/Algo.h>
|
||||
#include <audio/drain/Algo.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain{
|
||||
@@ -31,4 +29,3 @@ namespace audio {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,18 +1,16 @@
|
||||
/** @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/drain/EndPointCallback.h>
|
||||
#include <audio/drain/debug.h>
|
||||
#include <audio/drain/EndPointCallback.hpp>
|
||||
#include <audio/drain/debug.hpp>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "EndPointCallback"
|
||||
|
||||
audio::drain::EndPointCallback::EndPointCallback() :
|
||||
m_outputFunction(nullptr),
|
||||
m_inputFunction(nullptr) {
|
||||
m_outputFunction(null),
|
||||
m_inputFunction(null) {
|
||||
|
||||
}
|
||||
|
||||
@@ -27,14 +25,14 @@ void audio::drain::EndPointCallback::init(recordFunction _callback) {
|
||||
m_type = "EndPointCallback";
|
||||
}
|
||||
|
||||
std11::shared_ptr<audio::drain::EndPointCallback> audio::drain::EndPointCallback::create(playbackFunction _callback) {
|
||||
std11::shared_ptr<audio::drain::EndPointCallback> tmp(new audio::drain::EndPointCallback());
|
||||
ememory::SharedPtr<audio::drain::EndPointCallback> audio::drain::EndPointCallback::create(playbackFunction _callback) {
|
||||
ememory::SharedPtr<audio::drain::EndPointCallback> tmp(ETK_NEW(audio::drain::EndPointCallback));
|
||||
tmp->init(_callback);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
std11::shared_ptr<audio::drain::EndPointCallback> audio::drain::EndPointCallback::create(recordFunction _callback) {
|
||||
std11::shared_ptr<audio::drain::EndPointCallback> tmp(new audio::drain::EndPointCallback());
|
||||
ememory::SharedPtr<audio::drain::EndPointCallback> audio::drain::EndPointCallback::create(recordFunction _callback) {
|
||||
ememory::SharedPtr<audio::drain::EndPointCallback> tmp(ETK_NEW(audio::drain::EndPointCallback));
|
||||
tmp->init(_callback);
|
||||
return tmp;
|
||||
}
|
||||
@@ -52,7 +50,7 @@ bool audio::drain::EndPointCallback::process(audio::Time& _time,
|
||||
void*& _output,
|
||||
size_t& _outputNbChunk){
|
||||
audio::drain::AutoLogInOut tmpLog("EndPointCallback");
|
||||
if (m_inputFunction != nullptr) {
|
||||
if (m_inputFunction != null) {
|
||||
// Call user ...
|
||||
DRAIN_VERBOSE("call user set " << _inputNbChunk << "*" << m_input.getMap().size());
|
||||
m_inputFunction(_input,
|
||||
@@ -63,7 +61,7 @@ bool audio::drain::EndPointCallback::process(audio::Time& _time,
|
||||
m_output.getMap());
|
||||
return true;
|
||||
}
|
||||
if (m_outputFunction != nullptr) {
|
||||
if (m_outputFunction != null) {
|
||||
// update buffer size ...
|
||||
m_outputData.resize(_inputNbChunk*m_output.getMap().size()*m_formatSize);
|
||||
// clean output to prevent errors ...
|
||||
|
||||
@@ -1,29 +1,27 @@
|
||||
/** @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
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_END_POINT_CALLBACK_H__
|
||||
#define __AUDIO_DRAIN_ALGO_END_POINT_CALLBACK_H__
|
||||
|
||||
#include <audio/drain/EndPoint.h>
|
||||
#include <functional>
|
||||
#include <audio/drain/EndPoint.hpp>
|
||||
#include <etk/Function.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain {
|
||||
typedef std11::function<void (void* _data,
|
||||
typedef etk::Function<void (void* _data,
|
||||
const audio::Time& _playTime,
|
||||
size_t _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _frequency,
|
||||
const std::vector<audio::channel>& _map)> playbackFunction;
|
||||
typedef std11::function<void (const void* _data,
|
||||
const etk::Vector<audio::channel>& _map)> playbackFunction;
|
||||
typedef etk::Function<void (const void* _data,
|
||||
const audio::Time& _readTime,
|
||||
size_t _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _frequency,
|
||||
const std::vector<audio::channel>& _map)> recordFunction;
|
||||
const etk::Vector<audio::channel>& _map)> recordFunction;
|
||||
class EndPointCallback : public EndPoint {
|
||||
private:
|
||||
playbackFunction m_outputFunction;
|
||||
@@ -36,8 +34,8 @@ namespace audio {
|
||||
void init(playbackFunction _callback);
|
||||
void init(recordFunction _callback);
|
||||
public:
|
||||
static std11::shared_ptr<EndPointCallback> create(playbackFunction _callback);
|
||||
static std11::shared_ptr<EndPointCallback> create(recordFunction _callback);
|
||||
static ememory::SharedPtr<EndPointCallback> create(playbackFunction _callback);
|
||||
static ememory::SharedPtr<EndPointCallback> create(recordFunction _callback);
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
@@ -52,4 +50,3 @@ namespace audio {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,14 +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/drain/EndPointRead.h>
|
||||
#include <audio/drain/debug.h>
|
||||
#include <audio/drain/EndPointRead.hpp>
|
||||
#include <audio/drain/debug.hpp>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "EndPointRead"
|
||||
|
||||
audio::drain::EndPointRead::EndPointRead() {
|
||||
|
||||
@@ -20,8 +18,8 @@ void audio::drain::EndPointRead::init() {
|
||||
m_type = "EndPointRead";
|
||||
}
|
||||
|
||||
std11::shared_ptr<audio::drain::EndPointRead> audio::drain::EndPointRead::create() {
|
||||
std11::shared_ptr<audio::drain::EndPointRead> tmp(new audio::drain::EndPointRead());
|
||||
ememory::SharedPtr<audio::drain::EndPointRead> audio::drain::EndPointRead::create() {
|
||||
ememory::SharedPtr<audio::drain::EndPointRead> tmp(ETK_NEW(audio::drain::EndPointRead));
|
||||
tmp->init();
|
||||
return tmp;
|
||||
}
|
||||
@@ -45,7 +43,7 @@ void audio::drain::EndPointRead::setBufferSize(size_t _nbChunk) {
|
||||
DRAIN_TODO("...");
|
||||
}
|
||||
|
||||
void audio::drain::EndPointRead::setBufferSize(const std11::chrono::microseconds& _time) {
|
||||
void audio::drain::EndPointRead::setBufferSize(const echrono::microseconds& _time) {
|
||||
DRAIN_TODO("...");
|
||||
}
|
||||
|
||||
@@ -54,9 +52,9 @@ size_t audio::drain::EndPointRead::getBufferSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std11::chrono::microseconds audio::drain::EndPointRead::getBufferSizeMicrosecond() {
|
||||
echrono::microseconds audio::drain::EndPointRead::getBufferSizeMicrosecond() {
|
||||
DRAIN_TODO("...");
|
||||
return std11::chrono::microseconds(0);
|
||||
return echrono::microseconds(0);
|
||||
}
|
||||
|
||||
size_t audio::drain::EndPointRead::getBufferFillSize() {
|
||||
@@ -64,8 +62,8 @@ size_t audio::drain::EndPointRead::getBufferFillSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std11::chrono::microseconds audio::drain::EndPointRead::getBufferFillSizeMicrosecond() {
|
||||
echrono::microseconds audio::drain::EndPointRead::getBufferFillSizeMicrosecond() {
|
||||
DRAIN_TODO("...");
|
||||
return std11::chrono::microseconds(0);
|
||||
return echrono::microseconds(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +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
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_END_POINT_READ_H__
|
||||
#define __AUDIO_DRAIN_ALGO_END_POINT_READ_H__
|
||||
|
||||
#include <audio/drain/EndPoint.h>
|
||||
#include <audio/drain/EndPoint.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain{
|
||||
@@ -19,7 +17,7 @@ namespace audio {
|
||||
EndPointRead();
|
||||
void init();
|
||||
public:
|
||||
static std11::shared_ptr<EndPointRead> create();
|
||||
static ememory::SharedPtr<EndPointRead> create();
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
@@ -39,7 +37,7 @@ namespace audio {
|
||||
* @brief Set buffer size size of the buffer with the stored time in µs
|
||||
* @param[in] _time Time in microsecond of the buffer
|
||||
*/
|
||||
virtual void setBufferSize(const std11::chrono::microseconds& _time);
|
||||
virtual void setBufferSize(const echrono::microseconds& _time);
|
||||
/**
|
||||
* @brief get buffer size in chunk number
|
||||
* @return Number of chunk that can be written in the buffer
|
||||
@@ -49,7 +47,7 @@ namespace audio {
|
||||
* @brief Set buffer size size of the buffer with the stored time in µs
|
||||
* @return Time in microsecond that can be written in the buffer
|
||||
*/
|
||||
virtual std11::chrono::microseconds getBufferSizeMicrosecond();
|
||||
virtual echrono::microseconds getBufferSizeMicrosecond();
|
||||
/**
|
||||
* @brief Get buffer size filled in chunk number
|
||||
* @return Number of chunk in the buffer (that might be read/write)
|
||||
@@ -59,9 +57,8 @@ namespace audio {
|
||||
* @brief Set buffer size size of the buffer with the stored time in µs
|
||||
* @return Time in microsecond of the buffer (that might be read/write)
|
||||
*/
|
||||
virtual std11::chrono::microseconds getBufferFillSizeMicrosecond();
|
||||
virtual echrono::microseconds getBufferFillSizeMicrosecond();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,18 +1,17 @@
|
||||
/** @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/drain/EndPointWrite.h>
|
||||
#include <audio/drain/debug.h>
|
||||
#include <audio/drain/EndPointWrite.hpp>
|
||||
#include <audio/drain/debug.hpp>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "EndPointWrite"
|
||||
|
||||
audio::drain::EndPointWrite::EndPointWrite() :
|
||||
m_function(nullptr),
|
||||
m_bufferSizeMicroseconds(1000000) {
|
||||
m_function(null),
|
||||
m_bufferSizeMicroseconds(1000000),
|
||||
m_bufferSizeChunk(32),
|
||||
m_bufferUnderFlowSize(0) {
|
||||
|
||||
}
|
||||
|
||||
@@ -27,8 +26,8 @@ void audio::drain::EndPointWrite::init() {
|
||||
}
|
||||
}
|
||||
|
||||
std11::shared_ptr<audio::drain::EndPointWrite> audio::drain::EndPointWrite::create() {
|
||||
std11::shared_ptr<audio::drain::EndPointWrite> tmp(new audio::drain::EndPointWrite());
|
||||
ememory::SharedPtr<audio::drain::EndPointWrite> audio::drain::EndPointWrite::create() {
|
||||
ememory::SharedPtr<audio::drain::EndPointWrite> tmp(ETK_NEW(audio::drain::EndPointWrite));
|
||||
tmp->init();
|
||||
return tmp;
|
||||
}
|
||||
@@ -38,7 +37,7 @@ void audio::drain::EndPointWrite::configurationChange() {
|
||||
// update the buffer size ...
|
||||
if ( audio::getFormatBytes(m_output.getFormat())*m_output.getMap().size() != 0
|
||||
&& m_output.getFrequency() != 0) {
|
||||
if (std11::chrono::microseconds(0) != m_bufferSizeMicroseconds) {
|
||||
if (m_bufferSizeMicroseconds.get() != 0) {
|
||||
m_buffer.setCapacity(m_bufferSizeMicroseconds,
|
||||
audio::getFormatBytes(m_output.getFormat())*m_output.getMap().size(),
|
||||
m_output.getFrequency());
|
||||
@@ -59,7 +58,7 @@ bool audio::drain::EndPointWrite::process(audio::Time& _time,
|
||||
size_t& _outputNbChunk){
|
||||
audio::drain::AutoLogInOut tmpLog("EndPointWrite");
|
||||
//DRAIN_INFO(" nb Sample in buffer : " << m_buffer.size());
|
||||
if (m_function != nullptr) {
|
||||
if (m_function != null) {
|
||||
// TODO : Rework this ...
|
||||
if (m_buffer.getSize() <= 20000) {
|
||||
m_function(_time, _inputNbChunk, m_output.getFormat(), m_output.getFrequency(), m_output.getMap());
|
||||
@@ -71,20 +70,31 @@ bool audio::drain::EndPointWrite::process(audio::Time& _time,
|
||||
// set output pointer:
|
||||
_outputNbChunk = m_outputData.size()/(m_formatSize*m_output.getMap().size());
|
||||
_output = &m_outputData[0];
|
||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
// check if data in the tmpBuffer
|
||||
if (m_buffer.getSize() == 0) {
|
||||
DRAIN_WARNING("No data in the user buffer (write null data ... " << _outputNbChunk << " chunks)");
|
||||
if (m_bufferUnderFlowSize == 0) {
|
||||
DRAIN_WARNING("No data in the user buffer (write null data ... " << _outputNbChunk << " chunks)");
|
||||
m_bufferUnderFlowSize = 1;
|
||||
} else {
|
||||
if (m_bufferUnderFlowSize == 1) {
|
||||
m_bufferUnderFlowSize = 0;
|
||||
}
|
||||
m_bufferUnderFlowSize += _outputNbChunk;
|
||||
}
|
||||
// clear the buffer to force the flush on the next elements ...
|
||||
m_outputData.clear();
|
||||
_outputNbChunk = 0;
|
||||
generateStatus("EPW_UNDERFLOW");
|
||||
// just send no data ...
|
||||
return true;
|
||||
} else if (m_bufferUnderFlowSize > 1) {
|
||||
DRAIN_WARNING("No data in the user buffer (write null data ... " << m_bufferUnderFlowSize << " chunks [In the past])");
|
||||
}
|
||||
m_bufferUnderFlowSize = 0;
|
||||
DRAIN_VERBOSE("Write " << _outputNbChunk << " chunks");
|
||||
// check if we have enought data:
|
||||
int32_t nbChunkToCopy = std::min(_inputNbChunk, m_buffer.getSize());
|
||||
int32_t nbChunkToCopy = etk::min(_inputNbChunk, m_buffer.getSize());
|
||||
if (nbChunkToCopy != _inputNbChunk) {
|
||||
generateStatus("EPW_UNDERFLOW");
|
||||
}
|
||||
@@ -100,7 +110,7 @@ bool audio::drain::EndPointWrite::process(audio::Time& _time,
|
||||
}
|
||||
|
||||
void audio::drain::EndPointWrite::write(const void* _value, size_t _nbChunk) {
|
||||
std11::unique_lock<std11::mutex> lock(m_mutex);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
DRAIN_VERBOSE("[ASYNC] Write data : " << _nbChunk << " chunks" << " ==> " << m_output);
|
||||
int32_t nbOverflow = m_buffer.write(_value, _nbChunk);
|
||||
if (nbOverflow > 0) {
|
||||
@@ -109,7 +119,7 @@ void audio::drain::EndPointWrite::write(const void* _value, size_t _nbChunk) {
|
||||
}
|
||||
|
||||
void audio::drain::EndPointWrite::setBufferSize(size_t _nbChunk) {
|
||||
m_bufferSizeMicroseconds = std11::chrono::microseconds(0);
|
||||
m_bufferSizeMicroseconds = echrono::microseconds(0);
|
||||
m_bufferSizeChunk = _nbChunk;
|
||||
if ( audio::getFormatBytes(m_output.getFormat())*m_output.getMap().size() != 0
|
||||
&& m_output.getFrequency() != 0) {
|
||||
@@ -119,7 +129,7 @@ void audio::drain::EndPointWrite::setBufferSize(size_t _nbChunk) {
|
||||
}
|
||||
}
|
||||
|
||||
void audio::drain::EndPointWrite::setBufferSize(const std11::chrono::microseconds& _time) {
|
||||
void audio::drain::EndPointWrite::setBufferSize(const echrono::microseconds& _time) {
|
||||
m_bufferSizeMicroseconds = _time;
|
||||
m_bufferSizeChunk = 0;
|
||||
m_buffer.setCapacity(_time,
|
||||
@@ -131,20 +141,20 @@ size_t audio::drain::EndPointWrite::getBufferSize() {
|
||||
if (m_bufferSizeChunk != 0) {
|
||||
return m_bufferSizeChunk;
|
||||
}
|
||||
return (int64_t(m_output.getFrequency())*m_bufferSizeMicroseconds.count())/1000000LL;
|
||||
return (int64_t(m_output.getFrequency())*m_bufferSizeMicroseconds.get())/1000000000LL;
|
||||
}
|
||||
|
||||
std11::chrono::microseconds audio::drain::EndPointWrite::getBufferSizeMicrosecond() {
|
||||
if (m_bufferSizeMicroseconds != std11::chrono::microseconds(0) ) {
|
||||
echrono::microseconds audio::drain::EndPointWrite::getBufferSizeMicrosecond() {
|
||||
if (m_bufferSizeMicroseconds.get() != 0) {
|
||||
return m_bufferSizeMicroseconds;
|
||||
}
|
||||
return std11::chrono::microseconds(m_bufferSizeChunk*1000000LL/int64_t(m_output.getFrequency()));
|
||||
return echrono::microseconds(m_bufferSizeChunk*1000000LL/int64_t(m_output.getFrequency()));
|
||||
}
|
||||
|
||||
size_t audio::drain::EndPointWrite::getBufferFillSize() {
|
||||
return m_buffer.getSize()/(audio::getFormatBytes(m_output.getFormat())*m_output.getMap().size());
|
||||
}
|
||||
|
||||
std11::chrono::microseconds audio::drain::EndPointWrite::getBufferFillSizeMicrosecond() {
|
||||
return std11::chrono::microseconds(getBufferFillSize()*1000000LL/int64_t(m_output.getFrequency()));
|
||||
echrono::microseconds audio::drain::EndPointWrite::getBufferFillSizeMicrosecond() {
|
||||
return echrono::microseconds(getBufferFillSize()*1000000LL/int64_t(m_output.getFrequency()));
|
||||
}
|
||||
|
||||
@@ -1,29 +1,27 @@
|
||||
/** @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
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_ALGO_END_POINT_WRITE_H__
|
||||
#define __AUDIO_DRAIN_ALGO_ALGO_END_POINT_WRITE_H__
|
||||
|
||||
#include <audio/drain/EndPoint.h>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <audio/drain/CircularBuffer.h>
|
||||
#include <audio/drain/EndPoint.hpp>
|
||||
#include <etk/Function.hpp>
|
||||
#include <ethread/Mutex.hpp>
|
||||
#include <audio/drain/CircularBuffer.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain{
|
||||
typedef std11::function<void (const audio::Time& _time,
|
||||
typedef etk::Function<void (const audio::Time& _time,
|
||||
size_t _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _frequency,
|
||||
const std::vector<audio::channel>& _map)> playbackFunctionWrite;
|
||||
const etk::Vector<audio::channel>& _map)> playbackFunctionWrite;
|
||||
class EndPointWrite : public EndPoint {
|
||||
private:
|
||||
audio::drain::CircularBuffer m_buffer;
|
||||
playbackFunctionWrite m_function;
|
||||
std11::mutex m_mutex;
|
||||
ethread::Mutex m_mutex;
|
||||
protected:
|
||||
/**
|
||||
* @brief Constructor
|
||||
@@ -31,7 +29,7 @@ namespace audio {
|
||||
EndPointWrite();
|
||||
void init();
|
||||
public:
|
||||
static std11::shared_ptr<audio::drain::EndPointWrite> create();
|
||||
static ememory::SharedPtr<audio::drain::EndPointWrite> create();
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
@@ -47,8 +45,9 @@ namespace audio {
|
||||
m_function = _function;
|
||||
}
|
||||
protected:
|
||||
std11::chrono::microseconds m_bufferSizeMicroseconds; // 0 if m_bufferSizeChunk != 0
|
||||
echrono::microseconds m_bufferSizeMicroseconds; // 0 if m_bufferSizeChunk != 0
|
||||
size_t m_bufferSizeChunk; // 0 if m_bufferSizeMicroseconds != 0
|
||||
size_t m_bufferUnderFlowSize; //!< Limit display of underflow in the write callback
|
||||
public:
|
||||
/**
|
||||
* @brief Set buffer size in chunk number
|
||||
@@ -59,7 +58,7 @@ namespace audio {
|
||||
* @brief Set buffer size size of the buffer with the stored time in µs
|
||||
* @param[in] _time Time in microsecond of the buffer
|
||||
*/
|
||||
virtual void setBufferSize(const std11::chrono::microseconds& _time);
|
||||
virtual void setBufferSize(const echrono::microseconds& _time);
|
||||
/**
|
||||
* @brief get buffer size in chunk number
|
||||
* @return Number of chunk that can be written in the buffer
|
||||
@@ -69,7 +68,7 @@ namespace audio {
|
||||
* @brief Set buffer size size of the buffer with the stored time in µs
|
||||
* @return Time in microsecond that can be written in the buffer
|
||||
*/
|
||||
virtual std11::chrono::microseconds getBufferSizeMicrosecond();
|
||||
virtual echrono::microseconds getBufferSizeMicrosecond();
|
||||
/**
|
||||
* @brief Get buffer size filled in chunk number
|
||||
* @return Number of chunk in the buffer (that might be read/write)
|
||||
@@ -79,9 +78,8 @@ namespace audio {
|
||||
* @brief Set buffer size size of the buffer with the stored time in µs
|
||||
* @return Time in microsecond of the buffer (that might be read/write)
|
||||
*/
|
||||
virtual std11::chrono::microseconds getBufferFillSizeMicrosecond();
|
||||
virtual echrono::microseconds getBufferFillSizeMicrosecond();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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/drain/Equalizer.h>
|
||||
#include <audio/drain/Algo.h>
|
||||
#include <audio/drain/debug.h>
|
||||
#include <audio/drain/Equalizer.hpp>
|
||||
#include <audio/drain/Algo.hpp>
|
||||
#include <audio/drain/debug.hpp>
|
||||
|
||||
// see http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
|
||||
// see http://www.earlevel.com/main/2013/10/13/biquad-calculator-v2/
|
||||
@@ -18,13 +18,13 @@ audio::drain::Equalizer::Equalizer() {
|
||||
void audio::drain::Equalizer::init() {
|
||||
audio::drain::Algo::init();
|
||||
audio::drain::Algo::m_type = "Equalizer";
|
||||
m_supportedFormat.push_back(audio::format_int16);
|
||||
m_supportedFormat.push_back(audio::format_int16);
|
||||
m_supportedFormat.pushBack(audio::format_int16);
|
||||
m_supportedFormat.pushBack(audio::format_int16);
|
||||
configureBiQuad();
|
||||
}
|
||||
|
||||
std11::shared_ptr<audio::drain::Equalizer> audio::drain::Equalizer::create() {
|
||||
std11::shared_ptr<audio::drain::Equalizer> tmp(new audio::drain::Equalizer());
|
||||
ememory::SharedPtr<audio::drain::Equalizer> audio::drain::Equalizer::create() {
|
||||
ememory::SharedPtr<audio::drain::Equalizer> tmp(ETK_NEW(audio::drain::Equalizer));
|
||||
tmp->init();
|
||||
return tmp;
|
||||
}
|
||||
@@ -45,17 +45,17 @@ bool audio::drain::Equalizer::process(audio::Time& _time,
|
||||
size_t& _outputNbChunk) {
|
||||
_outputNbChunk = _inputNbChunk;
|
||||
_output = _input;
|
||||
if (_input == nullptr) {
|
||||
if (_input == null) {
|
||||
return false;
|
||||
}
|
||||
m_algo.process(_output, _input, _inputNbChunk);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool audio::drain::Equalizer::setParameter(const std::string& _parameter, const std::string& _value) {
|
||||
bool audio::drain::Equalizer::setParameter(const etk::String& _parameter, const etk::String& _value) {
|
||||
//DRAIN_WARNING("set : " << _parameter << " " << _value);
|
||||
if (_parameter == "config") {
|
||||
m_config = ejson::Object::create(_value);
|
||||
m_config = ejson::Object(_value);
|
||||
configureBiQuad();
|
||||
} else if (_parameter == "reset") {
|
||||
// TODO : m_algo.reset();
|
||||
@@ -64,23 +64,23 @@ bool audio::drain::Equalizer::setParameter(const std::string& _parameter, const
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string audio::drain::Equalizer::getParameter(const std::string& _parameter) const {
|
||||
etk::String audio::drain::Equalizer::getParameter(const etk::String& _parameter) const {
|
||||
return "error";
|
||||
}
|
||||
|
||||
std::string audio::drain::Equalizer::getParameterProperty(const std::string& _parameter) const {
|
||||
etk::String audio::drain::Equalizer::getParameterProperty(const etk::String& _parameter) const {
|
||||
return "error";
|
||||
}
|
||||
|
||||
void audio::drain::Equalizer::addBiquad(int32_t _idBiquad, const std11::shared_ptr<const ejson::Object>& _object) {
|
||||
void audio::drain::Equalizer::addBiquad(int32_t _idBiquad, const ejson::Object& _object) {
|
||||
// get type:
|
||||
std::string typeString = _object->getStringValue("type", "none");
|
||||
etk::String typeString = _object["type"].toString().get("none");
|
||||
if (typeString == "direct-value") {
|
||||
double a0 = _object->getNumberValue("a0", 0.0);
|
||||
double a1 = _object->getNumberValue("a1", 0.0);
|
||||
double a2 = _object->getNumberValue("a2", 0.0);
|
||||
double b0 = _object->getNumberValue("b0", 0.0);
|
||||
double b1 = _object->getNumberValue("b1", 0.0);
|
||||
double a0 = _object["a0"].toNumber().get(0.0);
|
||||
double a1 = _object["a1"].toNumber().get(0.0);
|
||||
double a2 = _object["a2"].toNumber().get(0.0);
|
||||
double b0 = _object["b0"].toNumber().get(0.0);
|
||||
double b1 = _object["b1"].toNumber().get(0.0);
|
||||
if (_idBiquad < 0) {
|
||||
m_algo.addBiquad(a0, a1, a2, b0, b1);
|
||||
} else {
|
||||
@@ -91,9 +91,9 @@ void audio::drain::Equalizer::addBiquad(int32_t _idBiquad, const std11::shared_p
|
||||
if (etk::from_string(type, typeString) == false) {
|
||||
DRAIN_ERROR("Can not parse equalizer type:'" << typeString << "'");
|
||||
}
|
||||
double gain = _object->getNumberValue("gain", 0.0);
|
||||
double frequency = _object->getNumberValue("cut-frequency", 0.0);
|
||||
double quality = _object->getNumberValue("quality", 0.0);
|
||||
double gain = _object["gain"].toNumber().get(0.0);
|
||||
double frequency = _object["cut-frequency"].toNumber().get(0.0);
|
||||
double quality = _object["quality"].toNumber().get(0.0);
|
||||
if (_idBiquad < 0) {
|
||||
m_algo.addBiquad(type, frequency, quality, gain);
|
||||
} else {
|
||||
@@ -106,16 +106,16 @@ void audio::drain::Equalizer::configureBiQuad() {
|
||||
m_algo.init(getOutputFormat().getFrequency(),
|
||||
getOutputFormat().getMap().size(),
|
||||
getOutputFormat().getFormat());
|
||||
if (m_config == nullptr) {
|
||||
if (m_config.exist() == false) {
|
||||
return;
|
||||
}
|
||||
// check for a global config:
|
||||
const std11::shared_ptr<const ejson::Array> global = m_config->getArray("global");
|
||||
if (global != nullptr) {
|
||||
const ejson::Array global = m_config["global"].toArray();
|
||||
if (global.exist() == true) {
|
||||
// only global configuration get all elements:
|
||||
for (size_t kkk=0; kkk<global->size(); ++kkk) {
|
||||
const std11::shared_ptr<const ejson::Object> tmpObject = global->getObject(kkk);
|
||||
if (tmpObject == nullptr) {
|
||||
for (size_t kkk=0; kkk<global.size(); ++kkk) {
|
||||
const ejson::Object tmpObject = global[kkk].toObject();
|
||||
if (tmpObject.exist() == false) {
|
||||
DRAIN_ERROR("Parse the configuration error : not a correct parameter:" << kkk);
|
||||
continue;
|
||||
}
|
||||
@@ -125,16 +125,16 @@ void audio::drain::Equalizer::configureBiQuad() {
|
||||
return;
|
||||
}
|
||||
for (size_t iii=0; iii<getOutputFormat().getMap().size(); ++iii) {
|
||||
std::string channelName = etk::to_string(getOutputFormat().getMap()[iii]);
|
||||
const std11::shared_ptr<const ejson::Array> channelConfig = m_config->getArray(channelName);
|
||||
if (channelConfig == nullptr) {
|
||||
etk::String channelName = etk::toString(getOutputFormat().getMap()[iii]);
|
||||
const ejson::Array channelConfig = m_config[channelName].toArray();
|
||||
if (channelConfig.exist() == false) {
|
||||
// no config ... not a problem ...
|
||||
continue;
|
||||
}
|
||||
// only global configuration get all elements:
|
||||
for (size_t kkk=0; kkk<channelConfig->size(); ++kkk) {
|
||||
const std11::shared_ptr<const ejson::Object> tmpObject = channelConfig->getObject(kkk);
|
||||
if (tmpObject == nullptr) {
|
||||
for (size_t kkk=0; kkk<channelConfig.size(); ++kkk) {
|
||||
const ejson::Object tmpObject = channelConfig[kkk].toObject();
|
||||
if (tmpObject.exist() == false) {
|
||||
DRAIN_ERROR("Parse the configuration error : not a correct parameter:" << kkk);
|
||||
continue;
|
||||
}
|
||||
@@ -145,6 +145,6 @@ void audio::drain::Equalizer::configureBiQuad() {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::pair<float,float> > audio::drain::Equalizer::calculateTheory() {
|
||||
etk::Vector<etk::Pair<float,float> > audio::drain::Equalizer::calculateTheory() {
|
||||
return m_algo.calculateTheory();
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
/** @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
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_EQUALIZER_H__
|
||||
#define __AUDIO_DRAIN_ALGO_EQUALIZER_H__
|
||||
|
||||
#include <audio/drain/Algo.h>
|
||||
#include <memory>
|
||||
#include <ejson/Object.h>
|
||||
#include <audio/algo/drain/Equalizer.h>
|
||||
#include <audio/drain/Algo.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <ejson/Object.hpp>
|
||||
#include <audio/algo/drain/Equalizer.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain {
|
||||
@@ -22,7 +20,7 @@ namespace audio {
|
||||
Equalizer();
|
||||
void init();
|
||||
public:
|
||||
static std11::shared_ptr<audio::drain::Equalizer> create();
|
||||
static ememory::SharedPtr<audio::drain::Equalizer> create();
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
@@ -36,13 +34,13 @@ namespace audio {
|
||||
void*& _output,
|
||||
size_t& _outputNbChunk);
|
||||
protected:
|
||||
std11::shared_ptr<ejson::Object> m_config; // configuration of the equalizer.
|
||||
ejson::Object m_config; // configuration of the equalizer.
|
||||
public:
|
||||
virtual bool setParameter(const std::string& _parameter, const std::string& _value);
|
||||
virtual std::string getParameter(const std::string& _parameter) const;
|
||||
virtual std::string getParameterProperty(const std::string& _parameter) const;
|
||||
virtual bool setParameter(const etk::String& _parameter, const etk::String& _value);
|
||||
virtual etk::String getParameter(const etk::String& _parameter) const;
|
||||
virtual etk::String getParameterProperty(const etk::String& _parameter) const;
|
||||
protected:
|
||||
void addBiquad(int32_t _idBiquad, const std11::shared_ptr<const ejson::Object>& _object);
|
||||
void addBiquad(int32_t _idBiquad, const ejson::Object& _object);
|
||||
audio::algo::drain::Equalizer m_algo;
|
||||
/**
|
||||
* @brief Configure biquad with the user spec.
|
||||
@@ -50,9 +48,8 @@ namespace audio {
|
||||
void configureBiQuad();
|
||||
public:
|
||||
// for debug & tools only
|
||||
std::vector<std::pair<float,float> > calculateTheory();
|
||||
etk::Vector<etk::Pair<float,float> > calculateTheory();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,15 +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)
|
||||
*/
|
||||
|
||||
#include <audio/drain/FormatUpdate.h>
|
||||
#include <iostream>
|
||||
#include <audio/drain/debug.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "FormatUpdate"
|
||||
#include <audio/drain/FormatUpdate.hpp>
|
||||
#include <audio/drain/debug.hpp>
|
||||
|
||||
#ifndef INT16_MAX
|
||||
#define INT16_MAX 0x7fff
|
||||
@@ -52,14 +48,14 @@ static void convert__int16_on_int32__to__int16(void* _input, void* _output, size
|
||||
int32_t* in = static_cast<int32_t*>(_input);
|
||||
int16_t* out = static_cast<int16_t*>(_output);
|
||||
for (size_t iii=0; iii<_nbSample; ++iii) {
|
||||
out[iii] = static_cast<int16_t>(std::min(std::max(INT16_MIN, in[iii]), INT16_MAX));
|
||||
out[iii] = static_cast<int16_t>(etk::min(etk::max(INT16_MIN, in[iii]), INT16_MAX));
|
||||
}
|
||||
}
|
||||
static void convert__int16_on_int32__to__int32(void* _input, void* _output, size_t _nbSample) {
|
||||
int32_t* in = static_cast<int32_t*>(_input);
|
||||
int32_t* out = static_cast<int32_t*>(_output);
|
||||
for (size_t iii=0; iii<_nbSample; ++iii) {
|
||||
int32_t value = std::min(std::max(INT16_MIN, in[iii]), INT16_MAX);
|
||||
int32_t value = etk::min(etk::max(INT16_MIN, in[iii]), INT16_MAX);
|
||||
out[iii] = value << 16;
|
||||
}
|
||||
}
|
||||
@@ -77,7 +73,7 @@ static void convert__int32__to__int16(void* _input, void* _output, size_t _nbSam
|
||||
int16_t* out = static_cast<int16_t*>(_output);
|
||||
for (size_t iii=0; iii<_nbSample; ++iii) {
|
||||
int32_t value = in[iii] >> 16;
|
||||
out[iii] = static_cast<int16_t>(std::min(std::max(INT16_MIN, value), INT16_MAX));
|
||||
out[iii] = static_cast<int16_t>(etk::min(etk::max(INT16_MIN, value), INT16_MAX));
|
||||
}
|
||||
}
|
||||
static void convert__int32__to__int16_on_int32(void* _input, void* _output, size_t _nbSample) {
|
||||
@@ -101,7 +97,7 @@ static void convert__float__to__int16(void* _input, void* _output, size_t _nbSam
|
||||
int16_t* out = static_cast<int16_t*>(_output);
|
||||
for (size_t iii=0; iii<_nbSample; ++iii) {
|
||||
float value = in[iii] * static_cast<float>(INT16_MAX);
|
||||
value = std::min(std::max(static_cast<float>(INT16_MIN), value), static_cast<float>(INT16_MAX));
|
||||
value = etk::min(etk::max(static_cast<float>(INT16_MIN), value), static_cast<float>(INT16_MAX));
|
||||
out[iii] = static_cast<int16_t>(value);
|
||||
//DRAIN_DEBUG(iii << " in=" << in[iii] << " out=" << out[iii]);
|
||||
}
|
||||
@@ -111,7 +107,7 @@ static void convert__float__to__int16_on_int32(void* _input, void* _output, size
|
||||
int32_t* out = static_cast<int32_t*>(_output);
|
||||
for (size_t iii=0; iii<_nbSample; ++iii) {
|
||||
float value = in[iii] * static_cast<float>(INT16_MAX);
|
||||
value = std::min(std::max(static_cast<float>(INT32_MIN), value), static_cast<float>(INT32_MAX));
|
||||
value = etk::min(etk::max(static_cast<float>(INT32_MIN), value), static_cast<float>(INT32_MAX));
|
||||
out[iii] = static_cast<int32_t>(value);
|
||||
}
|
||||
}
|
||||
@@ -120,14 +116,14 @@ static void convert__float__to__int32(void* _input, void* _output, size_t _nbSam
|
||||
int32_t* out = static_cast<int32_t*>(_output);
|
||||
for (size_t iii=0; iii<_nbSample; ++iii) {
|
||||
float value = in[iii] * static_cast<float>(INT32_MAX);
|
||||
value = std::min(std::max(static_cast<float>(INT32_MIN), value), static_cast<float>(INT32_MAX));
|
||||
value = etk::min(etk::max(static_cast<float>(INT32_MIN), value), static_cast<float>(INT32_MAX));
|
||||
out[iii] = static_cast<int32_t>(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
audio::drain::FormatUpdate::FormatUpdate() :
|
||||
m_functionConvert(nullptr) {
|
||||
m_functionConvert(null) {
|
||||
|
||||
}
|
||||
|
||||
@@ -136,8 +132,8 @@ void audio::drain::FormatUpdate::init() {
|
||||
m_type = "FormatUpdate";
|
||||
}
|
||||
|
||||
std11::shared_ptr<audio::drain::FormatUpdate> audio::drain::FormatUpdate::create() {
|
||||
std11::shared_ptr<audio::drain::FormatUpdate> tmp(new audio::drain::FormatUpdate());
|
||||
ememory::SharedPtr<audio::drain::FormatUpdate> audio::drain::FormatUpdate::create() {
|
||||
ememory::SharedPtr<audio::drain::FormatUpdate> tmp(ETK_NEW(audio::drain::FormatUpdate));
|
||||
tmp->init();
|
||||
return tmp;
|
||||
}
|
||||
@@ -255,7 +251,7 @@ bool audio::drain::FormatUpdate::process(audio::Time& _time,
|
||||
_outputNbChunk = _inputNbChunk;
|
||||
return true;
|
||||
}
|
||||
if (_input == nullptr) {
|
||||
if (_input == null) {
|
||||
_output = &(m_outputData[0]);
|
||||
_outputNbChunk = 0;
|
||||
DRAIN_ERROR("null pointer input ... ");
|
||||
@@ -264,7 +260,7 @@ bool audio::drain::FormatUpdate::process(audio::Time& _time,
|
||||
_outputNbChunk = _inputNbChunk;
|
||||
m_outputData.resize(_outputNbChunk*m_input.getMap().size()*m_formatSize);
|
||||
_output = &(m_outputData[0]);
|
||||
if (m_functionConvert == nullptr) {
|
||||
if (m_functionConvert == null) {
|
||||
DRAIN_ERROR("null function ptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,12 +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)
|
||||
*/
|
||||
#ifndef __AUDIO_DRAIN_ALGO_FORMAT_UPDATE_H__
|
||||
#define __AUDIO_DRAIN_ALGO_FORMAT_UPDATE_H__
|
||||
#pragma once
|
||||
|
||||
#include <audio/drain/Algo.h>
|
||||
#include <audio/drain/Algo.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain {
|
||||
@@ -18,7 +17,7 @@ namespace audio {
|
||||
FormatUpdate();
|
||||
void init();
|
||||
public:
|
||||
static std11::shared_ptr<audio::drain::FormatUpdate> create();
|
||||
static ememory::SharedPtr<audio::drain::FormatUpdate> create();
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
@@ -37,4 +36,3 @@ namespace audio {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,17 +1,13 @@
|
||||
/** @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 "IOFormatInterface.h"
|
||||
#include "debug.h"
|
||||
#include "IOFormatInterface.hpp"
|
||||
#include "debug.hpp"
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "IOFormatInterface"
|
||||
|
||||
|
||||
std::ostream& audio::drain::operator <<(std::ostream& _os, const IOFormatInterface& _obj) {
|
||||
etk::Stream& audio::drain::operator <<(etk::Stream& _os, const IOFormatInterface& _obj) {
|
||||
_os << "{";
|
||||
if (_obj.getConfigured() == false) {
|
||||
_os << "Not configured";
|
||||
@@ -29,11 +25,11 @@ audio::drain::IOFormatInterface::IOFormatInterface() :
|
||||
m_format(audio::format_unknow),
|
||||
m_map(),
|
||||
m_frequency(0) {
|
||||
m_map.push_back(audio::channel_frontLeft);
|
||||
m_map.push_back(audio::channel_frontRight);
|
||||
m_map.pushBack(audio::channel_frontLeft);
|
||||
m_map.pushBack(audio::channel_frontRight);
|
||||
}
|
||||
|
||||
audio::drain::IOFormatInterface::IOFormatInterface(std::vector<audio::channel> _map, audio::format _format, float _frequency) :
|
||||
audio::drain::IOFormatInterface::IOFormatInterface(etk::Vector<enum audio::channel> _map, enum audio::format _format, float _frequency) :
|
||||
m_configured(true),
|
||||
m_format(_format),
|
||||
m_map(_map),
|
||||
@@ -41,7 +37,7 @@ audio::drain::IOFormatInterface::IOFormatInterface(std::vector<audio::channel> _
|
||||
|
||||
}
|
||||
|
||||
void audio::drain::IOFormatInterface::set(std::vector<audio::channel> _map, audio::format _format, float _frequency) {
|
||||
void audio::drain::IOFormatInterface::set(etk::Vector<enum audio::channel> _map, enum audio::format _format, float _frequency) {
|
||||
bool hasChange = false;
|
||||
if (m_map != _map) {
|
||||
m_map = _map;
|
||||
@@ -69,11 +65,11 @@ bool audio::drain::IOFormatInterface::getConfigured() const {
|
||||
return m_configured;
|
||||
}
|
||||
|
||||
audio::format audio::drain::IOFormatInterface::getFormat() const {
|
||||
enum audio::format audio::drain::IOFormatInterface::getFormat() const {
|
||||
return m_format;
|
||||
}
|
||||
|
||||
void audio::drain::IOFormatInterface::setFormat(audio::format _value) {
|
||||
void audio::drain::IOFormatInterface::setFormat(enum audio::format _value) {
|
||||
if (m_format == _value) {
|
||||
return;
|
||||
}
|
||||
@@ -82,11 +78,11 @@ void audio::drain::IOFormatInterface::setFormat(audio::format _value) {
|
||||
configurationChange();
|
||||
}
|
||||
|
||||
const std::vector<audio::channel>& audio::drain::IOFormatInterface::getMap() const{
|
||||
const etk::Vector<enum audio::channel>& audio::drain::IOFormatInterface::getMap() const{
|
||||
return m_map;
|
||||
}
|
||||
|
||||
void audio::drain::IOFormatInterface::setMap(const std::vector<audio::channel>& _value) {
|
||||
void audio::drain::IOFormatInterface::setMap(const etk::Vector<enum audio::channel>& _value) {
|
||||
if (m_map == _value) {
|
||||
return;
|
||||
}
|
||||
@@ -109,11 +105,11 @@ void audio::drain::IOFormatInterface::setFrequency(float _value) {
|
||||
}
|
||||
|
||||
void audio::drain::IOFormatInterface::configurationChange() {
|
||||
if (m_ioChangeFunctor != nullptr) {
|
||||
if (m_ioChangeFunctor != null) {
|
||||
m_ioChangeFunctor();
|
||||
}
|
||||
}
|
||||
void audio::drain::IOFormatInterface::setCallback(const std11::function<void()>& _functor) {
|
||||
void audio::drain::IOFormatInterface::setCallback(const etk::Function<void()>& _functor) {
|
||||
m_ioChangeFunctor = _functor;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,62 +1,58 @@
|
||||
/** @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
|
||||
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_IO_FORMAT_INTERFACE_H__
|
||||
#define __AUDIO_DRAIN_ALGO_IO_FORMAT_INTERFACE_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include <audio/format.h>
|
||||
#include <audio/channel.h>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include "AutoLogInOut.h"
|
||||
#include "debug.h"
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <audio/format.hpp>
|
||||
#include <audio/channel.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <etk/Function.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include "AutoLogInOut.hpp"
|
||||
#include "debug.hpp"
|
||||
|
||||
namespace audio {
|
||||
namespace drain{
|
||||
class IOFormatInterface {
|
||||
public:
|
||||
IOFormatInterface();
|
||||
IOFormatInterface(std::vector<audio::channel> _map, audio::format _format=audio::format_int16, float _frequency=48000.0f);
|
||||
void set(std::vector<audio::channel> _map, audio::format _format=audio::format_int16, float _frequency=48000.0f);
|
||||
IOFormatInterface(etk::Vector<enum audio::channel> _map, enum audio::format _format=audio::format_int16, float _frequency=48000.0f);
|
||||
void set(etk::Vector<enum audio::channel> _map, enum audio::format _format=audio::format_int16, float _frequency=48000.0f);
|
||||
protected:
|
||||
bool m_configured;
|
||||
public:
|
||||
void setConfigured(bool _value);
|
||||
bool getConfigured() const;
|
||||
protected:
|
||||
audio::format m_format; //!< input Algo Format
|
||||
enum audio::format m_format; //!< input Algo Format
|
||||
public:
|
||||
/**
|
||||
* @brief Get the algo format.
|
||||
* @return the current Format.
|
||||
*/
|
||||
audio::format getFormat() const;
|
||||
enum audio::format getFormat() const;
|
||||
/**
|
||||
* @brief Set the algo format.
|
||||
* @param[in] _value New Format.
|
||||
*/
|
||||
void setFormat(audio::format _value);
|
||||
void setFormat(enum audio::format _value);
|
||||
protected:
|
||||
std::vector<audio::channel> m_map; //!< input channel Map
|
||||
etk::Vector<enum audio::channel> m_map; //!< input channel Map
|
||||
public:
|
||||
/**
|
||||
* @brief Get the algo channel Map.
|
||||
* @return the current channel Map.
|
||||
*/
|
||||
const std::vector<audio::channel>& getMap() const;
|
||||
const etk::Vector<enum audio::channel>& getMap() const;
|
||||
/**
|
||||
* @brief Set the algo channel Map.
|
||||
* @param[in] _value New channel Map.
|
||||
*/
|
||||
void setMap(const std::vector<audio::channel>& _value);
|
||||
void setMap(const etk::Vector<enum audio::channel>& _value);
|
||||
protected:
|
||||
float m_frequency; //!< input Algo Format
|
||||
public:
|
||||
@@ -77,17 +73,16 @@ namespace audio {
|
||||
*/
|
||||
int32_t getChunkSize() const;
|
||||
protected:
|
||||
std11::function<void()> m_ioChangeFunctor; //!< function pointer on the upper class
|
||||
etk::Function<void()> m_ioChangeFunctor; //!< function pointer on the upper class
|
||||
void configurationChange();
|
||||
public:
|
||||
/**
|
||||
* @brief Set the callback function to be notify when the arameter change.
|
||||
* @param[in] _functor Function to call.
|
||||
*/
|
||||
void setCallback(const std11::function<void()>& _functor);
|
||||
void setCallback(const etk::Function<void()>& _functor);
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::drain::IOFormatInterface& _obj);
|
||||
etk::Stream& operator <<(etk::Stream& _os, const audio::drain::IOFormatInterface& _obj);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,22 +1,18 @@
|
||||
/** @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 <string>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include <audio/format.h>
|
||||
#include <audio/channel.h>
|
||||
#include <audio/drain/Process.h>
|
||||
#include <audio/drain/ChannelReorder.h>
|
||||
#include <audio/drain/FormatUpdate.h>
|
||||
#include <audio/drain/Resampler.h>
|
||||
#include <audio/drain/debug.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Process"
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <audio/format.hpp>
|
||||
#include <audio/channel.hpp>
|
||||
#include <audio/drain/Process.hpp>
|
||||
#include <audio/drain/ChannelReorder.hpp>
|
||||
#include <audio/drain/FormatUpdate.hpp>
|
||||
#include <audio/drain/Resampler.hpp>
|
||||
#include <audio/drain/debug.hpp>
|
||||
|
||||
audio::drain::Process::Process() :
|
||||
m_isConfigured(false) {
|
||||
@@ -31,7 +27,7 @@ audio::drain::Process::~Process() {
|
||||
bool audio::drain::Process::push(audio::Time& _time,
|
||||
void* _data,
|
||||
size_t _nbChunk) {
|
||||
void* out = nullptr;
|
||||
void* out = null;
|
||||
size_t nbChunkOut;
|
||||
DRAIN_VERBOSE(" Process push");
|
||||
process(_time, _data, _nbChunk, out, nbChunkOut);
|
||||
@@ -42,24 +38,25 @@ bool audio::drain::Process::pull(audio::Time& _time,
|
||||
void* _data,
|
||||
size_t _nbChunk,
|
||||
size_t _chunkSize) {
|
||||
while(m_data.size()<_nbChunk*_chunkSize) {
|
||||
void* in = NULL;
|
||||
//DRAIN_DEBUG("Execute:");
|
||||
while(m_data.size() < _nbChunk*_chunkSize) {
|
||||
void* in = null;
|
||||
size_t nbChunkIn = _nbChunk - m_data.size()/_chunkSize;
|
||||
void* out = NULL;
|
||||
void* out = null;
|
||||
size_t nbChunkOut;
|
||||
if (nbChunkIn < 128) {
|
||||
nbChunkIn = 128;
|
||||
}
|
||||
// TODO : maybe remove this for input data ...
|
||||
for (int32_t iii=m_listAlgo.size()-1; iii >=0; --iii) {
|
||||
if (m_listAlgo[iii] != NULL) {
|
||||
if (m_listAlgo[iii] != null) {
|
||||
nbChunkIn = m_listAlgo[iii]->needInputData(nbChunkIn);
|
||||
}
|
||||
}
|
||||
if (nbChunkIn < 32) {
|
||||
nbChunkIn = 32;
|
||||
}
|
||||
|
||||
//DRAIN_DEBUG(" process:" << _time << " in=" << in << " nbChunkIn=" << nbChunkIn << " out=" << out << " nbChunkOut=" << nbChunkOut);
|
||||
// get data from the upstream
|
||||
process(_time, in, nbChunkIn, out, nbChunkOut);
|
||||
if (nbChunkOut > 0) {
|
||||
@@ -72,7 +69,7 @@ bool audio::drain::Process::pull(audio::Time& _time,
|
||||
}
|
||||
}
|
||||
// copy only data availlable :
|
||||
int32_t minByTeSize = std::min(m_data.size(), _nbChunk*_chunkSize);
|
||||
int32_t minByTeSize = etk::min(m_data.size(), _nbChunk*_chunkSize);
|
||||
if (minByTeSize >= 0) {
|
||||
memcpy(_data, &m_data[0], minByTeSize);
|
||||
m_data.erase(m_data.begin(), m_data.begin()+minByTeSize);
|
||||
@@ -94,8 +91,8 @@ bool audio::drain::Process::process(audio::Time& _time,
|
||||
}
|
||||
DRAIN_VERBOSE(" process : " << m_listAlgo.size() << " algos nbChunk=" << _inNbChunk);
|
||||
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||
//std::cout << " Algo " << iii+1 << "/" << m_listAlgo.size() << std::endl;
|
||||
if (m_listAlgo[iii] != nullptr) {
|
||||
DRAIN_VERBOSE(" Algo " << iii+1 << "/" << m_listAlgo.size());
|
||||
if (m_listAlgo[iii] != null) {
|
||||
m_listAlgo[iii]->process(_time, _inData, _inNbChunk, _outData, _outNbChunk);
|
||||
_inData = _outData;
|
||||
_inNbChunk = _outNbChunk;
|
||||
@@ -104,20 +101,21 @@ bool audio::drain::Process::process(audio::Time& _time,
|
||||
return true;
|
||||
}
|
||||
|
||||
void audio::drain::Process::pushBack(const std11::shared_ptr<audio::drain::Algo>& _algo) {
|
||||
void audio::drain::Process::pushBack(ememory::SharedPtr<audio::drain::Algo> _algo) {
|
||||
removeAlgoDynamic();
|
||||
_algo->setStatusFunction(std11::bind(&audio::drain::Process::generateStatus, this, std11::placeholders::_1, std11::placeholders::_2));
|
||||
m_listAlgo.push_back(_algo);
|
||||
_algo->setStatusFunction([=](const etk::String& _origin, const etk::String& _status) { generateStatus(_origin, _status);});
|
||||
m_listAlgo.pushBack(_algo);
|
||||
}
|
||||
|
||||
void audio::drain::Process::pushFront(const std11::shared_ptr<audio::drain::Algo>& _algo) {
|
||||
void audio::drain::Process::pushFront(ememory::SharedPtr<audio::drain::Algo> _algo) {
|
||||
removeAlgoDynamic();
|
||||
_algo->setStatusFunction(std11::bind(&audio::drain::Process::generateStatus, this, std11::placeholders::_1, std11::placeholders::_2));
|
||||
m_listAlgo.insert(m_listAlgo.begin(), _algo);
|
||||
_algo->setStatusFunction([=](const etk::String& _origin, const etk::String& _status) { generateStatus(_origin, _status);});
|
||||
m_listAlgo.pushFront(_algo);
|
||||
}
|
||||
|
||||
template<typename T> std::vector<T> getUnion(const std::vector<T>& _out, const std::vector<T>& _in) {
|
||||
std::vector<T> out;
|
||||
template<typename DRAIN_TYPE>
|
||||
etk::Vector<DRAIN_TYPE> getUnion(const etk::Vector<DRAIN_TYPE>& _out, const etk::Vector<DRAIN_TYPE>& _in) {
|
||||
etk::Vector<DRAIN_TYPE> out;
|
||||
if (_out.size() == 0) {
|
||||
// Last is ok for all format
|
||||
// ==> set the limit with the next element
|
||||
@@ -129,7 +127,7 @@ template<typename T> std::vector<T> getUnion(const std::vector<T>& _out, const s
|
||||
for (size_t ooo=0; ooo<_out.size(); ++ooo) {
|
||||
for (size_t iii=0; iii<_in.size(); ++iii) {
|
||||
if (_out[ooo] == _in[iii]) {
|
||||
out.push_back(_out[ooo]);
|
||||
out.pushBack(_out[ooo]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,54 +174,54 @@ void audio::drain::Process::updateAlgo(size_t _position) {
|
||||
)
|
||||
) {
|
||||
// step 1 : check frequency:
|
||||
std::vector<float> freqOut;
|
||||
std::vector<float> freqIn;
|
||||
etk::Vector<float> freqOut;
|
||||
etk::Vector<float> freqIn;
|
||||
if (_position == 0) {
|
||||
freqOut.push_back(m_inputConfig.getFrequency());
|
||||
freqOut.pushBack(m_inputConfig.getFrequency());
|
||||
} else {
|
||||
freqOut = m_listAlgo[_position-1]->getFrequencySupportedOutput();
|
||||
}
|
||||
if (_position == m_listAlgo.size()) {
|
||||
freqIn.push_back(m_outputConfig.getFrequency());
|
||||
freqIn.pushBack(m_outputConfig.getFrequency());
|
||||
} else {
|
||||
freqIn = m_listAlgo[_position]->getFrequencySupportedInput();
|
||||
}
|
||||
std::vector<float> freq = getUnion<float>(freqOut, freqIn);
|
||||
etk::Vector<float> freq = getUnion<float>(freqOut, freqIn);
|
||||
DRAIN_VERBOSE(" freq out :" << freqOut);
|
||||
DRAIN_VERBOSE(" freq in :" << freqIn);
|
||||
DRAIN_VERBOSE(" freq union :" << freq);
|
||||
|
||||
// step 2 : Check map:
|
||||
std::vector<std::vector<audio::channel> > mapOut;
|
||||
std::vector<std::vector<audio::channel> > mapIn;
|
||||
etk::Vector<etk::Vector<audio::channel> > mapOut;
|
||||
etk::Vector<etk::Vector<audio::channel> > mapIn;
|
||||
if (_position == 0) {
|
||||
mapOut.push_back(m_inputConfig.getMap());
|
||||
mapOut.pushBack(m_inputConfig.getMap());
|
||||
} else {
|
||||
mapOut = m_listAlgo[_position-1]->getMapSupportedOutput();
|
||||
}
|
||||
if (_position == m_listAlgo.size()) {
|
||||
mapIn.push_back(m_outputConfig.getMap());
|
||||
mapIn.pushBack(m_outputConfig.getMap());
|
||||
} else {
|
||||
mapIn = m_listAlgo[_position]->getMapSupportedInput();
|
||||
}
|
||||
std::vector<std::vector<audio::channel> > map = getUnion<std::vector<audio::channel> >(mapOut, mapIn);
|
||||
etk::Vector<etk::Vector<audio::channel> > map = getUnion<etk::Vector<audio::channel> >(mapOut, mapIn);
|
||||
DRAIN_VERBOSE(" map out :" << mapOut);
|
||||
DRAIN_VERBOSE(" map in :" << mapIn);
|
||||
DRAIN_VERBOSE(" map union :" << map);
|
||||
// step 3 : Check Format:
|
||||
std::vector<audio::format> formatOut;
|
||||
std::vector<audio::format> formatIn;
|
||||
etk::Vector<audio::format> formatOut;
|
||||
etk::Vector<audio::format> formatIn;
|
||||
if (_position == 0) {
|
||||
formatOut.push_back(m_inputConfig.getFormat());
|
||||
formatOut.pushBack(m_inputConfig.getFormat());
|
||||
} else {
|
||||
formatOut = m_listAlgo[_position-1]->getFormatSupportedOutput();
|
||||
}
|
||||
if (_position == m_listAlgo.size()) {
|
||||
formatIn.push_back(m_outputConfig.getFormat());
|
||||
formatIn.pushBack(m_outputConfig.getFormat());
|
||||
} else {
|
||||
formatIn = m_listAlgo[_position]->getFormatSupportedInput();
|
||||
}
|
||||
std::vector<audio::format> format = getUnion<audio::format>(formatOut, formatIn);
|
||||
etk::Vector<audio::format> format = getUnion<audio::format>(formatOut, formatIn);
|
||||
DRAIN_VERBOSE(" format out :" << formatOut);
|
||||
DRAIN_VERBOSE(" format in :" << formatIn);
|
||||
DRAIN_VERBOSE(" format union :" << format);
|
||||
@@ -337,23 +335,23 @@ void audio::drain::Process::updateAlgo(size_t _position) {
|
||||
if ( out.getFormat() != audio::format_int16
|
||||
/* && out.getFormat() != format_float */) {
|
||||
// need add a format Updater
|
||||
std11::shared_ptr<audio::drain::FormatUpdate> algo = audio::drain::FormatUpdate::create();
|
||||
ememory::SharedPtr<audio::drain::FormatUpdate> algo = audio::drain::FormatUpdate::create();
|
||||
algo->setTemporary();
|
||||
algo->setInputFormat(out);
|
||||
out.setFormat(audio::format_int16);
|
||||
algo->setOutputFormat(out);
|
||||
algo->setStatusFunction(std11::bind(&audio::drain::Process::generateStatus, this, std11::placeholders::_1, std11::placeholders::_2));
|
||||
algo->setStatusFunction([=](const etk::String& _origin, const etk::String& _status) { generateStatus(_origin, _status);});
|
||||
m_listAlgo.insert(m_listAlgo.begin()+_position, algo);
|
||||
DRAIN_VERBOSE("convert " << out.getFormat() << " -> " << in.getFormat());
|
||||
_position++;
|
||||
}
|
||||
// need add a resampler
|
||||
std11::shared_ptr<audio::drain::Resampler> algo = audio::drain::Resampler::create();
|
||||
ememory::SharedPtr<audio::drain::Resampler> algo = audio::drain::Resampler::create();
|
||||
algo->setTemporary();
|
||||
algo->setInputFormat(out);
|
||||
out.setFrequency(in.getFrequency());
|
||||
algo->setOutputFormat(out);
|
||||
algo->setStatusFunction(std11::bind(&audio::drain::Process::generateStatus, this, std11::placeholders::_1, std11::placeholders::_2));
|
||||
algo->setStatusFunction([=](const etk::String& _origin, const etk::String& _status) { generateStatus(_origin, _status);});
|
||||
m_listAlgo.insert(m_listAlgo.begin()+_position, algo);
|
||||
DRAIN_VERBOSE("convert " << out.getFrequency() << " -> " << in.getFrequency());
|
||||
out.setFrequency(in.getFrequency());
|
||||
@@ -361,24 +359,24 @@ void audio::drain::Process::updateAlgo(size_t _position) {
|
||||
}
|
||||
if (out.getMap() != in.getMap()) {
|
||||
// need add a channel Reorder
|
||||
std11::shared_ptr<audio::drain::ChannelReorder> algo = audio::drain::ChannelReorder::create();
|
||||
ememory::SharedPtr<audio::drain::ChannelReorder> algo = audio::drain::ChannelReorder::create();
|
||||
algo->setTemporary();
|
||||
algo->setInputFormat(out);
|
||||
out.setMap(in.getMap());
|
||||
algo->setOutputFormat(out);
|
||||
algo->setStatusFunction(std11::bind(&audio::drain::Process::generateStatus, this, std11::placeholders::_1, std11::placeholders::_2));
|
||||
algo->setStatusFunction([=](const etk::String& _origin, const etk::String& _status) { generateStatus(_origin, _status);});
|
||||
m_listAlgo.insert(m_listAlgo.begin()+_position, algo);
|
||||
DRAIN_VERBOSE("convert " << out.getMap() << " -> " << in.getMap());
|
||||
_position++;
|
||||
}
|
||||
if (out.getFormat() != in.getFormat()) {
|
||||
// need add a format Updater
|
||||
std11::shared_ptr<audio::drain::FormatUpdate> algo = audio::drain::FormatUpdate::create();
|
||||
ememory::SharedPtr<audio::drain::FormatUpdate> algo = audio::drain::FormatUpdate::create();
|
||||
algo->setTemporary();
|
||||
algo->setInputFormat(out);
|
||||
out.setFormat(in.getFormat());
|
||||
algo->setOutputFormat(out);
|
||||
algo->setStatusFunction(std11::bind(&audio::drain::Process::generateStatus, this, std11::placeholders::_1, std11::placeholders::_2));
|
||||
algo->setStatusFunction([=](const etk::String& _origin, const etk::String& _status) { generateStatus(_origin, _status);});
|
||||
m_listAlgo.insert(m_listAlgo.begin()+_position, algo);
|
||||
DRAIN_VERBOSE("convert " << out.getFormat() << " -> " << in.getFormat());
|
||||
_position++;
|
||||
@@ -429,7 +427,7 @@ bool audio::drain::Process::processIn(void* _inData,
|
||||
size_t _inNbChunk,
|
||||
void* _outData,
|
||||
size_t _outNbChunk){
|
||||
void* outData = nullptr;
|
||||
void* outData = null;
|
||||
size_t outSize = 0;
|
||||
bool error = process(_inData, _inNbChunk, outData, outSize);
|
||||
if (outSize != _outNbChunk) {
|
||||
@@ -442,146 +440,215 @@ bool audio::drain::Process::processIn(void* _inData,
|
||||
return false;
|
||||
}
|
||||
|
||||
static void link(etk::FSNode& _node, const std::string& _first, const std::string& _op, const std::string& _second, bool _isLink=true) {
|
||||
static void link(ememory::SharedPtr<etk::io::Interface>& _io, const etk::String& _first, const etk::String& _op, const etk::String& _second, bool _isLink=true) {
|
||||
if (_op == "->") {
|
||||
if (_isLink) {
|
||||
_node << " " << _first << " -> " << _second << ";\n";
|
||||
*_io << " " << _first << " -> " << _second << ";\n";
|
||||
} else {
|
||||
_node << " " << _first << " -> " << _second << " [style=dashed];\n";
|
||||
*_io << " " << _first << " -> " << _second << " [style=dashed];\n";
|
||||
}
|
||||
} else if (_op == "<-") {
|
||||
_node << " " << _first << " -> " <<_second<< " [color=transparent];\n";
|
||||
*_io << " " << _first << " -> " <<_second<< " [color=transparent];\n";
|
||||
if (_isLink) {
|
||||
_node << " " << _second << " -> " << _first << " [constraint=false];\n";
|
||||
*_io << " " << _second << " -> " << _first << " [constraint=false];\n";
|
||||
} else {
|
||||
_node << " " << _second << " -> " << _first << " [constraint=false, style=dashed];\n";
|
||||
*_io << " " << _second << " -> " << _first << " [constraint=false, style=dashed];\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void audio::drain::Process::generateDot(etk::FSNode& _node, int32_t _offset, int32_t _basicID, std::string& _nameIn, std::string& _nameOut, bool _reserseGraph) {
|
||||
_node << " subgraph clusterNode_" << _basicID << "_process {\n";
|
||||
_node << " label=\"Drain::Process" << (_reserseGraph?"_R":"_N") << "\";\n";
|
||||
_node << " node [shape=ellipse];\n";
|
||||
void audio::drain::Process::generateDot(ememory::SharedPtr<etk::io::Interface>& _io,
|
||||
int32_t _offset,
|
||||
int32_t _basicID,
|
||||
etk::String& _nameIn,
|
||||
etk::String& _nameOut,
|
||||
bool _reserseGraph) {
|
||||
*_io << " subgraph clusterNode_" << _basicID << "_process {\n";
|
||||
*_io << " label=\"Drain::Process" << (_reserseGraph?"_R":"_N") << "\";\n";
|
||||
*_io << " node [shape=ellipse];\n";
|
||||
|
||||
if (_reserseGraph == false) {
|
||||
_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in";
|
||||
_node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat())
|
||||
// ----------------------
|
||||
// -- STEP 1 --
|
||||
// ----------------------
|
||||
_nameIn = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_in";
|
||||
*_io << " " << _nameIn << " [ label=\"format=" << etk::toString(getInputConfig().getFormat())
|
||||
<< "\\n freq=" << getInputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n";
|
||||
} else {
|
||||
_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out";
|
||||
_node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat())
|
||||
<< "\\n freq=" << getOutputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n";
|
||||
}
|
||||
std::string connectString = _nameIn;
|
||||
_node << " node [shape=box];\n";
|
||||
if (_reserseGraph == false) {
|
||||
<< "\\n channelMap=" << etk::toString(getInputConfig().getMap()) << "\\n in\" ];\n";
|
||||
// ----------------------
|
||||
// -- STEP 2 --
|
||||
// ----------------------
|
||||
etk::String connectString = _nameIn;
|
||||
*_io << " node [shape=box];\n";
|
||||
// ----------------------
|
||||
// -- STEP 3 --
|
||||
// ----------------------
|
||||
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||
if (m_listAlgo[iii] == nullptr) {
|
||||
if (m_listAlgo[iii] == null) {
|
||||
continue;
|
||||
}
|
||||
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
|
||||
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'\\nname='" << m_listAlgo[iii]->getName() << "'\" ];\n";
|
||||
link(_node, connectString, "->", connectStringSecond);
|
||||
etk::String connectStringSecond = "ALGO_" + etk::toString(_basicID) + "__" + etk::toString(iii);
|
||||
*_io << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'";
|
||||
if (m_listAlgo[iii]->getName() != "") {
|
||||
*_io << "\\nname='" << m_listAlgo[iii]->getName() << "'";
|
||||
}
|
||||
etk::String tmpDesc = m_listAlgo[iii]->getDotDesc();
|
||||
if (tmpDesc.size() != 0) {
|
||||
*_io << tmpDesc;
|
||||
}
|
||||
*_io << "\" ];\n";
|
||||
link(_io, connectString, "->", connectStringSecond);
|
||||
connectString = connectStringSecond;
|
||||
}
|
||||
// ----------------------
|
||||
// -- STEP 4 --
|
||||
// ----------------------
|
||||
*_io << " node [shape=ellipse];\n";
|
||||
// ----------------------
|
||||
// -- STEP 5 --
|
||||
// ----------------------
|
||||
_nameOut = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_out";
|
||||
*_io << " " << _nameOut << " [ label=\"format=" << etk::toString(getOutputConfig().getFormat())
|
||||
<< "\\n freq=" << getOutputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::toString(getOutputConfig().getMap()) << "\\n out\" ];\n";
|
||||
// ----------------------
|
||||
// -- STEP 6 --
|
||||
// ----------------------
|
||||
link(_io, connectString, "->", _nameOut);
|
||||
} else {
|
||||
// ----------------------
|
||||
// -- STEP 1 --
|
||||
// ----------------------
|
||||
_nameIn = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_out";
|
||||
*_io << " " << _nameIn << " [ label=\"format=" << etk::toString(getOutputConfig().getFormat())
|
||||
<< "\\n freq=" << getOutputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::toString(getOutputConfig().getMap()) << "\\n out\" ];\n";
|
||||
// ----------------------
|
||||
// -- STEP 2 --
|
||||
// ----------------------
|
||||
etk::String connectString = _nameIn;
|
||||
*_io << " node [shape=box];\n";
|
||||
// ----------------------
|
||||
// -- STEP 3 --
|
||||
// ----------------------
|
||||
for (int32_t iii=m_listAlgo.size()-1; iii>=0; --iii) {
|
||||
//for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||
if (m_listAlgo[iii] == null) {
|
||||
continue;
|
||||
}
|
||||
etk::String connectStringSecond = "ALGO_" + etk::toString(_basicID) + "__" + etk::toString(iii);
|
||||
*_io << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'";
|
||||
if (m_listAlgo[iii]->getName() != "") {
|
||||
*_io << "\\nname='" << m_listAlgo[iii]->getName() << "'";
|
||||
}
|
||||
etk::String tmpDesc = m_listAlgo[iii]->getDotDesc();
|
||||
if (tmpDesc.size() != 0) {
|
||||
*_io << tmpDesc;
|
||||
}
|
||||
*_io << "\" ];\n";
|
||||
//link(_io, connectStringSecond, "<-", connectString);
|
||||
link(_io, connectString, "<-", connectStringSecond);
|
||||
//link(_io, connectStringSecond, "->", connectString);
|
||||
connectString = connectStringSecond;
|
||||
}
|
||||
// ----------------------
|
||||
// -- STEP 4 --
|
||||
// ----------------------
|
||||
*_io << " node [shape=ellipse];\n";
|
||||
// ----------------------
|
||||
// -- STEP 5 --
|
||||
// ----------------------
|
||||
_nameOut = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_in";
|
||||
*_io << " " << _nameOut << " [ label=\"format=" << etk::toString(getInputConfig().getFormat())
|
||||
<< "\\n freq=" << getInputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::toString(getInputConfig().getMap()) << "\\n in\" ];\n";
|
||||
// ----------------------
|
||||
// -- STEP 6 --
|
||||
// ----------------------
|
||||
link(_io, connectString, "<-", _nameOut);
|
||||
}
|
||||
*_io << " }\n";
|
||||
}
|
||||
|
||||
void audio::drain::Process::generateDotProcess(ememory::SharedPtr<etk::io::Interface>& _io, int32_t _offset, int32_t _basicID, etk::String& _nameIn, etk::String& _nameOut, bool _reserseGraph) {
|
||||
*_io << " subgraph clusterNode_" << _basicID << "_process {\n";
|
||||
*_io << " label=\"Drain::Process" << (_reserseGraph?"_R":"_N") << "\";\n";
|
||||
*_io << " node [shape=ellipse];\n";
|
||||
|
||||
if (_reserseGraph == true) {
|
||||
_nameIn = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_in";
|
||||
*_io << " " << _nameIn << " [ label=\"format=" << etk::toString(getInputConfig().getFormat())
|
||||
<< "\\n freq=" << getInputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::toString(getInputConfig().getMap()) << "\\n in\" ];\n";
|
||||
} else {
|
||||
_nameIn = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_out";
|
||||
*_io << " " << _nameIn << " [ label=\"format=" << etk::toString(getOutputConfig().getFormat())
|
||||
<< "\\n freq=" << getOutputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::toString(getOutputConfig().getMap()) << "\\n out\" ];\n";
|
||||
}
|
||||
etk::String connectString = _nameIn;
|
||||
*_io << " node [shape=box];\n";
|
||||
if (_reserseGraph == false) {
|
||||
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||
if (m_listAlgo[iii] == null) {
|
||||
continue;
|
||||
}
|
||||
etk::String connectStringSecond = "ALGO_" + etk::toString(_basicID) + "__" + etk::toString(iii);
|
||||
*_io << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'";
|
||||
if (m_listAlgo[iii]->getName() != "") {
|
||||
*_io << "\\nname='" << m_listAlgo[iii]->getName() << "'";
|
||||
}
|
||||
etk::String tmpDesc = m_listAlgo[iii]->getDotDesc();
|
||||
if (tmpDesc.size() != 0) {
|
||||
*_io << tmpDesc;
|
||||
}
|
||||
*_io << "\" ];\n";
|
||||
link(_io, connectString, "->", connectStringSecond);
|
||||
connectString = connectStringSecond;
|
||||
}
|
||||
} else {
|
||||
//for (int32_t iii=m_listAlgo.size()-1; iii>=0; --iii) {
|
||||
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||
if (m_listAlgo[iii] == nullptr) {
|
||||
if (m_listAlgo[iii] == null) {
|
||||
continue;
|
||||
}
|
||||
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
|
||||
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'\\nname='" << m_listAlgo[iii]->getName() << "'\" ];\n";
|
||||
link(_node, connectStringSecond, "<-", connectString);
|
||||
etk::String connectStringSecond = "ALGO_" + etk::toString(_basicID) + "__" + etk::toString(iii);
|
||||
*_io << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'";
|
||||
if (m_listAlgo[iii]->getName() != "") {
|
||||
*_io << "\\nname='" << m_listAlgo[iii]->getName() << "'";
|
||||
}
|
||||
etk::String tmpDesc = m_listAlgo[iii]->getDotDesc();
|
||||
if (tmpDesc.size() != 0) {
|
||||
*_io << tmpDesc;
|
||||
}
|
||||
*_io << "\" ];\n";
|
||||
link(_io, connectStringSecond, "<-", connectString);
|
||||
connectString = connectStringSecond;
|
||||
}
|
||||
}
|
||||
_node << " node [shape=ellipse];\n";
|
||||
if (_reserseGraph == false) {
|
||||
_nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out";
|
||||
_node << " " << _nameOut << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat())
|
||||
<< "\\n freq=" << getOutputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n";
|
||||
} else {
|
||||
_nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in";
|
||||
_node << " " << _nameOut << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat())
|
||||
<< "\\n freq=" << getInputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n";
|
||||
}
|
||||
if (_reserseGraph == false) {
|
||||
link(_node, connectString, "->", _nameOut);
|
||||
} else {
|
||||
link(_node, _nameOut, "<-", connectString);
|
||||
}
|
||||
_node << " }\n";
|
||||
}
|
||||
|
||||
void audio::drain::Process::generateDotProcess(etk::FSNode& _node, int32_t _offset, int32_t _basicID, std::string& _nameIn, std::string& _nameOut, bool _reserseGraph) {
|
||||
_node << " subgraph clusterNode_" << _basicID << "_process {\n";
|
||||
_node << " label=\"Drain::Process" << (_reserseGraph?"_R":"_N") << "\";\n";
|
||||
_node << " node [shape=ellipse];\n";
|
||||
|
||||
*_io << " node [shape=ellipse];\n";
|
||||
if (_reserseGraph == true) {
|
||||
_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in";
|
||||
_node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat())
|
||||
<< "\\n freq=" << getInputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n";
|
||||
} else {
|
||||
_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out";
|
||||
_node << " " << _nameIn << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat())
|
||||
<< "\\n freq=" << getOutputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n";
|
||||
}
|
||||
std::string connectString = _nameIn;
|
||||
_node << " node [shape=box];\n";
|
||||
if (_reserseGraph == false) {
|
||||
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||
if (m_listAlgo[iii] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
|
||||
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'\\nname='" << m_listAlgo[iii]->getName() << "'\" ];\n";
|
||||
link(_node, connectString, "->", connectStringSecond);
|
||||
connectString = connectStringSecond;
|
||||
}
|
||||
} else {
|
||||
//for (int32_t iii=m_listAlgo.size()-1; iii>=0; --iii) {
|
||||
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||
if (m_listAlgo[iii] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii);
|
||||
_node << " " << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'\\nname='" << m_listAlgo[iii]->getName() << "'\" ];\n";
|
||||
link(_node, connectStringSecond, "<-", connectString);
|
||||
connectString = connectStringSecond;
|
||||
}
|
||||
}
|
||||
_node << " node [shape=ellipse];\n";
|
||||
if (_reserseGraph == true) {
|
||||
_nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out";
|
||||
_node << " " << _nameOut << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat())
|
||||
_nameOut = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_out";
|
||||
*_io << " " << _nameOut << " [ label=\"format=" << etk::toString(getOutputConfig().getFormat())
|
||||
<< "\\n freq=" << getOutputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n";
|
||||
<< "\\n channelMap=" << etk::toString(getOutputConfig().getMap()) << "\\n out\" ];\n";
|
||||
} else {
|
||||
_nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in";
|
||||
_node << " " << _nameOut << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat())
|
||||
_nameOut = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_in";
|
||||
*_io << " " << _nameOut << " [ label=\"format=" << etk::toString(getInputConfig().getFormat())
|
||||
<< "\\n freq=" << getInputConfig().getFrequency()
|
||||
<< "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n";
|
||||
<< "\\n channelMap=" << etk::toString(getInputConfig().getMap()) << "\\n in\" ];\n";
|
||||
}
|
||||
if (_reserseGraph == false) {
|
||||
link(_node, connectString, "->", _nameOut);
|
||||
link(_io, connectString, "->", _nameOut);
|
||||
} else {
|
||||
link(_node, _nameOut, "<-", connectString);
|
||||
link(_io, _nameOut, "<-", connectString);
|
||||
}
|
||||
_node << " }\n";
|
||||
*_io << " }\n";
|
||||
}
|
||||
|
||||
|
||||
void audio::drain::Process::generateStatus(const std::string& _origin, const std::string& _status) {
|
||||
if (m_statusFunction != nullptr) {
|
||||
void audio::drain::Process::generateStatus(const etk::String& _origin, const etk::String& _status) {
|
||||
if (m_statusFunction != null) {
|
||||
m_statusFunction(_origin, _status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
/** @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
|
||||
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_PROCESS_H__
|
||||
#define __AUDIO_DRAIN_ALGO_PROCESS_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include <audio/format.h>
|
||||
#include <audio/channel.h>
|
||||
#include <audio/drain/Algo.h>
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/io/Interface.hpp>
|
||||
#include <audio/format.hpp>
|
||||
#include <audio/channel.hpp>
|
||||
#include <audio/drain/Algo.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain{
|
||||
typedef std11::function<void (const std::string& _origin, const std::string& _status)> statusFunction;
|
||||
typedef etk::Function<void (const etk::String& _origin, const etk::String& _status)> statusFunction;
|
||||
class Process {
|
||||
protected:
|
||||
std::vector<int8_t> m_data; //!< temporary overlap output buffer (change size of the output data)
|
||||
etk::Vector<int8_t> m_data; //!< temporary overlap output buffer (change size of the output data)
|
||||
public:
|
||||
Process();
|
||||
virtual ~Process();
|
||||
@@ -97,10 +93,10 @@ namespace audio {
|
||||
m_outputConfig = _interface;
|
||||
}
|
||||
protected:
|
||||
std::vector<std11::shared_ptr<drain::Algo> > m_listAlgo;
|
||||
etk::Vector<ememory::SharedPtr<drain::Algo> > m_listAlgo;
|
||||
public:
|
||||
void pushBack(const std11::shared_ptr<drain::Algo>& _algo);
|
||||
void pushFront(const std11::shared_ptr<drain::Algo>& _algo);
|
||||
void pushBack(ememory::SharedPtr<drain::Algo> _algo);
|
||||
void pushFront(ememory::SharedPtr<drain::Algo> _algo);
|
||||
void clear() {
|
||||
m_isConfigured = false;
|
||||
m_listAlgo.clear();
|
||||
@@ -108,61 +104,61 @@ namespace audio {
|
||||
size_t size() {
|
||||
return m_listAlgo.size();
|
||||
}
|
||||
std::vector<std11::shared_ptr<drain::Algo> >::iterator begin() {
|
||||
etk::Vector<ememory::SharedPtr<drain::Algo>>::Iterator begin() {
|
||||
return m_listAlgo.begin();
|
||||
}
|
||||
std::vector<std11::shared_ptr<drain::Algo> >::iterator end() {
|
||||
etk::Vector<ememory::SharedPtr<drain::Algo>>::Iterator end() {
|
||||
return m_listAlgo.end();
|
||||
}
|
||||
std11::shared_ptr<drain::Algo> operator[](int32_t _id) {
|
||||
ememory::SharedPtr<drain::Algo> operator[](int32_t _id) {
|
||||
return m_listAlgo[_id];
|
||||
}
|
||||
|
||||
template<typename T> std11::shared_ptr<T> get(const std::string& _name) {
|
||||
template<typename T> ememory::SharedPtr<T> get(const etk::String& _name) {
|
||||
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||
if (m_listAlgo[iii] == nullptr) {
|
||||
if (m_listAlgo[iii] == null) {
|
||||
continue;
|
||||
}
|
||||
if (m_listAlgo[iii]->getName() == _name) {
|
||||
return std11::dynamic_pointer_cast<T>(m_listAlgo[iii]);
|
||||
return ememory::dynamicPointerCast<T>(m_listAlgo[iii]);
|
||||
}
|
||||
}
|
||||
return std11::shared_ptr<T>();
|
||||
return ememory::SharedPtr<T>();
|
||||
}
|
||||
template<typename T> std11::shared_ptr<const T> get(const std::string& _name) const {
|
||||
template<typename T> ememory::SharedPtr<const T> get(const etk::String& _name) const {
|
||||
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||
if (m_listAlgo[iii] == nullptr) {
|
||||
if (m_listAlgo[iii] == null) {
|
||||
continue;
|
||||
}
|
||||
if (m_listAlgo[iii]->getName() == _name) {
|
||||
return std11::dynamic_pointer_cast<T>(m_listAlgo[iii]);
|
||||
return ememory::dynamicPointerCast<T>(m_listAlgo[iii]);
|
||||
}
|
||||
}
|
||||
return std11::shared_ptr<const T>();
|
||||
return ememory::SharedPtr<const T>();
|
||||
}
|
||||
template<typename T> std11::shared_ptr<T> get(int32_t _id) {
|
||||
return std11::dynamic_pointer_cast<T>(m_listAlgo[_id]);
|
||||
template<typename T> ememory::SharedPtr<T> get(int32_t _id) {
|
||||
return ememory::dynamicPointerCast<T>(m_listAlgo[_id]);
|
||||
}
|
||||
template<typename T> void removeIfFirst() {
|
||||
if (m_listAlgo.size() > 0) {
|
||||
std11::shared_ptr<T> algoEP = get<T>(0);
|
||||
if (algoEP != nullptr) {
|
||||
ememory::SharedPtr<T> algoEP = get<T>(0);
|
||||
if (algoEP != null) {
|
||||
m_listAlgo.erase(m_listAlgo.begin());
|
||||
}
|
||||
}
|
||||
}
|
||||
template<typename T> void removeIfLast() {
|
||||
if (m_listAlgo.size() > 0) {
|
||||
std11::shared_ptr<T> algoEP = get<T>(m_listAlgo.size()-1);
|
||||
if (algoEP != nullptr) {
|
||||
ememory::SharedPtr<T> algoEP = get<T>(m_listAlgo.size()-1);
|
||||
if (algoEP != null) {
|
||||
m_listAlgo.erase(m_listAlgo.begin()+m_listAlgo.size()-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
template<typename T> bool hasType() {
|
||||
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||
std11::shared_ptr<T> tmp = std11::dynamic_pointer_cast<T>(m_listAlgo[iii]);
|
||||
if (tmp != nullptr) {
|
||||
ememory::SharedPtr<T> tmp = ememory::dynamicPointerCast<T>(m_listAlgo[iii]);
|
||||
if (tmp != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -171,7 +167,7 @@ namespace audio {
|
||||
private:
|
||||
statusFunction m_statusFunction;
|
||||
public:
|
||||
void generateStatus(const std::string& _origin, const std::string& _status);
|
||||
void generateStatus(const etk::String& _origin, const etk::String& _status);
|
||||
void setStatusFunction(statusFunction _newFunction);
|
||||
private:
|
||||
bool m_isConfigured;
|
||||
@@ -182,11 +178,10 @@ namespace audio {
|
||||
void displayAlgo();
|
||||
void updateAlgo(size_t _position);
|
||||
public:
|
||||
void generateDot(etk::FSNode& _node, int32_t _offset, int32_t _basicID, std::string& _nameIn, std::string& _nameOut, bool _reserseGraph);
|
||||
void generateDot(ememory::SharedPtr<etk::io::Interface>& _io, int32_t _offset, int32_t _basicID, etk::String& _nameIn, etk::String& _nameOut, bool _reserseGraph);
|
||||
// TODO : Remove this one when we find a good way to do it ...
|
||||
void generateDotProcess(etk::FSNode& _node, int32_t _offset, int32_t _basicID, std::string& _nameIn, std::string& _nameOut, bool _reserseGraph);
|
||||
void generateDotProcess(ememory::SharedPtr<etk::io::Interface>& _io, int32_t _offset, int32_t _basicID, etk::String& _nameIn, etk::String& _nameOut, bool _reserseGraph);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,19 +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)
|
||||
*/
|
||||
|
||||
#include <audio/drain/Resampler.h>
|
||||
#include <iostream>
|
||||
#include <audio/drain/debug.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Resampler"
|
||||
#include <audio/drain/Resampler.hpp>
|
||||
#include <audio/drain/debug.hpp>
|
||||
|
||||
audio::drain::Resampler::Resampler() :
|
||||
#ifdef HAVE_SPEEX_DSP_RESAMPLE
|
||||
m_speexResampler(nullptr),
|
||||
m_speexResampler(null),
|
||||
#endif
|
||||
m_positionRead(0),
|
||||
m_positionWrite(0) {
|
||||
@@ -23,21 +19,21 @@ audio::drain::Resampler::Resampler() :
|
||||
void audio::drain::Resampler::init() {
|
||||
audio::drain::Algo::init();
|
||||
m_type = "Resampler";
|
||||
m_supportedFormat.push_back(audio::format_int16);
|
||||
m_supportedFormat.pushBack(audio::format_int16);
|
||||
m_residualTimeInResampler = audio::Duration(0);
|
||||
}
|
||||
|
||||
std11::shared_ptr<audio::drain::Resampler> audio::drain::Resampler::create() {
|
||||
std11::shared_ptr<audio::drain::Resampler> tmp(new audio::drain::Resampler());
|
||||
ememory::SharedPtr<audio::drain::Resampler> audio::drain::Resampler::create() {
|
||||
ememory::SharedPtr<audio::drain::Resampler> tmp(ETK_NEW(audio::drain::Resampler));
|
||||
tmp->init();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
audio::drain::Resampler::~Resampler() {
|
||||
#ifdef HAVE_SPEEX_DSP_RESAMPLE
|
||||
if (m_speexResampler != nullptr) {
|
||||
if (m_speexResampler != null) {
|
||||
speex_resampler_destroy(m_speexResampler);
|
||||
m_speexResampler = nullptr;
|
||||
m_speexResampler = null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -68,9 +64,9 @@ void audio::drain::Resampler::configurationChange() {
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_SPEEX_DSP_RESAMPLE
|
||||
if (m_speexResampler != nullptr) {
|
||||
if (m_speexResampler != null) {
|
||||
speex_resampler_destroy(m_speexResampler);
|
||||
m_speexResampler = nullptr;
|
||||
m_speexResampler = null;
|
||||
}
|
||||
int err = 0;
|
||||
DRAIN_WARNING("Create resampler for : " << m_input << " to " << m_output);
|
||||
@@ -99,7 +95,7 @@ bool audio::drain::Resampler::process(audio::Time& _time,
|
||||
_outputNbChunk = _inputNbChunk;
|
||||
return true;
|
||||
}
|
||||
if (_input == nullptr) {
|
||||
if (_input == null) {
|
||||
_output = &(m_outputData[0]);
|
||||
_outputNbChunk = 0;
|
||||
DRAIN_ERROR("null pointer input ... ");
|
||||
@@ -122,7 +118,7 @@ bool audio::drain::Resampler::process(audio::Time& _time,
|
||||
|
||||
m_outputData.resize(_outputNbChunk*m_output.getMap().size()*m_formatSize*16);
|
||||
_output = &(m_outputData[0]);
|
||||
if (m_speexResampler == nullptr) {
|
||||
if (m_speexResampler == null) {
|
||||
DRAIN_ERROR(" No speex resampler");
|
||||
return false;
|
||||
}
|
||||
@@ -149,12 +145,12 @@ bool audio::drain::Resampler::process(audio::Time& _time,
|
||||
_outputNbChunk = nbChunkOutput;
|
||||
DRAIN_VERBOSE(" process chunk=" << nbChunkInput << " out=" << nbChunkOutput);
|
||||
audio::Duration outTime(0, (int64_t(_outputNbChunk)*1000000000LL) / int64_t(m_output.getFrequency()));
|
||||
DRAIN_VERBOSE("convert " << _inputNbChunk << " ==> " << _outputNbChunk << " " << inTime.count() << " => " << outTime.count());
|
||||
DRAIN_VERBOSE("convert " << _inputNbChunk << " ==> " << _outputNbChunk << " " << inTime << " => " << outTime);
|
||||
// correct time :
|
||||
m_residualTimeInResampler -= outTime;
|
||||
/*
|
||||
if (m_residualTimeInResampler.count() < 0) {
|
||||
DRAIN_TODO("manage this case ... residual time in resampler : " << m_residualTimeInResampler.count() << "ns");
|
||||
if (m_residualTimeInResampler.get() < 0) {
|
||||
DRAIN_TODO("manage this case ... residual time in resampler : " << m_residualTimeInResampler << "ns");
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
|
||||
@@ -1,17 +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
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_RESAMPLER_H__
|
||||
#define __AUDIO_DRAIN_ALGO_RESAMPLER_H__
|
||||
|
||||
#include <audio/drain/Algo.h>
|
||||
#include <audio/drain/Algo.hpp>
|
||||
#ifdef HAVE_SPEEX_DSP_RESAMPLE
|
||||
#include <speex/speex_resampler.h>
|
||||
#endif
|
||||
#include <memory>
|
||||
#include <ememory/memory.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain {
|
||||
@@ -31,7 +29,7 @@ namespace audio {
|
||||
Resampler();
|
||||
void init();
|
||||
public:
|
||||
static std11::shared_ptr<audio::drain::Resampler> create();
|
||||
static ememory::SharedPtr<audio::drain::Resampler> create();
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
@@ -50,4 +48,3 @@ namespace audio {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,32 +1,30 @@
|
||||
/** @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/drain/Volume.h>
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <audio/drain/debug.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Volume"
|
||||
#include <audio/drain/Volume.hpp>
|
||||
extern "C" {
|
||||
#include <math.h>
|
||||
}
|
||||
#include <audio/drain/debug.hpp>
|
||||
|
||||
audio::drain::Volume::Volume() :
|
||||
m_volumeAppli(1.0f),
|
||||
m_functionConvert(nullptr) {
|
||||
m_functionConvert(null) {
|
||||
|
||||
}
|
||||
|
||||
void audio::drain::Volume::init() {
|
||||
audio::drain::Algo::init();
|
||||
m_type = "Volume";
|
||||
m_supportedFormat.push_back(audio::format_int16);
|
||||
m_supportedFormat.push_back(audio::format_int16_on_int32);
|
||||
m_supportedFormat.pushBack(audio::format_int16);
|
||||
m_supportedFormat.pushBack(audio::format_int16_on_int32);
|
||||
}
|
||||
|
||||
std11::shared_ptr<audio::drain::Volume> audio::drain::Volume::create() {
|
||||
std11::shared_ptr<audio::drain::Volume> tmp(new audio::drain::Volume());
|
||||
ememory::SharedPtr<audio::drain::Volume> audio::drain::Volume::create() {
|
||||
ememory::SharedPtr<audio::drain::Volume> tmp(ETK_NEW(audio::drain::Volume));
|
||||
tmp->init();
|
||||
return tmp;
|
||||
}
|
||||
@@ -40,7 +38,7 @@ static int32_t neareastsss(float _val) {
|
||||
while (_val > float(1<<out)) {
|
||||
out++;
|
||||
}
|
||||
return std::min(16,out);
|
||||
return etk::min(16,out);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +49,13 @@ static void convert__int16__to__int16(void* _input, void* _output, size_t _nbSam
|
||||
out[iii] = int16_t((int32_t(in[iii]) * int32_t(_volumeCoef)) >> _volumeDecalage);
|
||||
}
|
||||
}
|
||||
static void convert__int16__to__float(void* _input, void* _output, size_t _nbSample, int32_t _volumeCoef, int32_t _volumeDecalage, float _volumeAppli) {
|
||||
int16_t* in = static_cast<int16_t*>(_input);
|
||||
float* out = static_cast<float*>(_output);
|
||||
for (size_t iii=0; iii<_nbSample; ++iii) {
|
||||
out[iii] = double((int32_t(in[iii]) * int32_t(_volumeCoef)) >> _volumeDecalage) * 0.00003051757;
|
||||
}
|
||||
}
|
||||
|
||||
static void convert__int16__to__int32(void* _input, void* _output, size_t _nbSample, int32_t _volumeCoef, int32_t _volumeDecalage, float _volumeAppli) {
|
||||
int16_t* in = static_cast<int16_t*>(_input);
|
||||
@@ -104,7 +109,7 @@ void audio::drain::Volume::configurationChange() {
|
||||
DRAIN_DEBUG("Use converter : 'convert__int16__to__int32' for " << m_input.getFormat() << " to " << m_output.getFormat());
|
||||
break;
|
||||
case audio::format_float:
|
||||
DRAIN_ERROR("Impossible case 1");
|
||||
m_functionConvert = &convert__int16__to__float;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -157,7 +162,7 @@ void audio::drain::Volume::volumeChange() {
|
||||
float volumedB = 0.0f;
|
||||
bool mute = false;
|
||||
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
|
||||
if (m_volumeList[iii] == nullptr) {
|
||||
if (m_volumeList[iii] == null) {
|
||||
continue;
|
||||
}
|
||||
if (m_volumeList[iii]->getMute() == true) {
|
||||
@@ -176,7 +181,7 @@ void audio::drain::Volume::volumeChange() {
|
||||
#if (defined(__STDCPP_LLVM__) || __cplusplus < 201103L)
|
||||
m_volumeAppli = pow(10.0f, volumedB/20.0f);
|
||||
#else
|
||||
m_volumeAppli = std::pow(10.0f, volumedB/20.0f);
|
||||
m_volumeAppli = etk::pow(10.0f, volumedB/20.0f);
|
||||
#endif
|
||||
switch (m_input.getFormat()) {
|
||||
default:
|
||||
@@ -208,7 +213,14 @@ void audio::drain::Volume::volumeChange() {
|
||||
m_volumeDecalage = 0;
|
||||
break;
|
||||
case audio::format_float:
|
||||
DRAIN_ERROR("Impossible case 1");
|
||||
if (m_volumeAppli <= 1.0f) {
|
||||
m_volumeCoef = m_volumeAppli*float(1<<16);
|
||||
m_volumeDecalage = 16;
|
||||
} else {
|
||||
int32_t neareast = neareastsss(m_volumeAppli);
|
||||
m_volumeCoef = m_volumeAppli*float(1<<(16-neareast));
|
||||
m_volumeDecalage = 16-neareast;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -283,32 +295,32 @@ void audio::drain::Volume::volumeChange() {
|
||||
}
|
||||
|
||||
|
||||
std::vector<audio::format> audio::drain::Volume::getFormatSupportedInput() {
|
||||
std::vector<audio::format> tmp;
|
||||
etk::Vector<audio::format> audio::drain::Volume::getFormatSupportedInput() {
|
||||
etk::Vector<audio::format> tmp;
|
||||
if (m_output.getFormat() == audio::format_float) {
|
||||
tmp.push_back(audio::format_float);
|
||||
tmp.pushBack(audio::format_float);
|
||||
}
|
||||
if ( m_output.getFormat() == audio::format_int16
|
||||
|| m_output.getFormat() == audio::format_int16_on_int32
|
||||
|| m_output.getFormat() == audio::format_int32) {
|
||||
tmp.push_back(audio::format_int16);
|
||||
tmp.push_back(audio::format_int16_on_int32);
|
||||
tmp.push_back(audio::format_int32);
|
||||
tmp.pushBack(audio::format_int16);
|
||||
tmp.pushBack(audio::format_int16_on_int32);
|
||||
tmp.pushBack(audio::format_int32);
|
||||
}
|
||||
return tmp;
|
||||
};
|
||||
|
||||
std::vector<audio::format> audio::drain::Volume::getFormatSupportedOutput() {
|
||||
std::vector<audio::format> tmp;
|
||||
etk::Vector<audio::format> audio::drain::Volume::getFormatSupportedOutput() {
|
||||
etk::Vector<audio::format> tmp;
|
||||
if (m_input.getFormat() == audio::format_float) {
|
||||
tmp.push_back(audio::format_float);
|
||||
tmp.pushBack(audio::format_float);
|
||||
}
|
||||
if ( m_input.getFormat() == audio::format_int16
|
||||
|| m_input.getFormat() == audio::format_int16_on_int32
|
||||
|| m_input.getFormat() == audio::format_int32) {
|
||||
tmp.push_back(audio::format_int16);
|
||||
tmp.push_back(audio::format_int16_on_int32);
|
||||
tmp.push_back(audio::format_int32);
|
||||
tmp.pushBack(audio::format_int16);
|
||||
tmp.pushBack(audio::format_int16_on_int32);
|
||||
tmp.pushBack(audio::format_int32);
|
||||
}
|
||||
return tmp;
|
||||
};
|
||||
@@ -326,7 +338,7 @@ bool audio::drain::Volume::process(audio::Time& _time,
|
||||
_outputNbChunk = _inputNbChunk;
|
||||
return true;
|
||||
}
|
||||
if (_input == nullptr) {
|
||||
if (_input == null) {
|
||||
_output = &(m_outputData[0]);
|
||||
_outputNbChunk = 0;
|
||||
DRAIN_ERROR("null pointer input ... ");
|
||||
@@ -335,7 +347,7 @@ bool audio::drain::Volume::process(audio::Time& _time,
|
||||
_outputNbChunk = _inputNbChunk;
|
||||
m_outputData.resize(_outputNbChunk*m_input.getMap().size()*m_formatSize);
|
||||
_output = &(m_outputData[0]);
|
||||
if (m_functionConvert == nullptr) {
|
||||
if (m_functionConvert == null) {
|
||||
DRAIN_ERROR("null function ptr");
|
||||
return false;
|
||||
}
|
||||
@@ -344,12 +356,12 @@ bool audio::drain::Volume::process(audio::Time& _time,
|
||||
return true;
|
||||
}
|
||||
|
||||
void audio::drain::Volume::addVolumeStage(const std11::shared_ptr<audio::drain::VolumeElement>& _volume) {
|
||||
if (_volume == nullptr) {
|
||||
void audio::drain::Volume::addVolumeStage(const ememory::SharedPtr<audio::drain::VolumeElement>& _volume) {
|
||||
if (_volume == null) {
|
||||
return;
|
||||
}
|
||||
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
|
||||
if (m_volumeList[iii] == nullptr) {
|
||||
if (m_volumeList[iii] == null) {
|
||||
continue;
|
||||
}
|
||||
if (m_volumeList[iii] == _volume) {
|
||||
@@ -360,18 +372,18 @@ void audio::drain::Volume::addVolumeStage(const std11::shared_ptr<audio::drain::
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_volumeList.push_back(_volume);
|
||||
m_volumeList.pushBack(_volume);
|
||||
volumeChange();
|
||||
}
|
||||
|
||||
bool audio::drain::Volume::setParameter(const std::string& _parameter, const std::string& _value) {
|
||||
bool audio::drain::Volume::setParameter(const etk::String& _parameter, const etk::String& _value) {
|
||||
if (_parameter == "FLOW") {
|
||||
// set Volume ...
|
||||
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
|
||||
if (m_volumeList[iii] == nullptr) {
|
||||
for (auto &it : m_volumeList) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
if (m_volumeList[iii]->getName() == "FLOW") {
|
||||
if (it->getName() == "FLOW") {
|
||||
float value = 0;
|
||||
if (sscanf(_value.c_str(), "%fdB", &value) != 1) {
|
||||
return false;
|
||||
@@ -381,7 +393,7 @@ bool audio::drain::Volume::setParameter(const std::string& _parameter, const std
|
||||
DRAIN_ERROR("Can not set volume ... : '" << _parameter << "' out of range : [-300..300]");
|
||||
return false;
|
||||
}
|
||||
m_volumeList[iii]->setVolume(value);
|
||||
it->setVolume(value);
|
||||
DRAIN_DEBUG("Set volume : FLOW = " << value << " dB (from:" << _value << ")");
|
||||
volumeChange();
|
||||
return true;
|
||||
@@ -392,15 +404,15 @@ bool audio::drain::Volume::setParameter(const std::string& _parameter, const std
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string audio::drain::Volume::getParameter(const std::string& _parameter) const {
|
||||
etk::String audio::drain::Volume::getParameter(const etk::String& _parameter) const {
|
||||
if (_parameter == "FLOW") {
|
||||
// set Volume ...
|
||||
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
|
||||
if (m_volumeList[iii] == nullptr) {
|
||||
for (auto &it : m_volumeList) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
if (m_volumeList[iii]->getName() == "FLOW") {
|
||||
return etk::to_string(m_volumeList[iii]->getVolume()) + "dB";
|
||||
if (it->getName() == "FLOW") {
|
||||
return etk::toString(it->getVolume()) + "dB";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -408,14 +420,14 @@ std::string audio::drain::Volume::getParameter(const std::string& _parameter) co
|
||||
return "[ERROR]";
|
||||
}
|
||||
|
||||
std::string audio::drain::Volume::getParameterProperty(const std::string& _parameter) const {
|
||||
etk::String audio::drain::Volume::getParameterProperty(const etk::String& _parameter) const {
|
||||
if (_parameter == "FLOW") {
|
||||
// set Volume ...
|
||||
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
|
||||
if (m_volumeList[iii] == nullptr) {
|
||||
for (auto &it : m_volumeList) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
if (m_volumeList[iii]->getName() == "FLOW") {
|
||||
if (it->getName() == "FLOW") {
|
||||
return "[-300..300]dB";
|
||||
}
|
||||
}
|
||||
@@ -424,3 +436,16 @@ std::string audio::drain::Volume::getParameterProperty(const std::string& _param
|
||||
return "[ERROR]";
|
||||
}
|
||||
|
||||
etk::String audio::drain::Volume::getDotDesc() {
|
||||
etk::String out = audio::drain::Algo::getDotDesc();
|
||||
for (auto &it : m_volumeList) {
|
||||
if (it == null) {
|
||||
continue;
|
||||
}
|
||||
out += "\\n" + it->getName() + "=" + etk::toString(it->getVolume()) + "dB";
|
||||
if (it->getMute() == true) {
|
||||
out += " MUTE";
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,31 @@
|
||||
/** @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
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_VOLUME_H__
|
||||
#define __AUDIO_DRAIN_ALGO_VOLUME_H__
|
||||
|
||||
#include <audio/drain/Algo.h>
|
||||
#include <audio/drain/Algo.hpp>
|
||||
#ifdef HAVE_SPEEX_DSP_RESAMPLE
|
||||
#include <speex/speex_resampler.h>
|
||||
#endif
|
||||
#include <memory>
|
||||
#include <ememory/memory.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain {
|
||||
// data structure.
|
||||
class VolumeElement {
|
||||
public:
|
||||
VolumeElement(const std::string& _name="ERROR-VOLUME-NAME", float _volumedB=0.0f) :
|
||||
VolumeElement(const etk::String& _name="ERROR-VOLUME-NAME", float _volumedB=0.0f) :
|
||||
m_name(_name),
|
||||
m_volumedB(_volumedB),
|
||||
m_mute(false) {
|
||||
|
||||
}
|
||||
private:
|
||||
std::string m_name;
|
||||
etk::String m_name;
|
||||
public:
|
||||
std::string getName() const {
|
||||
etk::String getName() const {
|
||||
return m_name;
|
||||
}
|
||||
private:
|
||||
@@ -56,7 +54,7 @@ namespace audio {
|
||||
// TODO: Manage set volume
|
||||
class Volume : public audio::drain::Algo {
|
||||
private:
|
||||
std::vector<std11::shared_ptr<drain::VolumeElement> > m_volumeList;
|
||||
etk::Vector<ememory::SharedPtr<drain::VolumeElement> > m_volumeList;
|
||||
// for float input :
|
||||
float m_volumeAppli;
|
||||
// for integer input :
|
||||
@@ -71,7 +69,7 @@ namespace audio {
|
||||
Volume();
|
||||
void init();
|
||||
public:
|
||||
static std11::shared_ptr<Volume> create();
|
||||
static ememory::SharedPtr<Volume> create();
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
@@ -85,17 +83,18 @@ namespace audio {
|
||||
void*& _output,
|
||||
size_t& _outputNbChunk);
|
||||
public:
|
||||
virtual std::vector<audio::format> getFormatSupportedInput();
|
||||
virtual std::vector<audio::format> getFormatSupportedOutput();
|
||||
virtual etk::Vector<audio::format> getFormatSupportedInput();
|
||||
virtual etk::Vector<audio::format> getFormatSupportedOutput();
|
||||
public:
|
||||
virtual void addVolumeStage(const std11::shared_ptr<drain::VolumeElement>& _volume);
|
||||
virtual bool setParameter(const std::string& _parameter, const std::string& _value);
|
||||
virtual std::string getParameter(const std::string& _parameter) const;
|
||||
virtual std::string getParameterProperty(const std::string& _parameter) const;
|
||||
virtual void addVolumeStage(const ememory::SharedPtr<drain::VolumeElement>& _volume);
|
||||
virtual bool setParameter(const etk::String& _parameter, const etk::String& _value);
|
||||
virtual etk::String getParameter(const etk::String& _parameter) const;
|
||||
virtual etk::String getParameterProperty(const etk::String& _parameter) const;
|
||||
public:
|
||||
void volumeChange();
|
||||
public:
|
||||
virtual etk::String getDotDesc();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,12 +1,9 @@
|
||||
/** @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"
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ ""
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
/** @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
|
||||
|
||||
#ifndef __AUDIO_DRAIN_ALGO_CORE_H__
|
||||
#define __AUDIO_DRAIN_ALGO_CORE_H__
|
||||
|
||||
#include <string>
|
||||
#include <audio/format.h>
|
||||
#include <audio/drain/channel.h>
|
||||
#include <chrono>
|
||||
#include <etk/String.hpp>
|
||||
#include <audio/format.hpp>
|
||||
#include <audio/drain/channel.hpp>
|
||||
#include <echrono/Steady.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain {
|
||||
@@ -27,19 +25,18 @@ namespace audio {
|
||||
* @param[in] _name Name of the Algorithm.
|
||||
* @return Instanciate algorithm
|
||||
*/
|
||||
drain::Algo* createAlgo(const std::string& _name);
|
||||
drain::Algo* createAlgo(const etk::String& _name);
|
||||
/**
|
||||
* @brief Add a Factory Algorithm in the internal List (static for all instance)
|
||||
* @param[in] _name Name of the Algorithm.
|
||||
* @param[in] _functor Function of the factory
|
||||
*/
|
||||
void addAlgoFactory(const std::string& _name, std::function<drain::Algo*(void)> _functor);
|
||||
void addAlgoFactory(const etk::String& _name, etk::Function<drain::Algo*(void)> _functor);
|
||||
/**
|
||||
* @brief Remove a Factory Algorithm in the internal List (static for all instance)
|
||||
* @param[in] _name Name of the Algorithm.
|
||||
*/
|
||||
void RmAlgoFactory(const std::string& _name);
|
||||
void RmAlgoFactory(const etk::String& _name);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,13 +1,13 @@
|
||||
/** @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/drain/debug.h>
|
||||
#include <audio/drain/debug.hpp>
|
||||
|
||||
|
||||
int32_t audio::drain::getLogId() {
|
||||
static int32_t g_val = etk::log::registerInstance("audio-drain");
|
||||
static int32_t g_val = elog::registerInstance("audio-drain");
|
||||
return g_val;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/** @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)
|
||||
*/
|
||||
|
||||
#ifndef __AUDIO_DRAIN_DEBUG_H__
|
||||
#define __AUDIO_DRAIN_DEBUG_H__
|
||||
|
||||
#include <etk/log.h>
|
||||
#include <elog/log.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace drain {
|
||||
int32_t getLogId();
|
||||
}
|
||||
}
|
||||
#define DRAIN_BASE(info,data) TK_LOG_BASE(audio::drain::getLogId(),info,data)
|
||||
#define DRAIN_BASE(info,data) ELOG_BASE(audio::drain::getLogId(),info,data)
|
||||
|
||||
#define DRAIN_CRITICAL(data) DRAIN_BASE(1, data)
|
||||
#define DRAIN_ERROR(data) DRAIN_BASE(2, data)
|
||||
@@ -1,9 +1,7 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD 3 clauses (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#ifdef __AUDIO_DRAIN_DEBUG_H__
|
||||
1
authors.txt
Normal file
1
authors.txt
Normal file
@@ -0,0 +1 @@
|
||||
MR Edouard DUPIN <yui.heero@gmail.com>
|
||||
@@ -1,89 +0,0 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
project(audio_drain)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
## Find catkin macros and libraries
|
||||
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
|
||||
## is used, also find other catkin packages
|
||||
find_package(catkin REQUIRED COMPONENTS
|
||||
etk
|
||||
audio
|
||||
)
|
||||
|
||||
find_library(LIB_SPEEX_DSP libspeexdsp.a)
|
||||
find_library(SPEEX_DSP speexdsp)
|
||||
|
||||
###################################
|
||||
## catkin specific configuration ##
|
||||
###################################
|
||||
## The catkin_package macro generates cmake config files for your package
|
||||
## Declare things to be passed to dependent projects
|
||||
## INCLUDE_DIRS: uncomment this if you package contains header files
|
||||
## LIBRARIES: libraries you create in this project that dependent projects also need
|
||||
## CATKIN_DEPENDS: catkin_packages dependent projects also need
|
||||
## DEPENDS: system dependencies of this project that dependent projects also need
|
||||
catkin_package(
|
||||
INCLUDE_DIRS ../
|
||||
LIBRARIES ${PROJECT_NAME}
|
||||
CATKIN_DEPENDS etk audio
|
||||
DEPENDS system_lib
|
||||
)
|
||||
|
||||
###########
|
||||
## Build ##
|
||||
###########
|
||||
|
||||
## Specify additional locations of header files
|
||||
## Your package locations should be listed before other locations
|
||||
include_directories(
|
||||
..
|
||||
${speex_INCLUDE_DIRS}
|
||||
${catkin_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
## Declare a cpp library
|
||||
add_library(${PROJECT_NAME}
|
||||
../audio/drain/debug.cpp
|
||||
../audio/drain/airtalgo.cpp
|
||||
../audio/drain/Algo.cpp
|
||||
../audio/drain/ChannelReorder.cpp
|
||||
../audio/drain/CircularBuffer.cpp
|
||||
../audio/drain/EndPointCallback.cpp
|
||||
../audio/drain/EndPoint.cpp
|
||||
../audio/drain/EndPointRead.cpp
|
||||
../audio/drain/EndPointWrite.cpp
|
||||
../audio/drain/FormatUpdate.cpp
|
||||
../audio/drain/Process.cpp
|
||||
../audio/drain/Resampler.cpp
|
||||
../audio/drain/Volume.cpp
|
||||
../audio/drain/IOFormatInterface.cpp
|
||||
../audio/drain/AutoLogInOut.cpp
|
||||
)
|
||||
|
||||
#message("libspeex DSP file: ${LIB_SPEEX_DSP}")
|
||||
#message("libspeex DSP file: ${SPEEX_DSP}")
|
||||
|
||||
add_definitions(-DHAVE_SPEEX_DSP_RESAMPLE)
|
||||
|
||||
## Specify libraries to link a library or executable target against
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
${SPEEX_DSP}
|
||||
${catkin_LIBRARIES}
|
||||
)
|
||||
|
||||
#############
|
||||
## Install ##
|
||||
#############
|
||||
|
||||
## Mark executables and/or libraries for installation
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
|
||||
)
|
||||
|
||||
## Mark cpp header files for installation
|
||||
install(DIRECTORY ../audio/drain/
|
||||
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
)
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<package>
|
||||
<name>audio_drain</name>
|
||||
<version>0.1.0</version>
|
||||
<description>Ewol audio basic flow algo (really simple)</description>
|
||||
<maintainer email="yui.heero@gmail.com">Edouard DUPIN</maintainer>
|
||||
<license>Apache-2.0</license>
|
||||
<build_depend>etk</build_depend>
|
||||
<build_depend>audio</build_depend>
|
||||
<buildtool_depend>catkin</buildtool_depend>
|
||||
<run_depend>etk</run_depend>
|
||||
<run_depend>audio</run_depend>
|
||||
</package>
|
||||
85
doc/build.md
Normal file
85
doc/build.md
Normal file
@@ -0,0 +1,85 @@
|
||||
Build lib & build sample {#audio_algo_build}
|
||||
========================
|
||||
|
||||
@tableofcontents
|
||||
|
||||
Download: {#audio_algo_build_download}
|
||||
=========
|
||||
|
||||
ege use some tools to manage source and build it:
|
||||
|
||||
need google repo: {#audio_algo_build_download_repo}
|
||||
-----------------
|
||||
|
||||
see: http://source.android.com/source/downloading.html#installing-repo
|
||||
|
||||
On all platform:
|
||||
```{.sh}
|
||||
mkdir ~/.bin
|
||||
PATH=~/.bin:$PATH
|
||||
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
|
||||
chmod a+x ~/.bin/repo
|
||||
```
|
||||
|
||||
On ubuntu
|
||||
```{.sh}
|
||||
sudo apt-get install repo
|
||||
```
|
||||
|
||||
On archlinux
|
||||
```{.sh}
|
||||
sudo pacman -S repo
|
||||
```
|
||||
|
||||
lutin (build-system): {#audio_algo_build_download_lutin}
|
||||
---------------------
|
||||
|
||||
```{.sh}
|
||||
pip install lutin --user
|
||||
# optionnal dependency of lutin (manage image changing size for application release)
|
||||
pip install pillow --user
|
||||
```
|
||||
|
||||
|
||||
dependency: {#audio_algo_build_download_dependency}
|
||||
-----------
|
||||
|
||||
```{.sh}
|
||||
mkdir -p WORKING_DIRECTORY/framework
|
||||
cd WORKING_DIRECTORY/framework
|
||||
repo init -u git://github.com/atria-soft/manifest.git
|
||||
repo sync -j8
|
||||
cd ../..
|
||||
```
|
||||
|
||||
sources: {#audio_algo_build_download_sources}
|
||||
--------
|
||||
|
||||
They are already download in the repo manifest in:
|
||||
|
||||
```{.sh}
|
||||
cd WORKING_DIRECTORY/framework/musicdsp/audio-drain
|
||||
```
|
||||
|
||||
Build: {#audio_algo_build_build}
|
||||
======
|
||||
|
||||
you must stay in your working directory...
|
||||
```{.sh}
|
||||
cd WORKING_DIRECTORY
|
||||
```
|
||||
|
||||
library: {#audio_algo_build_build_library}
|
||||
--------
|
||||
|
||||
```{.sh}
|
||||
lutin -mdebug audio-drain
|
||||
```
|
||||
|
||||
Test sample: {#audio_algo_build_build_sample}
|
||||
------------
|
||||
|
||||
```{.sh}
|
||||
lutin -mdebug audio-drain-test?build?run
|
||||
```
|
||||
|
||||
56
doc/mainpage.md
Normal file
56
doc/mainpage.md
Normal file
@@ -0,0 +1,56 @@
|
||||
AUDIO-ALGO library {#mainpage}
|
||||
=============
|
||||
|
||||
@tableofcontents
|
||||
|
||||
What is AUDIO-ALGO: {#audio_algo_mainpage_what}
|
||||
==============
|
||||
|
||||
AUDIO-ALGO, Is a single Pipeline processing to simply update format, framerate, channel maps ...
|
||||
|
||||
What it does: {#audio_algo_mainpage_what_it_does}
|
||||
-------------
|
||||
|
||||
- Change format
|
||||
- Change framerate
|
||||
- change number of channel
|
||||
|
||||
AUDIO-ALGO is dependent of the STL (compatible with MacOs stl (CXX))
|
||||
|
||||
|
||||
What languages are supported? {#audio_algo_mainpage_language}
|
||||
=============================
|
||||
|
||||
AUDIO-ALGO is written in C++.
|
||||
|
||||
|
||||
Are there any licensing restrictions? {#audio_algo_mainpage_license_restriction}
|
||||
=====================================
|
||||
|
||||
AUDIO-ALGO is **FREE software** and _all sub-library are FREE and staticly linkable !!!_
|
||||
|
||||
|
||||
License (MPL v2.0) {#audio_algo_mainpage_license}
|
||||
==================
|
||||
|
||||
Copyright AUDIO-ALGO Edouard DUPIN
|
||||
|
||||
Licensed under the Mozilla Public License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
<https://www.mozilla.org/MPL/2.0>
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
Other pages {#audio_algo_mainpage_sub_page}
|
||||
===========
|
||||
|
||||
- @ref audio_algo_build
|
||||
- [**ewol coding style**](http://atria-soft.github.io/ewol/ewol_coding_style.html)
|
||||
|
||||
33
doxy_audio-drain.py
Normal file
33
doxy_audio-drain.py
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import doxy.module as module
|
||||
import doxy.debug as debug
|
||||
import doxy.tools as tools
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name)
|
||||
my_module.set_version("version.txt")
|
||||
my_module.set_title("Basic audio algo interface single pipe to process data")
|
||||
my_module.set_website("http://musicdsp.github.io/" + module_name)
|
||||
my_module.set_website_sources("http://github.com/musicdsp/" + module_name)
|
||||
my_module.add_path([
|
||||
"audio",
|
||||
"doc"
|
||||
])
|
||||
my_module.add_depend([
|
||||
'etk',
|
||||
'audio',
|
||||
'ejson'
|
||||
])
|
||||
my_module.add_exclude_symbols([
|
||||
'*operator<<*',
|
||||
])
|
||||
my_module.add_exclude_file([
|
||||
'debug.h',
|
||||
])
|
||||
my_module.add_file_patterns([
|
||||
'*.h',
|
||||
'*.md',
|
||||
])
|
||||
|
||||
return my_module
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.module as module
|
||||
import realog.debug as debug
|
||||
import lutin.tools as tools
|
||||
import lutin.debug as debug
|
||||
|
||||
|
||||
def get_type():
|
||||
@@ -14,7 +13,7 @@ def get_desc():
|
||||
return "single audio flow test"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
@@ -23,10 +22,9 @@ def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
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',
|
||||
'test/updateFlow.cpp',
|
||||
@@ -35,8 +33,13 @@ def create(target, module_name):
|
||||
'test/channelOrder.cpp',
|
||||
'test/equalizer.cpp'
|
||||
])
|
||||
my_module.add_module_depend(['audio-drain', 'gtest', 'etk', 'test-debug'])
|
||||
return my_module
|
||||
my_module.add_depend([
|
||||
'audio-drain',
|
||||
'etest',
|
||||
'etk',
|
||||
'test-debug'
|
||||
])
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.module as module
|
||||
import lutin.tools as tools
|
||||
import lutin.debug as debug
|
||||
import realog.debug as debug
|
||||
|
||||
|
||||
def get_type():
|
||||
@@ -11,7 +10,7 @@ def get_desc():
|
||||
return "Basic audio algo interface single pipe to provess data"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
@@ -20,58 +19,63 @@ def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
return "authors.txt"
|
||||
|
||||
def get_version():
|
||||
return [0,1,0]
|
||||
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/drain/debug.cpp',
|
||||
'audio/drain/airtalgo.cpp',
|
||||
'audio/drain/Algo.cpp',
|
||||
'audio/drain/ChannelReorder.cpp',
|
||||
'audio/drain/CircularBuffer.cpp',
|
||||
'audio/drain/EndPointCallback.cpp',
|
||||
'audio/drain/EndPoint.cpp',
|
||||
'audio/drain/EndPointRead.cpp',
|
||||
'audio/drain/EndPointWrite.cpp',
|
||||
'audio/drain/FormatUpdate.cpp',
|
||||
'audio/drain/Process.cpp',
|
||||
'audio/drain/Resampler.cpp',
|
||||
'audio/drain/Volume.cpp',
|
||||
'audio/drain/IOFormatInterface.cpp',
|
||||
'audio/drain/AutoLogInOut.cpp',
|
||||
'audio/drain/Equalizer.cpp'
|
||||
])
|
||||
'audio/drain/debug.cpp',
|
||||
'audio/drain/airtalgo.cpp',
|
||||
'audio/drain/Algo.cpp',
|
||||
'audio/drain/ChannelReorder.cpp',
|
||||
'audio/drain/CircularBuffer.cpp',
|
||||
'audio/drain/EndPointCallback.cpp',
|
||||
'audio/drain/EndPoint.cpp',
|
||||
'audio/drain/EndPointRead.cpp',
|
||||
'audio/drain/EndPointWrite.cpp',
|
||||
'audio/drain/FormatUpdate.cpp',
|
||||
'audio/drain/Process.cpp',
|
||||
'audio/drain/Resampler.cpp',
|
||||
'audio/drain/Volume.cpp',
|
||||
'audio/drain/IOFormatInterface.cpp',
|
||||
'audio/drain/AutoLogInOut.cpp',
|
||||
'audio/drain/Equalizer.cpp'
|
||||
])
|
||||
|
||||
my_module.add_header_file([
|
||||
'audio/drain/debug.h',
|
||||
'audio/drain/debugRemove.h',
|
||||
'audio/drain/airtalgo.h',
|
||||
'audio/drain/Algo.h',
|
||||
'audio/drain/ChannelReorder.h',
|
||||
'audio/drain/CircularBuffer.h',
|
||||
'audio/drain/EndPointCallback.h',
|
||||
'audio/drain/EndPoint.h',
|
||||
'audio/drain/EndPointRead.h',
|
||||
'audio/drain/EndPointWrite.h',
|
||||
'audio/drain/FormatUpdate.h',
|
||||
'audio/drain/Process.h',
|
||||
'audio/drain/Resampler.h',
|
||||
'audio/drain/Volume.h',
|
||||
'audio/drain/IOFormatInterface.h',
|
||||
'audio/drain/AutoLogInOut.h',
|
||||
'audio/drain/Equalizer.h'
|
||||
])
|
||||
'audio/drain/debug.hpp',
|
||||
'audio/drain/debugRemove.hpp',
|
||||
'audio/drain/airtalgo.hpp',
|
||||
'audio/drain/Algo.hpp',
|
||||
'audio/drain/ChannelReorder.hpp',
|
||||
'audio/drain/CircularBuffer.hpp',
|
||||
'audio/drain/EndPointCallback.hpp',
|
||||
'audio/drain/EndPoint.hpp',
|
||||
'audio/drain/EndPointRead.hpp',
|
||||
'audio/drain/EndPointWrite.hpp',
|
||||
'audio/drain/FormatUpdate.hpp',
|
||||
'audio/drain/Process.hpp',
|
||||
'audio/drain/Resampler.hpp',
|
||||
'audio/drain/Volume.hpp',
|
||||
'audio/drain/IOFormatInterface.hpp',
|
||||
'audio/drain/AutoLogInOut.hpp',
|
||||
'audio/drain/Equalizer.hpp'
|
||||
])
|
||||
|
||||
# TODO: my_module.add_optional_module_depend('speexdsp', "HAVE_SPEEX_DSP_RESAMPLE")
|
||||
my_module.compile_flags('c++', "-DHAVE_SPEEX_DSP_RESAMPLE")
|
||||
my_module.add_module_depend(['etk', 'audio', 'ejson', 'speex-dsp', 'audio-algo-drain'])
|
||||
my_module.add_path(tools.get_current_path(__file__))
|
||||
return my_module
|
||||
my_module.add_flag('c++', "-DHAVE_SPEEX_DSP_RESAMPLE")
|
||||
my_module.add_depend([
|
||||
'etk',
|
||||
'audio',
|
||||
'ejson',
|
||||
'speex-dsp',
|
||||
'audio-algo-drain'
|
||||
])
|
||||
my_module.add_path(".")
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2015, 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 <gtest/gtest.h>
|
||||
#include <audio/drain/Process.h>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
#include <audio/drain/Process.hpp>
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2015, 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 <gtest/gtest.h>
|
||||
#include <audio/drain/Process.h>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
#include <audio/drain/Process.hpp>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2015, 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 <gtest/gtest.h>
|
||||
#include <audio/drain/Process.h>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
#include <audio/drain/Process.hpp>
|
||||
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2015, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/etk.h>
|
||||
#include <test-debug/debug.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "test"
|
||||
#include <etk/etk.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
|
||||
int main(int _argc, const char** _argv) {
|
||||
// init Google test :
|
||||
::testing::InitGoogleTest(&_argc, const_cast<char **>(_argv));
|
||||
// the only one init for etk:
|
||||
etk::init(_argc, _argv);
|
||||
etest::init(_argc, _argv);
|
||||
for (int32_t iii=0; iii<_argc ; ++iii) {
|
||||
std::string data = _argv[iii];
|
||||
etk::String data = _argv[iii];
|
||||
if ( data == "-h"
|
||||
|| data == "--help") {
|
||||
TEST_INFO("Help : ");
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2015, 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 <gtest/gtest.h>
|
||||
#include <audio/drain/Process.h>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
#include <audio/drain/Process.hpp>
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2015, 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 <gtest/gtest.h>
|
||||
#include <audio/drain/Process.h>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
#include <audio/drain/Process.hpp>
|
||||
|
||||
|
||||
@@ -1,38 +1,33 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <appl/debug.h>
|
||||
#include <appl/Windows.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <ewol/widget/Entry.h>
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/Slider.h>
|
||||
#include <audio/drain/Equalizer.h>
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/Windows.hpp>
|
||||
#include <ewol/widget/Label.hpp>
|
||||
#include <ewol/widget/Entry.hpp>
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/widget/Slider.hpp>
|
||||
#include <audio/drain/Equalizer.hpp>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Windows"
|
||||
|
||||
#define APPL_SAVE_FILE_MACRO(type,fileName,dataPointer,nbElement) \
|
||||
define APPL_SAVE_FILE_MACRO(type,fileName,dataPointer,nbElement) \
|
||||
do { \
|
||||
static FILE *pointerOnFile = nullptr; \
|
||||
static FILE *pointerOnFile = null; \
|
||||
static bool errorOpen = false; \
|
||||
if (pointerOnFile == nullptr) { \
|
||||
if (pointerOnFile == null) { \
|
||||
APPL_WARNING("open file '" << fileName << "' type=" << #type); \
|
||||
pointerOnFile = fopen(fileName,"w"); \
|
||||
if ( errorOpen == false \
|
||||
&& pointerOnFile == nullptr) { \
|
||||
&& pointerOnFile == null) { \
|
||||
APPL_ERROR("ERROR OPEN file ... '" << fileName << "' type=" << #type); \
|
||||
errorOpen=true; \
|
||||
} \
|
||||
} \
|
||||
if (pointerOnFile != nullptr) { \
|
||||
if (pointerOnFile != null) { \
|
||||
fwrite((dataPointer), sizeof(type), (nbElement), pointerOnFile); \
|
||||
/* fflush(pointerOnFile);*/ \
|
||||
} \
|
||||
@@ -45,53 +40,53 @@ appl::Windows::Windows() :
|
||||
m_gain(0.0),
|
||||
m_quality(0.707) {
|
||||
addObjectType("appl::Windows");
|
||||
m_listSampleRate.push_back(192000);
|
||||
m_listSampleRate.push_back(176400);
|
||||
m_listSampleRate.push_back(96000);
|
||||
m_listSampleRate.push_back(88200);
|
||||
m_listSampleRate.push_back(48000);
|
||||
m_listSampleRate.push_back(44100);
|
||||
m_listSampleRate.push_back(32000);
|
||||
m_listSampleRate.push_back(22050);
|
||||
m_listSampleRate.push_back(16000);
|
||||
m_listSampleRate.push_back(11025);
|
||||
m_listSampleRate.push_back(8000);
|
||||
m_listSampleRate.push_back(4000);
|
||||
m_listType.push_back(audio::algo::drain::biQuadType_none);
|
||||
m_listType.push_back(audio::algo::drain::biQuadType_lowPass);
|
||||
m_listType.push_back(audio::algo::drain::biQuadType_highPass);
|
||||
m_listType.push_back(audio::algo::drain::biQuadType_bandPass);
|
||||
m_listType.push_back(audio::algo::drain::biQuadType_notch);
|
||||
m_listType.push_back(audio::algo::drain::biQuadType_peak);
|
||||
m_listType.push_back(audio::algo::drain::biQuadType_lowShelf);
|
||||
m_listType.push_back(audio::algo::drain::biQuadType_highShelf);
|
||||
m_listSampleRate.pushBack(192000);
|
||||
m_listSampleRate.pushBack(176400);
|
||||
m_listSampleRate.pushBack(96000);
|
||||
m_listSampleRate.pushBack(88200);
|
||||
m_listSampleRate.pushBack(48000);
|
||||
m_listSampleRate.pushBack(44100);
|
||||
m_listSampleRate.pushBack(32000);
|
||||
m_listSampleRate.pushBack(22050);
|
||||
m_listSampleRate.pushBack(16000);
|
||||
m_listSampleRate.pushBack(11025);
|
||||
m_listSampleRate.pushBack(8000);
|
||||
m_listSampleRate.pushBack(4000);
|
||||
m_listType.pushBack(audio::algo::drain::biQuadType_none);
|
||||
m_listType.pushBack(audio::algo::drain::biQuadType_lowPass);
|
||||
m_listType.pushBack(audio::algo::drain::biQuadType_highPass);
|
||||
m_listType.pushBack(audio::algo::drain::biQuadType_bandPass);
|
||||
m_listType.pushBack(audio::algo::drain::biQuadType_notch);
|
||||
m_listType.pushBack(audio::algo::drain::biQuadType_peak);
|
||||
m_listType.pushBack(audio::algo::drain::biQuadType_lowShelf);
|
||||
m_listType.pushBack(audio::algo::drain::biQuadType_highShelf);
|
||||
}
|
||||
|
||||
void appl::Windows::init() {
|
||||
ewol::widget::Windows::init();
|
||||
setTitle("Drain Equalizer Profiler");
|
||||
|
||||
m_gui = ewol::widget::Composer::create(ewol::widget::Composer::file, "DATA:gui.xml");
|
||||
if (m_gui != nullptr) {
|
||||
m_gui = ewol::widget::Composer::create(ewol::widget::Composer::file, "DATA:///gui.xml");
|
||||
if (m_gui != null) {
|
||||
setSubWidget(m_gui);
|
||||
}
|
||||
subBind(ewol::widget::Button, "sample-rate-low", signalPressed, shared_from_this(), &appl::Windows::onCallbackSampleRateLow);
|
||||
subBind(ewol::widget::Button, "sample-rate-up", signalPressed, shared_from_this(), &appl::Windows::onCallbackSampleRateUp);
|
||||
subBind(ewol::widget::Button, "type-low", signalPressed, shared_from_this(), &appl::Windows::onCallbackTypeLow);
|
||||
subBind(ewol::widget::Button, "type-up", signalPressed, shared_from_this(), &appl::Windows::onCallbackTypeUp);
|
||||
subBind(ewol::widget::Button, "sample-rate-low", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSampleRateLow);
|
||||
subBind(ewol::widget::Button, "sample-rate-up", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSampleRateUp);
|
||||
subBind(ewol::widget::Button, "type-low", signalPressed, sharedFromThis(), &appl::Windows::onCallbackTypeLow);
|
||||
subBind(ewol::widget::Button, "type-up", signalPressed, sharedFromThis(), &appl::Windows::onCallbackTypeUp);
|
||||
|
||||
subBind(ewol::widget::Entry, "gain", signalModify, shared_from_this(), &appl::Windows::onCallbackGain);
|
||||
subBind(ewol::widget::Slider, "gain-slider", signalChange, shared_from_this(), &appl::Windows::onCallbackGainSlider);
|
||||
subBind(ewol::widget::Entry, "gain", signalModify, sharedFromThis(), &appl::Windows::onCallbackGain);
|
||||
subBind(ewol::widget::Slider, "gain-slider", signalChange, sharedFromThis(), &appl::Windows::onCallbackGainSlider);
|
||||
|
||||
subBind(ewol::widget::Entry, "frequency", signalModify, shared_from_this(), &appl::Windows::onCallbackFrequency);
|
||||
subBind(ewol::widget::Slider, "frequency-slider", signalChange, shared_from_this(), &appl::Windows::onCallbackFrequencySlider);
|
||||
subBind(ewol::widget::Entry, "frequency", signalModify, sharedFromThis(), &appl::Windows::onCallbackFrequency);
|
||||
subBind(ewol::widget::Slider, "frequency-slider", signalChange, sharedFromThis(), &appl::Windows::onCallbackFrequencySlider);
|
||||
|
||||
subBind(ewol::widget::Entry, "quality", signalModify, shared_from_this(), &appl::Windows::onCallbackQuality);
|
||||
subBind(ewol::widget::Slider, "quality-slider", signalChange, shared_from_this(), &appl::Windows::onCallbackQualitySlider);
|
||||
subBind(ewol::widget::Entry, "quality", signalModify, sharedFromThis(), &appl::Windows::onCallbackQuality);
|
||||
subBind(ewol::widget::Slider, "quality-slider", signalChange, sharedFromThis(), &appl::Windows::onCallbackQualitySlider);
|
||||
|
||||
subBind(ewol::widget::Button, "display16", signalPressed, shared_from_this(), &appl::Windows::onCallbackStart16);
|
||||
subBind(ewol::widget::Button, "displayFloat", signalPressed, shared_from_this(), &appl::Windows::onCallbackStartFloat);
|
||||
m_displayer = std11::dynamic_pointer_cast<appl::widget::DisplayFrequency>(getSubObjectNamed("displayer"));
|
||||
subBind(ewol::widget::Button, "display16", signalPressed, sharedFromThis(), &appl::Windows::onCallbackStart16);
|
||||
subBind(ewol::widget::Button, "displayFloat", signalPressed, sharedFromThis(), &appl::Windows::onCallbackStartFloat);
|
||||
m_displayer = ememory::dynamicPointerCast<appl::widget::DisplayFrequency>(getSubObjectNamed("displayer"));
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
@@ -105,15 +100,15 @@ void appl::Windows::onCallbackSampleRateUp() {
|
||||
} else {
|
||||
m_sampleRate = m_listSampleRate[0];
|
||||
}
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
|
||||
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::to_string(m_sampleRate/2));
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
|
||||
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::toString(m_sampleRate/2));
|
||||
onCallbackStart();
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_sampleRate = m_listSampleRate[0];
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
|
||||
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::to_string(m_sampleRate/2));
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
|
||||
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::toString(m_sampleRate/2));
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
@@ -126,15 +121,15 @@ void appl::Windows::onCallbackSampleRateLow() {
|
||||
} else {
|
||||
m_sampleRate = m_listSampleRate[m_listSampleRate.size()-1];
|
||||
}
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
|
||||
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::to_string(m_sampleRate/2));
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
|
||||
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::toString(m_sampleRate/2));
|
||||
onCallbackStart();
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_sampleRate = m_listSampleRate[0];
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
|
||||
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::to_string(m_sampleRate/2));
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
|
||||
ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::toString(m_sampleRate/2));
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
@@ -147,13 +142,13 @@ void appl::Windows::onCallbackTypeUp() {
|
||||
} else {
|
||||
m_type = m_listType[0];
|
||||
}
|
||||
ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type));
|
||||
ewol::parameterSetOnObjectNamed("type", "value", etk::toString(m_type));
|
||||
onCallbackStart();
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_type = m_listType[0];
|
||||
ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type));
|
||||
ewol::parameterSetOnObjectNamed("type", "value", etk::toString(m_type));
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
@@ -166,79 +161,79 @@ void appl::Windows::onCallbackTypeLow() {
|
||||
} else {
|
||||
m_type = m_listType[m_listType.size()-1];
|
||||
}
|
||||
ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type));
|
||||
ewol::parameterSetOnObjectNamed("type", "value", etk::toString(m_type));
|
||||
onCallbackStart();
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_type = m_listType[0];
|
||||
ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type));
|
||||
ewol::parameterSetOnObjectNamed("type", "value", etk::toString(m_type));
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
|
||||
void appl::Windows::onCallbackGain(const std::string& _value) {
|
||||
void appl::Windows::onCallbackGain(const etk::String& _value) {
|
||||
m_gain = etk::string_to_float(_value);
|
||||
ewol::parameterSetOnObjectNamed("gain-slider", "value", etk::to_string(_value));
|
||||
ewol::parameterSetOnObjectNamed("gain-slider", "value", etk::toString(_value));
|
||||
APPL_INFO("Gain " << m_gain);
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
void appl::Windows::onCallbackGainSlider(const float& _value) {
|
||||
m_gain = _value;
|
||||
ewol::parameterSetOnObjectNamed("gain", "value", etk::to_string(_value));
|
||||
ewol::parameterSetOnObjectNamed("gain", "value", etk::toString(_value));
|
||||
APPL_INFO("Gain " << m_gain);
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void appl::Windows::onCallbackQuality(const std::string& _value) {
|
||||
void appl::Windows::onCallbackQuality(const etk::String& _value) {
|
||||
m_quality = etk::string_to_float(_value);
|
||||
ewol::parameterSetOnObjectNamed("quality-slider", "value", etk::to_string(_value));
|
||||
ewol::parameterSetOnObjectNamed("quality-slider", "value", etk::toString(_value));
|
||||
APPL_INFO("quality " << m_quality);
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
void appl::Windows::onCallbackQualitySlider(const float& _value) {
|
||||
m_quality = _value;
|
||||
ewol::parameterSetOnObjectNamed("quality", "value", etk::to_string(_value));
|
||||
ewol::parameterSetOnObjectNamed("quality", "value", etk::toString(_value));
|
||||
APPL_INFO("quality " << m_quality);
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
|
||||
void appl::Windows::onCallbackFrequency(const std::string& _value) {
|
||||
void appl::Windows::onCallbackFrequency(const etk::String& _value) {
|
||||
m_cutFrequency = etk::string_to_float(_value);
|
||||
ewol::parameterSetOnObjectNamed("frequency-slider", "value", etk::to_string(_value));
|
||||
ewol::parameterSetOnObjectNamed("frequency-slider", "value", etk::toString(_value));
|
||||
APPL_INFO("cut frequency " << m_cutFrequency);
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
void appl::Windows::onCallbackFrequencySlider(const float& _value) {
|
||||
m_cutFrequency = _value;
|
||||
ewol::parameterSetOnObjectNamed("frequency", "value", etk::to_string(_value));
|
||||
ewol::parameterSetOnObjectNamed("frequency", "value", etk::toString(_value));
|
||||
APPL_INFO("cut frequency " << m_cutFrequency);
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <audio/algo/drain/BiQuad.h>
|
||||
#include <audio/float_t.h>
|
||||
#include <audio/int16_16_t.h>
|
||||
#include <appl/debug.hpp>
|
||||
#include <audio/algo/drain/BiQuad.hpp>
|
||||
#include <audio/float_t.hpp>
|
||||
#include <audio/int16_16_t.hpp>
|
||||
|
||||
void appl::Windows::onCallbackStart() {
|
||||
APPL_INFO("start ");
|
||||
int32_t iii = 10;
|
||||
std::vector<audio::channel> map;
|
||||
map.push_back(audio::channel_frontCenter);
|
||||
etk::Vector<audio::channel> map;
|
||||
map.pushBack(audio::channel_frontCenter);
|
||||
// audio::drain::IOFormatInterface format(map, audio::format_int16, m_sampleRate);
|
||||
// audio::drain::IOFormatInterface format(map, audio::format_float, m_sampleRate);
|
||||
// create biquad
|
||||
audio::algo::drain::BiQuad<audio::float_t> bq;
|
||||
// configure parameter
|
||||
bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate);
|
||||
std::vector<std::pair<float,float> > theory = bq.calculateTheory(m_sampleRate);
|
||||
etk::Vector<etk::Pair<float,float> > theory = bq.calculateTheory(m_sampleRate);
|
||||
m_displayer->clear();
|
||||
m_displayer->setValue(theory);
|
||||
}
|
||||
@@ -250,7 +245,7 @@ void appl::Windows::onCallbackStart16() {
|
||||
audio::algo::drain::BiQuad<audio::int16_16_t> bq;
|
||||
// configure parameter
|
||||
bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate);
|
||||
std::vector<std::pair<float,float> > pratic;
|
||||
etk::Vector<etk::Pair<float,float> > pratic;
|
||||
size_t len = 512;
|
||||
for (size_t iii=1; iii < len; iii++) {
|
||||
float freq = iii / (len - 1.0) * m_sampleRate / 2.0;
|
||||
@@ -259,7 +254,7 @@ void appl::Windows::onCallbackStart16() {
|
||||
double m_phase = 0;
|
||||
double baseCycle = 2.0*M_PI/double(m_sampleRate) * double(freq);
|
||||
float gain = 0;
|
||||
std::vector<audio::int16_16_t> data;
|
||||
etk::Vector<audio::int16_16_t> data;
|
||||
// create sinus
|
||||
data.resize(16000, 0);
|
||||
for (int32_t iii=0; iii<data.size(); iii++) {
|
||||
@@ -270,19 +265,19 @@ void appl::Windows::onCallbackStart16() {
|
||||
}
|
||||
}
|
||||
// process
|
||||
int16_t* output = nullptr;
|
||||
void* outputVoid = nullptr;
|
||||
int16_t* output = null;
|
||||
void* outputVoid = null;
|
||||
size_t outputNbChunk = 0;
|
||||
APPL_SAVE_FILE_MACRO(int16_t,"aaa_test_INPUT_16.raw",&data[0],data.size());
|
||||
bq.process(&data[0], &data[0], data.size(), 1, 1);
|
||||
APPL_SAVE_FILE_MACRO(int16_t,"aaa_test_OUTPUT_16.raw",&data[0],data.size());
|
||||
audio::int16_16_t value = 0;
|
||||
for (size_t iii=800; iii<data.size()-200; ++iii) {
|
||||
value = std::max(value, data[iii]);
|
||||
value = etk::max(value, data[iii]);
|
||||
}
|
||||
gain = 20.0 * std::log10(value.getDouble()/32000.0);
|
||||
gain = 20.0 * etk::log10(value.getDouble()/32000.0);
|
||||
APPL_VERBOSE("LEVEL " << iii << " out = " << value << " % : " << gain);
|
||||
pratic.push_back(std::make_pair<float, float>(float(freq),float(gain)));
|
||||
pratic.pushBack(etk::makePair<float, float>(float(freq),float(gain)));
|
||||
}
|
||||
m_displayer->setValue(pratic);
|
||||
}
|
||||
@@ -293,7 +288,7 @@ void appl::Windows::onCallbackStartFloat() {
|
||||
audio::algo::drain::BiQuad<audio::float_t> bq;
|
||||
// configure parameter
|
||||
bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate);
|
||||
std::vector<std::pair<float,float> > pratic;
|
||||
etk::Vector<etk::Pair<float,float> > pratic;
|
||||
size_t len = 512;
|
||||
for (size_t iii=1; iii < len; iii++) {
|
||||
float freq = iii / (len - 1.0) * m_sampleRate / 2.0;
|
||||
@@ -302,7 +297,7 @@ void appl::Windows::onCallbackStartFloat() {
|
||||
double m_phase = 0;
|
||||
double baseCycle = 2.0*M_PI/double(m_sampleRate) * double(freq);
|
||||
float gain = 0;
|
||||
std::vector<audio::float_t> data;
|
||||
etk::Vector<audio::float_t> data;
|
||||
// create sinus
|
||||
data.resize(16000, 0);
|
||||
for (int32_t iii=0; iii<data.size(); iii++) {
|
||||
@@ -317,11 +312,11 @@ void appl::Windows::onCallbackStartFloat() {
|
||||
APPL_SAVE_FILE_MACRO(float,"aaa_test_OUTPUT_F.raw",&data[0],data.size());
|
||||
audio::float_t value = 0.0f;
|
||||
for (size_t iii=800; iii<data.size()-200; ++iii) {
|
||||
value = std::max(value, data[iii]);
|
||||
value = etk::max(value, data[iii]);
|
||||
}
|
||||
gain = 20.0 * std::log10(value.getDouble()/1.0);
|
||||
gain = 20.0 * etk::log10(value.getDouble()/1.0);
|
||||
APPL_VERBOSE("LEVEL " << iii << " out = " << value << " % : " << gain);
|
||||
pratic.push_back(std::make_pair<float, float>(float(freq),float(gain)));
|
||||
pratic.pushBack(etk::makePair<float, float>(float(freq),float(gain)));
|
||||
}
|
||||
m_displayer->setValue(pratic);
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __APPL_WINDOWS_H__
|
||||
#define __APPL_WINDOWS_H__
|
||||
|
||||
#include <ewol/widget/Windows.h>
|
||||
#include <ewol/widget/Layer.h>
|
||||
#include <ewol/widget/Composer.h>
|
||||
#include <audio/algo/drain/BiQuadType.h>
|
||||
#include <appl/widget/DisplayFrequency.h>
|
||||
|
||||
namespace appl {
|
||||
class Windows : public ewol::widget::Windows {
|
||||
protected:
|
||||
Windows();
|
||||
void init();
|
||||
public:
|
||||
DECLARE_FACTORY(Windows);
|
||||
protected:
|
||||
std::shared_ptr<ewol::widget::Composer> m_gui;
|
||||
std::shared_ptr<appl::widget::DisplayFrequency> m_displayer;
|
||||
void onCallbackSampleRateLow();
|
||||
void onCallbackSampleRateUp();
|
||||
void onCallbackTypeUp();
|
||||
void onCallbackTypeLow();
|
||||
void onCallbackGain(const std::string& _value);
|
||||
void onCallbackGainSlider(const float& _value);
|
||||
void onCallbackFrequency(const std::string& _value);
|
||||
void onCallbackFrequencySlider(const float& _value);
|
||||
void onCallbackQuality(const std::string& _value);
|
||||
void onCallbackQualitySlider(const float& _value);
|
||||
void onCallbackStart();
|
||||
void onCallbackStart16();
|
||||
void onCallbackStartFloat();
|
||||
protected:
|
||||
int32_t m_sampleRate;
|
||||
std::vector<int32_t> m_listSampleRate;
|
||||
enum audio::algo::drain::biQuadType m_type;
|
||||
std::vector<enum audio::algo::drain::biQuadType> m_listType;
|
||||
float m_cutFrequency;
|
||||
float m_gain;
|
||||
float m_quality;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
47
tools/drainBiQuadProfiling/appl/Windows.hpp
Normal file
47
tools/drainBiQuadProfiling/appl/Windows.hpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <ewol/widget/Windows.hpp>
|
||||
#include <ewol/widget/Layer.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <audio/algo/drain/BiQuadType.hpp>
|
||||
#include <appl/widget/DisplayFrequency.hpp>
|
||||
|
||||
namespace appl {
|
||||
class Windows : public ewol::widget::Windows {
|
||||
protected:
|
||||
Windows();
|
||||
void init();
|
||||
public:
|
||||
DECLARE_FACTORY(Windows);
|
||||
protected:
|
||||
ememory::SharedPtr<ewol::widget::Composer> m_gui;
|
||||
ememory::SharedPtr<appl::widget::DisplayFrequency> m_displayer;
|
||||
void onCallbackSampleRateLow();
|
||||
void onCallbackSampleRateUp();
|
||||
void onCallbackTypeUp();
|
||||
void onCallbackTypeLow();
|
||||
void onCallbackGain(const etk::String& _value);
|
||||
void onCallbackGainSlider(const float& _value);
|
||||
void onCallbackFrequency(const etk::String& _value);
|
||||
void onCallbackFrequencySlider(const float& _value);
|
||||
void onCallbackQuality(const etk::String& _value);
|
||||
void onCallbackQualitySlider(const float& _value);
|
||||
void onCallbackStart();
|
||||
void onCallbackStart16();
|
||||
void onCallbackStartFloat();
|
||||
protected:
|
||||
int32_t m_sampleRate;
|
||||
etk::Vector<int32_t> m_listSampleRate;
|
||||
enum audio::algo::drain::biQuadType m_type;
|
||||
etk::Vector<enum audio::algo::drain::biQuadType> m_listType;
|
||||
float m_cutFrequency;
|
||||
float m_gain;
|
||||
float m_quality;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = etk::log::registerInstance("drain-equalizer");
|
||||
static int32_t g_val = elog::registerInstance("drain-equalizer");
|
||||
return g_val;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
#ifndef __APPL_DEBUG_H__
|
||||
#define __APPL_DEBUG_H__
|
||||
|
||||
#include <etk/log.h>
|
||||
#include <elog/log.hpp>
|
||||
|
||||
namespace appl {
|
||||
int32_t getLogId();
|
||||
};
|
||||
#define APPL_BASE(info,data) TK_LOG_BASE(appl::getLogId(),info,data)
|
||||
#define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data)
|
||||
|
||||
#define APPL_CRITICAL(data) APPL_BASE(1, data)
|
||||
#define APPL_ERROR(data) APPL_BASE(2, data)
|
||||
@@ -40,4 +35,3 @@ namespace appl {
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
@@ -1,22 +1,20 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <gale/context/commandLine.h>
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <gale/context/commandLine.hpp>
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <appl/Windows.h>
|
||||
#include <ewol/object/Object.h>
|
||||
#include <ewol/widget/Manager.h>
|
||||
#include <ewol/context/Context.h>
|
||||
#include <appl/widget/DisplayFrequency.h>
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/Windows.hpp>
|
||||
#include <ewol/object/Object.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <ewol/context/Context.hpp>
|
||||
#include <appl/widget/DisplayFrequency.hpp>
|
||||
|
||||
|
||||
class MainApplication : public ewol::context::Application {
|
||||
@@ -34,7 +32,7 @@ class MainApplication : public ewol::context::Application {
|
||||
// add local widget list:
|
||||
appl::widget::DisplayFrequency::createManagerWidget(_context.getWidgetManager());
|
||||
|
||||
std::shared_ptr<ewol::widget::Windows> basicWindows = appl::Windows::create();
|
||||
ememory::SharedPtr<ewol::widget::Windows> basicWindows = appl::Windows::create();
|
||||
// create the specific windows
|
||||
_context.setWindows(basicWindows);
|
||||
APPL_INFO("==> Init APPL (END)");
|
||||
@@ -54,7 +52,7 @@ class MainApplication : public ewol::context::Application {
|
||||
* @return std IO
|
||||
*/
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
return ewol::run(new MainApplication(), _argc, _argv);
|
||||
return ewol::run(ETK_NEW(MainApplication), _argc, _argv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __APPL_MAIN_H__
|
||||
#define __APPL_MAIN_H__
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
7
tools/drainBiQuadProfiling/appl/main.hpp
Normal file
7
tools/drainBiQuadProfiling/appl/main.hpp
Normal file
@@ -0,0 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <appl/widget/DisplayFrequency.h>
|
||||
#include <appl/debug.h>
|
||||
#include <etk/tool.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "DisplayFrequency"
|
||||
|
||||
#include <appl/widget/DisplayFrequency.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
|
||||
appl::widget::DisplayFrequency::DisplayFrequency() :
|
||||
m_gainMin(0.0f),
|
||||
@@ -34,8 +28,8 @@ appl::widget::DisplayFrequency::~DisplayFrequency() {
|
||||
}
|
||||
|
||||
|
||||
void appl::widget::DisplayFrequency::setValue(const std::vector<std::pair<float,float> >& _data) {
|
||||
m_data.push_back(_data);
|
||||
void appl::widget::DisplayFrequency::setValue(const etk::Vector<etk::Pair<float,float> >& _data) {
|
||||
m_data.pushBack(_data);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
@@ -89,23 +83,23 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() {
|
||||
bool displayLog = true;
|
||||
for (size_t kkk=0; kkk<m_data.size(); kkk++) {
|
||||
for (size_t iii=0; iii<m_data[kkk].size(); ++iii) {
|
||||
if (std::abs(m_data[kkk][iii].second) != std::numeric_limits<float>::infinity()) {
|
||||
m_gainMax = std::max(m_gainMax, m_data[kkk][iii].second);
|
||||
m_gainMin = std::min(m_gainMin, m_data[kkk][iii].second);
|
||||
if (isinf(etk::abs(m_data[kkk][iii].second)) == false) {
|
||||
m_gainMax = etk::max(m_gainMax, m_data[kkk][iii].second);
|
||||
m_gainMin = etk::min(m_gainMin, m_data[kkk][iii].second);
|
||||
}
|
||||
if (displayLog == false) {
|
||||
if (std::abs(m_data[kkk][iii].first) != std::numeric_limits<float>::infinity()) {
|
||||
m_frequencyMax = std::max(m_frequencyMax, m_data[kkk][iii].first);
|
||||
m_frequencyMin = std::min(m_frequencyMin, m_data[kkk][iii].first);
|
||||
if (isinf(etk::abs(m_data[kkk][iii].first)) == false) {
|
||||
m_frequencyMax = etk::max(m_frequencyMax, m_data[kkk][iii].first);
|
||||
m_frequencyMin = etk::min(m_frequencyMin, m_data[kkk][iii].first);
|
||||
}
|
||||
} else {
|
||||
if (std::abs(m_data[kkk][iii].first) != std::numeric_limits<float>::infinity()) {
|
||||
if (isinf(etk::abs(m_data[kkk][iii].first)) == false) {
|
||||
if (m_data[kkk][iii].first == 0) {
|
||||
continue;
|
||||
}
|
||||
m_frequencyMax = std::max(m_frequencyMax, std::log(m_data[kkk][iii].first));
|
||||
m_frequencyMin = std::min(m_frequencyMin, std::log(m_data[kkk][iii].first));
|
||||
APPL_INFO("plop " << m_data[kkk][iii].first << " " << std::log(m_data[kkk][iii].first));
|
||||
m_frequencyMax = etk::max(m_frequencyMax, etk::log(m_data[kkk][iii].first));
|
||||
m_frequencyMin = etk::min(m_frequencyMin, etk::log(m_data[kkk][iii].first));
|
||||
APPL_INFO("plop " << m_data[kkk][iii].first << " " << etk::log(m_data[kkk][iii].first));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,33 +137,33 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() {
|
||||
}
|
||||
} else {
|
||||
m_draw.setPos( m_borderSize
|
||||
+ vec2(ratioX*(std::log(m_data[kkk][0].first) - m_frequencyMin),
|
||||
+ vec2(ratioX*(etk::log(m_data[kkk][0].first) - m_frequencyMin),
|
||||
ratioY*(m_data[kkk][0].second - m_gainMin)));
|
||||
float baseX = 0;
|
||||
for (size_t iii=1; iii<m_data[kkk].size(); ++iii) {
|
||||
m_draw.lineTo( m_borderSize
|
||||
+ vec2(ratioX*(std::log(m_data[kkk][iii].first) - m_frequencyMin),
|
||||
+ vec2(ratioX*(etk::log(m_data[kkk][iii].first) - m_frequencyMin),
|
||||
ratioY*(m_data[kkk][iii].second - m_gainMin)));
|
||||
}
|
||||
}
|
||||
}
|
||||
m_text.setDefaultColorFg(etk::color::green);
|
||||
std::string textToDisplay = etk::to_string(m_frequencyMin) + " Hz";
|
||||
etk::String textToDisplay = etk::toString(m_frequencyMin) + " Hz";
|
||||
vec3 size = m_text.calculateSize(textToDisplay);
|
||||
m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y()-size.y()));
|
||||
m_text.print(textToDisplay);
|
||||
|
||||
textToDisplay = etk::to_string(m_frequencyMax) + " Hz";
|
||||
textToDisplay = etk::toString(m_frequencyMax) + " Hz";
|
||||
size = m_text.calculateSize(textToDisplay);
|
||||
m_text.setPos(vec2(m_size.x()-m_borderSize.x()-size.x(), m_borderSize.y()-size.y()));
|
||||
m_text.print(textToDisplay);
|
||||
|
||||
textToDisplay = etk::to_string(m_gainMin) + " dB";
|
||||
textToDisplay = etk::toString(m_gainMin) + " dB";
|
||||
size = m_text.calculateSize(textToDisplay);
|
||||
m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y()));
|
||||
m_text.print(textToDisplay);
|
||||
|
||||
textToDisplay = etk::to_string(m_gainMax) + " dB";
|
||||
textToDisplay = etk::toString(m_gainMax) + " dB";
|
||||
size = m_text.calculateSize(textToDisplay);
|
||||
m_text.setPos(vec2(m_borderSize.x(), m_size.y() - m_borderSize.y()));
|
||||
m_text.print(textToDisplay);
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
#ifndef __APPL_WIDGET_DISPLAY_FREQUENCY_H__
|
||||
#define __APPL_WIDGET_DISPLAY_FREQUENCY_H__
|
||||
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <ewol/compositing/Drawing.h>
|
||||
#include <ewol/compositing/Text.h>
|
||||
#include <ewol/widget/Manager.h>
|
||||
#include <ewol/widget/Widget.hpp>
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
#include <ewol/compositing/Text.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
namespace appl {
|
||||
namespace widget {
|
||||
@@ -30,12 +25,12 @@ namespace appl {
|
||||
//! @brief destructor
|
||||
virtual ~DisplayFrequency();
|
||||
private:
|
||||
std::vector<std::vector<std::pair<float,float> > > m_data; //!< data that might be displayed
|
||||
etk::Vector<etk::Vector<etk::Pair<float,float> > > m_data; //!< data that might be displayed
|
||||
public:
|
||||
void clear() {
|
||||
m_data.clear();
|
||||
}
|
||||
void setValue(const std::vector<std::pair<float,float> >& _data);
|
||||
void setValue(const etk::Vector<etk::Pair<float,float> >& _data);
|
||||
private:
|
||||
float m_gainMin; //!< display minimum gain value
|
||||
float m_gainMax; //!< display maximum gain value
|
||||
@@ -55,4 +50,3 @@ namespace appl {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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 "basic test and profiling of equalizer work or not"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
@@ -24,21 +24,24 @@ def get_compagny_name():
|
||||
def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
def configure(target, my_module):
|
||||
my_module.add_src_file([
|
||||
'appl/main.cpp',
|
||||
'appl/debug.cpp',
|
||||
'appl/Windows.cpp',
|
||||
'appl/widget/DisplayFrequency.cpp',
|
||||
])
|
||||
my_module.add_module_depend(['ewol', 'audio-drain', 'audio-river'])
|
||||
my_module.compile_flags('c++', [
|
||||
"-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\""
|
||||
])
|
||||
my_module.add_path(tools.get_current_path(__file__))
|
||||
'appl/main.cpp',
|
||||
'appl/debug.cpp',
|
||||
'appl/Windows.cpp',
|
||||
'appl/widget/DisplayFrequency.cpp',
|
||||
])
|
||||
my_module.add_depend([
|
||||
'ewol',
|
||||
'audio-drain',
|
||||
'audio-river'
|
||||
])
|
||||
my_module.add_flag('c++', [
|
||||
"-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\""
|
||||
])
|
||||
my_module.add_path(".")
|
||||
my_module.copy_path("data/*")
|
||||
return my_module
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +1,31 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/ewol.h>
|
||||
#include <appl/debug.h>
|
||||
#include <appl/Windows.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <ewol/widget/Entry.h>
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/Slider.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Windows"
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/Windows.hpp>
|
||||
#include <ewol/widget/Label.hpp>
|
||||
#include <ewol/widget/Entry.hpp>
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/widget/Slider.hpp>
|
||||
|
||||
#define APPL_SAVE_FILE_MACRO(type,fileName,dataPointer,nbElement) \
|
||||
do { \
|
||||
static FILE *pointerOnFile = nullptr; \
|
||||
static FILE *pointerOnFile = null; \
|
||||
static bool errorOpen = false; \
|
||||
if (pointerOnFile == nullptr) { \
|
||||
if (pointerOnFile == null) { \
|
||||
APPL_WARNING("open file '" << fileName << "' type=" << #type); \
|
||||
pointerOnFile = fopen(fileName,"w"); \
|
||||
if ( errorOpen == false \
|
||||
&& pointerOnFile == nullptr) { \
|
||||
&& pointerOnFile == null) { \
|
||||
APPL_ERROR("ERROR OPEN file ... '" << fileName << "' type=" << #type); \
|
||||
errorOpen=true; \
|
||||
} \
|
||||
} \
|
||||
if (pointerOnFile != nullptr) { \
|
||||
if (pointerOnFile != null) { \
|
||||
fwrite((dataPointer), sizeof(type), (nbElement), pointerOnFile); \
|
||||
/* fflush(pointerOnFile);*/ \
|
||||
} \
|
||||
@@ -39,18 +34,18 @@
|
||||
appl::Windows::Windows() :
|
||||
m_sampleRate(48000) {
|
||||
addObjectType("appl::Windows");
|
||||
m_listSampleRate.push_back(192000);
|
||||
m_listSampleRate.push_back(176400);
|
||||
m_listSampleRate.push_back(96000);
|
||||
m_listSampleRate.push_back(88200);
|
||||
m_listSampleRate.push_back(48000);
|
||||
m_listSampleRate.push_back(44100);
|
||||
m_listSampleRate.push_back(32000);
|
||||
m_listSampleRate.push_back(22050);
|
||||
m_listSampleRate.push_back(16000);
|
||||
m_listSampleRate.push_back(11025);
|
||||
m_listSampleRate.push_back(8000);
|
||||
m_listSampleRate.push_back(4000);
|
||||
m_listSampleRate.pushBack(192000);
|
||||
m_listSampleRate.pushBack(176400);
|
||||
m_listSampleRate.pushBack(96000);
|
||||
m_listSampleRate.pushBack(88200);
|
||||
m_listSampleRate.pushBack(48000);
|
||||
m_listSampleRate.pushBack(44100);
|
||||
m_listSampleRate.pushBack(32000);
|
||||
m_listSampleRate.pushBack(22050);
|
||||
m_listSampleRate.pushBack(16000);
|
||||
m_listSampleRate.pushBack(11025);
|
||||
m_listSampleRate.pushBack(8000);
|
||||
m_listSampleRate.pushBack(4000);
|
||||
m_listGain.resize(10, 0.0f);
|
||||
}
|
||||
|
||||
@@ -58,27 +53,27 @@ void appl::Windows::init() {
|
||||
ewol::widget::Windows::init();
|
||||
setTitle("Drain Equalizer Profiler");
|
||||
|
||||
m_gui = ewol::widget::Composer::create(ewol::widget::Composer::file, "DATA:gui.xml");
|
||||
if (m_gui != nullptr) {
|
||||
m_gui = ewol::widget::Composer::create(ewol::widget::Composer::file, "DATA:///gui.xml");
|
||||
if (m_gui != null) {
|
||||
setSubWidget(m_gui);
|
||||
}
|
||||
subBind(ewol::widget::Button, "sample-rate-low", signalPressed, shared_from_this(), &appl::Windows::onCallbackSampleRateLow);
|
||||
subBind(ewol::widget::Button, "sample-rate-up", signalPressed, shared_from_this(), &appl::Windows::onCallbackSampleRateUp);
|
||||
subBind(ewol::widget::Button, "sample-rate-low", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSampleRateLow);
|
||||
subBind(ewol::widget::Button, "sample-rate-up", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSampleRateUp);
|
||||
|
||||
subBind(ewol::widget::Slider, "gain-0", signalChange, shared_from_this(), &appl::Windows::onCallbackGain0);
|
||||
subBind(ewol::widget::Slider, "gain-1", signalChange, shared_from_this(), &appl::Windows::onCallbackGain1);
|
||||
subBind(ewol::widget::Slider, "gain-2", signalChange, shared_from_this(), &appl::Windows::onCallbackGain2);
|
||||
subBind(ewol::widget::Slider, "gain-3", signalChange, shared_from_this(), &appl::Windows::onCallbackGain3);
|
||||
subBind(ewol::widget::Slider, "gain-4", signalChange, shared_from_this(), &appl::Windows::onCallbackGain4);
|
||||
subBind(ewol::widget::Slider, "gain-5", signalChange, shared_from_this(), &appl::Windows::onCallbackGain5);
|
||||
subBind(ewol::widget::Slider, "gain-6", signalChange, shared_from_this(), &appl::Windows::onCallbackGain6);
|
||||
subBind(ewol::widget::Slider, "gain-7", signalChange, shared_from_this(), &appl::Windows::onCallbackGain7);
|
||||
subBind(ewol::widget::Slider, "gain-8", signalChange, shared_from_this(), &appl::Windows::onCallbackGain8);
|
||||
subBind(ewol::widget::Slider, "gain-9", signalChange, shared_from_this(), &appl::Windows::onCallbackGain9);
|
||||
subBind(ewol::widget::Slider, "gain-0", signalChange, sharedFromThis(), &appl::Windows::onCallbackGain0);
|
||||
subBind(ewol::widget::Slider, "gain-1", signalChange, sharedFromThis(), &appl::Windows::onCallbackGain1);
|
||||
subBind(ewol::widget::Slider, "gain-2", signalChange, sharedFromThis(), &appl::Windows::onCallbackGain2);
|
||||
subBind(ewol::widget::Slider, "gain-3", signalChange, sharedFromThis(), &appl::Windows::onCallbackGain3);
|
||||
subBind(ewol::widget::Slider, "gain-4", signalChange, sharedFromThis(), &appl::Windows::onCallbackGain4);
|
||||
subBind(ewol::widget::Slider, "gain-5", signalChange, sharedFromThis(), &appl::Windows::onCallbackGain5);
|
||||
subBind(ewol::widget::Slider, "gain-6", signalChange, sharedFromThis(), &appl::Windows::onCallbackGain6);
|
||||
subBind(ewol::widget::Slider, "gain-7", signalChange, sharedFromThis(), &appl::Windows::onCallbackGain7);
|
||||
subBind(ewol::widget::Slider, "gain-8", signalChange, sharedFromThis(), &appl::Windows::onCallbackGain8);
|
||||
subBind(ewol::widget::Slider, "gain-9", signalChange, sharedFromThis(), &appl::Windows::onCallbackGain9);
|
||||
|
||||
subBind(ewol::widget::Button, "display16", signalPressed, shared_from_this(), &appl::Windows::onCallbackStart16);
|
||||
subBind(ewol::widget::Button, "displayFloat", signalPressed, shared_from_this(), &appl::Windows::onCallbackStartFloat);
|
||||
m_displayer = std11::dynamic_pointer_cast<appl::widget::DisplayFrequency>(getSubObjectNamed("displayer"));
|
||||
subBind(ewol::widget::Button, "display16", signalPressed, sharedFromThis(), &appl::Windows::onCallbackStart16);
|
||||
subBind(ewol::widget::Button, "displayFloat", signalPressed, sharedFromThis(), &appl::Windows::onCallbackStartFloat);
|
||||
m_displayer = ememory::dynamicPointerCast<appl::widget::DisplayFrequency>(getSubObjectNamed("displayer"));
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
@@ -92,13 +87,13 @@ void appl::Windows::onCallbackSampleRateUp() {
|
||||
} else {
|
||||
m_sampleRate = m_listSampleRate[0];
|
||||
}
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
|
||||
onCallbackStart();
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_sampleRate = m_listSampleRate[0];
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
@@ -111,13 +106,13 @@ void appl::Windows::onCallbackSampleRateLow() {
|
||||
} else {
|
||||
m_sampleRate = m_listSampleRate[m_listSampleRate.size()-1];
|
||||
}
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
|
||||
onCallbackStart();
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_sampleRate = m_listSampleRate[0];
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate));
|
||||
ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate));
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
@@ -126,18 +121,18 @@ void appl::Windows::onCallbackGain(const float& _value, int32_t _id) {
|
||||
onCallbackStart();
|
||||
}
|
||||
|
||||
std11::shared_ptr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum audio::format _format) {
|
||||
std::vector<audio::channel> map;
|
||||
map.push_back(audio::channel_frontCenter);
|
||||
ememory::SharedPtr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum audio::format _format) {
|
||||
etk::Vector<audio::channel> map;
|
||||
map.pushBack(audio::channel_frontCenter);
|
||||
audio::drain::IOFormatInterface format(map, _format, m_sampleRate);
|
||||
// create equalizer
|
||||
std11::shared_ptr<audio::drain::Equalizer> out = audio::drain::Equalizer::create();
|
||||
ememory::SharedPtr<audio::drain::Equalizer> out = audio::drain::Equalizer::create();
|
||||
// configure input
|
||||
out->setInputFormat(format);
|
||||
// configure output
|
||||
out->setOutputFormat(format);
|
||||
// create ejson:
|
||||
std::string conf;
|
||||
etk::String conf;
|
||||
conf += "{\n";
|
||||
conf += " global: [\n";
|
||||
for (size_t iii=3; iii<m_listGain.size(); ++iii) {
|
||||
@@ -162,8 +157,8 @@ std11::shared_ptr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum a
|
||||
conf += " {\n";
|
||||
conf += " type:'peak',\n";
|
||||
conf += " quality:2,\n";
|
||||
conf += " cut-frequency:" + etk::to_string(cutFrequency) + ",\n";
|
||||
conf += " gain:" + etk::to_string(m_listGain[iii]) + "\n";
|
||||
conf += " cut-frequency:" + etk::toString(cutFrequency) + ",\n";
|
||||
conf += " gain:" + etk::toString(m_listGain[iii]) + "\n";
|
||||
conf += " }\n";
|
||||
}
|
||||
conf += " ]\n";
|
||||
@@ -176,8 +171,8 @@ std11::shared_ptr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum a
|
||||
|
||||
void appl::Windows::onCallbackStart() {
|
||||
APPL_INFO("start ");
|
||||
std11::shared_ptr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer();
|
||||
std::vector<std::pair<float,float> > theory = eq->calculateTheory();
|
||||
ememory::SharedPtr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer();
|
||||
etk::Vector<etk::Pair<float,float> > theory = eq->calculateTheory();
|
||||
m_displayer->clear();
|
||||
m_displayer->setValue(theory);
|
||||
}
|
||||
@@ -185,10 +180,10 @@ void appl::Windows::onCallbackStart() {
|
||||
|
||||
void appl::Windows::onCallbackStart16() {
|
||||
APPL_INFO("start ");
|
||||
std11::shared_ptr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer(audio::format_int16);
|
||||
std::vector<std::pair<float,float> > pratic;
|
||||
ememory::SharedPtr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer(audio::format_int16);
|
||||
etk::Vector<etk::Pair<float,float> > pratic;
|
||||
size_t len = 512;
|
||||
std::vector<int16_t> data;
|
||||
etk::Vector<int16_t> data;
|
||||
data.resize(16000, 0);
|
||||
for (size_t iii=1; iii < len; iii++) {
|
||||
float freq = iii / (len - 1.0) * m_sampleRate / 2.0;
|
||||
@@ -205,8 +200,8 @@ void appl::Windows::onCallbackStart16() {
|
||||
}
|
||||
}
|
||||
// process
|
||||
int16_t* output = nullptr;
|
||||
void* outputVoid = nullptr;
|
||||
int16_t* output = null;
|
||||
void* outputVoid = null;
|
||||
size_t outputNbChunk = 0;
|
||||
audio::Time time;
|
||||
APPL_SAVE_FILE_MACRO(int16_t, "aaa_test_INPUT.raw", &data[0], data.size());
|
||||
@@ -215,21 +210,21 @@ void appl::Windows::onCallbackStart16() {
|
||||
APPL_SAVE_FILE_MACRO(int16_t, "aaa_test_OUTPUT.raw", output, outputNbChunk);
|
||||
int16_t value = 0;
|
||||
for (size_t iii=800; iii<outputNbChunk-200; ++iii) {
|
||||
value = std::max(value, output[iii]);
|
||||
value = etk::max(value, output[iii]);
|
||||
}
|
||||
gain = 20.0 * std::log10(double(value)/32000.0);
|
||||
gain = 20.0 * etk::log10(double(value)/32000.0);
|
||||
APPL_VERBOSE("LEVEL " << iii << " out = " << value << " % : " << gain);
|
||||
pratic.push_back(std::make_pair<float, float>(float(freq),float(gain)));
|
||||
pratic.pushBack(etk::makePair<float, float>(float(freq),float(gain)));
|
||||
}
|
||||
m_displayer->setValue(pratic);
|
||||
}
|
||||
|
||||
void appl::Windows::onCallbackStartFloat() {
|
||||
APPL_INFO("start ");
|
||||
std11::shared_ptr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer(audio::format_float);
|
||||
std::vector<std::pair<float,float> > pratic;
|
||||
ememory::SharedPtr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer(audio::format_float);
|
||||
etk::Vector<etk::Pair<float,float> > pratic;
|
||||
size_t len = 512;
|
||||
std::vector<float> data;
|
||||
etk::Vector<float> data;
|
||||
data.resize(16000, 0);
|
||||
for (size_t iii=1; iii < len; iii++) {
|
||||
float freq = iii / (len - 1.0) * m_sampleRate / 2.0;
|
||||
@@ -246,8 +241,8 @@ void appl::Windows::onCallbackStartFloat() {
|
||||
}
|
||||
}
|
||||
// process
|
||||
float* output = nullptr;
|
||||
void* outputVoid = nullptr;
|
||||
float* output = null;
|
||||
void* outputVoid = null;
|
||||
size_t outputNbChunk = 0;
|
||||
audio::Time time;
|
||||
APPL_SAVE_FILE_MACRO(int16_t,"aaa_test_INPUT_F.raw",&data[0],data.size());
|
||||
@@ -256,11 +251,11 @@ void appl::Windows::onCallbackStartFloat() {
|
||||
APPL_SAVE_FILE_MACRO(int16_t,"aaa_test_OUTPUT_F.raw",output, outputNbChunk);
|
||||
float value = 0;
|
||||
for (size_t iii=800; iii<outputNbChunk-200; ++iii) {
|
||||
value = std::max(value, output[iii]);
|
||||
value = etk::max(value, output[iii]);
|
||||
}
|
||||
gain = 20.0 * std::log10(double(value)/1.0);
|
||||
gain = 20.0 * etk::log10(double(value)/1.0);
|
||||
APPL_VERBOSE("LEVEL " << iii << " out = " << value << " % : " << gain);
|
||||
pratic.push_back(std::make_pair<float, float>(float(freq),float(gain)));
|
||||
pratic.pushBack(etk::makePair<float, float>(float(freq),float(gain)));
|
||||
}
|
||||
m_displayer->setValue(pratic);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifndef __APPL_WINDOWS_H__
|
||||
#define __APPL_WINDOWS_H__
|
||||
|
||||
#include <ewol/widget/Windows.h>
|
||||
#include <ewol/widget/Layer.h>
|
||||
#include <ewol/widget/Composer.h>
|
||||
#include <audio/drain/Equalizer.h>
|
||||
#include <appl/widget/DisplayFrequency.h>
|
||||
#include <ewol/widget/Windows.hpp>
|
||||
#include <ewol/widget/Layer.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <audio/drain/Equalizer.hpp>
|
||||
#include <appl/widget/DisplayFrequency.hpp>
|
||||
|
||||
namespace appl {
|
||||
class Windows : public ewol::widget::Windows {
|
||||
@@ -23,8 +19,8 @@ namespace appl {
|
||||
public:
|
||||
DECLARE_FACTORY(Windows);
|
||||
protected:
|
||||
std::shared_ptr<ewol::widget::Composer> m_gui;
|
||||
std::shared_ptr<appl::widget::DisplayFrequency> m_displayer;
|
||||
ememory::SharedPtr<ewol::widget::Composer> m_gui;
|
||||
ememory::SharedPtr<appl::widget::DisplayFrequency> m_displayer;
|
||||
void onCallbackSampleRateLow();
|
||||
void onCallbackSampleRateUp();
|
||||
void onCallbackGain0(const float& _value) {
|
||||
@@ -63,12 +59,10 @@ namespace appl {
|
||||
void onCallbackStartFloat();
|
||||
protected:
|
||||
int32_t m_sampleRate;
|
||||
std::vector<int32_t> m_listSampleRate;
|
||||
etk::Vector<int32_t> m_listSampleRate;
|
||||
|
||||
std::vector<float> m_listGain;
|
||||
std11::shared_ptr<audio::drain::Equalizer> createEqualizer(enum audio::format _format = audio::format_float);
|
||||
etk::Vector<float> m_listGain;
|
||||
ememory::SharedPtr<audio::drain::Equalizer> createEqualizer(enum audio::format _format = audio::format_float);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,15 +1,13 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = etk::log::registerInstance("drain-equalizer");
|
||||
static int32_t g_val = elog::registerInstance("drain-equalizer");
|
||||
return g_val;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
#ifndef __APPL_DEBUG_H__
|
||||
#define __APPL_DEBUG_H__
|
||||
|
||||
#include <etk/log.h>
|
||||
#include <elog/log.hpp>
|
||||
|
||||
namespace appl {
|
||||
int32_t getLogId();
|
||||
};
|
||||
#define APPL_BASE(info,data) TK_LOG_BASE(appl::getLogId(),info,data)
|
||||
#define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data)
|
||||
|
||||
#define APPL_CRITICAL(data) APPL_BASE(1, data)
|
||||
#define APPL_ERROR(data) APPL_BASE(2, data)
|
||||
@@ -40,4 +35,3 @@ namespace appl {
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
@@ -1,22 +1,20 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <gale/context/commandLine.h>
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <gale/context/commandLine.hpp>
|
||||
|
||||
#include <appl/debug.h>
|
||||
#include <appl/Windows.h>
|
||||
#include <ewol/object/Object.h>
|
||||
#include <ewol/widget/Manager.h>
|
||||
#include <ewol/context/Context.h>
|
||||
#include <appl/widget/DisplayFrequency.h>
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/Windows.hpp>
|
||||
#include <ewol/object/Object.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <ewol/context/Context.hpp>
|
||||
#include <appl/widget/DisplayFrequency.hpp>
|
||||
|
||||
|
||||
class MainApplication : public ewol::context::Application {
|
||||
@@ -34,7 +32,7 @@ class MainApplication : public ewol::context::Application {
|
||||
// add local widget list:
|
||||
appl::widget::DisplayFrequency::createManagerWidget(_context.getWidgetManager());
|
||||
|
||||
std::shared_ptr<ewol::widget::Windows> basicWindows = appl::Windows::create();
|
||||
ememory::SharedPtr<ewol::widget::Windows> basicWindows = appl::Windows::create();
|
||||
// create the specific windows
|
||||
_context.setWindows(basicWindows);
|
||||
APPL_INFO("==> Init APPL (END)");
|
||||
@@ -54,7 +52,7 @@ class MainApplication : public ewol::context::Application {
|
||||
* @return std IO
|
||||
*/
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
return ewol::run(new MainApplication(), _argc, _argv);
|
||||
return ewol::run(ETK_NEW(MainApplication), _argc, _argv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __APPL_MAIN_H__
|
||||
#define __APPL_MAIN_H__
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
7
tools/drainEqualizerProfiling/appl/main.hpp
Normal file
7
tools/drainEqualizerProfiling/appl/main.hpp
Normal file
@@ -0,0 +1,7 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <appl/widget/DisplayFrequency.h>
|
||||
#include <appl/debug.h>
|
||||
#include <etk/tool.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "DisplayFrequency"
|
||||
|
||||
#include <appl/widget/DisplayFrequency.hpp>
|
||||
#include <appl/debug.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
|
||||
appl::widget::DisplayFrequency::DisplayFrequency() :
|
||||
m_gainMin(0.0f),
|
||||
@@ -34,8 +28,8 @@ appl::widget::DisplayFrequency::~DisplayFrequency() {
|
||||
}
|
||||
|
||||
|
||||
void appl::widget::DisplayFrequency::setValue(const std::vector<std::pair<float,float> >& _data) {
|
||||
m_data.push_back(_data);
|
||||
void appl::widget::DisplayFrequency::setValue(const etk::Vector<etk::Pair<float,float> >& _data) {
|
||||
m_data.pushBack(_data);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
@@ -89,24 +83,24 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() {
|
||||
bool displayLog = true;
|
||||
for (size_t kkk=0; kkk<m_data.size(); kkk++) {
|
||||
for (size_t iii=0; iii<m_data[kkk].size(); ++iii) {
|
||||
if (std::abs(m_data[kkk][iii].second) != std::numeric_limits<float>::infinity()) {
|
||||
m_gainMax = std::max(m_gainMax, m_data[kkk][iii].second);
|
||||
m_gainMin = std::min(m_gainMin, m_data[kkk][iii].second);
|
||||
if (isinf(etk::abs(m_data[kkk][iii].second)) == false) {
|
||||
m_gainMax = etk::max(m_gainMax, m_data[kkk][iii].second);
|
||||
m_gainMin = etk::min(m_gainMin, m_data[kkk][iii].second);
|
||||
//APPL_INFO("plop " << m_data[kkk][iii].second);
|
||||
}
|
||||
if (displayLog == false) {
|
||||
if (std::abs(m_data[kkk][iii].first) != std::numeric_limits<float>::infinity()) {
|
||||
m_frequencyMax = std::max(m_frequencyMax, m_data[kkk][iii].first);
|
||||
m_frequencyMin = std::min(m_frequencyMin, m_data[kkk][iii].first);
|
||||
if (isinf(etk::abs(m_data[kkk][iii].first)) == false) {
|
||||
m_frequencyMax = etk::max(m_frequencyMax, m_data[kkk][iii].first);
|
||||
m_frequencyMin = etk::min(m_frequencyMin, m_data[kkk][iii].first);
|
||||
}
|
||||
} else {
|
||||
if (std::abs(m_data[kkk][iii].first) != std::numeric_limits<float>::infinity()) {
|
||||
if (isinf(etk::abs(m_data[kkk][iii].first))) == false) {
|
||||
if (m_data[kkk][iii].first == 0) {
|
||||
continue;
|
||||
}
|
||||
m_frequencyMax = std::max(m_frequencyMax, std::log(m_data[kkk][iii].first));
|
||||
m_frequencyMin = std::min(m_frequencyMin, std::log(m_data[kkk][iii].first));
|
||||
//APPL_INFO("plop " << m_data[kkk][iii].first << " " << std::log(m_data[kkk][iii].first));
|
||||
m_frequencyMax = etk::max(m_frequencyMax, etk::log(m_data[kkk][iii].first));
|
||||
m_frequencyMin = etk::min(m_frequencyMin, etk::log(m_data[kkk][iii].first));
|
||||
//APPL_INFO("plop " << m_data[kkk][iii].first << " " << etk::log(m_data[kkk][iii].first));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,33 +144,33 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() {
|
||||
}
|
||||
} else {
|
||||
m_draw.setPos( m_borderSize
|
||||
+ vec2(ratioX*(std::log(m_data[kkk][0].first) - m_frequencyMin),
|
||||
+ vec2(ratioX*(etk::log(m_data[kkk][0].first) - m_frequencyMin),
|
||||
ratioY*(m_data[kkk][0].second - m_gainMin)));
|
||||
float baseX = 0;
|
||||
for (size_t iii=1; iii<m_data[kkk].size(); ++iii) {
|
||||
m_draw.lineTo( m_borderSize
|
||||
+ vec2(ratioX*(std::log(m_data[kkk][iii].first) - m_frequencyMin),
|
||||
+ vec2(ratioX*(etk::log(m_data[kkk][iii].first) - m_frequencyMin),
|
||||
ratioY*(m_data[kkk][iii].second - m_gainMin)));
|
||||
}
|
||||
}
|
||||
}
|
||||
m_text.setDefaultColorFg(etk::color::green);
|
||||
std::string textToDisplay = etk::to_string(m_frequencyMin) + " Hz";
|
||||
etk::String textToDisplay = etk::toString(m_frequencyMin) + " Hz";
|
||||
vec3 size = m_text.calculateSize(textToDisplay);
|
||||
m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y()-size.y()));
|
||||
m_text.print(textToDisplay);
|
||||
|
||||
textToDisplay = etk::to_string(m_frequencyMax) + " Hz";
|
||||
textToDisplay = etk::toString(m_frequencyMax) + " Hz";
|
||||
size = m_text.calculateSize(textToDisplay);
|
||||
m_text.setPos(vec2(m_size.x()-m_borderSize.x()-size.x(), m_borderSize.y()-size.y()));
|
||||
m_text.print(textToDisplay);
|
||||
|
||||
textToDisplay = etk::to_string(m_gainMin) + " dB";
|
||||
textToDisplay = etk::toString(m_gainMin) + " dB";
|
||||
size = m_text.calculateSize(textToDisplay);
|
||||
m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y()));
|
||||
m_text.print(textToDisplay);
|
||||
|
||||
textToDisplay = etk::to_string(m_gainMax) + " dB";
|
||||
textToDisplay = etk::toString(m_gainMax) + " dB";
|
||||
size = m_text.calculateSize(textToDisplay);
|
||||
m_text.setPos(vec2(m_borderSize.x(), m_size.y() - m_borderSize.y()));
|
||||
m_text.print(textToDisplay);
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE-2 (see license file)
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
#ifndef __APPL_WIDGET_DISPLAY_FREQUENCY_H__
|
||||
#define __APPL_WIDGET_DISPLAY_FREQUENCY_H__
|
||||
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <ewol/compositing/Drawing.h>
|
||||
#include <ewol/compositing/Text.h>
|
||||
#include <ewol/widget/Manager.h>
|
||||
#include <ewol/widget/Widget.hpp>
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
#include <ewol/compositing/Text.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
namespace appl {
|
||||
namespace widget {
|
||||
@@ -30,12 +25,12 @@ namespace appl {
|
||||
//! @brief destructor
|
||||
virtual ~DisplayFrequency();
|
||||
private:
|
||||
std::vector<std::vector<std::pair<float,float> > > m_data; //!< data that might be displayed
|
||||
etk::Vector<etk::Vector<etk::Pair<float,float> > > m_data; //!< data that might be displayed
|
||||
public:
|
||||
void clear() {
|
||||
m_data.clear();
|
||||
}
|
||||
void setValue(const std::vector<std::pair<float,float> >& _data);
|
||||
void setValue(const etk::Vector<etk::Pair<float,float> >& _data);
|
||||
private:
|
||||
float m_gainMin; //!< display minimum gain value
|
||||
float m_gainMax; //!< display maximum gain value
|
||||
@@ -55,4 +50,3 @@ namespace appl {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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 "basic test and profiling of equalizer work or not"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
@@ -24,21 +24,24 @@ def get_compagny_name():
|
||||
def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
def configure(target, my_module):
|
||||
my_module.add_src_file([
|
||||
'appl/main.cpp',
|
||||
'appl/debug.cpp',
|
||||
'appl/Windows.cpp',
|
||||
'appl/widget/DisplayFrequency.cpp',
|
||||
])
|
||||
my_module.add_module_depend(['ewol', 'audio-drain', 'audio-river'])
|
||||
my_module.compile_flags('c++', [
|
||||
"-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\""
|
||||
])
|
||||
my_module.add_path(tools.get_current_path(__file__))
|
||||
'appl/main.cpp',
|
||||
'appl/debug.cpp',
|
||||
'appl/Windows.cpp',
|
||||
'appl/widget/DisplayFrequency.cpp',
|
||||
])
|
||||
my_module.add_depend([
|
||||
'ewol',
|
||||
'audio-drain',
|
||||
'audio-river'
|
||||
])
|
||||
my_module.add_flag('c++', [
|
||||
"-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\""
|
||||
])
|
||||
my_module.add_path(".")
|
||||
my_module.copy_path("data/*")
|
||||
return my_module
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
||||
1
version.txt
Normal file
1
version.txt
Normal file
@@ -0,0 +1 @@
|
||||
1.0.0
|
||||
Reference in New Issue
Block a user