Compare commits

...

15 Commits

62 changed files with 1140 additions and 633 deletions

373
LICENSE Normal file
View 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.

View File

@ -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
[![Build Status](https://travis-ci.org/musicdsp/audio-drain.svg?branch=master)](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.

View File

@ -1,10 +1,10 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <audio/drain/Algo.hpp>
#include <functional>
#include <etk/Function.hpp>
#include "debug.hpp"
audio::drain::Algo::Algo() :
@ -17,8 +17,8 @@ audio::drain::Algo::Algo() :
void audio::drain::Algo::init() {
// set notification callback :
m_input.setCallback(std::bind(&audio::drain::Algo::configurationChangeLocal, this));
m_output.setCallback(std::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();
}
@ -59,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 ...
@ -102,8 +116,8 @@ 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 {

View File

@ -1,17 +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)
*/
#pragma once
#include <string>
#include <vector>
#include <cstdint>
#include <etk/String.hpp>
#include <etk/Vector.hpp>
#include <audio/format.hpp>
#include <audio/channel.hpp>
#include <chrono>
#include <functional>
#include <echrono/Steady.hpp>
#include <etk/Function.hpp>
#include <ememory/memory.hpp>
#include "AutoLogInOut.hpp"
#include "IOFormatInterface.hpp"
@ -27,26 +26,28 @@ namespace audio {
* @brief audio-algo library namespace
*/
namespace drain{
typedef std::function<void (const std::string& _origin, const std::string& _status)> algoStatusFunction;
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:
@ -61,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
@ -136,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;
@ -200,19 +201,19 @@ 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]"; };
};
}
}

View File

@ -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.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]");
}

View File

@ -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)
*/
#pragma once
#include <string>
#include <etk/String.hpp>
#include "debug.hpp"
namespace audio {
namespace drain{
class AutoLogInOut {
private:
std::string m_value;
etk::String m_value;
public:
AutoLogInOut(const std::string& _value);
AutoLogInOut(const etk::String& _value);
~AutoLogInOut();
};
}

View File

@ -1,11 +1,10 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <audio/drain/ChannelReorder.hpp>
#include <iostream>
#include "debug.hpp"
@ -20,7 +19,7 @@ void audio::drain::ChannelReorder::init() {
}
ememory::SharedPtr<audio::drain::ChannelReorder> audio::drain::ChannelReorder::create() {
ememory::SharedPtr<audio::drain::ChannelReorder> tmp(new audio::drain::ChannelReorder());
ememory::SharedPtr<audio::drain::ChannelReorder> tmp(ETK_NEW(audio::drain::ChannelReorder));
tmp->init();
return tmp;
}
@ -57,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 ... ");

View File

@ -1,7 +1,7 @@
/** @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

View File

@ -1,7 +1,7 @@
/** @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.hpp>
@ -9,8 +9,8 @@
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(std::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 += std::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;

View File

@ -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)
*/
#pragma once
#include <etk/types.hpp>
#include <vector>
#include <chrono>
#include <etk/Vector.hpp>
#include <echrono/Steady.hpp>
#include <audio/Time.hpp>
#include <audio/Duration.hpp>
@ -40,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
@ -71,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(std::chrono::milliseconds _capacity, size_t _chunkSize, uint32_t _frequency);
void setCapacity(std::chrono::microseconds _capacity, size_t _chunkSize, uint32_t _frequency) {
setCapacity(std::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.

View File

@ -1,7 +1,7 @@
/** @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

View File

@ -1,7 +1,7 @@
/** @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.hpp>
@ -9,8 +9,8 @@
audio::drain::EndPointCallback::EndPointCallback() :
m_outputFunction(nullptr),
m_inputFunction(nullptr) {
m_outputFunction(null),
m_inputFunction(null) {
}
@ -26,13 +26,13 @@ void audio::drain::EndPointCallback::init(recordFunction _callback) {
}
ememory::SharedPtr<audio::drain::EndPointCallback> audio::drain::EndPointCallback::create(playbackFunction _callback) {
ememory::SharedPtr<audio::drain::EndPointCallback> tmp(new audio::drain::EndPointCallback());
ememory::SharedPtr<audio::drain::EndPointCallback> tmp(ETK_NEW(audio::drain::EndPointCallback));
tmp->init(_callback);
return tmp;
}
ememory::SharedPtr<audio::drain::EndPointCallback> audio::drain::EndPointCallback::create(recordFunction _callback) {
ememory::SharedPtr<audio::drain::EndPointCallback> tmp(new audio::drain::EndPointCallback());
ememory::SharedPtr<audio::drain::EndPointCallback> tmp(ETK_NEW(audio::drain::EndPointCallback));
tmp->init(_callback);
return tmp;
}
@ -50,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,
@ -61,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 ...

View File

@ -1,27 +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
#include <audio/drain/EndPoint.hpp>
#include <functional>
#include <etk/Function.hpp>
namespace audio {
namespace drain {
typedef std::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 std::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;

View File

@ -1,7 +1,7 @@
/** @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.hpp>
@ -19,7 +19,7 @@ void audio::drain::EndPointRead::init() {
}
ememory::SharedPtr<audio::drain::EndPointRead> audio::drain::EndPointRead::create() {
ememory::SharedPtr<audio::drain::EndPointRead> tmp(new audio::drain::EndPointRead());
ememory::SharedPtr<audio::drain::EndPointRead> tmp(ETK_NEW(audio::drain::EndPointRead));
tmp->init();
return tmp;
}
@ -43,7 +43,7 @@ void audio::drain::EndPointRead::setBufferSize(size_t _nbChunk) {
DRAIN_TODO("...");
}
void audio::drain::EndPointRead::setBufferSize(const std::chrono::microseconds& _time) {
void audio::drain::EndPointRead::setBufferSize(const echrono::microseconds& _time) {
DRAIN_TODO("...");
}
@ -52,9 +52,9 @@ size_t audio::drain::EndPointRead::getBufferSize() {
return 0;
}
std::chrono::microseconds audio::drain::EndPointRead::getBufferSizeMicrosecond() {
echrono::microseconds audio::drain::EndPointRead::getBufferSizeMicrosecond() {
DRAIN_TODO("...");
return std::chrono::microseconds(0);
return echrono::microseconds(0);
}
size_t audio::drain::EndPointRead::getBufferFillSize() {
@ -62,8 +62,8 @@ size_t audio::drain::EndPointRead::getBufferFillSize() {
return 0;
}
std::chrono::microseconds audio::drain::EndPointRead::getBufferFillSizeMicrosecond() {
echrono::microseconds audio::drain::EndPointRead::getBufferFillSizeMicrosecond() {
DRAIN_TODO("...");
return std::chrono::microseconds(0);
return echrono::microseconds(0);
}

View File

@ -1,7 +1,7 @@
/** @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
@ -37,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 std::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
@ -47,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 std::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)
@ -57,7 +57,7 @@ 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 std::chrono::microseconds getBufferFillSizeMicrosecond();
virtual echrono::microseconds getBufferFillSizeMicrosecond();
};
}
}

View File

@ -1,15 +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.hpp>
#include <audio/drain/debug.hpp>
audio::drain::EndPointWrite::EndPointWrite() :
m_function(nullptr),
m_bufferSizeMicroseconds(1000000) {
m_function(null),
m_bufferSizeMicroseconds(1000000),
m_bufferSizeChunk(32),
m_bufferUnderFlowSize(0) {
}
@ -25,7 +27,7 @@ void audio::drain::EndPointWrite::init() {
}
ememory::SharedPtr<audio::drain::EndPointWrite> audio::drain::EndPointWrite::create() {
ememory::SharedPtr<audio::drain::EndPointWrite> tmp(new audio::drain::EndPointWrite());
ememory::SharedPtr<audio::drain::EndPointWrite> tmp(ETK_NEW(audio::drain::EndPointWrite));
tmp->init();
return tmp;
}
@ -35,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 (std::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());
@ -56,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());
@ -68,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];
std::unique_lock<std::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");
}
@ -97,7 +110,7 @@ bool audio::drain::EndPointWrite::process(audio::Time& _time,
}
void audio::drain::EndPointWrite::write(const void* _value, size_t _nbChunk) {
std::unique_lock<std::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) {
@ -106,7 +119,7 @@ void audio::drain::EndPointWrite::write(const void* _value, size_t _nbChunk) {
}
void audio::drain::EndPointWrite::setBufferSize(size_t _nbChunk) {
m_bufferSizeMicroseconds = std::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) {
@ -116,7 +129,7 @@ void audio::drain::EndPointWrite::setBufferSize(size_t _nbChunk) {
}
}
void audio::drain::EndPointWrite::setBufferSize(const std::chrono::microseconds& _time) {
void audio::drain::EndPointWrite::setBufferSize(const echrono::microseconds& _time) {
m_bufferSizeMicroseconds = _time;
m_bufferSizeChunk = 0;
m_buffer.setCapacity(_time,
@ -128,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;
}
std::chrono::microseconds audio::drain::EndPointWrite::getBufferSizeMicrosecond() {
if (m_bufferSizeMicroseconds != std::chrono::microseconds(0) ) {
echrono::microseconds audio::drain::EndPointWrite::getBufferSizeMicrosecond() {
if (m_bufferSizeMicroseconds.get() != 0) {
return m_bufferSizeMicroseconds;
}
return std::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());
}
std::chrono::microseconds audio::drain::EndPointWrite::getBufferFillSizeMicrosecond() {
return std::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()));
}

View File

@ -1,27 +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
#include <audio/drain/EndPoint.hpp>
#include <functional>
#include <mutex>
#include <etk/Function.hpp>
#include <ethread/Mutex.hpp>
#include <audio/drain/CircularBuffer.hpp>
namespace audio {
namespace drain{
typedef std::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;
std::mutex m_mutex;
ethread::Mutex m_mutex;
protected:
/**
* @brief Constructor
@ -45,8 +45,9 @@ namespace audio {
m_function = _function;
}
protected:
std::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
@ -57,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 std::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
@ -67,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 std::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)
@ -77,7 +78,7 @@ 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 std::chrono::microseconds getBufferFillSizeMicrosecond();
virtual echrono::microseconds getBufferFillSizeMicrosecond();
};
}
}

View File

@ -1,7 +1,7 @@
/** @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.hpp>
@ -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();
}
ememory::SharedPtr<audio::drain::Equalizer> audio::drain::Equalizer::create() {
ememory::SharedPtr<audio::drain::Equalizer> tmp(new audio::drain::Equalizer());
ememory::SharedPtr<audio::drain::Equalizer> tmp(ETK_NEW(audio::drain::Equalizer));
tmp->init();
return tmp;
}
@ -45,14 +45,14 @@ 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(_value);
@ -64,17 +64,17 @@ 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 ejson::Object& _object) {
// get type:
std::string typeString = _object["type"].toString().get("none");
etk::String typeString = _object["type"].toString().get("none");
if (typeString == "direct-value") {
double a0 = _object["a0"].toNumber().get(0.0);
double a1 = _object["a1"].toNumber().get(0.0);
@ -125,7 +125,7 @@ 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]);
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 ...
@ -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();
}

View File

@ -1,7 +1,7 @@
/** @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
@ -36,9 +36,9 @@ namespace audio {
protected:
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 ejson::Object& _object);
audio::algo::drain::Equalizer m_algo;
@ -48,7 +48,7 @@ namespace audio {
void configureBiQuad();
public:
// for debug & tools only
std::vector<std::pair<float,float> > calculateTheory();
etk::Vector<etk::Pair<float,float> > calculateTheory();
};
}
}

View File

@ -1,11 +1,10 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
* @license MPL v2.0 (see license file)
*/
#include <audio/drain/FormatUpdate.hpp>
#include <iostream>
#include <audio/drain/debug.hpp>
#ifndef INT16_MAX
@ -49,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;
}
}
@ -74,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) {
@ -98,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]);
}
@ -108,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);
}
}
@ -117,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) {
}
@ -134,7 +133,7 @@ void audio::drain::FormatUpdate::init() {
}
ememory::SharedPtr<audio::drain::FormatUpdate> audio::drain::FormatUpdate::create() {
ememory::SharedPtr<audio::drain::FormatUpdate> tmp(new audio::drain::FormatUpdate());
ememory::SharedPtr<audio::drain::FormatUpdate> tmp(ETK_NEW(audio::drain::FormatUpdate));
tmp->init();
return tmp;
}
@ -252,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 ... ");
@ -261,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;
}

View File

@ -1,7 +1,7 @@
/** @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

View File

@ -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 "IOFormatInterface.hpp"
#include "debug.hpp"
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";
@ -25,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<enum audio::channel> _map, enum 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),
@ -37,7 +37,7 @@ audio::drain::IOFormatInterface::IOFormatInterface(std::vector<enum audio::chann
}
void audio::drain::IOFormatInterface::set(std::vector<enum audio::channel> _map, enum 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;
@ -78,11 +78,11 @@ void audio::drain::IOFormatInterface::setFormat(enum audio::format _value) {
configurationChange();
}
const std::vector<enum 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<enum audio::channel>& _value) {
void audio::drain::IOFormatInterface::setMap(const etk::Vector<enum audio::channel>& _value) {
if (m_map == _value) {
return;
}
@ -105,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 std::function<void()>& _functor) {
void audio::drain::IOFormatInterface::setCallback(const etk::Function<void()>& _functor) {
m_ioChangeFunctor = _functor;
}

View File

@ -1,17 +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)
*/
#pragma once
#include <string>
#include <vector>
#include <cstdint>
#include <etk/String.hpp>
#include <etk/Vector.hpp>
#include <audio/format.hpp>
#include <audio/channel.hpp>
#include <chrono>
#include <functional>
#include <echrono/Steady.hpp>
#include <etk/Function.hpp>
#include <ememory/memory.hpp>
#include "AutoLogInOut.hpp"
#include "debug.hpp"
@ -21,8 +20,8 @@ namespace audio {
class IOFormatInterface {
public:
IOFormatInterface();
IOFormatInterface(std::vector<enum audio::channel> _map, enum audio::format _format=audio::format_int16, float _frequency=48000.0f);
void set(std::vector<enum audio::channel> _map, enum 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:
@ -42,18 +41,18 @@ namespace audio {
*/
void setFormat(enum audio::format _value);
protected:
std::vector<enum 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<enum 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<enum audio::channel>& _value);
void setMap(const etk::Vector<enum audio::channel>& _value);
protected:
float m_frequency; //!< input Algo Format
public:
@ -74,16 +73,16 @@ namespace audio {
*/
int32_t getChunkSize() const;
protected:
std::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 std::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);
}
}

View File

@ -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)
*/
#include <string>
#include <vector>
#include <cstdint>
#include <etk/String.hpp>
#include <etk/Vector.hpp>
#include <audio/format.hpp>
#include <audio/channel.hpp>
#include <audio/drain/Process.hpp>
@ -28,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);
@ -39,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) {
@ -69,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);
@ -91,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;
@ -103,18 +103,19 @@ bool audio::drain::Process::process(audio::Time& _time,
void audio::drain::Process::pushBack(ememory::SharedPtr<audio::drain::Algo> _algo) {
removeAlgoDynamic();
_algo->setStatusFunction(std::bind(&audio::drain::Process::generateStatus, this, std::placeholders::_1, std::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(ememory::SharedPtr<audio::drain::Algo> _algo) {
removeAlgoDynamic();
_algo->setStatusFunction(std::bind(&audio::drain::Process::generateStatus, this, std::placeholders::_1, std::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
@ -126,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]);
}
}
}
@ -173,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);
@ -339,7 +340,7 @@ void audio::drain::Process::updateAlgo(size_t _position) {
algo->setInputFormat(out);
out.setFormat(audio::format_int16);
algo->setOutputFormat(out);
algo->setStatusFunction(std::bind(&audio::drain::Process::generateStatus, this, std::placeholders::_1, std::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++;
@ -350,7 +351,7 @@ void audio::drain::Process::updateAlgo(size_t _position) {
algo->setInputFormat(out);
out.setFrequency(in.getFrequency());
algo->setOutputFormat(out);
algo->setStatusFunction(std::bind(&audio::drain::Process::generateStatus, this, std::placeholders::_1, std::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());
@ -363,7 +364,7 @@ void audio::drain::Process::updateAlgo(size_t _position) {
algo->setInputFormat(out);
out.setMap(in.getMap());
algo->setOutputFormat(out);
algo->setStatusFunction(std::bind(&audio::drain::Process::generateStatus, this, std::placeholders::_1, std::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++;
@ -375,7 +376,7 @@ void audio::drain::Process::updateAlgo(size_t _position) {
algo->setInputFormat(out);
out.setFormat(in.getFormat());
algo->setOutputFormat(out);
algo->setStatusFunction(std::bind(&audio::drain::Process::generateStatus, this, std::placeholders::_1, std::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++;
@ -426,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) {
@ -439,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);
}
}

View File

@ -1,26 +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
#include <string>
#include <vector>
#include <cstdint>
#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 <chrono>
#include <echrono/Steady.hpp>
#include <ememory/memory.hpp>
#include <etk/os/FSNode.hpp>
namespace audio {
namespace drain{
typedef std::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();
@ -94,7 +93,7 @@ namespace audio {
m_outputConfig = _interface;
}
protected:
std::vector<ememory::SharedPtr<drain::Algo> > m_listAlgo;
etk::Vector<ememory::SharedPtr<drain::Algo> > m_listAlgo;
public:
void pushBack(ememory::SharedPtr<drain::Algo> _algo);
void pushFront(ememory::SharedPtr<drain::Algo> _algo);
@ -105,19 +104,19 @@ namespace audio {
size_t size() {
return m_listAlgo.size();
}
std::vector<ememory::SharedPtr<drain::Algo> >::iterator begin() {
etk::Vector<ememory::SharedPtr<drain::Algo>>::Iterator begin() {
return m_listAlgo.begin();
}
std::vector<ememory::SharedPtr<drain::Algo> >::iterator end() {
etk::Vector<ememory::SharedPtr<drain::Algo>>::Iterator end() {
return m_listAlgo.end();
}
ememory::SharedPtr<drain::Algo> operator[](int32_t _id) {
return m_listAlgo[_id];
}
template<typename T> ememory::SharedPtr<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) {
@ -126,9 +125,9 @@ namespace audio {
}
return ememory::SharedPtr<T>();
}
template<typename T> ememory::SharedPtr<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) {
@ -143,7 +142,7 @@ namespace audio {
template<typename T> void removeIfFirst() {
if (m_listAlgo.size() > 0) {
ememory::SharedPtr<T> algoEP = get<T>(0);
if (algoEP != nullptr) {
if (algoEP != null) {
m_listAlgo.erase(m_listAlgo.begin());
}
}
@ -151,7 +150,7 @@ namespace audio {
template<typename T> void removeIfLast() {
if (m_listAlgo.size() > 0) {
ememory::SharedPtr<T> algoEP = get<T>(m_listAlgo.size()-1);
if (algoEP != nullptr) {
if (algoEP != null) {
m_listAlgo.erase(m_listAlgo.begin()+m_listAlgo.size()-1);
}
}
@ -159,7 +158,7 @@ namespace audio {
template<typename T> bool hasType() {
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
ememory::SharedPtr<T> tmp = ememory::dynamicPointerCast<T>(m_listAlgo[iii]);
if (tmp != nullptr) {
if (tmp != null) {
return true;
}
}
@ -168,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;
@ -179,9 +178,9 @@ 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);
};
}
}

View File

@ -1,16 +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.hpp>
#include <iostream>
#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) {
@ -20,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);
}
ememory::SharedPtr<audio::drain::Resampler> audio::drain::Resampler::create() {
ememory::SharedPtr<audio::drain::Resampler> tmp(new audio::drain::Resampler());
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
}
@ -65,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);
@ -96,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 ... ");
@ -119,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;
}
@ -146,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;

View File

@ -1,7 +1,7 @@
/** @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

View File

@ -1,29 +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.hpp>
#include <iostream>
#include <cmath>
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);
}
ememory::SharedPtr<audio::drain::Volume> audio::drain::Volume::create() {
ememory::SharedPtr<audio::drain::Volume> tmp(new audio::drain::Volume());
ememory::SharedPtr<audio::drain::Volume> tmp(ETK_NEW(audio::drain::Volume));
tmp->init();
return tmp;
}
@ -37,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);
}
@ -48,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);
@ -101,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;
@ -154,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) {
@ -173,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:
@ -205,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;
@ -280,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;
};
@ -323,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 ... ");
@ -332,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;
}
@ -342,11 +357,11 @@ bool audio::drain::Volume::process(audio::Time& _time,
}
void audio::drain::Volume::addVolumeStage(const ememory::SharedPtr<audio::drain::VolumeElement>& _volume) {
if (_volume == nullptr) {
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) {
@ -357,18 +372,18 @@ void audio::drain::Volume::addVolumeStage(const ememory::SharedPtr<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;
@ -378,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;
@ -389,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";
}
}
}
@ -405,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";
}
}
@ -421,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;
}

View File

@ -1,7 +1,7 @@
/** @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
@ -16,16 +16,16 @@ namespace audio {
// 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:
@ -54,7 +54,7 @@ namespace audio {
// TODO: Manage set volume
class Volume : public audio::drain::Algo {
private:
std::vector<ememory::SharedPtr<drain::VolumeElement> > m_volumeList;
etk::Vector<ememory::SharedPtr<drain::VolumeElement> > m_volumeList;
// for float input :
float m_volumeAppli;
// for integer input :
@ -83,15 +83,17 @@ 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 ememory::SharedPtr<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 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();
};
}
}

View File

@ -1,7 +1,7 @@
/** @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.hpp"

View File

@ -1,14 +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
#include <string>
#include <etk/String.hpp>
#include <audio/format.hpp>
#include <audio/drain/channel.hpp>
#include <chrono>
#include <echrono/Steady.hpp>
namespace audio {
namespace drain {
@ -25,18 +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);
}
}

View File

@ -1,7 +1,7 @@
/** @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.hpp>

View File

@ -1,7 +1,7 @@
/** @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__

View File

@ -1,7 +1,7 @@
/** @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)
*/
#ifdef __AUDIO_DRAIN_DEBUG_H__

View File

@ -30,16 +30,16 @@ Are there any licensing restrictions? {#audio_algo_mainpage_license_r
AUDIO-ALGO is **FREE software** and _all sub-library are FREE and staticly linkable !!!_
License (APACHE-2.0) {#audio_algo_mainpage_license}
====================
License (MPL v2.0) {#audio_algo_mainpage_license}
==================
Copyright AUDIO-ALGO Edouard DUPIN
Licensed under the Apache License, Version 2.0 (the "License");
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
<http://www.apache.org/licenses/LICENSE-2.0>
<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,

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
import realog.debug as debug
import lutin.tools as tools
@ -13,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"
@ -35,7 +35,7 @@ def configure(target, my_module):
])
my_module.add_depend([
'audio-drain',
'gtest',
'etest',
'etk',
'test-debug'
])

View File

@ -1,6 +1,6 @@
#!/usr/bin/python
import lutin.tools as tools
import lutin.debug as debug
import realog.debug as debug
def get_type():
@ -10,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"

View File

@ -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.hpp>
#include <gtest/gtest.h>
#include <etest/etest.hpp>
#include <audio/drain/Process.hpp>

View File

@ -1,11 +1,11 @@
/** @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.hpp>
#include <gtest/gtest.h>
#include <etest/etest.hpp>
#include <audio/drain/Process.hpp>

View File

@ -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.hpp>
#include <gtest/gtest.h>
#include <etest/etest.hpp>
#include <audio/drain/Process.hpp>

View File

@ -1,20 +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.hpp>
#include <test-debug/debug.hpp>
#include <gtest/gtest.h>
#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 : ");

View File

@ -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.hpp>
#include <gtest/gtest.h>
#include <etest/etest.hpp>
#include <audio/drain/Process.hpp>

View File

@ -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.hpp>
#include <gtest/gtest.h>
#include <etest/etest.hpp>
#include <audio/drain/Process.hpp>

View File

@ -1,7 +1,7 @@
/** @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 <etk/types.hpp>
@ -16,18 +16,18 @@
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);*/ \
} \
@ -40,34 +40,34 @@ 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, sharedFromThis(), &appl::Windows::onCallbackSampleRateLow);
@ -100,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();
}
@ -121,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();
}
@ -142,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();
}
@ -161,58 +161,58 @@ 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();
}
@ -225,15 +225,15 @@ void appl::Windows::onCallbackFrequencySlider(const float& _value) {
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);
}
@ -245,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;
@ -254,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++) {
@ -265,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);
}
@ -288,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;
@ -297,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++) {
@ -312,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);
}

View File

@ -1,7 +1,7 @@
/** @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
@ -25,20 +25,20 @@ namespace appl {
void onCallbackSampleRateUp();
void onCallbackTypeUp();
void onCallbackTypeLow();
void onCallbackGain(const std::string& _value);
void onCallbackGain(const etk::String& _value);
void onCallbackGainSlider(const float& _value);
void onCallbackFrequency(const std::string& _value);
void onCallbackFrequency(const etk::String& _value);
void onCallbackFrequencySlider(const float& _value);
void onCallbackQuality(const std::string& _value);
void onCallbackQuality(const etk::String& _value);
void onCallbackQualitySlider(const float& _value);
void onCallbackStart();
void onCallbackStart16();
void onCallbackStartFloat();
protected:
int32_t m_sampleRate;
std::vector<int32_t> m_listSampleRate;
etk::Vector<int32_t> m_listSampleRate;
enum audio::algo::drain::biQuadType m_type;
std::vector<enum audio::algo::drain::biQuadType> m_listType;
etk::Vector<enum audio::algo::drain::biQuadType> m_listType;
float m_cutFrequency;
float m_gain;
float m_quality;

View File

@ -1,7 +1,7 @@
/** @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)
*/

View File

@ -1,7 +1,7 @@
/** @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

View File

@ -1,7 +1,7 @@
/** @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)
*/
@ -52,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);
}

View File

@ -1,7 +1,7 @@
/** @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

View File

@ -1,7 +1,7 @@
/** @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 <appl/widget/DisplayFrequency.hpp>
@ -28,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();
}
@ -83,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));
}
}
}
@ -137,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);

View File

@ -1,7 +1,7 @@
/** @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
@ -25,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

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
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"

View File

@ -1,7 +1,7 @@
/** @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 <ewol/ewol.hpp>
@ -14,18 +14,18 @@
#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);*/ \
} \
@ -34,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);
}
@ -53,8 +53,8 @@ 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, sharedFromThis(), &appl::Windows::onCallbackSampleRateLow);
@ -87,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();
}
@ -106,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();
}
@ -122,8 +122,8 @@ void appl::Windows::onCallbackGain(const float& _value, int32_t _id) {
}
ememory::SharedPtr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum audio::format _format) {
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, _format, m_sampleRate);
// create equalizer
ememory::SharedPtr<audio::drain::Equalizer> out = audio::drain::Equalizer::create();
@ -132,7 +132,7 @@ ememory::SharedPtr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum
// 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) {
@ -157,8 +157,8 @@ ememory::SharedPtr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum
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";
@ -172,7 +172,7 @@ ememory::SharedPtr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum
void appl::Windows::onCallbackStart() {
APPL_INFO("start ");
ememory::SharedPtr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer();
std::vector<std::pair<float,float> > theory = eq->calculateTheory();
etk::Vector<etk::Pair<float,float> > theory = eq->calculateTheory();
m_displayer->clear();
m_displayer->setValue(theory);
}
@ -181,9 +181,9 @@ void appl::Windows::onCallbackStart() {
void appl::Windows::onCallbackStart16() {
APPL_INFO("start ");
ememory::SharedPtr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer(audio::format_int16);
std::vector<std::pair<float,float> > pratic;
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;
@ -200,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());
@ -210,11 +210,11 @@ 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);
}
@ -222,9 +222,9 @@ void appl::Windows::onCallbackStart16() {
void appl::Windows::onCallbackStartFloat() {
APPL_INFO("start ");
ememory::SharedPtr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer(audio::format_float);
std::vector<std::pair<float,float> > pratic;
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;
@ -241,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());
@ -251,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);
}

View File

@ -1,7 +1,7 @@
/** @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
@ -59,9 +59,9 @@ 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;
etk::Vector<float> m_listGain;
ememory::SharedPtr<audio::drain::Equalizer> createEqualizer(enum audio::format _format = audio::format_float);
};
}

View File

@ -1,7 +1,7 @@
/** @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)
*/

View File

@ -1,7 +1,7 @@
/** @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

View File

@ -1,7 +1,7 @@
/** @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)
*/
@ -52,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);
}

View File

@ -1,7 +1,7 @@
/** @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

View File

@ -1,7 +1,7 @@
/** @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 <appl/widget/DisplayFrequency.hpp>
@ -28,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();
}
@ -83,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));
}
}
}
@ -144,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);

View File

@ -1,7 +1,7 @@
/** @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
@ -25,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

View File

@ -1,5 +1,5 @@
#!/usr/bin/python
import lutin.debug as debug
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"

View File

@ -1 +1 @@
0.3.0
1.0.0