Compare commits
	
		
			24 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| f7a565017c | |||
| 9408e2590c | |||
| 9f8b23080b | |||
| fccbf4953e | |||
| 1863974f8f | |||
| 746a6413f2 | |||
| 09889ba745 | |||
| 3e2ef8ce59 | |||
| 57adfb43c8 | |||
| 567bdd6a86 | |||
| 2bd207471f | |||
| e1b155410a | |||
| afc8b186c7 | |||
| 2483530165 | |||
| 3df9a989d8 | |||
| 2b64dbf401 | |||
| 77c9b99c7a | |||
| 7a217bfbd2 | |||
| 185bc5a21c | |||
| dbba4af26d | |||
| 73d7141574 | |||
| 2cd03d30e4 | |||
| 1401d1dea6 | |||
| 8f0ce824b9 | 
							
								
								
									
										373
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										373
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,373 @@ | |||||||
|  | Mozilla Public License Version 2.0 | ||||||
|  | ================================== | ||||||
|  |  | ||||||
|  | 1. Definitions | ||||||
|  | -------------- | ||||||
|  |  | ||||||
|  | 1.1. "Contributor" | ||||||
|  |     means each individual or legal entity that creates, contributes to | ||||||
|  |     the creation of, or owns Covered Software. | ||||||
|  |  | ||||||
|  | 1.2. "Contributor Version" | ||||||
|  |     means the combination of the Contributions of others (if any) used | ||||||
|  |     by a Contributor and that particular Contributor's Contribution. | ||||||
|  |  | ||||||
|  | 1.3. "Contribution" | ||||||
|  |     means Covered Software of a particular Contributor. | ||||||
|  |  | ||||||
|  | 1.4. "Covered Software" | ||||||
|  |     means Source Code Form to which the initial Contributor has attached | ||||||
|  |     the notice in Exhibit A, the Executable Form of such Source Code | ||||||
|  |     Form, and Modifications of such Source Code Form, in each case | ||||||
|  |     including portions thereof. | ||||||
|  |  | ||||||
|  | 1.5. "Incompatible With Secondary Licenses" | ||||||
|  |     means | ||||||
|  |  | ||||||
|  |     (a) that the initial Contributor has attached the notice described | ||||||
|  |         in Exhibit B to the Covered Software; or | ||||||
|  |  | ||||||
|  |     (b) that the Covered Software was made available under the terms of | ||||||
|  |         version 1.1 or earlier of the License, but not also under the | ||||||
|  |         terms of a Secondary License. | ||||||
|  |  | ||||||
|  | 1.6. "Executable Form" | ||||||
|  |     means any form of the work other than Source Code Form. | ||||||
|  |  | ||||||
|  | 1.7. "Larger Work" | ||||||
|  |     means a work that combines Covered Software with other material, in | ||||||
|  |     a separate file or files, that is not Covered Software. | ||||||
|  |  | ||||||
|  | 1.8. "License" | ||||||
|  |     means this document. | ||||||
|  |  | ||||||
|  | 1.9. "Licensable" | ||||||
|  |     means having the right to grant, to the maximum extent possible, | ||||||
|  |     whether at the time of the initial grant or subsequently, any and | ||||||
|  |     all of the rights conveyed by this License. | ||||||
|  |  | ||||||
|  | 1.10. "Modifications" | ||||||
|  |     means any of the following: | ||||||
|  |  | ||||||
|  |     (a) any file in Source Code Form that results from an addition to, | ||||||
|  |         deletion from, or modification of the contents of Covered | ||||||
|  |         Software; or | ||||||
|  |  | ||||||
|  |     (b) any new file in Source Code Form that contains any Covered | ||||||
|  |         Software. | ||||||
|  |  | ||||||
|  | 1.11. "Patent Claims" of a Contributor | ||||||
|  |     means any patent claim(s), including without limitation, method, | ||||||
|  |     process, and apparatus claims, in any patent Licensable by such | ||||||
|  |     Contributor that would be infringed, but for the grant of the | ||||||
|  |     License, by the making, using, selling, offering for sale, having | ||||||
|  |     made, import, or transfer of either its Contributions or its | ||||||
|  |     Contributor Version. | ||||||
|  |  | ||||||
|  | 1.12. "Secondary License" | ||||||
|  |     means either the GNU General Public License, Version 2.0, the GNU | ||||||
|  |     Lesser General Public License, Version 2.1, the GNU Affero General | ||||||
|  |     Public License, Version 3.0, or any later versions of those | ||||||
|  |     licenses. | ||||||
|  |  | ||||||
|  | 1.13. "Source Code Form" | ||||||
|  |     means the form of the work preferred for making modifications. | ||||||
|  |  | ||||||
|  | 1.14. "You" (or "Your") | ||||||
|  |     means an individual or a legal entity exercising rights under this | ||||||
|  |     License. For legal entities, "You" includes any entity that | ||||||
|  |     controls, is controlled by, or is under common control with You. For | ||||||
|  |     purposes of this definition, "control" means (a) the power, direct | ||||||
|  |     or indirect, to cause the direction or management of such entity, | ||||||
|  |     whether by contract or otherwise, or (b) ownership of more than | ||||||
|  |     fifty percent (50%) of the outstanding shares or beneficial | ||||||
|  |     ownership of such entity. | ||||||
|  |  | ||||||
|  | 2. License Grants and Conditions | ||||||
|  | -------------------------------- | ||||||
|  |  | ||||||
|  | 2.1. Grants | ||||||
|  |  | ||||||
|  | Each Contributor hereby grants You a world-wide, royalty-free, | ||||||
|  | non-exclusive license: | ||||||
|  |  | ||||||
|  | (a) under intellectual property rights (other than patent or trademark) | ||||||
|  |     Licensable by such Contributor to use, reproduce, make available, | ||||||
|  |     modify, display, perform, distribute, and otherwise exploit its | ||||||
|  |     Contributions, either on an unmodified basis, with Modifications, or | ||||||
|  |     as part of a Larger Work; and | ||||||
|  |  | ||||||
|  | (b) under Patent Claims of such Contributor to make, use, sell, offer | ||||||
|  |     for sale, have made, import, and otherwise transfer either its | ||||||
|  |     Contributions or its Contributor Version. | ||||||
|  |  | ||||||
|  | 2.2. Effective Date | ||||||
|  |  | ||||||
|  | The licenses granted in Section 2.1 with respect to any Contribution | ||||||
|  | become effective for each Contribution on the date the Contributor first | ||||||
|  | distributes such Contribution. | ||||||
|  |  | ||||||
|  | 2.3. Limitations on Grant Scope | ||||||
|  |  | ||||||
|  | The licenses granted in this Section 2 are the only rights granted under | ||||||
|  | this License. No additional rights or licenses will be implied from the | ||||||
|  | distribution or licensing of Covered Software under this License. | ||||||
|  | Notwithstanding Section 2.1(b) above, no patent license is granted by a | ||||||
|  | Contributor: | ||||||
|  |  | ||||||
|  | (a) for any code that a Contributor has removed from Covered Software; | ||||||
|  |     or | ||||||
|  |  | ||||||
|  | (b) for infringements caused by: (i) Your and any other third party's | ||||||
|  |     modifications of Covered Software, or (ii) the combination of its | ||||||
|  |     Contributions with other software (except as part of its Contributor | ||||||
|  |     Version); or | ||||||
|  |  | ||||||
|  | (c) under Patent Claims infringed by Covered Software in the absence of | ||||||
|  |     its Contributions. | ||||||
|  |  | ||||||
|  | This License does not grant any rights in the trademarks, service marks, | ||||||
|  | or logos of any Contributor (except as may be necessary to comply with | ||||||
|  | the notice requirements in Section 3.4). | ||||||
|  |  | ||||||
|  | 2.4. Subsequent Licenses | ||||||
|  |  | ||||||
|  | No Contributor makes additional grants as a result of Your choice to | ||||||
|  | distribute the Covered Software under a subsequent version of this | ||||||
|  | License (see Section 10.2) or under the terms of a Secondary License (if | ||||||
|  | permitted under the terms of Section 3.3). | ||||||
|  |  | ||||||
|  | 2.5. Representation | ||||||
|  |  | ||||||
|  | Each Contributor represents that the Contributor believes its | ||||||
|  | Contributions are its original creation(s) or it has sufficient rights | ||||||
|  | to grant the rights to its Contributions conveyed by this License. | ||||||
|  |  | ||||||
|  | 2.6. Fair Use | ||||||
|  |  | ||||||
|  | This License is not intended to limit any rights You have under | ||||||
|  | applicable copyright doctrines of fair use, fair dealing, or other | ||||||
|  | equivalents. | ||||||
|  |  | ||||||
|  | 2.7. Conditions | ||||||
|  |  | ||||||
|  | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted | ||||||
|  | in Section 2.1. | ||||||
|  |  | ||||||
|  | 3. Responsibilities | ||||||
|  | ------------------- | ||||||
|  |  | ||||||
|  | 3.1. Distribution of Source Form | ||||||
|  |  | ||||||
|  | All distribution of Covered Software in Source Code Form, including any | ||||||
|  | Modifications that You create or to which You contribute, must be under | ||||||
|  | the terms of this License. You must inform recipients that the Source | ||||||
|  | Code Form of the Covered Software is governed by the terms of this | ||||||
|  | License, and how they can obtain a copy of this License. You may not | ||||||
|  | attempt to alter or restrict the recipients' rights in the Source Code | ||||||
|  | Form. | ||||||
|  |  | ||||||
|  | 3.2. Distribution of Executable Form | ||||||
|  |  | ||||||
|  | If You distribute Covered Software in Executable Form then: | ||||||
|  |  | ||||||
|  | (a) such Covered Software must also be made available in Source Code | ||||||
|  |     Form, as described in Section 3.1, and You must inform recipients of | ||||||
|  |     the Executable Form how they can obtain a copy of such Source Code | ||||||
|  |     Form by reasonable means in a timely manner, at a charge no more | ||||||
|  |     than the cost of distribution to the recipient; and | ||||||
|  |  | ||||||
|  | (b) You may distribute such Executable Form under the terms of this | ||||||
|  |     License, or sublicense it under different terms, provided that the | ||||||
|  |     license for the Executable Form does not attempt to limit or alter | ||||||
|  |     the recipients' rights in the Source Code Form under this License. | ||||||
|  |  | ||||||
|  | 3.3. Distribution of a Larger Work | ||||||
|  |  | ||||||
|  | You may create and distribute a Larger Work under terms of Your choice, | ||||||
|  | provided that You also comply with the requirements of this License for | ||||||
|  | the Covered Software. If the Larger Work is a combination of Covered | ||||||
|  | Software with a work governed by one or more Secondary Licenses, and the | ||||||
|  | Covered Software is not Incompatible With Secondary Licenses, this | ||||||
|  | License permits You to additionally distribute such Covered Software | ||||||
|  | under the terms of such Secondary License(s), so that the recipient of | ||||||
|  | the Larger Work may, at their option, further distribute the Covered | ||||||
|  | Software under the terms of either this License or such Secondary | ||||||
|  | License(s). | ||||||
|  |  | ||||||
|  | 3.4. Notices | ||||||
|  |  | ||||||
|  | You may not remove or alter the substance of any license notices | ||||||
|  | (including copyright notices, patent notices, disclaimers of warranty, | ||||||
|  | or limitations of liability) contained within the Source Code Form of | ||||||
|  | the Covered Software, except that You may alter any license notices to | ||||||
|  | the extent required to remedy known factual inaccuracies. | ||||||
|  |  | ||||||
|  | 3.5. Application of Additional Terms | ||||||
|  |  | ||||||
|  | You may choose to offer, and to charge a fee for, warranty, support, | ||||||
|  | indemnity or liability obligations to one or more recipients of Covered | ||||||
|  | Software. However, You may do so only on Your own behalf, and not on | ||||||
|  | behalf of any Contributor. You must make it absolutely clear that any | ||||||
|  | such warranty, support, indemnity, or liability obligation is offered by | ||||||
|  | You alone, and You hereby agree to indemnify every Contributor for any | ||||||
|  | liability incurred by such Contributor as a result of warranty, support, | ||||||
|  | indemnity or liability terms You offer. You may include additional | ||||||
|  | disclaimers of warranty and limitations of liability specific to any | ||||||
|  | jurisdiction. | ||||||
|  |  | ||||||
|  | 4. Inability to Comply Due to Statute or Regulation | ||||||
|  | --------------------------------------------------- | ||||||
|  |  | ||||||
|  | If it is impossible for You to comply with any of the terms of this | ||||||
|  | License with respect to some or all of the Covered Software due to | ||||||
|  | statute, judicial order, or regulation then You must: (a) comply with | ||||||
|  | the terms of this License to the maximum extent possible; and (b) | ||||||
|  | describe the limitations and the code they affect. Such description must | ||||||
|  | be placed in a text file included with all distributions of the Covered | ||||||
|  | Software under this License. Except to the extent prohibited by statute | ||||||
|  | or regulation, such description must be sufficiently detailed for a | ||||||
|  | recipient of ordinary skill to be able to understand it. | ||||||
|  |  | ||||||
|  | 5. Termination | ||||||
|  | -------------- | ||||||
|  |  | ||||||
|  | 5.1. The rights granted under this License will terminate automatically | ||||||
|  | if You fail to comply with any of its terms. However, if You become | ||||||
|  | compliant, then the rights granted under this License from a particular | ||||||
|  | Contributor are reinstated (a) provisionally, unless and until such | ||||||
|  | Contributor explicitly and finally terminates Your grants, and (b) on an | ||||||
|  | ongoing basis, if such Contributor fails to notify You of the | ||||||
|  | non-compliance by some reasonable means prior to 60 days after You have | ||||||
|  | come back into compliance. Moreover, Your grants from a particular | ||||||
|  | Contributor are reinstated on an ongoing basis if such Contributor | ||||||
|  | notifies You of the non-compliance by some reasonable means, this is the | ||||||
|  | first time You have received notice of non-compliance with this License | ||||||
|  | from such Contributor, and You become compliant prior to 30 days after | ||||||
|  | Your receipt of the notice. | ||||||
|  |  | ||||||
|  | 5.2. If You initiate litigation against any entity by asserting a patent | ||||||
|  | infringement claim (excluding declaratory judgment actions, | ||||||
|  | counter-claims, and cross-claims) alleging that a Contributor Version | ||||||
|  | directly or indirectly infringes any patent, then the rights granted to | ||||||
|  | You by any and all Contributors for the Covered Software under Section | ||||||
|  | 2.1 of this License shall terminate. | ||||||
|  |  | ||||||
|  | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all | ||||||
|  | end user license agreements (excluding distributors and resellers) which | ||||||
|  | have been validly granted by You or Your distributors under this License | ||||||
|  | prior to termination shall survive termination. | ||||||
|  |  | ||||||
|  | ************************************************************************ | ||||||
|  | *                                                                      * | ||||||
|  | *  6. Disclaimer of Warranty                                           * | ||||||
|  | *  -------------------------                                           * | ||||||
|  | *                                                                      * | ||||||
|  | *  Covered Software is provided under this License on an "as is"       * | ||||||
|  | *  basis, without warranty of any kind, either expressed, implied, or  * | ||||||
|  | *  statutory, including, without limitation, warranties that the       * | ||||||
|  | *  Covered Software is free of defects, merchantable, fit for a        * | ||||||
|  | *  particular purpose or non-infringing. The entire risk as to the     * | ||||||
|  | *  quality and performance of the Covered Software is with You.        * | ||||||
|  | *  Should any Covered Software prove defective in any respect, You     * | ||||||
|  | *  (not any Contributor) assume the cost of any necessary servicing,   * | ||||||
|  | *  repair, or correction. This disclaimer of warranty constitutes an   * | ||||||
|  | *  essential part of this License. No use of any Covered Software is   * | ||||||
|  | *  authorized under this License except under this disclaimer.         * | ||||||
|  | *                                                                      * | ||||||
|  | ************************************************************************ | ||||||
|  |  | ||||||
|  | ************************************************************************ | ||||||
|  | *                                                                      * | ||||||
|  | *  7. Limitation of Liability                                          * | ||||||
|  | *  --------------------------                                          * | ||||||
|  | *                                                                      * | ||||||
|  | *  Under no circumstances and under no legal theory, whether tort      * | ||||||
|  | *  (including negligence), contract, or otherwise, shall any           * | ||||||
|  | *  Contributor, or anyone who distributes Covered Software as          * | ||||||
|  | *  permitted above, be liable to You for any direct, indirect,         * | ||||||
|  | *  special, incidental, or consequential damages of any character      * | ||||||
|  | *  including, without limitation, damages for lost profits, loss of    * | ||||||
|  | *  goodwill, work stoppage, computer failure or malfunction, or any    * | ||||||
|  | *  and all other commercial damages or losses, even if such party      * | ||||||
|  | *  shall have been informed of the possibility of such damages. This   * | ||||||
|  | *  limitation of liability shall not apply to liability for death or   * | ||||||
|  | *  personal injury resulting from such party's negligence to the       * | ||||||
|  | *  extent applicable law prohibits such limitation. Some               * | ||||||
|  | *  jurisdictions do not allow the exclusion or limitation of           * | ||||||
|  | *  incidental or consequential damages, so this exclusion and          * | ||||||
|  | *  limitation may not apply to You.                                    * | ||||||
|  | *                                                                      * | ||||||
|  | ************************************************************************ | ||||||
|  |  | ||||||
|  | 8. Litigation | ||||||
|  | ------------- | ||||||
|  |  | ||||||
|  | Any litigation relating to this License may be brought only in the | ||||||
|  | courts of a jurisdiction where the defendant maintains its principal | ||||||
|  | place of business and such litigation shall be governed by laws of that | ||||||
|  | jurisdiction, without reference to its conflict-of-law provisions. | ||||||
|  | Nothing in this Section shall prevent a party's ability to bring | ||||||
|  | cross-claims or counter-claims. | ||||||
|  |  | ||||||
|  | 9. Miscellaneous | ||||||
|  | ---------------- | ||||||
|  |  | ||||||
|  | This License represents the complete agreement concerning the subject | ||||||
|  | matter hereof. If any provision of this License is held to be | ||||||
|  | unenforceable, such provision shall be reformed only to the extent | ||||||
|  | necessary to make it enforceable. Any law or regulation which provides | ||||||
|  | that the language of a contract shall be construed against the drafter | ||||||
|  | shall not be used to construe this License against a Contributor. | ||||||
|  |  | ||||||
|  | 10. Versions of the License | ||||||
|  | --------------------------- | ||||||
|  |  | ||||||
|  | 10.1. New Versions | ||||||
|  |  | ||||||
|  | Mozilla Foundation is the license steward. Except as provided in Section | ||||||
|  | 10.3, no one other than the license steward has the right to modify or | ||||||
|  | publish new versions of this License. Each version will be given a | ||||||
|  | distinguishing version number. | ||||||
|  |  | ||||||
|  | 10.2. Effect of New Versions | ||||||
|  |  | ||||||
|  | You may distribute the Covered Software under the terms of the version | ||||||
|  | of the License under which You originally received the Covered Software, | ||||||
|  | or under the terms of any subsequent version published by the license | ||||||
|  | steward. | ||||||
|  |  | ||||||
|  | 10.3. Modified Versions | ||||||
|  |  | ||||||
|  | If you create software not governed by this License, and you want to | ||||||
|  | create a new license for such software, you may create and use a | ||||||
|  | modified version of this License if you rename the license and remove | ||||||
|  | any references to the name of the license steward (except to note that | ||||||
|  | such modified license differs from this License). | ||||||
|  |  | ||||||
|  | 10.4. Distributing Source Code Form that is Incompatible With Secondary | ||||||
|  | Licenses | ||||||
|  |  | ||||||
|  | If You choose to distribute Source Code Form that is Incompatible With | ||||||
|  | Secondary Licenses under the terms of this version of the License, the | ||||||
|  | notice described in Exhibit B of this License must be attached. | ||||||
|  |  | ||||||
|  | Exhibit A - Source Code Form License Notice | ||||||
|  | ------------------------------------------- | ||||||
|  |  | ||||||
|  |   This Source Code Form is subject to the terms of the Mozilla Public | ||||||
|  |   License, v. 2.0. If a copy of the MPL was not distributed with this | ||||||
|  |   file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||||
|  |  | ||||||
|  | If it is not possible or desirable to put the notice in a particular | ||||||
|  | file, then You may include the notice in a location (such as a LICENSE | ||||||
|  | file in a relevant directory) where a recipient would be likely to look | ||||||
|  | for such a notice. | ||||||
|  |  | ||||||
|  | You may add additional accurate notices of copyright ownership. | ||||||
|  |  | ||||||
|  | Exhibit B - "Incompatible With Secondary Licenses" Notice | ||||||
|  | --------------------------------------------------------- | ||||||
|  |  | ||||||
|  |   This Source Code Form is "Incompatible With Secondary Licenses", as | ||||||
|  |   defined by the Mozilla Public License, v. 2.0. | ||||||
							
								
								
									
										18
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								README.md
									
									
									
									
									
								
							| @@ -1,4 +1,20 @@ | |||||||
| # audio-drain | # audio-drain | ||||||
| (APACHE v2.0) audio: processing pipe for simple agorithms (resampling, change format, reorder channel, volume ...) 1 flow | (MPL v2.0) audio: processing pipe for simple agorithms (resampling, change format, reorder channel, volume ...) 1 flow | ||||||
|  |  | ||||||
| [](https://travis-ci.org/musicdsp/audio-drain) | [](https://travis-ci.org/musicdsp/audio-drain) | ||||||
|  |  | ||||||
|  | License (MPL v2.0) | ||||||
|  | ===================== | ||||||
|  | Copyright audio Edouard DUPIN | ||||||
|  |  | ||||||
|  | Licensed under the Mozilla Public License, Version 2.0 (the "License"); | ||||||
|  | you may not use this file except in compliance with the License. | ||||||
|  | You may obtain a copy of the License at | ||||||
|  |  | ||||||
|  | 	https://www.mozilla.org/MPL/2.0 | ||||||
|  |  | ||||||
|  | Unless required by applicable law or agreed to in writing, software | ||||||
|  | distributed under the License is distributed on an "AS IS" BASIS, | ||||||
|  | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||
|  | See the License for the specific language governing permissions and | ||||||
|  | limitations under the License. | ||||||
|   | |||||||
| @@ -1,11 +1,11 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #include <audio/drain/Algo.h> | #include <audio/drain/Algo.hpp> | ||||||
| #include <functional> | #include <etk/Function.hpp> | ||||||
| #include "debug.h" | #include "debug.hpp" | ||||||
|  |  | ||||||
| audio::drain::Algo::Algo() : | audio::drain::Algo::Algo() : | ||||||
|   m_temporary(false), |   m_temporary(false), | ||||||
| @@ -17,8 +17,8 @@ audio::drain::Algo::Algo() : | |||||||
|  |  | ||||||
| void audio::drain::Algo::init() { | void audio::drain::Algo::init() { | ||||||
| 	// set notification callback : | 	// set notification callback : | ||||||
| 	m_input.setCallback(std::bind(&audio::drain::Algo::configurationChangeLocal, this)); | 	m_input.setCallback([=](){audio::drain::Algo::configurationChangeLocal();}); | ||||||
| 	m_output.setCallback(std::bind(&audio::drain::Algo::configurationChangeLocal, this)); | 	m_output.setCallback([=](){audio::drain::Algo::configurationChangeLocal();}); | ||||||
| 	// first configure ==> update the internal parameters | 	// first configure ==> update the internal parameters | ||||||
| 	configurationChange(); | 	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 audio::drain::Algo::needInputData(size_t _output) { | ||||||
| 	size_t input = _output; | 	size_t input = _output; | ||||||
| 	/* NOT good at all ... | 	/* NOT good at all ... | ||||||
| @@ -102,8 +116,8 @@ void audio::drain::Algo::setStatusFunction(algoStatusFunction _newFunction) { | |||||||
| 	m_statusFunction = _newFunction; | 	m_statusFunction = _newFunction; | ||||||
| } | } | ||||||
|  |  | ||||||
| void audio::drain::Algo::generateStatus(const std::string& _status) { | void audio::drain::Algo::generateStatus(const etk::String& _status) { | ||||||
| 	if (m_statusFunction != nullptr) { | 	if (m_statusFunction != null) { | ||||||
| 		if (m_name.size() == 0) { | 		if (m_name.size() == 0) { | ||||||
| 			m_statusFunction(m_type, _status); | 			m_statusFunction(m_type, _status); | ||||||
| 		} else { | 		} else { | ||||||
|   | |||||||
| @@ -1,46 +1,53 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <string> | #include <etk/String.hpp> | ||||||
| #include <vector> | #include <etk/Vector.hpp> | ||||||
| #include <stdint.h> | #include <audio/format.hpp> | ||||||
| #include <audio/format.h> | #include <audio/channel.hpp> | ||||||
| #include <audio/channel.h> | #include <echrono/Steady.hpp> | ||||||
| #include <chrono> | #include <etk/Function.hpp> | ||||||
| #include <functional> | #include <ememory/memory.hpp> | ||||||
| #include <ememory/memory.h> | #include "AutoLogInOut.hpp" | ||||||
| #include "AutoLogInOut.h" | #include "IOFormatInterface.hpp" | ||||||
| #include "IOFormatInterface.h" | #include <audio/Time.hpp> | ||||||
| #include <audio/Time.h> | #include <audio/Duration.hpp> | ||||||
| #include <audio/Duration.h> | #include "debug.hpp" | ||||||
| #include "debug.h" |  | ||||||
| 
 | 
 | ||||||
|  | /**
 | ||||||
|  |  * @brief Audio library namespace | ||||||
|  |  */ | ||||||
| namespace audio { | namespace audio { | ||||||
|  | 	/**
 | ||||||
|  | 	 * @brief audio-algo library namespace | ||||||
|  | 	 */ | ||||||
| 	namespace drain{ | 	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> { | 		class Algo : public ememory::EnableSharedFromThis<Algo> { | ||||||
| 			private: | 			private: | ||||||
| 				std::string m_name; | 				etk::String m_name; | ||||||
| 			public: | 			public: | ||||||
| 				const std::string& getName() const { | 				const etk::String& getName() const { | ||||||
| 					return m_name; | 					return m_name; | ||||||
| 				} | 				} | ||||||
| 				void setName(const std::string& _name) { | 				void setName(const etk::String& _name) { | ||||||
| 					m_name = _name; | 					m_name = _name; | ||||||
| 				} | 				} | ||||||
| 			protected: | 			protected: | ||||||
| 				std::string m_type; | 				etk::String m_type; | ||||||
| 			public: | 			public: | ||||||
| 				const std::string& getType() const { | 				const etk::String& getType() const { | ||||||
| 					return m_type; | 					return m_type; | ||||||
| 				} | 				} | ||||||
| 				void setType(const std::string& _type) { | 				void setType(const etk::String& _type) { | ||||||
| 					m_type = _type; | 					m_type = _type; | ||||||
| 				} | 				} | ||||||
|  | 			public: | ||||||
|  | 				virtual etk::String getDotDesc(); | ||||||
| 			private: | 			private: | ||||||
| 				bool m_temporary; | 				bool m_temporary; | ||||||
| 			public: | 			public: | ||||||
| @@ -55,9 +62,9 @@ namespace audio { | |||||||
| 			public: | 			public: | ||||||
| 				void setStatusFunction(algoStatusFunction _newFunction); | 				void setStatusFunction(algoStatusFunction _newFunction); | ||||||
| 			protected: | 			protected: | ||||||
| 				void generateStatus(const std::string& _status); | 				void generateStatus(const etk::String& _status); | ||||||
| 			protected: | 			protected: | ||||||
| 				std::vector<int8_t> m_outputData; | 				etk::Vector<int8_t> m_outputData; | ||||||
| 				int8_t m_formatSize; //!< sample size
 | 				int8_t m_formatSize; //!< sample size
 | ||||||
| 				/**
 | 				/**
 | ||||||
| 				 * @brief Constructor | 				 * @brief Constructor | ||||||
| @@ -130,58 +137,58 @@ namespace audio { | |||||||
| 				// TODO : Manage the change of the timestamp ...
 | 				// TODO : Manage the change of the timestamp ...
 | ||||||
| 				virtual size_t needInputData(size_t _output); | 				virtual size_t needInputData(size_t _output); | ||||||
| 			protected: // note when nothing ==> support all type
 | 			protected: // note when nothing ==> support all type
 | ||||||
| 				std::vector<audio::format> m_supportedFormat; | 				etk::Vector<audio::format> m_supportedFormat; | ||||||
| 			public: | 			public: | ||||||
| 				virtual std::vector<audio::format> getFormatSupportedInput() { | 				virtual etk::Vector<audio::format> getFormatSupportedInput() { | ||||||
| 					if (m_output.getConfigured() == true) { | 					if (m_output.getConfigured() == true) { | ||||||
| 						std::vector<audio::format> out; | 						etk::Vector<audio::format> out; | ||||||
| 						out.push_back(m_output.getFormat()); | 						out.pushBack(m_output.getFormat()); | ||||||
| 						return out; | 						return out; | ||||||
| 					} | 					} | ||||||
| 					return m_supportedFormat; | 					return m_supportedFormat; | ||||||
| 				}; | 				}; | ||||||
| 				virtual std::vector<audio::format> getFormatSupportedOutput() { | 				virtual etk::Vector<audio::format> getFormatSupportedOutput() { | ||||||
| 					if (m_input.getConfigured() == true) { | 					if (m_input.getConfigured() == true) { | ||||||
| 						std::vector<audio::format> out; | 						etk::Vector<audio::format> out; | ||||||
| 						out.push_back(m_input.getFormat()); | 						out.pushBack(m_input.getFormat()); | ||||||
| 						return out; | 						return out; | ||||||
| 					} | 					} | ||||||
| 					return m_supportedFormat; | 					return m_supportedFormat; | ||||||
| 				}; | 				}; | ||||||
| 			protected: // note when nothing ==> support all type
 | 			protected: // note when nothing ==> support all type
 | ||||||
| 				std::vector<std::vector<audio::channel> > m_supportedMap; | 				etk::Vector<etk::Vector<audio::channel> > m_supportedMap; | ||||||
| 			public: | 			public: | ||||||
| 				virtual std::vector<std::vector<audio::channel> > getMapSupportedInput() { | 				virtual etk::Vector<etk::Vector<audio::channel> > getMapSupportedInput() { | ||||||
| 					if (m_output.getConfigured() == true) { | 					if (m_output.getConfigured() == true) { | ||||||
| 						std::vector<std::vector<audio::channel> > out; | 						etk::Vector<etk::Vector<audio::channel> > out; | ||||||
| 						out.push_back(m_output.getMap()); | 						out.pushBack(m_output.getMap()); | ||||||
| 						return out; | 						return out; | ||||||
| 					} | 					} | ||||||
| 					return m_supportedMap; | 					return m_supportedMap; | ||||||
| 				}; | 				}; | ||||||
| 				virtual std::vector<std::vector<audio::channel> > getMapSupportedOutput() { | 				virtual etk::Vector<etk::Vector<audio::channel> > getMapSupportedOutput() { | ||||||
| 					if (m_input.getConfigured() == true) { | 					if (m_input.getConfigured() == true) { | ||||||
| 						std::vector<std::vector<audio::channel> > out; | 						etk::Vector<etk::Vector<audio::channel> > out; | ||||||
| 						out.push_back(m_input.getMap()); | 						out.pushBack(m_input.getMap()); | ||||||
| 						return out; | 						return out; | ||||||
| 					} | 					} | ||||||
| 					return m_supportedMap; | 					return m_supportedMap; | ||||||
| 				}; | 				}; | ||||||
| 			protected: // note when nothing ==> support all type
 | 			protected: // note when nothing ==> support all type
 | ||||||
| 				std::vector<float> m_supportedFrequency; | 				etk::Vector<float> m_supportedFrequency; | ||||||
| 			public: | 			public: | ||||||
| 				virtual std::vector<float> getFrequencySupportedInput() { | 				virtual etk::Vector<float> getFrequencySupportedInput() { | ||||||
| 					if (m_output.getConfigured() == true) { | 					if (m_output.getConfigured() == true) { | ||||||
| 						std::vector<float> out; | 						etk::Vector<float> out; | ||||||
| 						out.push_back(m_output.getFrequency()); | 						out.pushBack(m_output.getFrequency()); | ||||||
| 						return out; | 						return out; | ||||||
| 					} | 					} | ||||||
| 					return m_supportedFrequency; | 					return m_supportedFrequency; | ||||||
| 				}; | 				}; | ||||||
| 				virtual std::vector<float> getFrequencySupportedOutput() { | 				virtual etk::Vector<float> getFrequencySupportedOutput() { | ||||||
| 					if (m_input.getConfigured() == true) { | 					if (m_input.getConfigured() == true) { | ||||||
| 						std::vector<float> out; | 						etk::Vector<float> out; | ||||||
| 						out.push_back(m_input.getFrequency()); | 						out.pushBack(m_input.getFrequency()); | ||||||
| 						return out; | 						return out; | ||||||
| 					} | 					} | ||||||
| 					return m_supportedFrequency; | 					return m_supportedFrequency; | ||||||
| @@ -194,21 +201,21 @@ namespace audio { | |||||||
| 				 * @return true set done | 				 * @return true set done | ||||||
| 				 * @return false An error occured | 				 * @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 | 				 * @brief Get a parameter value | ||||||
| 				 * @param[in] _parameter Parameter name. | 				 * @param[in] _parameter Parameter name. | ||||||
| 				 * @return The requested value. | 				 * @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 | 				 * @brief Get a parameter value | ||||||
| 				 * @param[in] _parameter Parameter name. | 				 * @param[in] _parameter Parameter name. | ||||||
| 				 * @return The requested value. | 				 * @return The requested value. | ||||||
| 				 */ | 				 */ | ||||||
| 				virtual std::string getParameterProperty(const std::string& _parameter) const { return "[ERROR]"; }; | 				virtual etk::String getParameterProperty(const etk::String& _parameter) const { return "[ERROR]"; }; | ||||||
| 		}; | 		}; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| #include "debugRemove.h" | #include "debugRemove.hpp" | ||||||
| 
 | 
 | ||||||
| @@ -1,13 +1,13 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include "AutoLogInOut.h" | #include "AutoLogInOut.hpp" | ||||||
| #include "debug.h" | #include "debug.hpp" | ||||||
|  |  | ||||||
| audio::drain::AutoLogInOut::AutoLogInOut(const std::string& _value) : | audio::drain::AutoLogInOut::AutoLogInOut(const etk::String& _value) : | ||||||
|   m_value(_value) { |   m_value(_value) { | ||||||
| 	DRAIN_VERBOSE("                 '" << m_value << "' [START]"); | 	DRAIN_VERBOSE("                 '" << m_value << "' [START]"); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,24 +1,24 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <string> | #include <etk/String.hpp> | ||||||
| #include "debug.h" | #include "debug.hpp" | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain{ | 	namespace drain{ | ||||||
| 		class AutoLogInOut { | 		class AutoLogInOut { | ||||||
| 			private: | 			private: | ||||||
| 				std::string m_value; | 				etk::String m_value; | ||||||
| 			public: | 			public: | ||||||
| 				AutoLogInOut(const std::string& _value); | 				AutoLogInOut(const etk::String& _value); | ||||||
| 				~AutoLogInOut(); | 				~AutoLogInOut(); | ||||||
| 		}; | 		}; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #include "debugRemove.h" | #include "debugRemove.hpp" | ||||||
| 
 | 
 | ||||||
| @@ -1,13 +1,11 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <audio/drain/ChannelReorder.h> | #include <audio/drain/ChannelReorder.hpp> | ||||||
| #include <iostream> | #include "debug.hpp" | ||||||
| #include "debug.h" |  | ||||||
| #include "debug.h" |  | ||||||
|  |  | ||||||
|  |  | ||||||
| audio::drain::ChannelReorder::ChannelReorder() { | audio::drain::ChannelReorder::ChannelReorder() { | ||||||
| @@ -21,7 +19,7 @@ void audio::drain::ChannelReorder::init() { | |||||||
| } | } | ||||||
|  |  | ||||||
| ememory::SharedPtr<audio::drain::ChannelReorder> audio::drain::ChannelReorder::create() { | 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(); | 	tmp->init(); | ||||||
| 	return tmp; | 	return tmp; | ||||||
| } | } | ||||||
| @@ -58,7 +56,7 @@ bool audio::drain::ChannelReorder::process(audio::Time& _time, | |||||||
| 		_output = _input; | 		_output = _input; | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| 	if (_input == nullptr) { | 	if (_input == null) { | ||||||
| 		_output = &(m_outputData[0]); | 		_output = &(m_outputData[0]); | ||||||
| 		_outputNbChunk = 0; | 		_outputNbChunk = 0; | ||||||
| 		DRAIN_ERROR("null pointer input ... "); | 		DRAIN_ERROR("null pointer input ... "); | ||||||
|   | |||||||
| @@ -1,11 +1,11 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <audio/drain/Algo.h> | #include <audio/drain/Algo.hpp> | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain{ | 	namespace drain{ | ||||||
| @@ -1,16 +1,16 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <audio/drain/CircularBuffer.h> | #include <audio/drain/CircularBuffer.hpp> | ||||||
| #include <audio/drain/debug.h> | #include <audio/drain/debug.hpp> | ||||||
|  |  | ||||||
| audio::drain::CircularBuffer::CircularBuffer(const audio::drain::CircularBuffer& _obj) : | audio::drain::CircularBuffer::CircularBuffer(const audio::drain::CircularBuffer& _obj) : | ||||||
|   m_data(), |   m_data(), | ||||||
|   m_write(nullptr), |   m_write(null), | ||||||
|   m_read(nullptr), |   m_read(null), | ||||||
|   m_timeRead(), |   m_timeRead(), | ||||||
|   m_capacity(0), |   m_capacity(0), | ||||||
|   m_sizeChunk(0), |   m_sizeChunk(0), | ||||||
| @@ -27,8 +27,8 @@ audio::drain::CircularBuffer& audio::drain::CircularBuffer::operator=(const audi | |||||||
|  |  | ||||||
| audio::drain::CircularBuffer::CircularBuffer() : | audio::drain::CircularBuffer::CircularBuffer() : | ||||||
|   m_data(), |   m_data(), | ||||||
|   m_write(nullptr), |   m_write(null), | ||||||
|   m_read(nullptr), |   m_read(null), | ||||||
|   m_timeRead(), |   m_timeRead(), | ||||||
|   m_capacity(0), |   m_capacity(0), | ||||||
|   m_sizeChunk(0), |   m_sizeChunk(0), | ||||||
| @@ -38,8 +38,8 @@ audio::drain::CircularBuffer::CircularBuffer() : | |||||||
|  |  | ||||||
| audio::drain::CircularBuffer::~CircularBuffer() { | audio::drain::CircularBuffer::~CircularBuffer() { | ||||||
| 	m_data.clear(); | 	m_data.clear(); | ||||||
| 	m_read = nullptr; | 	m_read = null; | ||||||
| 	m_write = nullptr; | 	m_write = null; | ||||||
| } | } | ||||||
|  |  | ||||||
| void audio::drain::CircularBuffer::setCapacity(size_t _capacity, size_t _chunkSize, uint32_t _frequency) { | 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; | 		_chunkSize = 8; | ||||||
| 	} | 	} | ||||||
| 	m_data.clear(); | 	m_data.clear(); | ||||||
| 	m_write = nullptr; | 	m_write = null; | ||||||
| 	m_read = nullptr; | 	m_read = null; | ||||||
| 	m_frequency = _frequency; | 	m_frequency = _frequency; | ||||||
| 	m_capacity = _capacity; | 	m_capacity = _capacity; | ||||||
| 	m_sizeChunk = _chunkSize; | 	m_sizeChunk = _chunkSize; | ||||||
| @@ -75,9 +75,9 @@ void audio::drain::CircularBuffer::setCapacity(size_t _capacity, size_t _chunkSi | |||||||
| 	m_write = &m_data[0]; | 	m_write = &m_data[0]; | ||||||
| } | } | ||||||
|  |  | ||||||
| void audio::drain::CircularBuffer::setCapacity(std::chrono::milliseconds _capacity, size_t _chunkSize, uint32_t _frequency) { | void audio::drain::CircularBuffer::setCapacity(echrono::Duration _capacity, size_t _chunkSize, uint32_t _frequency) { | ||||||
| 	uint32_t nbSampleNeeded = _frequency*_capacity.count()/1000; | 	uint32_t nbSampleNeeded = _frequency*_capacity.get()/1000000000LL; | ||||||
| 	DRAIN_DEBUG("buffer setCapacity(" << _capacity.count() << "ms ," << _chunkSize << ")"); | 	DRAIN_DEBUG("buffer setCapacity(" << _capacity << " ," << _chunkSize << ")"); | ||||||
| 	setCapacity(nbSampleNeeded, _chunkSize, _frequency); | 	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) { | 	if (0 < m_size) { | ||||||
| 		// check the time of the read : | 		// check the time of the read : | ||||||
| 		audio::Duration deltaTime = m_timeRead - _time; | 		audio::Duration deltaTime = m_timeRead - _time; | ||||||
| 		if (deltaTime.count() == 0) { | 		if (deltaTime.get() == 0) { | ||||||
| 			// nothing to do ==> just copy data ... | 			// nothing to do ==> just copy data ... | ||||||
| 		} else if (deltaTime.count() > 0) { | 		} else if (deltaTime.get() > 0) { | ||||||
| 			// Add empty sample in the output buffer ... | 			// Add empty sample in the output buffer ... | ||||||
| 			size_t nbSampleEmpty = m_frequency*deltaTime.count()/100000000; | 			size_t nbSampleEmpty = m_frequency*deltaTime.get()/1000000000LL; | ||||||
| 			nbSampleEmpty = std::min(nbSampleEmpty, _nbChunk); | 			nbSampleEmpty = etk::min(nbSampleEmpty, _nbChunk); | ||||||
| 			DRAIN_WARNING("add Empty sample in the output buffer " << nbSampleEmpty << " / " << _nbChunk); | 			DRAIN_WARNING("add Empty sample in the output buffer " << nbSampleEmpty << " / " << _nbChunk); | ||||||
| 			memset(_data, 0, nbSampleEmpty * m_sizeChunk); | 			memset(_data, 0, nbSampleEmpty * m_sizeChunk); | ||||||
| 			if (nbSampleEmpty == _nbChunk) { | 			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); | 			DRAIN_VERBOSE("crop nb sample : m_size=" << m_size << " _nbChunk=" << _nbChunk); | ||||||
| 			_nbChunk = m_size; | 			_nbChunk = m_size; | ||||||
| 		} | 		} | ||||||
| 		m_timeRead += std::chrono::microseconds(_nbChunk*1000000/m_frequency); | 		m_timeRead += echrono::microseconds(_nbChunk*1000000/m_frequency); | ||||||
| 		if (usedSizeBeforeEnd >= _nbChunk) { | 		if (usedSizeBeforeEnd >= _nbChunk) { | ||||||
| 			// all Data will be copy | 			// all Data will be copy | ||||||
| 			memcpy(_data, m_read, _nbChunk * m_sizeChunk); | 			memcpy(_data, m_read, _nbChunk * m_sizeChunk); | ||||||
| @@ -257,11 +257,11 @@ void audio::drain::CircularBuffer::setReadPosition(const audio::Time& _time) { | |||||||
| 	if (0 < m_size) { | 	if (0 < m_size) { | ||||||
| 		// check the time of the read : | 		// check the time of the read : | ||||||
| 		audio::Duration deltaTime = _time - m_timeRead; | 		audio::Duration deltaTime = _time - m_timeRead; | ||||||
| 		size_t nbSampleToRemove = int64_t(m_frequency)*int64_t(deltaTime.count())/1000000000LL; | 		size_t nbSampleToRemove = int64_t(m_frequency)*int64_t(deltaTime.get())/1000000000LL; | ||||||
| 		nbSampleToRemove = std::min(nbSampleToRemove, m_size); | 		nbSampleToRemove = etk::min(nbSampleToRemove, m_size); | ||||||
| 		DRAIN_VERBOSE("Remove sample in the buffer " << 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)); | 		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) { | 		if (usedSizeBeforeEnd >= nbSampleToRemove) { | ||||||
| 			usedSizeBeforeEnd -= nbSampleToRemove; | 			usedSizeBeforeEnd -= nbSampleToRemove; | ||||||
| 			m_size -= nbSampleToRemove; | 			m_size -= nbSampleToRemove; | ||||||
|   | |||||||
| @@ -1,15 +1,15 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <etk/types.h> | #include <etk/types.hpp> | ||||||
| #include <vector> | #include <etk/Vector.hpp> | ||||||
| #include <chrono> | #include <echrono/Steady.hpp> | ||||||
| #include <audio/Time.h> | #include <audio/Time.hpp> | ||||||
| #include <audio/Duration.h> | #include <audio/Duration.hpp> | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain { | 	namespace drain { | ||||||
| @@ -40,7 +40,7 @@ namespace audio { | |||||||
| 		 */ | 		 */ | ||||||
| 		class CircularBuffer { | 		class CircularBuffer { | ||||||
| 			private: | 			private: | ||||||
| 				std::vector<uint8_t> m_data; //!< data pointer
 | 				etk::Vector<uint8_t> m_data; //!< data pointer
 | ||||||
| 				void* m_write; //!< write pointer
 | 				void* m_write; //!< write pointer
 | ||||||
| 				void* m_read; //!< read pointer
 | 				void* m_read; //!< read pointer
 | ||||||
| 				audio::Time m_timeRead; //!< current read time
 | 				audio::Time m_timeRead; //!< current read time
 | ||||||
| @@ -71,14 +71,11 @@ namespace audio { | |||||||
| 				void setCapacity(size_t _capacity, size_t _chunkSize, uint32_t _frequency); | 				void setCapacity(size_t _capacity, size_t _chunkSize, uint32_t _frequency); | ||||||
| 				/**
 | 				/**
 | ||||||
| 				 * @brief set the capacity of the circular buffer. | 				 * @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] _chunkSize Size of one chunk. | ||||||
| 				 * @param[in] _frequency Frequency of the buffer | 				 * @param[in] _frequency Frequency of the buffer | ||||||
| 				 */ | 				 */ | ||||||
| 				void setCapacity(std::chrono::milliseconds _capacity, size_t _chunkSize, uint32_t _frequency); | 				void setCapacity(echrono::Duration _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); |  | ||||||
| 				} |  | ||||||
| 				/**
 | 				/**
 | ||||||
| 				 * @brief get free size of the buffer. | 				 * @brief get free size of the buffer. | ||||||
| 				 * @return Number of free chunk. | 				 * @return Number of free chunk. | ||||||
| @@ -1,11 +1,11 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <audio/drain/Algo.h> | #include <audio/drain/Algo.hpp> | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain{ | 	namespace drain{ | ||||||
| @@ -1,16 +1,16 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <audio/drain/EndPointCallback.h> | #include <audio/drain/EndPointCallback.hpp> | ||||||
| #include <audio/drain/debug.h> | #include <audio/drain/debug.hpp> | ||||||
|  |  | ||||||
|  |  | ||||||
| audio::drain::EndPointCallback::EndPointCallback() : | audio::drain::EndPointCallback::EndPointCallback() : | ||||||
|   m_outputFunction(nullptr), |   m_outputFunction(null), | ||||||
|   m_inputFunction(nullptr) { |   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> 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); | 	tmp->init(_callback); | ||||||
| 	return tmp; | 	return tmp; | ||||||
| } | } | ||||||
|  |  | ||||||
| ememory::SharedPtr<audio::drain::EndPointCallback> audio::drain::EndPointCallback::create(recordFunction _callback) { | 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); | 	tmp->init(_callback); | ||||||
| 	return tmp; | 	return tmp; | ||||||
| } | } | ||||||
| @@ -50,7 +50,7 @@ bool audio::drain::EndPointCallback::process(audio::Time& _time, | |||||||
|                                              void*& _output, |                                              void*& _output, | ||||||
|                                              size_t& _outputNbChunk){ |                                              size_t& _outputNbChunk){ | ||||||
| 	audio::drain::AutoLogInOut tmpLog("EndPointCallback"); | 	audio::drain::AutoLogInOut tmpLog("EndPointCallback"); | ||||||
| 	if (m_inputFunction != nullptr) { | 	if (m_inputFunction != null) { | ||||||
| 		// Call user ... | 		// Call user ... | ||||||
| 		DRAIN_VERBOSE("call user set " << _inputNbChunk << "*" << m_input.getMap().size()); | 		DRAIN_VERBOSE("call user set " << _inputNbChunk << "*" << m_input.getMap().size()); | ||||||
| 		m_inputFunction(_input, | 		m_inputFunction(_input, | ||||||
| @@ -61,7 +61,7 @@ bool audio::drain::EndPointCallback::process(audio::Time& _time, | |||||||
| 		                m_output.getMap()); | 		                m_output.getMap()); | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| 	if (m_outputFunction != nullptr) { | 	if (m_outputFunction != null) { | ||||||
| 		// update buffer size ... | 		// update buffer size ... | ||||||
| 		m_outputData.resize(_inputNbChunk*m_output.getMap().size()*m_formatSize); | 		m_outputData.resize(_inputNbChunk*m_output.getMap().size()*m_formatSize); | ||||||
| 		// clean output to prevent errors ... | 		// clean output to prevent errors ... | ||||||
|   | |||||||
| @@ -1,27 +1,27 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <audio/drain/EndPoint.h> | #include <audio/drain/EndPoint.hpp> | ||||||
| #include <functional> | #include <etk/Function.hpp> | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain { | 	namespace drain { | ||||||
| 		typedef std::function<void (void* _data, | 		typedef etk::Function<void (void* _data, | ||||||
| 		                              const audio::Time& _playTime, | 		                              const audio::Time& _playTime, | ||||||
| 		                              size_t _nbChunk, | 		                              size_t _nbChunk, | ||||||
| 		                              enum audio::format _format, | 		                              enum audio::format _format, | ||||||
| 		                              uint32_t _frequency, | 		                              uint32_t _frequency, | ||||||
| 		                              const std::vector<audio::channel>& _map)> playbackFunction; | 		                              const etk::Vector<audio::channel>& _map)> playbackFunction; | ||||||
| 		typedef std::function<void (const void* _data, | 		typedef etk::Function<void (const void* _data, | ||||||
| 		                              const audio::Time& _readTime, | 		                              const audio::Time& _readTime, | ||||||
| 		                              size_t _nbChunk, | 		                              size_t _nbChunk, | ||||||
| 		                              enum audio::format _format, | 		                              enum audio::format _format, | ||||||
| 		                              uint32_t _frequency, | 		                              uint32_t _frequency, | ||||||
| 		                              const std::vector<audio::channel>& _map)> recordFunction; | 		                              const etk::Vector<audio::channel>& _map)> recordFunction; | ||||||
| 		class EndPointCallback : public EndPoint { | 		class EndPointCallback : public EndPoint { | ||||||
| 			private: | 			private: | ||||||
| 				playbackFunction m_outputFunction; | 				playbackFunction m_outputFunction; | ||||||
| @@ -1,11 +1,11 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <audio/drain/EndPointRead.h> | #include <audio/drain/EndPointRead.hpp> | ||||||
| #include <audio/drain/debug.h> | #include <audio/drain/debug.hpp> | ||||||
|  |  | ||||||
|  |  | ||||||
| audio::drain::EndPointRead::EndPointRead() { | audio::drain::EndPointRead::EndPointRead() { | ||||||
| @@ -19,7 +19,7 @@ void audio::drain::EndPointRead::init() { | |||||||
| } | } | ||||||
|  |  | ||||||
| ememory::SharedPtr<audio::drain::EndPointRead> audio::drain::EndPointRead::create() { | 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(); | 	tmp->init(); | ||||||
| 	return tmp; | 	return tmp; | ||||||
| } | } | ||||||
| @@ -43,7 +43,7 @@ void audio::drain::EndPointRead::setBufferSize(size_t _nbChunk) { | |||||||
| 	DRAIN_TODO("..."); | 	DRAIN_TODO("..."); | ||||||
| } | } | ||||||
|  |  | ||||||
| void audio::drain::EndPointRead::setBufferSize(const std::chrono::microseconds& _time) { | void audio::drain::EndPointRead::setBufferSize(const echrono::microseconds& _time) { | ||||||
| 	DRAIN_TODO("..."); | 	DRAIN_TODO("..."); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -52,9 +52,9 @@ size_t audio::drain::EndPointRead::getBufferSize() { | |||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| std::chrono::microseconds audio::drain::EndPointRead::getBufferSizeMicrosecond() { | echrono::microseconds audio::drain::EndPointRead::getBufferSizeMicrosecond() { | ||||||
| 	DRAIN_TODO("..."); | 	DRAIN_TODO("..."); | ||||||
| 	return std::chrono::microseconds(0); | 	return echrono::microseconds(0); | ||||||
| } | } | ||||||
|  |  | ||||||
| size_t audio::drain::EndPointRead::getBufferFillSize() { | size_t audio::drain::EndPointRead::getBufferFillSize() { | ||||||
| @@ -62,8 +62,8 @@ size_t audio::drain::EndPointRead::getBufferFillSize() { | |||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| std::chrono::microseconds audio::drain::EndPointRead::getBufferFillSizeMicrosecond() { | echrono::microseconds audio::drain::EndPointRead::getBufferFillSizeMicrosecond() { | ||||||
| 	DRAIN_TODO("..."); | 	DRAIN_TODO("..."); | ||||||
| 	return std::chrono::microseconds(0); | 	return echrono::microseconds(0); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,11 +1,11 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <audio/drain/EndPoint.h> | #include <audio/drain/EndPoint.hpp> | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain{ | 	namespace drain{ | ||||||
| @@ -37,7 +37,7 @@ namespace audio { | |||||||
| 				 * @brief Set buffer size size of the buffer with the stored time in µs | 				 * @brief Set buffer size size of the buffer with the stored time in µs | ||||||
| 				 * @param[in] _time Time in microsecond of the buffer | 				 * @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 | 				 * @brief get buffer size in chunk number | ||||||
| 				 * @return Number of chunk that can be written in the buffer | 				 * @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 | 				 * @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 | 				 * @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 | 				 * @brief Get buffer size filled in chunk number | ||||||
| 				 * @return Number of chunk in the buffer (that might be read/write) | 				 * @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 | 				 * @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) | 				 * @return Time in microsecond of the buffer (that might be read/write) | ||||||
| 				 */ | 				 */ | ||||||
| 				virtual std::chrono::microseconds getBufferFillSizeMicrosecond(); | 				virtual echrono::microseconds getBufferFillSizeMicrosecond(); | ||||||
| 		}; | 		}; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -1,15 +1,17 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #include <audio/drain/EndPointWrite.h> | #include <audio/drain/EndPointWrite.hpp> | ||||||
| #include <audio/drain/debug.h> | #include <audio/drain/debug.hpp> | ||||||
|  |  | ||||||
|  |  | ||||||
| audio::drain::EndPointWrite::EndPointWrite() : | audio::drain::EndPointWrite::EndPointWrite() : | ||||||
|   m_function(nullptr), |   m_function(null), | ||||||
|   m_bufferSizeMicroseconds(1000000) { |   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> 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(); | 	tmp->init(); | ||||||
| 	return tmp; | 	return tmp; | ||||||
| } | } | ||||||
| @@ -35,7 +37,7 @@ void audio::drain::EndPointWrite::configurationChange() { | |||||||
| 	// update the buffer size ... | 	// update the buffer size ... | ||||||
| 	if (    audio::getFormatBytes(m_output.getFormat())*m_output.getMap().size() != 0 | 	if (    audio::getFormatBytes(m_output.getFormat())*m_output.getMap().size() != 0 | ||||||
| 	     && m_output.getFrequency() != 0) { | 	     && m_output.getFrequency() != 0) { | ||||||
| 		if (std::chrono::microseconds(0) != m_bufferSizeMicroseconds) { | 		if (m_bufferSizeMicroseconds.get() != 0) { | ||||||
| 			m_buffer.setCapacity(m_bufferSizeMicroseconds, | 			m_buffer.setCapacity(m_bufferSizeMicroseconds, | ||||||
| 			                     audio::getFormatBytes(m_output.getFormat())*m_output.getMap().size(), | 			                     audio::getFormatBytes(m_output.getFormat())*m_output.getMap().size(), | ||||||
| 			                     m_output.getFrequency()); | 			                     m_output.getFrequency()); | ||||||
| @@ -56,7 +58,7 @@ bool audio::drain::EndPointWrite::process(audio::Time& _time, | |||||||
|                                           size_t& _outputNbChunk){ |                                           size_t& _outputNbChunk){ | ||||||
| 	audio::drain::AutoLogInOut tmpLog("EndPointWrite"); | 	audio::drain::AutoLogInOut tmpLog("EndPointWrite"); | ||||||
| 	//DRAIN_INFO("                              nb Sample in buffer : " << m_buffer.size()); | 	//DRAIN_INFO("                              nb Sample in buffer : " << m_buffer.size()); | ||||||
| 	if (m_function != nullptr) { | 	if (m_function != null) { | ||||||
| 		// TODO : Rework this ... | 		// TODO : Rework this ... | ||||||
| 		if (m_buffer.getSize() <= 20000) { | 		if (m_buffer.getSize() <= 20000) { | ||||||
| 			m_function(_time, _inputNbChunk, m_output.getFormat(), m_output.getFrequency(), m_output.getMap()); | 			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: | 	// set output pointer: | ||||||
| 	_outputNbChunk = m_outputData.size()/(m_formatSize*m_output.getMap().size()); | 	_outputNbChunk = m_outputData.size()/(m_formatSize*m_output.getMap().size()); | ||||||
| 	_output = &m_outputData[0]; | 	_output = &m_outputData[0]; | ||||||
| 	std::unique_lock<std::mutex> lock(m_mutex); | 	ethread::UniqueLock lock(m_mutex); | ||||||
| 	// check if data in the tmpBuffer | 	// check if data in the tmpBuffer | ||||||
| 	if (m_buffer.getSize() == 0) { | 	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 ... | 		// clear the buffer to force the flush on the next elements ... | ||||||
| 		m_outputData.clear(); | 		m_outputData.clear(); | ||||||
| 		_outputNbChunk = 0; | 		_outputNbChunk = 0; | ||||||
| 		generateStatus("EPW_UNDERFLOW"); | 		generateStatus("EPW_UNDERFLOW"); | ||||||
| 		// just send no data ... | 		// just send no data ... | ||||||
| 		return true; | 		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"); | 	DRAIN_VERBOSE("Write " << _outputNbChunk << " chunks"); | ||||||
| 	// check if we have enought data: | 	// 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) { | 	if (nbChunkToCopy != _inputNbChunk) { | ||||||
| 		generateStatus("EPW_UNDERFLOW"); | 		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) { | 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); | 	DRAIN_VERBOSE("[ASYNC] Write data : " << _nbChunk << " chunks" << " ==> " << m_output); | ||||||
| 	int32_t nbOverflow = m_buffer.write(_value, _nbChunk); | 	int32_t nbOverflow = m_buffer.write(_value, _nbChunk); | ||||||
| 	if (nbOverflow > 0) { | 	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) { | void audio::drain::EndPointWrite::setBufferSize(size_t _nbChunk) { | ||||||
| 	m_bufferSizeMicroseconds = std::chrono::microseconds(0); | 	m_bufferSizeMicroseconds = echrono::microseconds(0); | ||||||
| 	m_bufferSizeChunk = _nbChunk; | 	m_bufferSizeChunk = _nbChunk; | ||||||
| 	if (    audio::getFormatBytes(m_output.getFormat())*m_output.getMap().size() != 0 | 	if (    audio::getFormatBytes(m_output.getFormat())*m_output.getMap().size() != 0 | ||||||
| 	     && m_output.getFrequency() != 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_bufferSizeMicroseconds = _time; | ||||||
| 	m_bufferSizeChunk = 0; | 	m_bufferSizeChunk = 0; | ||||||
| 	m_buffer.setCapacity(_time, | 	m_buffer.setCapacity(_time, | ||||||
| @@ -128,20 +141,20 @@ size_t audio::drain::EndPointWrite::getBufferSize() { | |||||||
| 	if (m_bufferSizeChunk != 0) { | 	if (m_bufferSizeChunk != 0) { | ||||||
| 		return m_bufferSizeChunk; | 		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() { | echrono::microseconds audio::drain::EndPointWrite::getBufferSizeMicrosecond() { | ||||||
| 	if (m_bufferSizeMicroseconds != std::chrono::microseconds(0) ) { | 	if (m_bufferSizeMicroseconds.get() != 0) { | ||||||
| 		return m_bufferSizeMicroseconds; | 		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() { | size_t audio::drain::EndPointWrite::getBufferFillSize() { | ||||||
| 	return m_buffer.getSize()/(audio::getFormatBytes(m_output.getFormat())*m_output.getMap().size()); | 	return m_buffer.getSize()/(audio::getFormatBytes(m_output.getFormat())*m_output.getMap().size()); | ||||||
| } | } | ||||||
|  |  | ||||||
| std::chrono::microseconds audio::drain::EndPointWrite::getBufferFillSizeMicrosecond() { | echrono::microseconds audio::drain::EndPointWrite::getBufferFillSizeMicrosecond() { | ||||||
| 	return std::chrono::microseconds(getBufferFillSize()*1000000LL/int64_t(m_output.getFrequency())); | 	return echrono::microseconds(getBufferFillSize()*1000000LL/int64_t(m_output.getFrequency())); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,27 +1,27 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <audio/drain/EndPoint.h> | #include <audio/drain/EndPoint.hpp> | ||||||
| #include <functional> | #include <etk/Function.hpp> | ||||||
| #include <mutex> | #include <ethread/Mutex.hpp> | ||||||
| #include <audio/drain/CircularBuffer.h> | #include <audio/drain/CircularBuffer.hpp> | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain{ | 	namespace drain{ | ||||||
| 		typedef std::function<void (const audio::Time& _time, | 		typedef etk::Function<void (const audio::Time& _time, | ||||||
| 		                              size_t _nbChunk, | 		                              size_t _nbChunk, | ||||||
| 		                              enum audio::format _format, | 		                              enum audio::format _format, | ||||||
| 		                              uint32_t _frequency, | 		                              uint32_t _frequency, | ||||||
| 		                              const std::vector<audio::channel>& _map)> playbackFunctionWrite; | 		                              const etk::Vector<audio::channel>& _map)> playbackFunctionWrite; | ||||||
| 		class EndPointWrite : public EndPoint { | 		class EndPointWrite : public EndPoint { | ||||||
| 			private: | 			private: | ||||||
| 				audio::drain::CircularBuffer m_buffer; | 				audio::drain::CircularBuffer m_buffer; | ||||||
| 				playbackFunctionWrite m_function; | 				playbackFunctionWrite m_function; | ||||||
| 				std::mutex m_mutex; | 				ethread::Mutex m_mutex; | ||||||
| 			protected: | 			protected: | ||||||
| 				/**
 | 				/**
 | ||||||
| 				 * @brief Constructor | 				 * @brief Constructor | ||||||
| @@ -45,8 +45,9 @@ namespace audio { | |||||||
| 					m_function = _function; | 					m_function = _function; | ||||||
| 				} | 				} | ||||||
| 			protected: | 			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_bufferSizeChunk; // 0 if m_bufferSizeMicroseconds != 0
 | ||||||
|  | 				size_t m_bufferUnderFlowSize; //!< Limit display of underflow in the write callback
 | ||||||
| 			public: | 			public: | ||||||
| 				/**
 | 				/**
 | ||||||
| 				 * @brief Set buffer size in chunk number | 				 * @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 | 				 * @brief Set buffer size size of the buffer with the stored time in µs | ||||||
| 				 * @param[in] _time Time in microsecond of the buffer | 				 * @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 | 				 * @brief get buffer size in chunk number | ||||||
| 				 * @return Number of chunk that can be written in the buffer | 				 * @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 | 				 * @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 | 				 * @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 | 				 * @brief Get buffer size filled in chunk number | ||||||
| 				 * @return Number of chunk in the buffer (that might be read/write) | 				 * @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 | 				 * @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) | 				 * @return Time in microsecond of the buffer (that might be read/write) | ||||||
| 				 */ | 				 */ | ||||||
| 				virtual std::chrono::microseconds getBufferFillSizeMicrosecond(); | 				virtual echrono::microseconds getBufferFillSizeMicrosecond(); | ||||||
| 		}; | 		}; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -1,12 +1,12 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <audio/drain/Equalizer.h> | #include <audio/drain/Equalizer.hpp> | ||||||
| #include <audio/drain/Algo.h> | #include <audio/drain/Algo.hpp> | ||||||
| #include <audio/drain/debug.h> | #include <audio/drain/debug.hpp> | ||||||
|  |  | ||||||
| // see http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt | // see http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt | ||||||
| // see http://www.earlevel.com/main/2013/10/13/biquad-calculator-v2/ | // see http://www.earlevel.com/main/2013/10/13/biquad-calculator-v2/ | ||||||
| @@ -18,13 +18,13 @@ audio::drain::Equalizer::Equalizer() { | |||||||
| void audio::drain::Equalizer::init() { | void audio::drain::Equalizer::init() { | ||||||
| 	audio::drain::Algo::init(); | 	audio::drain::Algo::init(); | ||||||
| 	audio::drain::Algo::m_type = "Equalizer"; | 	audio::drain::Algo::m_type = "Equalizer"; | ||||||
| 	m_supportedFormat.push_back(audio::format_int16); | 	m_supportedFormat.pushBack(audio::format_int16); | ||||||
| 	m_supportedFormat.push_back(audio::format_int16); | 	m_supportedFormat.pushBack(audio::format_int16); | ||||||
| 	configureBiQuad(); | 	configureBiQuad(); | ||||||
| } | } | ||||||
|  |  | ||||||
| ememory::SharedPtr<audio::drain::Equalizer> audio::drain::Equalizer::create() { | 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(); | 	tmp->init(); | ||||||
| 	return tmp; | 	return tmp; | ||||||
| } | } | ||||||
| @@ -45,14 +45,14 @@ bool audio::drain::Equalizer::process(audio::Time& _time, | |||||||
|                                       size_t& _outputNbChunk) { |                                       size_t& _outputNbChunk) { | ||||||
| 	_outputNbChunk = _inputNbChunk; | 	_outputNbChunk = _inputNbChunk; | ||||||
| 	_output = _input; | 	_output = _input; | ||||||
| 	if (_input == nullptr) { | 	if (_input == null) { | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| 	m_algo.process(_output, _input, _inputNbChunk); | 	m_algo.process(_output, _input, _inputNbChunk); | ||||||
| 	return true; | 	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); | 	//DRAIN_WARNING("set : " << _parameter << " " << _value); | ||||||
| 	if (_parameter == "config") { | 	if (_parameter == "config") { | ||||||
| 		m_config = ejson::Object(_value); | 		m_config = ejson::Object(_value); | ||||||
| @@ -64,17 +64,17 @@ bool audio::drain::Equalizer::setParameter(const std::string& _parameter, const | |||||||
| 	return false; | 	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"; | 	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"; | 	return "error"; | ||||||
| } | } | ||||||
|  |  | ||||||
| void audio::drain::Equalizer::addBiquad(int32_t _idBiquad, const ejson::Object& _object) { | void audio::drain::Equalizer::addBiquad(int32_t _idBiquad, const ejson::Object& _object) { | ||||||
| 	// get type: | 	// get type: | ||||||
| 	std::string typeString = _object["type"].toString().get("none"); | 	etk::String typeString = _object["type"].toString().get("none"); | ||||||
| 	if (typeString == "direct-value") { | 	if (typeString == "direct-value") { | ||||||
| 		double a0 = _object["a0"].toNumber().get(0.0); | 		double a0 = _object["a0"].toNumber().get(0.0); | ||||||
| 		double a1 = _object["a1"].toNumber().get(0.0); | 		double a1 = _object["a1"].toNumber().get(0.0); | ||||||
| @@ -125,7 +125,7 @@ void audio::drain::Equalizer::configureBiQuad() { | |||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	for (size_t iii=0; iii<getOutputFormat().getMap().size(); ++iii) { | 	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(); | 		const ejson::Array channelConfig = m_config[channelName].toArray(); | ||||||
| 		if (channelConfig.exist() == false) { | 		if (channelConfig.exist() == false) { | ||||||
| 			// no config ... not a problem ... | 			// no config ... not a problem ... | ||||||
| @@ -145,6 +145,6 @@ void audio::drain::Equalizer::configureBiQuad() { | |||||||
| 	return; | 	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(); | 	return m_algo.calculateTheory(); | ||||||
| } | } | ||||||
| @@ -1,14 +1,14 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <audio/drain/Algo.h> | #include <audio/drain/Algo.hpp> | ||||||
| #include <ememory/memory.h> | #include <ememory/memory.hpp> | ||||||
| #include <ejson/Object.h> | #include <ejson/Object.hpp> | ||||||
| #include <audio/algo/drain/Equalizer.h> | #include <audio/algo/drain/Equalizer.hpp> | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain { | 	namespace drain { | ||||||
| @@ -36,9 +36,9 @@ namespace audio { | |||||||
| 			protected: | 			protected: | ||||||
| 				ejson::Object m_config; // configuration of the equalizer.
 | 				ejson::Object m_config; // configuration of the equalizer.
 | ||||||
| 			public: | 			public: | ||||||
| 				virtual bool setParameter(const std::string& _parameter, const std::string& _value); | 				virtual bool setParameter(const etk::String& _parameter, const etk::String& _value); | ||||||
| 				virtual std::string getParameter(const std::string& _parameter) const; | 				virtual etk::String getParameter(const etk::String& _parameter) const; | ||||||
| 				virtual std::string getParameterProperty(const std::string& _parameter) const; | 				virtual etk::String getParameterProperty(const etk::String& _parameter) const; | ||||||
| 			protected: | 			protected: | ||||||
| 				void addBiquad(int32_t _idBiquad, const ejson::Object& _object); | 				void addBiquad(int32_t _idBiquad, const ejson::Object& _object); | ||||||
| 				audio::algo::drain::Equalizer m_algo; | 				audio::algo::drain::Equalizer m_algo; | ||||||
| @@ -48,7 +48,7 @@ namespace audio { | |||||||
| 				void configureBiQuad(); | 				void configureBiQuad(); | ||||||
| 			public: | 			public: | ||||||
| 				// for debug & tools only
 | 				// for debug & tools only
 | ||||||
| 				std::vector<std::pair<float,float> > calculateTheory(); | 				etk::Vector<etk::Pair<float,float> > calculateTheory(); | ||||||
| 		}; | 		}; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -1,12 +1,11 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <audio/drain/FormatUpdate.h> | #include <audio/drain/FormatUpdate.hpp> | ||||||
| #include <iostream> | #include <audio/drain/debug.hpp> | ||||||
| #include <audio/drain/debug.h> |  | ||||||
|  |  | ||||||
| #ifndef INT16_MAX | #ifndef INT16_MAX | ||||||
| 	#define INT16_MAX 0x7fff | 	#define INT16_MAX 0x7fff | ||||||
| @@ -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); | 	int32_t* in = static_cast<int32_t*>(_input); | ||||||
| 	int16_t* out = static_cast<int16_t*>(_output); | 	int16_t* out = static_cast<int16_t*>(_output); | ||||||
| 	for (size_t iii=0; iii<_nbSample; ++iii) { | 	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) { | 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* in = static_cast<int32_t*>(_input); | ||||||
| 	int32_t* out = static_cast<int32_t*>(_output); | 	int32_t* out = static_cast<int32_t*>(_output); | ||||||
| 	for (size_t iii=0; iii<_nbSample; ++iii) { | 	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; | 		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); | 	int16_t* out = static_cast<int16_t*>(_output); | ||||||
| 	for (size_t iii=0; iii<_nbSample; ++iii) { | 	for (size_t iii=0; iii<_nbSample; ++iii) { | ||||||
| 		int32_t value = in[iii] >> 16; | 		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) { | 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); | 	int16_t* out = static_cast<int16_t*>(_output); | ||||||
| 	for (size_t iii=0; iii<_nbSample; ++iii) { | 	for (size_t iii=0; iii<_nbSample; ++iii) { | ||||||
| 		float value = in[iii] * static_cast<float>(INT16_MAX); | 		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); | 		out[iii] = static_cast<int16_t>(value); | ||||||
| 		//DRAIN_DEBUG(iii << " in=" << in[iii] << " out=" << out[iii]); | 		//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); | 	int32_t* out = static_cast<int32_t*>(_output); | ||||||
| 	for (size_t iii=0; iii<_nbSample; ++iii) { | 	for (size_t iii=0; iii<_nbSample; ++iii) { | ||||||
| 		float value = in[iii] * static_cast<float>(INT16_MAX); | 		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); | 		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); | 	int32_t* out = static_cast<int32_t*>(_output); | ||||||
| 	for (size_t iii=0; iii<_nbSample; ++iii) { | 	for (size_t iii=0; iii<_nbSample; ++iii) { | ||||||
| 		float value = in[iii] * static_cast<float>(INT32_MAX); | 		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); | 		out[iii] = static_cast<int32_t>(value); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| audio::drain::FormatUpdate::FormatUpdate() : | 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> 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(); | 	tmp->init(); | ||||||
| 	return tmp; | 	return tmp; | ||||||
| } | } | ||||||
| @@ -252,7 +251,7 @@ bool audio::drain::FormatUpdate::process(audio::Time& _time, | |||||||
| 		_outputNbChunk = _inputNbChunk; | 		_outputNbChunk = _inputNbChunk; | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| 	if (_input == nullptr) { | 	if (_input == null) { | ||||||
| 		_output = &(m_outputData[0]); | 		_output = &(m_outputData[0]); | ||||||
| 		_outputNbChunk = 0; | 		_outputNbChunk = 0; | ||||||
| 		DRAIN_ERROR("null pointer input ... "); | 		DRAIN_ERROR("null pointer input ... "); | ||||||
| @@ -261,7 +260,7 @@ bool audio::drain::FormatUpdate::process(audio::Time& _time, | |||||||
| 	_outputNbChunk = _inputNbChunk; | 	_outputNbChunk = _inputNbChunk; | ||||||
| 	m_outputData.resize(_outputNbChunk*m_input.getMap().size()*m_formatSize); | 	m_outputData.resize(_outputNbChunk*m_input.getMap().size()*m_formatSize); | ||||||
| 	_output = &(m_outputData[0]); | 	_output = &(m_outputData[0]); | ||||||
| 	if (m_functionConvert == nullptr) { | 	if (m_functionConvert == null) { | ||||||
| 		DRAIN_ERROR("null function ptr"); | 		DRAIN_ERROR("null function ptr"); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -1,11 +1,11 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <audio/drain/Algo.h> | #include <audio/drain/Algo.hpp> | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain { | 	namespace drain { | ||||||
| @@ -1,13 +1,13 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include "IOFormatInterface.h" | #include "IOFormatInterface.hpp" | ||||||
| #include "debug.h" | #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 << "{"; | 	_os << "{"; | ||||||
| 	if (_obj.getConfigured() == false) { | 	if (_obj.getConfigured() == false) { | ||||||
| 		_os << "Not configured"; | 		_os << "Not configured"; | ||||||
| @@ -25,11 +25,11 @@ audio::drain::IOFormatInterface::IOFormatInterface() : | |||||||
|   m_format(audio::format_unknow), |   m_format(audio::format_unknow), | ||||||
|   m_map(), |   m_map(), | ||||||
|   m_frequency(0) { |   m_frequency(0) { | ||||||
| 	m_map.push_back(audio::channel_frontLeft); | 	m_map.pushBack(audio::channel_frontLeft); | ||||||
| 	m_map.push_back(audio::channel_frontRight); | 	m_map.pushBack(audio::channel_frontRight); | ||||||
| } | } | ||||||
|  |  | ||||||
| audio::drain::IOFormatInterface::IOFormatInterface(std::vector<audio::channel> _map, audio::format _format, float _frequency) : | audio::drain::IOFormatInterface::IOFormatInterface(etk::Vector<enum audio::channel> _map, enum audio::format _format, float _frequency) : | ||||||
|   m_configured(true), |   m_configured(true), | ||||||
|   m_format(_format), |   m_format(_format), | ||||||
|   m_map(_map), |   m_map(_map), | ||||||
| @@ -37,7 +37,7 @@ audio::drain::IOFormatInterface::IOFormatInterface(std::vector<audio::channel> _ | |||||||
| 	 | 	 | ||||||
| } | } | ||||||
|  |  | ||||||
| void audio::drain::IOFormatInterface::set(std::vector<audio::channel> _map, audio::format _format, float _frequency) { | void audio::drain::IOFormatInterface::set(etk::Vector<enum audio::channel> _map, enum audio::format _format, float _frequency) { | ||||||
| 	bool hasChange = false; | 	bool hasChange = false; | ||||||
| 	if (m_map != _map) { | 	if (m_map != _map) { | ||||||
| 		m_map = _map; | 		m_map = _map; | ||||||
| @@ -65,11 +65,11 @@ bool audio::drain::IOFormatInterface::getConfigured() const { | |||||||
| 	return m_configured; | 	return m_configured; | ||||||
| } | } | ||||||
|  |  | ||||||
| audio::format audio::drain::IOFormatInterface::getFormat() const { | enum audio::format audio::drain::IOFormatInterface::getFormat() const { | ||||||
| 	return m_format; | 	return m_format; | ||||||
| } | } | ||||||
|  |  | ||||||
| void audio::drain::IOFormatInterface::setFormat(audio::format _value) { | void audio::drain::IOFormatInterface::setFormat(enum audio::format _value) { | ||||||
| 	if (m_format == _value) { | 	if (m_format == _value) { | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| @@ -78,11 +78,11 @@ void audio::drain::IOFormatInterface::setFormat(audio::format _value) { | |||||||
| 	configurationChange(); | 	configurationChange(); | ||||||
| } | } | ||||||
|  |  | ||||||
| const std::vector<audio::channel>& audio::drain::IOFormatInterface::getMap() const{ | const etk::Vector<enum audio::channel>& audio::drain::IOFormatInterface::getMap() const{ | ||||||
| 	return m_map; | 	return m_map; | ||||||
| } | } | ||||||
|  |  | ||||||
| void audio::drain::IOFormatInterface::setMap(const std::vector<audio::channel>& _value) { | void audio::drain::IOFormatInterface::setMap(const etk::Vector<enum audio::channel>& _value) { | ||||||
| 	if (m_map == _value) { | 	if (m_map == _value) { | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| @@ -105,11 +105,11 @@ void audio::drain::IOFormatInterface::setFrequency(float _value) { | |||||||
| } | } | ||||||
|  |  | ||||||
| void audio::drain::IOFormatInterface::configurationChange() { | void audio::drain::IOFormatInterface::configurationChange() { | ||||||
| 	if (m_ioChangeFunctor != nullptr) { | 	if (m_ioChangeFunctor != null) { | ||||||
| 		m_ioChangeFunctor(); | 		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; | 	m_ioChangeFunctor = _functor; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,59 +1,58 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <string> | #include <etk/String.hpp> | ||||||
| #include <vector> | #include <etk/Vector.hpp> | ||||||
| #include <stdint.h> | #include <audio/format.hpp> | ||||||
| #include <audio/format.h> | #include <audio/channel.hpp> | ||||||
| #include <audio/channel.h> | #include <echrono/Steady.hpp> | ||||||
| #include <chrono> | #include <etk/Function.hpp> | ||||||
| #include <functional> | #include <ememory/memory.hpp> | ||||||
| #include <ememory/memory.h> | #include "AutoLogInOut.hpp" | ||||||
| #include "AutoLogInOut.h" | #include "debug.hpp" | ||||||
| #include "debug.h" |  | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain{ | 	namespace drain{ | ||||||
| 		class IOFormatInterface { | 		class IOFormatInterface { | ||||||
| 			public: | 			public: | ||||||
| 				IOFormatInterface(); | 				IOFormatInterface(); | ||||||
| 				IOFormatInterface(std::vector<audio::channel> _map, audio::format _format=audio::format_int16, float _frequency=48000.0f); | 				IOFormatInterface(etk::Vector<enum audio::channel> _map, enum audio::format _format=audio::format_int16, float _frequency=48000.0f); | ||||||
| 				void set(std::vector<audio::channel> _map, 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: | 			protected: | ||||||
| 				bool m_configured; | 				bool m_configured; | ||||||
| 			public: | 			public: | ||||||
| 				void setConfigured(bool _value); | 				void setConfigured(bool _value); | ||||||
| 				bool getConfigured() const; | 				bool getConfigured() const; | ||||||
| 			protected: | 			protected: | ||||||
| 				audio::format m_format; //!< input Algo Format
 | 				enum audio::format m_format; //!< input Algo Format
 | ||||||
| 			public: | 			public: | ||||||
| 				/**
 | 				/**
 | ||||||
| 				 * @brief Get the algo format. | 				 * @brief Get the algo format. | ||||||
| 				 * @return the current Format. | 				 * @return the current Format. | ||||||
| 				 */ | 				 */ | ||||||
| 				audio::format getFormat() const; | 				enum audio::format getFormat() const; | ||||||
| 				/**
 | 				/**
 | ||||||
| 				 * @brief Set the algo format. | 				 * @brief Set the algo format. | ||||||
| 				 * @param[in] _value New Format. | 				 * @param[in] _value New Format. | ||||||
| 				 */ | 				 */ | ||||||
| 				void setFormat(audio::format _value); | 				void setFormat(enum audio::format _value); | ||||||
| 			protected: | 			protected: | ||||||
| 				std::vector<audio::channel> m_map; //!< input channel Map
 | 				etk::Vector<enum audio::channel> m_map; //!< input channel Map
 | ||||||
| 			public: | 			public: | ||||||
| 				/**
 | 				/**
 | ||||||
| 				 * @brief Get the algo channel Map. | 				 * @brief Get the algo channel Map. | ||||||
| 				 * @return the current channel Map. | 				 * @return the current channel Map. | ||||||
| 				 */ | 				 */ | ||||||
| 				const std::vector<audio::channel>& getMap() const; | 				const etk::Vector<enum audio::channel>& getMap() const; | ||||||
| 				/**
 | 				/**
 | ||||||
| 				 * @brief Set the algo channel Map. | 				 * @brief Set the algo channel Map. | ||||||
| 				 * @param[in] _value New channel Map. | 				 * @param[in] _value New channel Map. | ||||||
| 				 */ | 				 */ | ||||||
| 				void setMap(const std::vector<audio::channel>& _value); | 				void setMap(const etk::Vector<enum audio::channel>& _value); | ||||||
| 			protected: | 			protected: | ||||||
| 				float m_frequency; //!< input Algo Format
 | 				float m_frequency; //!< input Algo Format
 | ||||||
| 			public: | 			public: | ||||||
| @@ -74,16 +73,16 @@ namespace audio { | |||||||
| 				 */ | 				 */ | ||||||
| 				int32_t getChunkSize() const; | 				int32_t getChunkSize() const; | ||||||
| 			protected: | 			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(); | 				void configurationChange(); | ||||||
| 			public: | 			public: | ||||||
| 				/**
 | 				/**
 | ||||||
| 				 * @brief Set the callback function to be notify when the arameter change. | 				 * @brief Set the callback function to be notify when the arameter change. | ||||||
| 				 * @param[in] _functor Function to call. | 				 * @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); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @@ -1,19 +1,18 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <string> | #include <etk/String.hpp> | ||||||
| #include <vector> | #include <etk/Vector.hpp> | ||||||
| #include <stdint.h> | #include <audio/format.hpp> | ||||||
| #include <audio/format.h> | #include <audio/channel.hpp> | ||||||
| #include <audio/channel.h> | #include <audio/drain/Process.hpp> | ||||||
| #include <audio/drain/Process.h> | #include <audio/drain/ChannelReorder.hpp> | ||||||
| #include <audio/drain/ChannelReorder.h> | #include <audio/drain/FormatUpdate.hpp> | ||||||
| #include <audio/drain/FormatUpdate.h> | #include <audio/drain/Resampler.hpp> | ||||||
| #include <audio/drain/Resampler.h> | #include <audio/drain/debug.hpp> | ||||||
| #include <audio/drain/debug.h> |  | ||||||
|  |  | ||||||
| audio::drain::Process::Process() : | audio::drain::Process::Process() : | ||||||
|   m_isConfigured(false) { |   m_isConfigured(false) { | ||||||
| @@ -28,7 +27,7 @@ audio::drain::Process::~Process() { | |||||||
| bool audio::drain::Process::push(audio::Time& _time, | bool audio::drain::Process::push(audio::Time& _time, | ||||||
|                                  void* _data, |                                  void* _data, | ||||||
|                                  size_t _nbChunk) { |                                  size_t _nbChunk) { | ||||||
| 	void* out = nullptr; | 	void* out = null; | ||||||
| 	size_t nbChunkOut; | 	size_t nbChunkOut; | ||||||
| 	DRAIN_VERBOSE("        Process push"); | 	DRAIN_VERBOSE("        Process push"); | ||||||
| 	process(_time, _data, _nbChunk, out, nbChunkOut); | 	process(_time, _data, _nbChunk, out, nbChunkOut); | ||||||
| @@ -39,24 +38,25 @@ bool audio::drain::Process::pull(audio::Time& _time, | |||||||
|                                  void* _data, |                                  void* _data, | ||||||
|                                  size_t _nbChunk, |                                  size_t _nbChunk, | ||||||
|                                  size_t _chunkSize) { |                                  size_t _chunkSize) { | ||||||
| 	while(m_data.size()<_nbChunk*_chunkSize) { | 	//DRAIN_DEBUG("Execute:"); | ||||||
| 		void* in = NULL; | 	while(m_data.size() < _nbChunk*_chunkSize) { | ||||||
|  | 		void* in = null; | ||||||
| 		size_t nbChunkIn = _nbChunk - m_data.size()/_chunkSize; | 		size_t nbChunkIn = _nbChunk - m_data.size()/_chunkSize; | ||||||
| 		void* out = NULL; | 		void* out = null; | ||||||
| 		size_t nbChunkOut; | 		size_t nbChunkOut; | ||||||
| 		if (nbChunkIn < 128) { | 		if (nbChunkIn < 128) { | ||||||
| 			nbChunkIn = 128; | 			nbChunkIn = 128; | ||||||
| 		} | 		} | ||||||
| 		// TODO : maybe remove this for input data ... | 		// TODO : maybe remove this for input data ... | ||||||
| 		for (int32_t iii=m_listAlgo.size()-1; iii >=0; --iii) { | 		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); | 				nbChunkIn = m_listAlgo[iii]->needInputData(nbChunkIn); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		if (nbChunkIn < 32) { | 		if (nbChunkIn < 32) { | ||||||
| 			nbChunkIn = 32; | 			nbChunkIn = 32; | ||||||
| 		} | 		} | ||||||
| 		 | 		//DRAIN_DEBUG("    process:" << _time << " in=" << in << " nbChunkIn=" << nbChunkIn << " out=" << out << " nbChunkOut=" << nbChunkOut); | ||||||
| 		// get data from the upstream | 		// get data from the upstream | ||||||
| 		process(_time, in, nbChunkIn, out, nbChunkOut); | 		process(_time, in, nbChunkIn, out, nbChunkOut); | ||||||
| 		if (nbChunkOut > 0) { | 		if (nbChunkOut > 0) { | ||||||
| @@ -69,7 +69,7 @@ bool audio::drain::Process::pull(audio::Time& _time, | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	// copy only data availlable : | 	// 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) { | 	if (minByTeSize >= 0) { | ||||||
| 		memcpy(_data, &m_data[0], minByTeSize); | 		memcpy(_data, &m_data[0], minByTeSize); | ||||||
| 		m_data.erase(m_data.begin(), m_data.begin()+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); | 	DRAIN_VERBOSE(" process : " << m_listAlgo.size() << " algos nbChunk=" << _inNbChunk); | ||||||
| 	for (size_t iii=0; iii<m_listAlgo.size(); ++iii) { | 	for (size_t iii=0; iii<m_listAlgo.size(); ++iii) { | ||||||
| 		//std::cout << "            Algo " << iii+1 << "/" << m_listAlgo.size() << std::endl; | 		DRAIN_VERBOSE("            Algo " << iii+1 << "/" << m_listAlgo.size()); | ||||||
| 		if (m_listAlgo[iii] != nullptr) { | 		if (m_listAlgo[iii] != null) { | ||||||
| 			m_listAlgo[iii]->process(_time, _inData, _inNbChunk, _outData, _outNbChunk); | 			m_listAlgo[iii]->process(_time, _inData, _inNbChunk, _outData, _outNbChunk); | ||||||
| 			_inData = _outData; | 			_inData = _outData; | ||||||
| 			_inNbChunk = _outNbChunk; | 			_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) { | void audio::drain::Process::pushBack(ememory::SharedPtr<audio::drain::Algo> _algo) { | ||||||
| 	removeAlgoDynamic(); | 	removeAlgoDynamic(); | ||||||
| 	_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.push_back(_algo); | 	m_listAlgo.pushBack(_algo); | ||||||
| } | } | ||||||
|  |  | ||||||
| void audio::drain::Process::pushFront(ememory::SharedPtr<audio::drain::Algo> _algo) { | void audio::drain::Process::pushFront(ememory::SharedPtr<audio::drain::Algo> _algo) { | ||||||
| 	removeAlgoDynamic(); | 	removeAlgoDynamic(); | ||||||
| 	_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(), _algo); | 	m_listAlgo.pushFront(_algo); | ||||||
| } | } | ||||||
|  |  | ||||||
| template<typename T> std::vector<T> getUnion(const std::vector<T>& _out, const std::vector<T>& _in) { | template<typename DRAIN_TYPE> | ||||||
| 	std::vector<T> out; | 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) { | 	if (_out.size() == 0) { | ||||||
| 		// Last is ok for all format | 		// Last is ok for all format | ||||||
| 		// ==> set the limit with the next element | 		// ==> 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 ooo=0; ooo<_out.size(); ++ooo) { | ||||||
| 			for (size_t iii=0; iii<_in.size(); ++iii) { | 			for (size_t iii=0; iii<_in.size(); ++iii) { | ||||||
| 				if (_out[ooo] == _in[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: | 		// step 1 : check frequency: | ||||||
| 		std::vector<float> freqOut; | 		etk::Vector<float> freqOut; | ||||||
| 		std::vector<float> freqIn; | 		etk::Vector<float> freqIn; | ||||||
| 		if (_position == 0) { | 		if (_position == 0) { | ||||||
| 			freqOut.push_back(m_inputConfig.getFrequency()); | 			freqOut.pushBack(m_inputConfig.getFrequency()); | ||||||
| 		} else { | 		} else { | ||||||
| 			freqOut = m_listAlgo[_position-1]->getFrequencySupportedOutput(); | 			freqOut = m_listAlgo[_position-1]->getFrequencySupportedOutput(); | ||||||
| 		} | 		} | ||||||
| 		if (_position == m_listAlgo.size()) { | 		if (_position == m_listAlgo.size()) { | ||||||
| 			freqIn.push_back(m_outputConfig.getFrequency()); | 			freqIn.pushBack(m_outputConfig.getFrequency()); | ||||||
| 		} else { | 		} else { | ||||||
| 			freqIn = m_listAlgo[_position]->getFrequencySupportedInput(); | 			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 out   :" << freqOut); | ||||||
| 		DRAIN_VERBOSE("        freq in    :" << freqIn); | 		DRAIN_VERBOSE("        freq in    :" << freqIn); | ||||||
| 		DRAIN_VERBOSE("        freq union :" << freq); | 		DRAIN_VERBOSE("        freq union :" << freq); | ||||||
| 		 | 		 | ||||||
| 		// step 2 : Check map: | 		// step 2 : Check map: | ||||||
| 		std::vector<std::vector<audio::channel> > mapOut; | 		etk::Vector<etk::Vector<audio::channel> > mapOut; | ||||||
| 		std::vector<std::vector<audio::channel> > mapIn; | 		etk::Vector<etk::Vector<audio::channel> > mapIn; | ||||||
| 		if (_position == 0) { | 		if (_position == 0) { | ||||||
| 			mapOut.push_back(m_inputConfig.getMap()); | 			mapOut.pushBack(m_inputConfig.getMap()); | ||||||
| 		} else { | 		} else { | ||||||
| 			mapOut = m_listAlgo[_position-1]->getMapSupportedOutput(); | 			mapOut = m_listAlgo[_position-1]->getMapSupportedOutput(); | ||||||
| 		} | 		} | ||||||
| 		if (_position == m_listAlgo.size()) { | 		if (_position == m_listAlgo.size()) { | ||||||
| 			mapIn.push_back(m_outputConfig.getMap()); | 			mapIn.pushBack(m_outputConfig.getMap()); | ||||||
| 		} else { | 		} else { | ||||||
| 			mapIn = m_listAlgo[_position]->getMapSupportedInput(); | 			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 out   :" << mapOut); | ||||||
| 		DRAIN_VERBOSE("        map in    :" << mapIn); | 		DRAIN_VERBOSE("        map in    :" << mapIn); | ||||||
| 		DRAIN_VERBOSE("        map union :" << map); | 		DRAIN_VERBOSE("        map union :" << map); | ||||||
| 		// step 3 : Check Format: | 		// step 3 : Check Format: | ||||||
| 		std::vector<audio::format> formatOut; | 		etk::Vector<audio::format> formatOut; | ||||||
| 		std::vector<audio::format> formatIn; | 		etk::Vector<audio::format> formatIn; | ||||||
| 		if (_position == 0) { | 		if (_position == 0) { | ||||||
| 			formatOut.push_back(m_inputConfig.getFormat()); | 			formatOut.pushBack(m_inputConfig.getFormat()); | ||||||
| 		} else { | 		} else { | ||||||
| 			formatOut = m_listAlgo[_position-1]->getFormatSupportedOutput(); | 			formatOut = m_listAlgo[_position-1]->getFormatSupportedOutput(); | ||||||
| 		} | 		} | ||||||
| 		if (_position == m_listAlgo.size()) { | 		if (_position == m_listAlgo.size()) { | ||||||
| 			formatIn.push_back(m_outputConfig.getFormat()); | 			formatIn.pushBack(m_outputConfig.getFormat()); | ||||||
| 		} else { | 		} else { | ||||||
| 			formatIn = m_listAlgo[_position]->getFormatSupportedInput(); | 			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 out   :" << formatOut); | ||||||
| 		DRAIN_VERBOSE("        format in    :" << formatIn); | 		DRAIN_VERBOSE("        format in    :" << formatIn); | ||||||
| 		DRAIN_VERBOSE("        format union :" << format); | 		DRAIN_VERBOSE("        format union :" << format); | ||||||
| @@ -339,7 +340,7 @@ void audio::drain::Process::updateAlgo(size_t _position) { | |||||||
| 				algo->setInputFormat(out); | 				algo->setInputFormat(out); | ||||||
| 				out.setFormat(audio::format_int16); | 				out.setFormat(audio::format_int16); | ||||||
| 				algo->setOutputFormat(out); | 				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); | 				m_listAlgo.insert(m_listAlgo.begin()+_position, algo); | ||||||
| 				DRAIN_VERBOSE("convert " << out.getFormat() << " -> " << in.getFormat()); | 				DRAIN_VERBOSE("convert " << out.getFormat() << " -> " << in.getFormat()); | ||||||
| 				_position++; | 				_position++; | ||||||
| @@ -350,7 +351,7 @@ void audio::drain::Process::updateAlgo(size_t _position) { | |||||||
| 			algo->setInputFormat(out); | 			algo->setInputFormat(out); | ||||||
| 			out.setFrequency(in.getFrequency()); | 			out.setFrequency(in.getFrequency()); | ||||||
| 			algo->setOutputFormat(out); | 			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); | 			m_listAlgo.insert(m_listAlgo.begin()+_position, algo); | ||||||
| 			DRAIN_VERBOSE("convert " << out.getFrequency() << " -> " << in.getFrequency()); | 			DRAIN_VERBOSE("convert " << out.getFrequency() << " -> " << in.getFrequency()); | ||||||
| 			out.setFrequency(in.getFrequency()); | 			out.setFrequency(in.getFrequency()); | ||||||
| @@ -363,7 +364,7 @@ void audio::drain::Process::updateAlgo(size_t _position) { | |||||||
| 			algo->setInputFormat(out); | 			algo->setInputFormat(out); | ||||||
| 			out.setMap(in.getMap()); | 			out.setMap(in.getMap()); | ||||||
| 			algo->setOutputFormat(out); | 			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); | 			m_listAlgo.insert(m_listAlgo.begin()+_position, algo); | ||||||
| 			DRAIN_VERBOSE("convert " << out.getMap() << " -> " << in.getMap()); | 			DRAIN_VERBOSE("convert " << out.getMap() << " -> " << in.getMap()); | ||||||
| 			_position++; | 			_position++; | ||||||
| @@ -375,7 +376,7 @@ void audio::drain::Process::updateAlgo(size_t _position) { | |||||||
| 			algo->setInputFormat(out); | 			algo->setInputFormat(out); | ||||||
| 			out.setFormat(in.getFormat()); | 			out.setFormat(in.getFormat()); | ||||||
| 			algo->setOutputFormat(out); | 			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); | 			m_listAlgo.insert(m_listAlgo.begin()+_position, algo); | ||||||
| 			DRAIN_VERBOSE("convert " << out.getFormat() << " -> " << in.getFormat()); | 			DRAIN_VERBOSE("convert " << out.getFormat() << " -> " << in.getFormat()); | ||||||
| 			_position++; | 			_position++; | ||||||
| @@ -426,7 +427,7 @@ bool audio::drain::Process::processIn(void* _inData, | |||||||
|                                       size_t _inNbChunk, |                                       size_t _inNbChunk, | ||||||
|                                       void* _outData, |                                       void* _outData, | ||||||
|                                       size_t _outNbChunk){ |                                       size_t _outNbChunk){ | ||||||
| 	void* outData = nullptr; | 	void* outData = null; | ||||||
| 	size_t outSize = 0; | 	size_t outSize = 0; | ||||||
| 	bool error = process(_inData, _inNbChunk, outData, outSize); | 	bool error = process(_inData, _inNbChunk, outData, outSize); | ||||||
| 	if (outSize != _outNbChunk) { | 	if (outSize != _outNbChunk) { | ||||||
| @@ -439,146 +440,215 @@ bool audio::drain::Process::processIn(void* _inData, | |||||||
| 	return false; | 	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 (_op == "->") { | ||||||
| 		if (_isLink) { | 		if (_isLink) { | ||||||
| 			_node << "			" << _first << " -> " << _second << ";\n"; | 			*_io << "			" << _first << " -> " << _second << ";\n"; | ||||||
| 		} else { | 		} else { | ||||||
| 			_node << "			" << _first << " -> " << _second << " [style=dashed];\n"; | 			*_io << "			" << _first << " -> " << _second << " [style=dashed];\n"; | ||||||
| 		} | 		} | ||||||
| 	} else if (_op == "<-") { | 	} else if (_op == "<-") { | ||||||
| 		_node << "			" << _first << " -> " <<_second<< " [color=transparent];\n"; | 		*_io << "			" << _first << " -> " <<_second<< " [color=transparent];\n"; | ||||||
| 		if (_isLink) { | 		if (_isLink) { | ||||||
| 			_node << "			" << _second << " -> " << _first << " [constraint=false];\n"; | 			*_io << "			" << _second << " -> " << _first << " [constraint=false];\n"; | ||||||
| 		} else { | 		} 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) { | void audio::drain::Process::generateDot(ememory::SharedPtr<etk::io::Interface>& _io, | ||||||
| 	_node << "			subgraph clusterNode_" << _basicID << "_process {\n"; |                                         int32_t _offset, | ||||||
| 	_node << "				label=\"Drain::Process" << (_reserseGraph?"_R":"_N") << "\";\n"; |                                         int32_t _basicID, | ||||||
| 	_node << "				node [shape=ellipse];\n"; |                                         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) { | 	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 freq=" << getInputConfig().getFrequency() | ||||||
| 		                                        << "\\n channelMap=" << etk::to_string(getInputConfig().getMap()) << "\\n in\" ];\n"; | 		                                        << "\\n channelMap=" << etk::toString(getInputConfig().getMap()) << "\\n in\" ];\n"; | ||||||
| 	} else { | 		// ---------------------- | ||||||
| 		_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_out"; | 		// --       STEP 2     -- | ||||||
| 		_node << "				" << _nameIn << " [ label=\"format=" << etk::to_string(getOutputConfig().getFormat()) | 		// ---------------------- | ||||||
| 		                                              << "\\n freq=" << getOutputConfig().getFrequency() | 		etk::String connectString = _nameIn; | ||||||
| 		                                        << "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n"; | 		*_io << "				node [shape=box];\n"; | ||||||
| 	} | 		// ---------------------- | ||||||
| 	std::string connectString = _nameIn; | 		// --       STEP 3     -- | ||||||
| 	_node << "				node [shape=box];\n"; | 		// ---------------------- | ||||||
| 	if (_reserseGraph == false) { |  | ||||||
| 		for (size_t iii=0; iii<m_listAlgo.size(); ++iii) { | 		for (size_t iii=0; iii<m_listAlgo.size(); ++iii) { | ||||||
| 			if (m_listAlgo[iii] == nullptr) { | 			if (m_listAlgo[iii] == null) { | ||||||
| 				continue; | 				continue; | ||||||
| 			} | 			} | ||||||
| 			std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii); | 			etk::String connectStringSecond = "ALGO_" + etk::toString(_basicID) + "__" + etk::toString(iii); | ||||||
| 			_node << "				" << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'\\nname='" << m_listAlgo[iii]->getName() << "'\" ];\n"; | 			*_io << "				" << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'"; | ||||||
| 			link(_node, connectString, "->", connectStringSecond); | 			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; | 			connectString = connectStringSecond; | ||||||
| 		} | 		} | ||||||
| 	} else { | 	} else { | ||||||
| 		//for (int32_t iii=m_listAlgo.size()-1; iii>=0; --iii) { | 		//for (int32_t iii=m_listAlgo.size()-1; iii>=0; --iii) { | ||||||
| 		for (size_t iii=0; iii<m_listAlgo.size(); ++iii) { | 		for (size_t iii=0; iii<m_listAlgo.size(); ++iii) { | ||||||
| 			if (m_listAlgo[iii] == nullptr) { | 			if (m_listAlgo[iii] == null) { | ||||||
| 				continue; | 				continue; | ||||||
| 			} | 			} | ||||||
| 			std::string connectStringSecond = "ALGO_" + etk::to_string(_basicID) + "__" + etk::to_string(iii); | 			etk::String connectStringSecond = "ALGO_" + etk::toString(_basicID) + "__" + etk::toString(iii); | ||||||
| 			_node << "				" << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'\\nname='" << m_listAlgo[iii]->getName() << "'\" ];\n"; | 			*_io << "				" << connectStringSecond << " [label=\"ALGO\\ntype='" << m_listAlgo[iii]->getType() << "'"; | ||||||
| 			link(_node, connectStringSecond, "<-", connectString); | 			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; | 			connectString = connectStringSecond; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	_node << "				node [shape=ellipse];\n"; | 	*_io << "				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"; |  | ||||||
| 	 |  | ||||||
| 	if (_reserseGraph == true) { | 	if (_reserseGraph == true) { | ||||||
| 		_nameIn = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in"; | 		_nameOut = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_out"; | ||||||
| 		_node << "				" << _nameIn << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat()) | 		*_io << "				" << _nameOut << " [ label=\"format=" << etk::toString(getOutputConfig().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()) |  | ||||||
| 		                                               << "\\n freq=" << getOutputConfig().getFrequency() | 		                                               << "\\n freq=" << getOutputConfig().getFrequency() | ||||||
| 		                                         << "\\n channelMap=" << etk::to_string(getOutputConfig().getMap()) << "\\n out\" ];\n"; | 		                                         << "\\n channelMap=" << etk::toString(getOutputConfig().getMap()) << "\\n out\" ];\n"; | ||||||
| 	} else { | 	} else { | ||||||
| 		_nameOut = "INTERFACE_ALGO_" + etk::to_string(_basicID) + "_in"; | 		_nameOut = "INTERFACE_ALGO_" + etk::toString(_basicID) + "_in"; | ||||||
| 		_node << "				" << _nameOut << " [ label=\"format=" << etk::to_string(getInputConfig().getFormat()) | 		*_io << "				" << _nameOut << " [ label=\"format=" << etk::toString(getInputConfig().getFormat()) | ||||||
| 		                                               << "\\n freq=" << getInputConfig().getFrequency() | 		                                               << "\\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) { | 	if (_reserseGraph == false) { | ||||||
| 		link(_node, connectString,                                      "->", _nameOut); | 		link(_io, connectString,                                      "->", _nameOut); | ||||||
| 	} else { | 	} 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) { | void audio::drain::Process::generateStatus(const etk::String& _origin, const etk::String& _status) { | ||||||
| 	if (m_statusFunction != nullptr) { | 	if (m_statusFunction != null) { | ||||||
| 		m_statusFunction(_origin, _status); | 		m_statusFunction(_origin, _status); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,26 +1,25 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <string> | #include <etk/String.hpp> | ||||||
| #include <vector> | #include <etk/Vector.hpp> | ||||||
| #include <stdint.h> | #include <etk/io/Interface.hpp> | ||||||
| #include <audio/format.h> | #include <audio/format.hpp> | ||||||
| #include <audio/channel.h> | #include <audio/channel.hpp> | ||||||
| #include <audio/drain/Algo.h> | #include <audio/drain/Algo.hpp> | ||||||
| #include <chrono> | #include <echrono/Steady.hpp> | ||||||
| #include <ememory/memory.h> | #include <ememory/memory.hpp> | ||||||
| #include <etk/os/FSNode.h> |  | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain{ | 	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 { | 		class Process { | ||||||
| 			protected: | 			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: | 			public: | ||||||
| 				Process(); | 				Process(); | ||||||
| 				virtual ~Process(); | 				virtual ~Process(); | ||||||
| @@ -94,7 +93,7 @@ namespace audio { | |||||||
| 					m_outputConfig = _interface; | 					m_outputConfig = _interface; | ||||||
| 				} | 				} | ||||||
| 			protected: | 			protected: | ||||||
| 				std::vector<ememory::SharedPtr<drain::Algo> > m_listAlgo; | 				etk::Vector<ememory::SharedPtr<drain::Algo> > m_listAlgo; | ||||||
| 			public: | 			public: | ||||||
| 				void pushBack(ememory::SharedPtr<drain::Algo> _algo); | 				void pushBack(ememory::SharedPtr<drain::Algo> _algo); | ||||||
| 				void pushFront(ememory::SharedPtr<drain::Algo> _algo); | 				void pushFront(ememory::SharedPtr<drain::Algo> _algo); | ||||||
| @@ -105,19 +104,19 @@ namespace audio { | |||||||
| 				size_t size() { | 				size_t size() { | ||||||
| 					return m_listAlgo.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(); | 					return m_listAlgo.begin(); | ||||||
| 				} | 				} | ||||||
| 				std::vector<ememory::SharedPtr<drain::Algo> >::iterator end() { | 				etk::Vector<ememory::SharedPtr<drain::Algo>>::Iterator end() { | ||||||
| 					return m_listAlgo.end(); | 					return m_listAlgo.end(); | ||||||
| 				} | 				} | ||||||
| 				ememory::SharedPtr<drain::Algo> operator[](int32_t _id) { | 				ememory::SharedPtr<drain::Algo> operator[](int32_t _id) { | ||||||
| 					return m_listAlgo[_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) { | 					for (size_t iii=0; iii<m_listAlgo.size(); ++iii) { | ||||||
| 						if (m_listAlgo[iii] == nullptr) { | 						if (m_listAlgo[iii] == null) { | ||||||
| 							continue; | 							continue; | ||||||
| 						} | 						} | ||||||
| 						if (m_listAlgo[iii]->getName() == _name) { | 						if (m_listAlgo[iii]->getName() == _name) { | ||||||
| @@ -126,9 +125,9 @@ namespace audio { | |||||||
| 					} | 					} | ||||||
| 					return ememory::SharedPtr<T>(); | 					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) { | 					for (size_t iii=0; iii<m_listAlgo.size(); ++iii) { | ||||||
| 						if (m_listAlgo[iii] == nullptr) { | 						if (m_listAlgo[iii] == null) { | ||||||
| 							continue; | 							continue; | ||||||
| 						} | 						} | ||||||
| 						if (m_listAlgo[iii]->getName() == _name) { | 						if (m_listAlgo[iii]->getName() == _name) { | ||||||
| @@ -143,7 +142,7 @@ namespace audio { | |||||||
| 				template<typename T> void removeIfFirst() { | 				template<typename T> void removeIfFirst() { | ||||||
| 					if (m_listAlgo.size() > 0) { | 					if (m_listAlgo.size() > 0) { | ||||||
| 						ememory::SharedPtr<T> algoEP = get<T>(0); | 						ememory::SharedPtr<T> algoEP = get<T>(0); | ||||||
| 						if (algoEP != nullptr) { | 						if (algoEP != null) { | ||||||
| 							m_listAlgo.erase(m_listAlgo.begin()); | 							m_listAlgo.erase(m_listAlgo.begin()); | ||||||
| 						} | 						} | ||||||
| 					} | 					} | ||||||
| @@ -151,7 +150,7 @@ namespace audio { | |||||||
| 				template<typename T> void removeIfLast() { | 				template<typename T> void removeIfLast() { | ||||||
| 					if (m_listAlgo.size() > 0) { | 					if (m_listAlgo.size() > 0) { | ||||||
| 						ememory::SharedPtr<T> algoEP = get<T>(m_listAlgo.size()-1); | 						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); | 							m_listAlgo.erase(m_listAlgo.begin()+m_listAlgo.size()-1); | ||||||
| 						} | 						} | ||||||
| 					} | 					} | ||||||
| @@ -159,7 +158,7 @@ namespace audio { | |||||||
| 				template<typename T> bool hasType() { | 				template<typename T> bool hasType() { | ||||||
| 					for (size_t iii=0; iii<m_listAlgo.size(); ++iii) { | 					for (size_t iii=0; iii<m_listAlgo.size(); ++iii) { | ||||||
| 						ememory::SharedPtr<T> tmp = ememory::dynamicPointerCast<T>(m_listAlgo[iii]); | 						ememory::SharedPtr<T> tmp = ememory::dynamicPointerCast<T>(m_listAlgo[iii]); | ||||||
| 						if (tmp != nullptr) { | 						if (tmp != null) { | ||||||
| 							return true; | 							return true; | ||||||
| 						} | 						} | ||||||
| 					} | 					} | ||||||
| @@ -168,7 +167,7 @@ namespace audio { | |||||||
| 			private: | 			private: | ||||||
| 				statusFunction m_statusFunction; | 				statusFunction m_statusFunction; | ||||||
| 			public: | 			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); | 				void setStatusFunction(statusFunction _newFunction); | ||||||
| 			private: | 			private: | ||||||
| 				bool m_isConfigured; | 				bool m_isConfigured; | ||||||
| @@ -179,9 +178,9 @@ namespace audio { | |||||||
| 				void displayAlgo(); | 				void displayAlgo(); | ||||||
| 				void updateAlgo(size_t _position); | 				void updateAlgo(size_t _position); | ||||||
| 			public: | 			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 ...
 | 				// 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); | ||||||
| 		}; | 		}; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -1,16 +1,15 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <audio/drain/Resampler.h> | #include <audio/drain/Resampler.hpp> | ||||||
| #include <iostream> | #include <audio/drain/debug.hpp> | ||||||
| #include <audio/drain/debug.h> |  | ||||||
|  |  | ||||||
| audio::drain::Resampler::Resampler() : | audio::drain::Resampler::Resampler() : | ||||||
|   #ifdef HAVE_SPEEX_DSP_RESAMPLE |   #ifdef HAVE_SPEEX_DSP_RESAMPLE | ||||||
|     m_speexResampler(nullptr), |     m_speexResampler(null), | ||||||
|   #endif |   #endif | ||||||
|   m_positionRead(0), |   m_positionRead(0), | ||||||
|   m_positionWrite(0) { |   m_positionWrite(0) { | ||||||
| @@ -20,21 +19,21 @@ audio::drain::Resampler::Resampler() : | |||||||
| void audio::drain::Resampler::init() { | void audio::drain::Resampler::init() { | ||||||
| 	audio::drain::Algo::init(); | 	audio::drain::Algo::init(); | ||||||
| 	m_type = "Resampler"; | 	m_type = "Resampler"; | ||||||
| 	m_supportedFormat.push_back(audio::format_int16); | 	m_supportedFormat.pushBack(audio::format_int16); | ||||||
| 	m_residualTimeInResampler = audio::Duration(0); | 	m_residualTimeInResampler = audio::Duration(0); | ||||||
| } | } | ||||||
|  |  | ||||||
| ememory::SharedPtr<audio::drain::Resampler> audio::drain::Resampler::create() { | 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(); | 	tmp->init(); | ||||||
| 	return tmp; | 	return tmp; | ||||||
| } | } | ||||||
|  |  | ||||||
| audio::drain::Resampler::~Resampler() { | audio::drain::Resampler::~Resampler() { | ||||||
| 	#ifdef HAVE_SPEEX_DSP_RESAMPLE | 	#ifdef HAVE_SPEEX_DSP_RESAMPLE | ||||||
| 		if (m_speexResampler != nullptr) { | 		if (m_speexResampler != null) { | ||||||
| 			speex_resampler_destroy(m_speexResampler); | 			speex_resampler_destroy(m_speexResampler); | ||||||
| 			m_speexResampler = nullptr; | 			m_speexResampler = null; | ||||||
| 		} | 		} | ||||||
| 	#endif | 	#endif | ||||||
| } | } | ||||||
| @@ -65,9 +64,9 @@ void audio::drain::Resampler::configurationChange() { | |||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	#ifdef HAVE_SPEEX_DSP_RESAMPLE | 	#ifdef HAVE_SPEEX_DSP_RESAMPLE | ||||||
| 		if (m_speexResampler != nullptr) { | 		if (m_speexResampler != null) { | ||||||
| 			speex_resampler_destroy(m_speexResampler); | 			speex_resampler_destroy(m_speexResampler); | ||||||
| 			m_speexResampler = nullptr; | 			m_speexResampler = null; | ||||||
| 		} | 		} | ||||||
| 		int err = 0; | 		int err = 0; | ||||||
| 		DRAIN_WARNING("Create resampler for : " << m_input << " to " << m_output); | 		DRAIN_WARNING("Create resampler for : " << m_input << " to " << m_output); | ||||||
| @@ -96,7 +95,7 @@ bool audio::drain::Resampler::process(audio::Time& _time, | |||||||
| 		_outputNbChunk = _inputNbChunk; | 		_outputNbChunk = _inputNbChunk; | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| 	if (_input == nullptr) { | 	if (_input == null) { | ||||||
| 		_output = &(m_outputData[0]); | 		_output = &(m_outputData[0]); | ||||||
| 		_outputNbChunk = 0; | 		_outputNbChunk = 0; | ||||||
| 		DRAIN_ERROR("null pointer input ... "); | 		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); | 		m_outputData.resize(_outputNbChunk*m_output.getMap().size()*m_formatSize*16); | ||||||
| 		_output = &(m_outputData[0]); | 		_output = &(m_outputData[0]); | ||||||
| 		if (m_speexResampler == nullptr) { | 		if (m_speexResampler == null) { | ||||||
| 			DRAIN_ERROR("                               No speex resampler"); | 			DRAIN_ERROR("                               No speex resampler"); | ||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
| @@ -146,12 +145,12 @@ bool audio::drain::Resampler::process(audio::Time& _time, | |||||||
| 		_outputNbChunk = nbChunkOutput; | 		_outputNbChunk = nbChunkOutput; | ||||||
| 		DRAIN_VERBOSE("                               process chunk=" << nbChunkInput << " out=" << nbChunkOutput); | 		DRAIN_VERBOSE("                               process chunk=" << nbChunkInput << " out=" << nbChunkOutput); | ||||||
| 		audio::Duration outTime(0, (int64_t(_outputNbChunk)*1000000000LL) / int64_t(m_output.getFrequency())); | 		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 : | 		// correct time : | ||||||
| 		m_residualTimeInResampler -= outTime; | 		m_residualTimeInResampler -= outTime; | ||||||
| 		/* | 		/* | ||||||
| 		if (m_residualTimeInResampler.count() < 0) { | 		if (m_residualTimeInResampler.get() < 0) { | ||||||
| 			DRAIN_TODO("manage this case ... residual time in resampler : " << m_residualTimeInResampler.count() << "ns"); | 			DRAIN_TODO("manage this case ... residual time in resampler : " << m_residualTimeInResampler << "ns"); | ||||||
| 		} | 		} | ||||||
| 		*/ | 		*/ | ||||||
| 		return true; | 		return true; | ||||||
|   | |||||||
| @@ -1,15 +1,15 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <audio/drain/Algo.h> | #include <audio/drain/Algo.hpp> | ||||||
| #ifdef HAVE_SPEEX_DSP_RESAMPLE | #ifdef HAVE_SPEEX_DSP_RESAMPLE | ||||||
| 	#include <speex/speex_resampler.h> | 	#include <speex/speex_resampler.h> | ||||||
| #endif | #endif | ||||||
| #include <ememory/memory.h> | #include <ememory/memory.hpp> | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain { | 	namespace drain { | ||||||
| @@ -1,29 +1,30 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <audio/drain/Volume.h> | #include <audio/drain/Volume.hpp> | ||||||
| #include <iostream> | extern "C" { | ||||||
| #include <math.h> | 	#include <math.h> | ||||||
| #include <audio/drain/debug.h> | } | ||||||
|  | #include <audio/drain/debug.hpp> | ||||||
|  |  | ||||||
| audio::drain::Volume::Volume() : | audio::drain::Volume::Volume() : | ||||||
|   m_volumeAppli(1.0f), |   m_volumeAppli(1.0f), | ||||||
|   m_functionConvert(nullptr) { |   m_functionConvert(null) { | ||||||
| 	 | 	 | ||||||
| } | } | ||||||
|  |  | ||||||
| void audio::drain::Volume::init() { | void audio::drain::Volume::init() { | ||||||
| 	audio::drain::Algo::init(); | 	audio::drain::Algo::init(); | ||||||
| 	m_type = "Volume"; | 	m_type = "Volume"; | ||||||
| 	m_supportedFormat.push_back(audio::format_int16); | 	m_supportedFormat.pushBack(audio::format_int16); | ||||||
| 	m_supportedFormat.push_back(audio::format_int16_on_int32); | 	m_supportedFormat.pushBack(audio::format_int16_on_int32); | ||||||
| } | } | ||||||
|  |  | ||||||
| ememory::SharedPtr<audio::drain::Volume> audio::drain::Volume::create() { | 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(); | 	tmp->init(); | ||||||
| 	return tmp; | 	return tmp; | ||||||
| } | } | ||||||
| @@ -37,7 +38,7 @@ static int32_t neareastsss(float _val) { | |||||||
| 	while (_val > float(1<<out)) { | 	while (_val > float(1<<out)) { | ||||||
| 		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); | 		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) { | 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); | 	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()); | 					DRAIN_DEBUG("Use converter : 'convert__int16__to__int32' for " << m_input.getFormat() << " to " << m_output.getFormat()); | ||||||
| 					break; | 					break; | ||||||
| 				case audio::format_float: | 				case audio::format_float: | ||||||
| 					DRAIN_ERROR("Impossible case 1"); | 					m_functionConvert = &convert__int16__to__float; | ||||||
| 					break; | 					break; | ||||||
| 			} | 			} | ||||||
| 			break; | 			break; | ||||||
| @@ -154,7 +162,7 @@ void audio::drain::Volume::volumeChange() { | |||||||
| 	float volumedB = 0.0f; | 	float volumedB = 0.0f; | ||||||
| 	bool mute = false; | 	bool mute = false; | ||||||
| 	for (size_t iii=0; iii<m_volumeList.size(); ++iii) { | 	for (size_t iii=0; iii<m_volumeList.size(); ++iii) { | ||||||
| 		if (m_volumeList[iii] == nullptr) { | 		if (m_volumeList[iii] == null) { | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
| 		if (m_volumeList[iii]->getMute() == true) { | 		if (m_volumeList[iii]->getMute() == true) { | ||||||
| @@ -173,7 +181,7 @@ void audio::drain::Volume::volumeChange() { | |||||||
| 	#if (defined(__STDCPP_LLVM__) || __cplusplus < 201103L) | 	#if (defined(__STDCPP_LLVM__) || __cplusplus < 201103L) | ||||||
| 		m_volumeAppli = pow(10.0f, volumedB/20.0f); | 		m_volumeAppli = pow(10.0f, volumedB/20.0f); | ||||||
| 	#else | 	#else | ||||||
| 		m_volumeAppli = std::pow(10.0f, volumedB/20.0f); | 		m_volumeAppli = etk::pow(10.0f, volumedB/20.0f); | ||||||
| 	#endif | 	#endif | ||||||
| 	switch (m_input.getFormat()) { | 	switch (m_input.getFormat()) { | ||||||
| 		default: | 		default: | ||||||
| @@ -205,7 +213,14 @@ void audio::drain::Volume::volumeChange() { | |||||||
| 					m_volumeDecalage = 0; | 					m_volumeDecalage = 0; | ||||||
| 					break; | 					break; | ||||||
| 				case audio::format_float: | 				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; | ||||||
| 			} | 			} | ||||||
| 			break; | 			break; | ||||||
| @@ -280,32 +295,32 @@ void audio::drain::Volume::volumeChange() { | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| std::vector<audio::format> audio::drain::Volume::getFormatSupportedInput() { | etk::Vector<audio::format> audio::drain::Volume::getFormatSupportedInput() { | ||||||
| 	std::vector<audio::format> tmp; | 	etk::Vector<audio::format> tmp; | ||||||
| 	if (m_output.getFormat() == audio::format_float) { | 	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 | 	if (    m_output.getFormat() == audio::format_int16 | ||||||
| 	     || m_output.getFormat() == audio::format_int16_on_int32 | 	     || m_output.getFormat() == audio::format_int16_on_int32 | ||||||
| 	     || m_output.getFormat() == audio::format_int32) { | 	     || m_output.getFormat() == audio::format_int32) { | ||||||
| 		tmp.push_back(audio::format_int16); | 		tmp.pushBack(audio::format_int16); | ||||||
| 		tmp.push_back(audio::format_int16_on_int32); | 		tmp.pushBack(audio::format_int16_on_int32); | ||||||
| 		tmp.push_back(audio::format_int32); | 		tmp.pushBack(audio::format_int32); | ||||||
| 	} | 	} | ||||||
| 	return tmp; | 	return tmp; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| std::vector<audio::format> audio::drain::Volume::getFormatSupportedOutput() { | etk::Vector<audio::format> audio::drain::Volume::getFormatSupportedOutput() { | ||||||
| 		std::vector<audio::format> tmp; | 	etk::Vector<audio::format> tmp; | ||||||
| 	if (m_input.getFormat() == audio::format_float) { | 	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 | 	if (    m_input.getFormat() == audio::format_int16 | ||||||
| 	     || m_input.getFormat() == audio::format_int16_on_int32 | 	     || m_input.getFormat() == audio::format_int16_on_int32 | ||||||
| 	     || m_input.getFormat() == audio::format_int32) { | 	     || m_input.getFormat() == audio::format_int32) { | ||||||
| 		tmp.push_back(audio::format_int16); | 		tmp.pushBack(audio::format_int16); | ||||||
| 		tmp.push_back(audio::format_int16_on_int32); | 		tmp.pushBack(audio::format_int16_on_int32); | ||||||
| 		tmp.push_back(audio::format_int32); | 		tmp.pushBack(audio::format_int32); | ||||||
| 	} | 	} | ||||||
| 	return tmp; | 	return tmp; | ||||||
| }; | }; | ||||||
| @@ -323,7 +338,7 @@ bool audio::drain::Volume::process(audio::Time& _time, | |||||||
| 		_outputNbChunk = _inputNbChunk; | 		_outputNbChunk = _inputNbChunk; | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| 	if (_input == nullptr) { | 	if (_input == null) { | ||||||
| 		_output = &(m_outputData[0]); | 		_output = &(m_outputData[0]); | ||||||
| 		_outputNbChunk = 0; | 		_outputNbChunk = 0; | ||||||
| 		DRAIN_ERROR("null pointer input ... "); | 		DRAIN_ERROR("null pointer input ... "); | ||||||
| @@ -332,7 +347,7 @@ bool audio::drain::Volume::process(audio::Time& _time, | |||||||
| 	_outputNbChunk = _inputNbChunk; | 	_outputNbChunk = _inputNbChunk; | ||||||
| 	m_outputData.resize(_outputNbChunk*m_input.getMap().size()*m_formatSize); | 	m_outputData.resize(_outputNbChunk*m_input.getMap().size()*m_formatSize); | ||||||
| 	_output = &(m_outputData[0]); | 	_output = &(m_outputData[0]); | ||||||
| 	if (m_functionConvert == nullptr) { | 	if (m_functionConvert == null) { | ||||||
| 		DRAIN_ERROR("null function ptr"); | 		DRAIN_ERROR("null function ptr"); | ||||||
| 		return false; | 		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) { | void audio::drain::Volume::addVolumeStage(const ememory::SharedPtr<audio::drain::VolumeElement>& _volume) { | ||||||
| 	if (_volume == nullptr) { | 	if (_volume == null) { | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	for (size_t iii=0; iii<m_volumeList.size(); ++iii) { | 	for (size_t iii=0; iii<m_volumeList.size(); ++iii) { | ||||||
| 		if (m_volumeList[iii] == nullptr) { | 		if (m_volumeList[iii] == null) { | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
| 		if (m_volumeList[iii] == _volume) { | 		if (m_volumeList[iii] == _volume) { | ||||||
| @@ -357,18 +372,18 @@ void audio::drain::Volume::addVolumeStage(const ememory::SharedPtr<audio::drain: | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	m_volumeList.push_back(_volume); | 	m_volumeList.pushBack(_volume); | ||||||
| 	volumeChange(); | 	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") { | 	if (_parameter == "FLOW") { | ||||||
| 		// set Volume ... | 		// set Volume ... | ||||||
| 		for (size_t iii=0; iii<m_volumeList.size(); ++iii) { | 		for (auto &it : m_volumeList) { | ||||||
| 			if (m_volumeList[iii] == nullptr) { | 			if (it == null) { | ||||||
| 				continue; | 				continue; | ||||||
| 			} | 			} | ||||||
| 			if (m_volumeList[iii]->getName() == "FLOW") { | 			if (it->getName() == "FLOW") { | ||||||
| 				float value = 0; | 				float value = 0; | ||||||
| 				if (sscanf(_value.c_str(), "%fdB", &value) != 1) { | 				if (sscanf(_value.c_str(), "%fdB", &value) != 1) { | ||||||
| 					return false; | 					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]"); | 					DRAIN_ERROR("Can not set volume ... : '" << _parameter << "' out of range : [-300..300]"); | ||||||
| 					return false; | 					return false; | ||||||
| 				} | 				} | ||||||
| 				m_volumeList[iii]->setVolume(value); | 				it->setVolume(value); | ||||||
| 				DRAIN_DEBUG("Set volume : FLOW = " << value << " dB (from:" << _value << ")"); | 				DRAIN_DEBUG("Set volume : FLOW = " << value << " dB (from:" << _value << ")"); | ||||||
| 				volumeChange(); | 				volumeChange(); | ||||||
| 				return true; | 				return true; | ||||||
| @@ -389,15 +404,15 @@ bool audio::drain::Volume::setParameter(const std::string& _parameter, const std | |||||||
| 	return false; | 	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") { | 	if (_parameter == "FLOW") { | ||||||
| 		// set Volume ... | 		// set Volume ... | ||||||
| 		for (size_t iii=0; iii<m_volumeList.size(); ++iii) { | 		for (auto &it : m_volumeList) { | ||||||
| 			if (m_volumeList[iii] == nullptr) { | 			if (it == null) { | ||||||
| 				continue; | 				continue; | ||||||
| 			} | 			} | ||||||
| 			if (m_volumeList[iii]->getName() == "FLOW") { | 			if (it->getName() == "FLOW") { | ||||||
| 				return etk::to_string(m_volumeList[iii]->getVolume()) + "dB"; | 				return etk::toString(it->getVolume()) + "dB"; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -405,14 +420,14 @@ std::string audio::drain::Volume::getParameter(const std::string& _parameter) co | |||||||
| 	return "[ERROR]"; | 	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") { | 	if (_parameter == "FLOW") { | ||||||
| 		// set Volume ... | 		// set Volume ... | ||||||
| 		for (size_t iii=0; iii<m_volumeList.size(); ++iii) { | 		for (auto &it : m_volumeList) { | ||||||
| 			if (m_volumeList[iii] == nullptr) { | 			if (it == null) { | ||||||
| 				continue; | 				continue; | ||||||
| 			} | 			} | ||||||
| 			if (m_volumeList[iii]->getName() == "FLOW") { | 			if (it->getName() == "FLOW") { | ||||||
| 				return "[-300..300]dB"; | 				return "[-300..300]dB"; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @@ -421,3 +436,16 @@ std::string audio::drain::Volume::getParameterProperty(const std::string& _param | |||||||
| 	return "[ERROR]"; | 	return "[ERROR]"; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | etk::String audio::drain::Volume::getDotDesc() { | ||||||
|  | 	etk::String out = audio::drain::Algo::getDotDesc(); | ||||||
|  | 	for (auto &it : m_volumeList) { | ||||||
|  | 		if (it == null) { | ||||||
|  | 			continue; | ||||||
|  | 		} | ||||||
|  | 		out += "\\n" + it->getName() + "=" + etk::toString(it->getVolume()) + "dB"; | ||||||
|  | 		if (it->getMute() == true) { | ||||||
|  | 			out += " MUTE"; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	return out; | ||||||
|  | } | ||||||
|   | |||||||
| @@ -1,31 +1,31 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <audio/drain/Algo.h> | #include <audio/drain/Algo.hpp> | ||||||
| #ifdef HAVE_SPEEX_DSP_RESAMPLE | #ifdef HAVE_SPEEX_DSP_RESAMPLE | ||||||
| 	#include <speex/speex_resampler.h> | 	#include <speex/speex_resampler.h> | ||||||
| #endif | #endif | ||||||
| #include <ememory/memory.h> | #include <ememory/memory.hpp> | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain { | 	namespace drain { | ||||||
| 		// data structure.
 | 		// data structure.
 | ||||||
| 		class VolumeElement { | 		class VolumeElement { | ||||||
| 			public: | 			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_name(_name), | ||||||
| 				  m_volumedB(_volumedB), | 				  m_volumedB(_volumedB), | ||||||
| 				  m_mute(false) { | 				  m_mute(false) { | ||||||
| 					 | 					 | ||||||
| 				} | 				} | ||||||
| 			private: | 			private: | ||||||
| 				std::string m_name; | 				etk::String m_name; | ||||||
| 			public: | 			public: | ||||||
| 				std::string getName() const { | 				etk::String getName() const { | ||||||
| 					return m_name; | 					return m_name; | ||||||
| 				} | 				} | ||||||
| 			private: | 			private: | ||||||
| @@ -54,7 +54,7 @@ namespace audio { | |||||||
| 		// TODO: Manage set volume
 | 		// TODO: Manage set volume
 | ||||||
| 		class Volume : public audio::drain::Algo { | 		class Volume : public audio::drain::Algo { | ||||||
| 			private: | 			private: | ||||||
| 				std::vector<ememory::SharedPtr<drain::VolumeElement> > m_volumeList; | 				etk::Vector<ememory::SharedPtr<drain::VolumeElement> > m_volumeList; | ||||||
| 				// for float input :
 | 				// for float input :
 | ||||||
| 				float m_volumeAppli; | 				float m_volumeAppli; | ||||||
| 				// for integer input :
 | 				// for integer input :
 | ||||||
| @@ -83,15 +83,17 @@ namespace audio { | |||||||
| 				                     void*& _output, | 				                     void*& _output, | ||||||
| 				                     size_t& _outputNbChunk); | 				                     size_t& _outputNbChunk); | ||||||
| 			public: | 			public: | ||||||
| 				virtual std::vector<audio::format> getFormatSupportedInput(); | 				virtual etk::Vector<audio::format> getFormatSupportedInput(); | ||||||
| 				virtual std::vector<audio::format> getFormatSupportedOutput(); | 				virtual etk::Vector<audio::format> getFormatSupportedOutput(); | ||||||
| 			public: | 			public: | ||||||
| 				virtual void addVolumeStage(const ememory::SharedPtr<drain::VolumeElement>& _volume); | 				virtual void addVolumeStage(const ememory::SharedPtr<drain::VolumeElement>& _volume); | ||||||
| 				virtual bool setParameter(const std::string& _parameter, const std::string& _value); | 				virtual bool setParameter(const etk::String& _parameter, const etk::String& _value); | ||||||
| 				virtual std::string getParameter(const std::string& _parameter) const; | 				virtual etk::String getParameter(const etk::String& _parameter) const; | ||||||
| 				virtual std::string getParameterProperty(const std::string& _parameter) const; | 				virtual etk::String getParameterProperty(const etk::String& _parameter) const; | ||||||
| 			public: | 			public: | ||||||
| 				void volumeChange(); | 				void volumeChange(); | ||||||
|  | 			public: | ||||||
|  | 				virtual etk::String getDotDesc(); | ||||||
| 		}; | 		}; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -1,9 +1,9 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include "debug.h" | #include "debug.hpp" | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,14 +1,14 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <string> | #include <etk/String.hpp> | ||||||
| #include <audio/format.h> | #include <audio/format.hpp> | ||||||
| #include <audio/drain/channel.h> | #include <audio/drain/channel.hpp> | ||||||
| #include <chrono> | #include <echrono/Steady.hpp> | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain { | 	namespace drain { | ||||||
| @@ -25,18 +25,18 @@ namespace audio { | |||||||
| 		 * @param[in] _name Name of the Algorithm. | 		 * @param[in] _name Name of the Algorithm. | ||||||
| 		 * @return Instanciate 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) | 		 * @brief Add a Factory Algorithm in the internal List (static for all instance) | ||||||
| 		 * @param[in] _name Name of the Algorithm. | 		 * @param[in] _name Name of the Algorithm. | ||||||
| 		 * @param[in] _functor Function of the factory | 		 * @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) | 		 * @brief Remove a Factory Algorithm in the internal List (static for all instance) | ||||||
| 		 * @param[in] _name Name of the Algorithm. | 		 * @param[in] _name Name of the Algorithm. | ||||||
| 		 */ | 		 */ | ||||||
| 		void RmAlgoFactory(const std::string& _name); | 		void RmAlgoFactory(const etk::String& _name); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @@ -1,10 +1,10 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <audio/drain/debug.h> | #include <audio/drain/debug.hpp> | ||||||
|  |  | ||||||
|  |  | ||||||
| int32_t audio::drain::getLogId() { | int32_t audio::drain::getLogId() { | ||||||
|   | |||||||
| @@ -1,13 +1,13 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @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__ | #ifndef __AUDIO_DRAIN_DEBUG_H__ | ||||||
| #define __AUDIO_DRAIN_DEBUG_H__ | #define __AUDIO_DRAIN_DEBUG_H__ | ||||||
| 
 | 
 | ||||||
| #include <elog/log.h> | #include <elog/log.hpp> | ||||||
| 
 | 
 | ||||||
| namespace audio { | namespace audio { | ||||||
| 	namespace drain { | 	namespace drain { | ||||||
| @@ -1,7 +1,7 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @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__ | #ifdef __AUDIO_DRAIN_DEBUG_H__ | ||||||
| @@ -1,89 +0,0 @@ | |||||||
| cmake_minimum_required(VERSION 2.8.3) |  | ||||||
| project(audio_drain) |  | ||||||
|  |  | ||||||
| set(CMAKE_VERBOSE_MAKEFILE ON) |  | ||||||
|  |  | ||||||
| ## Find catkin macros and libraries |  | ||||||
| ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) |  | ||||||
| ## is used, also find other catkin packages |  | ||||||
| find_package(catkin REQUIRED COMPONENTS |  | ||||||
|   etk |  | ||||||
|   audio |  | ||||||
|   ) |  | ||||||
|  |  | ||||||
| find_library(LIB_SPEEX_DSP libspeexdsp.a) |  | ||||||
| find_library(SPEEX_DSP speexdsp) |  | ||||||
|  |  | ||||||
| ################################### |  | ||||||
| ## catkin specific configuration ## |  | ||||||
| ################################### |  | ||||||
| ## The catkin_package macro generates cmake config files for your package |  | ||||||
| ## Declare things to be passed to dependent projects |  | ||||||
| ## INCLUDE_DIRS: uncomment this if you package contains header files |  | ||||||
| ## LIBRARIES: libraries you create in this project that dependent projects also need |  | ||||||
| ## CATKIN_DEPENDS: catkin_packages dependent projects also need |  | ||||||
| ## DEPENDS: system dependencies of this project that dependent projects also need |  | ||||||
| catkin_package( |  | ||||||
|   INCLUDE_DIRS ../ |  | ||||||
|   LIBRARIES ${PROJECT_NAME} |  | ||||||
|   CATKIN_DEPENDS etk audio |  | ||||||
|   DEPENDS system_lib |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| ########### |  | ||||||
| ## Build ## |  | ||||||
| ########### |  | ||||||
|  |  | ||||||
| ## Specify additional locations of header files |  | ||||||
| ## Your package locations should be listed before other locations |  | ||||||
| include_directories( |  | ||||||
|   .. |  | ||||||
|   ${speex_INCLUDE_DIRS} |  | ||||||
|   ${catkin_INCLUDE_DIRS} |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| ## Declare a cpp library |  | ||||||
| add_library(${PROJECT_NAME} |  | ||||||
|   ../audio/drain/debug.cpp |  | ||||||
|   ../audio/drain/airtalgo.cpp |  | ||||||
|   ../audio/drain/Algo.cpp |  | ||||||
|   ../audio/drain/ChannelReorder.cpp |  | ||||||
|   ../audio/drain/CircularBuffer.cpp |  | ||||||
|   ../audio/drain/EndPointCallback.cpp |  | ||||||
|   ../audio/drain/EndPoint.cpp |  | ||||||
|   ../audio/drain/EndPointRead.cpp |  | ||||||
|   ../audio/drain/EndPointWrite.cpp |  | ||||||
|   ../audio/drain/FormatUpdate.cpp |  | ||||||
|   ../audio/drain/Process.cpp |  | ||||||
|   ../audio/drain/Resampler.cpp |  | ||||||
|   ../audio/drain/Volume.cpp |  | ||||||
|   ../audio/drain/IOFormatInterface.cpp |  | ||||||
|   ../audio/drain/AutoLogInOut.cpp |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| #message("libspeex DSP file: ${LIB_SPEEX_DSP}") |  | ||||||
| #message("libspeex DSP file: ${SPEEX_DSP}") |  | ||||||
|  |  | ||||||
| add_definitions(-DHAVE_SPEEX_DSP_RESAMPLE) |  | ||||||
|  |  | ||||||
| ## Specify libraries to link a library or executable target against |  | ||||||
| target_link_libraries(${PROJECT_NAME} |  | ||||||
|   ${SPEEX_DSP} |  | ||||||
|   ${catkin_LIBRARIES} |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| ############# |  | ||||||
| ## Install ## |  | ||||||
| ############# |  | ||||||
|  |  | ||||||
| ## Mark executables and/or libraries for installation |  | ||||||
| install(TARGETS ${PROJECT_NAME} |  | ||||||
|   ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} |  | ||||||
|   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| ## Mark cpp header files for installation |  | ||||||
| install(DIRECTORY ../audio/drain/ |  | ||||||
|   DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} |  | ||||||
|   FILES_MATCHING PATTERN "*.h" |  | ||||||
| ) |  | ||||||
| @@ -1,13 +0,0 @@ | |||||||
| <?xml version="1.0"?> |  | ||||||
| <package> |  | ||||||
|   <name>audio_drain</name> |  | ||||||
|   <version>0.1.0</version> |  | ||||||
|   <description>Ewol audio basic flow algo (really simple)</description> |  | ||||||
|   <maintainer email="yui.heero@gmail.com">Edouard DUPIN</maintainer> |  | ||||||
|   <license>Apache-2.0</license> |  | ||||||
|   <build_depend>etk</build_depend> |  | ||||||
|   <build_depend>audio</build_depend> |  | ||||||
|   <buildtool_depend>catkin</buildtool_depend> |  | ||||||
|   <run_depend>etk</run_depend> |  | ||||||
|   <run_depend>audio</run_depend> |  | ||||||
| </package> |  | ||||||
							
								
								
									
										85
									
								
								doc/build.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								doc/build.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,85 @@ | |||||||
|  | Build lib & build sample                           {#audio_algo_build} | ||||||
|  | ======================== | ||||||
|  |  | ||||||
|  | @tableofcontents | ||||||
|  |  | ||||||
|  | Download:                                          {#audio_algo_build_download} | ||||||
|  | ========= | ||||||
|  |  | ||||||
|  | ege use some tools to manage source and build it: | ||||||
|  |  | ||||||
|  | need google repo:                                  {#audio_algo_build_download_repo} | ||||||
|  | ----------------- | ||||||
|  |  | ||||||
|  | see: http://source.android.com/source/downloading.html#installing-repo | ||||||
|  |  | ||||||
|  | On all platform: | ||||||
|  | ```{.sh} | ||||||
|  | 	mkdir ~/.bin | ||||||
|  | 	PATH=~/.bin:$PATH | ||||||
|  | 	curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo | ||||||
|  | 	chmod a+x ~/.bin/repo | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | On ubuntu | ||||||
|  | ```{.sh} | ||||||
|  | 	sudo apt-get install repo | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | On archlinux | ||||||
|  | ```{.sh} | ||||||
|  | 	sudo pacman -S repo | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | lutin (build-system):                              {#audio_algo_build_download_lutin} | ||||||
|  | --------------------- | ||||||
|  |  | ||||||
|  | ```{.sh} | ||||||
|  | 	pip install lutin --user | ||||||
|  | 	# optionnal dependency of lutin (manage image changing size for application release) | ||||||
|  | 	pip install pillow --user | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  |  | ||||||
|  | dependency:                                        {#audio_algo_build_download_dependency} | ||||||
|  | ----------- | ||||||
|  |  | ||||||
|  | ```{.sh} | ||||||
|  | 	mkdir -p WORKING_DIRECTORY/framework | ||||||
|  | 	cd WORKING_DIRECTORY/framework | ||||||
|  | 	repo init -u git://github.com/atria-soft/manifest.git | ||||||
|  | 	repo sync -j8 | ||||||
|  | 	cd ../.. | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | sources:                                           {#audio_algo_build_download_sources} | ||||||
|  | -------- | ||||||
|  |  | ||||||
|  | They are already download in the repo manifest in: | ||||||
|  |  | ||||||
|  | ```{.sh} | ||||||
|  | 	cd WORKING_DIRECTORY/framework/musicdsp/audio-drain | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Build:                                             {#audio_algo_build_build} | ||||||
|  | ====== | ||||||
|  |  | ||||||
|  | you must stay in your working directory... | ||||||
|  | ```{.sh} | ||||||
|  | 	cd WORKING_DIRECTORY | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | library:                                           {#audio_algo_build_build_library} | ||||||
|  | -------- | ||||||
|  |  | ||||||
|  | ```{.sh} | ||||||
|  | 	lutin -mdebug audio-drain | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Test sample:                                            {#audio_algo_build_build_sample} | ||||||
|  | ------------ | ||||||
|  |  | ||||||
|  | ```{.sh} | ||||||
|  | 	lutin -mdebug audio-drain-test?build?run | ||||||
|  | ``` | ||||||
|  |  | ||||||
							
								
								
									
										56
									
								
								doc/mainpage.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								doc/mainpage.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,56 @@ | |||||||
|  | AUDIO-ALGO library                                {#mainpage} | ||||||
|  | ============= | ||||||
|  |  | ||||||
|  | @tableofcontents | ||||||
|  |  | ||||||
|  | What is AUDIO-ALGO:                               {#audio_algo_mainpage_what} | ||||||
|  | ============== | ||||||
|  |  | ||||||
|  | AUDIO-ALGO, Is a single Pipeline processing to simply update format, framerate, channel maps ... | ||||||
|  |  | ||||||
|  | What it does:                               {#audio_algo_mainpage_what_it_does} | ||||||
|  | ------------- | ||||||
|  |  | ||||||
|  |   - Change format | ||||||
|  |   - Change framerate | ||||||
|  |   - change number of channel | ||||||
|  |  | ||||||
|  | AUDIO-ALGO is dependent of the STL (compatible with MacOs stl (CXX)) | ||||||
|  |  | ||||||
|  |  | ||||||
|  | What languages are supported?                    {#audio_algo_mainpage_language} | ||||||
|  | ============================= | ||||||
|  |  | ||||||
|  | AUDIO-ALGO is written in C++. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | Are there any licensing restrictions?            {#audio_algo_mainpage_license_restriction} | ||||||
|  | ===================================== | ||||||
|  |  | ||||||
|  | AUDIO-ALGO is **FREE software** and _all sub-library are FREE and staticly linkable !!!_ | ||||||
|  |  | ||||||
|  |  | ||||||
|  | License (MPL v2.0)                               {#audio_algo_mainpage_license} | ||||||
|  | ================== | ||||||
|  |  | ||||||
|  | Copyright AUDIO-ALGO Edouard DUPIN | ||||||
|  |  | ||||||
|  | Licensed under the Mozilla Public License, Version 2.0 (the "License"); | ||||||
|  | you may not use this file except in compliance with the License. | ||||||
|  | You may obtain a copy of the License at | ||||||
|  |  | ||||||
|  | <https://www.mozilla.org/MPL/2.0> | ||||||
|  |  | ||||||
|  | Unless required by applicable law or agreed to in writing, software | ||||||
|  | distributed under the License is distributed on an "AS IS" BASIS, | ||||||
|  | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||
|  | See the License for the specific language governing permissions and | ||||||
|  | limitations under the License. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | Other pages                              {#audio_algo_mainpage_sub_page} | ||||||
|  | =========== | ||||||
|  |  | ||||||
|  |   - @ref audio_algo_build | ||||||
|  |   - [**ewol coding style**](http://atria-soft.github.io/ewol/ewol_coding_style.html) | ||||||
|  |  | ||||||
							
								
								
									
										33
									
								
								doxy_audio-drain.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								doxy_audio-drain.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | |||||||
|  | #!/usr/bin/python | ||||||
|  | import os | ||||||
|  | import doxy.module as module | ||||||
|  | import doxy.debug as debug | ||||||
|  | import doxy.tools as tools | ||||||
|  |  | ||||||
|  | def create(target, module_name): | ||||||
|  | 	my_module = module.Module(__file__, module_name) | ||||||
|  | 	my_module.set_version("version.txt") | ||||||
|  | 	my_module.set_title("Basic audio algo interface single pipe to process data") | ||||||
|  | 	my_module.set_website("http://musicdsp.github.io/" + module_name) | ||||||
|  | 	my_module.set_website_sources("http://github.com/musicdsp/" + module_name) | ||||||
|  | 	my_module.add_path([ | ||||||
|  | 	    "audio", | ||||||
|  | 	    "doc" | ||||||
|  | 	    ]) | ||||||
|  | 	my_module.add_depend([ | ||||||
|  | 	    'etk', | ||||||
|  | 	    'audio', | ||||||
|  | 	    'ejson' | ||||||
|  | 	    ]) | ||||||
|  | 	my_module.add_exclude_symbols([ | ||||||
|  | 	    '*operator<<*', | ||||||
|  | 	    ]) | ||||||
|  | 	my_module.add_exclude_file([ | ||||||
|  | 	    'debug.h', | ||||||
|  | 	    ]) | ||||||
|  | 	my_module.add_file_patterns([ | ||||||
|  | 	    '*.h', | ||||||
|  | 	    '*.md', | ||||||
|  | 	    ]) | ||||||
|  | 	 | ||||||
|  | 	return my_module | ||||||
| @@ -1,7 +1,6 @@ | |||||||
| #!/usr/bin/python | #!/usr/bin/python | ||||||
| import lutin.module as module | import realog.debug as debug | ||||||
| import lutin.tools as tools | import lutin.tools as tools | ||||||
| import lutin.debug as debug |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def get_type(): | def get_type(): | ||||||
| @@ -14,7 +13,7 @@ def get_desc(): | |||||||
| 	return "single audio flow test" | 	return "single audio flow test" | ||||||
|  |  | ||||||
| def get_licence(): | def get_licence(): | ||||||
| 	return "APACHE-2" | 	return "MPL-2" | ||||||
|  |  | ||||||
| def get_compagny_type(): | def get_compagny_type(): | ||||||
| 	return "com" | 	return "com" | ||||||
| @@ -25,8 +24,7 @@ def get_compagny_name(): | |||||||
| def get_maintainer(): | def get_maintainer(): | ||||||
| 	return "authors.txt" | 	return "authors.txt" | ||||||
|  |  | ||||||
| def create(target, module_name): | def configure(target, my_module): | ||||||
| 	my_module = module.Module(__file__, module_name, get_type()) |  | ||||||
| 	my_module.add_src_file([ | 	my_module.add_src_file([ | ||||||
| 		'test/main.cpp', | 		'test/main.cpp', | ||||||
| 		'test/updateFlow.cpp', | 		'test/updateFlow.cpp', | ||||||
| @@ -35,8 +33,13 @@ def create(target, module_name): | |||||||
| 		'test/channelOrder.cpp', | 		'test/channelOrder.cpp', | ||||||
| 		'test/equalizer.cpp' | 		'test/equalizer.cpp' | ||||||
| 		]) | 		]) | ||||||
| 	my_module.add_depend(['audio-drain', 'gtest', 'etk', 'test-debug']) | 	my_module.add_depend([ | ||||||
| 	return my_module | 	    'audio-drain', | ||||||
|  | 	    'etest', | ||||||
|  | 	    'etk', | ||||||
|  | 	    'test-debug' | ||||||
|  | 	    ]) | ||||||
|  | 	return True | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,7 +1,6 @@ | |||||||
| #!/usr/bin/python | #!/usr/bin/python | ||||||
| import lutin.module as module |  | ||||||
| import lutin.tools as tools | import lutin.tools as tools | ||||||
| import lutin.debug as debug | import realog.debug as debug | ||||||
|  |  | ||||||
|  |  | ||||||
| def get_type(): | def get_type(): | ||||||
| @@ -11,7 +10,7 @@ def get_desc(): | |||||||
| 	return "Basic audio algo interface single pipe to provess data" | 	return "Basic audio algo interface single pipe to provess data" | ||||||
|  |  | ||||||
| def get_licence(): | def get_licence(): | ||||||
| 	return "APACHE-2" | 	return "MPL-2" | ||||||
|  |  | ||||||
| def get_compagny_type(): | def get_compagny_type(): | ||||||
| 	return "com" | 	return "com" | ||||||
| @@ -25,53 +24,58 @@ def get_maintainer(): | |||||||
| def get_version(): | def get_version(): | ||||||
| 	return "version.txt" | 	return "version.txt" | ||||||
|  |  | ||||||
| def create(target, module_name): | def configure(target, my_module): | ||||||
| 	my_module = module.Module(__file__, module_name, get_type()) |  | ||||||
| 	 | 	 | ||||||
| 	my_module.add_src_file([ | 	my_module.add_src_file([ | ||||||
| 		'audio/drain/debug.cpp', | 	    'audio/drain/debug.cpp', | ||||||
| 		'audio/drain/airtalgo.cpp', | 	    'audio/drain/airtalgo.cpp', | ||||||
| 		'audio/drain/Algo.cpp', | 	    'audio/drain/Algo.cpp', | ||||||
| 		'audio/drain/ChannelReorder.cpp', | 	    'audio/drain/ChannelReorder.cpp', | ||||||
| 		'audio/drain/CircularBuffer.cpp', | 	    'audio/drain/CircularBuffer.cpp', | ||||||
| 		'audio/drain/EndPointCallback.cpp', | 	    'audio/drain/EndPointCallback.cpp', | ||||||
| 		'audio/drain/EndPoint.cpp', | 	    'audio/drain/EndPoint.cpp', | ||||||
| 		'audio/drain/EndPointRead.cpp', | 	    'audio/drain/EndPointRead.cpp', | ||||||
| 		'audio/drain/EndPointWrite.cpp', | 	    'audio/drain/EndPointWrite.cpp', | ||||||
| 		'audio/drain/FormatUpdate.cpp', | 	    'audio/drain/FormatUpdate.cpp', | ||||||
| 		'audio/drain/Process.cpp', | 	    'audio/drain/Process.cpp', | ||||||
| 		'audio/drain/Resampler.cpp', | 	    'audio/drain/Resampler.cpp', | ||||||
| 		'audio/drain/Volume.cpp', | 	    'audio/drain/Volume.cpp', | ||||||
| 		'audio/drain/IOFormatInterface.cpp', | 	    'audio/drain/IOFormatInterface.cpp', | ||||||
| 		'audio/drain/AutoLogInOut.cpp', | 	    'audio/drain/AutoLogInOut.cpp', | ||||||
| 		'audio/drain/Equalizer.cpp' | 	    'audio/drain/Equalizer.cpp' | ||||||
| 		]) | 	    ]) | ||||||
| 	 | 	 | ||||||
| 	my_module.add_header_file([ | 	my_module.add_header_file([ | ||||||
| 		'audio/drain/debug.h', | 	    'audio/drain/debug.hpp', | ||||||
| 		'audio/drain/debugRemove.h', | 	    'audio/drain/debugRemove.hpp', | ||||||
| 		'audio/drain/airtalgo.h', | 	    'audio/drain/airtalgo.hpp', | ||||||
| 		'audio/drain/Algo.h', | 	    'audio/drain/Algo.hpp', | ||||||
| 		'audio/drain/ChannelReorder.h', | 	    'audio/drain/ChannelReorder.hpp', | ||||||
| 		'audio/drain/CircularBuffer.h', | 	    'audio/drain/CircularBuffer.hpp', | ||||||
| 		'audio/drain/EndPointCallback.h', | 	    'audio/drain/EndPointCallback.hpp', | ||||||
| 		'audio/drain/EndPoint.h', | 	    'audio/drain/EndPoint.hpp', | ||||||
| 		'audio/drain/EndPointRead.h', | 	    'audio/drain/EndPointRead.hpp', | ||||||
| 		'audio/drain/EndPointWrite.h', | 	    'audio/drain/EndPointWrite.hpp', | ||||||
| 		'audio/drain/FormatUpdate.h', | 	    'audio/drain/FormatUpdate.hpp', | ||||||
| 		'audio/drain/Process.h', | 	    'audio/drain/Process.hpp', | ||||||
| 		'audio/drain/Resampler.h', | 	    'audio/drain/Resampler.hpp', | ||||||
| 		'audio/drain/Volume.h', | 	    'audio/drain/Volume.hpp', | ||||||
| 		'audio/drain/IOFormatInterface.h', | 	    'audio/drain/IOFormatInterface.hpp', | ||||||
| 		'audio/drain/AutoLogInOut.h', | 	    'audio/drain/AutoLogInOut.hpp', | ||||||
| 		'audio/drain/Equalizer.h' | 	    'audio/drain/Equalizer.hpp' | ||||||
| 		]) | 	    ]) | ||||||
| 	 | 	 | ||||||
| 	# TODO: my_module.add_optional_module_depend('speexdsp', "HAVE_SPEEX_DSP_RESAMPLE") | 	# TODO: my_module.add_optional_module_depend('speexdsp', "HAVE_SPEEX_DSP_RESAMPLE") | ||||||
| 	my_module.add_flag('c++', "-DHAVE_SPEEX_DSP_RESAMPLE") | 	my_module.add_flag('c++', "-DHAVE_SPEEX_DSP_RESAMPLE") | ||||||
| 	my_module.add_depend(['etk', 'audio', 'ejson', 'speex-dsp', 'audio-algo-drain']) | 	my_module.add_depend([ | ||||||
| 	my_module.add_path(tools.get_current_path(__file__)) | 	    'etk', | ||||||
| 	return my_module | 	    'audio', | ||||||
|  | 	    'ejson', | ||||||
|  | 	    'speex-dsp', | ||||||
|  | 	    'audio-algo-drain' | ||||||
|  | 	    ]) | ||||||
|  | 	my_module.add_path(".") | ||||||
|  | 	return True | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,10 +1,10 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2015, Edouard DUPIN, all right reserved |  * @copyright 2015, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <test-debug/debug.h> | #include <test-debug/debug.hpp> | ||||||
| #include <gtest/gtest.h> | #include <etest/etest.hpp> | ||||||
| #include <audio/drain/Process.h> | #include <audio/drain/Process.hpp> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,12 +1,12 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2015, Edouard DUPIN, all right reserved |  * @copyright 2015, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <test-debug/debug.h> | #include <test-debug/debug.hpp> | ||||||
| #include <gtest/gtest.h> | #include <etest/etest.hpp> | ||||||
| #include <audio/drain/Process.h> | #include <audio/drain/Process.hpp> | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,10 +1,10 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2015, Edouard DUPIN, all right reserved |  * @copyright 2015, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <test-debug/debug.h> | #include <test-debug/debug.hpp> | ||||||
| #include <gtest/gtest.h> | #include <etest/etest.hpp> | ||||||
| #include <audio/drain/Process.h> | #include <audio/drain/Process.hpp> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,20 +1,17 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2015, Edouard DUPIN, all right reserved |  * @copyright 2015, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <etk/etk.h> | #include <etk/etk.hpp> | ||||||
| #include <test-debug/debug.h> | #include <test-debug/debug.hpp> | ||||||
| #include <gtest/gtest.h> | #include <etest/etest.hpp> | ||||||
|  |  | ||||||
| int main(int _argc, const char** _argv) { | int main(int _argc, const char** _argv) { | ||||||
| 	// init Google test : | 	etest::init(_argc, _argv); | ||||||
| 	::testing::InitGoogleTest(&_argc, const_cast<char **>(_argv)); |  | ||||||
| 	// the only one init for etk: |  | ||||||
| 	etk::init(_argc, _argv); |  | ||||||
| 	for (int32_t iii=0; iii<_argc ; ++iii) { | 	for (int32_t iii=0; iii<_argc ; ++iii) { | ||||||
| 		std::string data = _argv[iii]; | 		etk::String data = _argv[iii]; | ||||||
| 		if (    data == "-h" | 		if (    data == "-h" | ||||||
| 		     || data == "--help") { | 		     || data == "--help") { | ||||||
| 			TEST_INFO("Help : "); | 			TEST_INFO("Help : "); | ||||||
|   | |||||||
| @@ -1,10 +1,10 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2015, Edouard DUPIN, all right reserved |  * @copyright 2015, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <test-debug/debug.h> | #include <test-debug/debug.hpp> | ||||||
| #include <gtest/gtest.h> | #include <etest/etest.hpp> | ||||||
| #include <audio/drain/Process.h> | #include <audio/drain/Process.hpp> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,10 +1,10 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2015, Edouard DUPIN, all right reserved |  * @copyright 2015, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <test-debug/debug.h> | #include <test-debug/debug.hpp> | ||||||
| #include <gtest/gtest.h> | #include <etest/etest.hpp> | ||||||
| #include <audio/drain/Process.h> | #include <audio/drain/Process.hpp> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,33 +1,33 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <etk/types.h> | #include <etk/types.hpp> | ||||||
| #include <ewol/ewol.h> | #include <ewol/ewol.hpp> | ||||||
| #include <appl/debug.h> | #include <appl/debug.hpp> | ||||||
| #include <appl/Windows.h> | #include <appl/Windows.hpp> | ||||||
| #include <ewol/widget/Label.h> | #include <ewol/widget/Label.hpp> | ||||||
| #include <ewol/widget/Entry.h> | #include <ewol/widget/Entry.hpp> | ||||||
| #include <ewol/widget/Button.h> | #include <ewol/widget/Button.hpp> | ||||||
| #include <ewol/widget/Slider.h> | #include <ewol/widget/Slider.hpp> | ||||||
| #include <audio/drain/Equalizer.h> | #include <audio/drain/Equalizer.hpp> | ||||||
|  |  | ||||||
| define APPL_SAVE_FILE_MACRO(type,fileName,dataPointer,nbElement) \ | define APPL_SAVE_FILE_MACRO(type,fileName,dataPointer,nbElement) \ | ||||||
| 	do { \ | 	do { \ | ||||||
| 		static FILE *pointerOnFile = nullptr; \ | 		static FILE *pointerOnFile = null; \ | ||||||
| 		static bool errorOpen = false; \ | 		static bool errorOpen = false; \ | ||||||
| 		if (pointerOnFile == nullptr) { \ | 		if (pointerOnFile == null) { \ | ||||||
| 			APPL_WARNING("open file '" << fileName << "' type=" << #type); \ | 			APPL_WARNING("open file '" << fileName << "' type=" << #type); \ | ||||||
| 			pointerOnFile = fopen(fileName,"w"); \ | 			pointerOnFile = fopen(fileName,"w"); \ | ||||||
| 			if (    errorOpen == false \ | 			if (    errorOpen == false \ | ||||||
| 			     && pointerOnFile == nullptr) { \ | 			     && pointerOnFile == null) { \ | ||||||
| 				APPL_ERROR("ERROR OPEN file ... '" << fileName << "' type=" << #type); \ | 				APPL_ERROR("ERROR OPEN file ... '" << fileName << "' type=" << #type); \ | ||||||
| 				errorOpen=true; \ | 				errorOpen=true; \ | ||||||
| 			} \ | 			} \ | ||||||
| 		} \ | 		} \ | ||||||
| 		if (pointerOnFile != nullptr) { \ | 		if (pointerOnFile != null) { \ | ||||||
| 			fwrite((dataPointer), sizeof(type), (nbElement), pointerOnFile); \ | 			fwrite((dataPointer), sizeof(type), (nbElement), pointerOnFile); \ | ||||||
| 			/* fflush(pointerOnFile);*/ \ | 			/* fflush(pointerOnFile);*/ \ | ||||||
| 		} \ | 		} \ | ||||||
| @@ -40,34 +40,34 @@ appl::Windows::Windows() : | |||||||
|   m_gain(0.0), |   m_gain(0.0), | ||||||
|   m_quality(0.707) { |   m_quality(0.707) { | ||||||
| 	addObjectType("appl::Windows"); | 	addObjectType("appl::Windows"); | ||||||
| 	m_listSampleRate.push_back(192000); | 	m_listSampleRate.pushBack(192000); | ||||||
| 	m_listSampleRate.push_back(176400); | 	m_listSampleRate.pushBack(176400); | ||||||
| 	m_listSampleRate.push_back(96000); | 	m_listSampleRate.pushBack(96000); | ||||||
| 	m_listSampleRate.push_back(88200); | 	m_listSampleRate.pushBack(88200); | ||||||
| 	m_listSampleRate.push_back(48000); | 	m_listSampleRate.pushBack(48000); | ||||||
| 	m_listSampleRate.push_back(44100); | 	m_listSampleRate.pushBack(44100); | ||||||
| 	m_listSampleRate.push_back(32000); | 	m_listSampleRate.pushBack(32000); | ||||||
| 	m_listSampleRate.push_back(22050); | 	m_listSampleRate.pushBack(22050); | ||||||
| 	m_listSampleRate.push_back(16000); | 	m_listSampleRate.pushBack(16000); | ||||||
| 	m_listSampleRate.push_back(11025); | 	m_listSampleRate.pushBack(11025); | ||||||
| 	m_listSampleRate.push_back(8000); | 	m_listSampleRate.pushBack(8000); | ||||||
| 	m_listSampleRate.push_back(4000); | 	m_listSampleRate.pushBack(4000); | ||||||
| 	m_listType.push_back(audio::algo::drain::biQuadType_none); | 	m_listType.pushBack(audio::algo::drain::biQuadType_none); | ||||||
| 	m_listType.push_back(audio::algo::drain::biQuadType_lowPass); | 	m_listType.pushBack(audio::algo::drain::biQuadType_lowPass); | ||||||
| 	m_listType.push_back(audio::algo::drain::biQuadType_highPass); | 	m_listType.pushBack(audio::algo::drain::biQuadType_highPass); | ||||||
| 	m_listType.push_back(audio::algo::drain::biQuadType_bandPass); | 	m_listType.pushBack(audio::algo::drain::biQuadType_bandPass); | ||||||
| 	m_listType.push_back(audio::algo::drain::biQuadType_notch); | 	m_listType.pushBack(audio::algo::drain::biQuadType_notch); | ||||||
| 	m_listType.push_back(audio::algo::drain::biQuadType_peak); | 	m_listType.pushBack(audio::algo::drain::biQuadType_peak); | ||||||
| 	m_listType.push_back(audio::algo::drain::biQuadType_lowShelf); | 	m_listType.pushBack(audio::algo::drain::biQuadType_lowShelf); | ||||||
| 	m_listType.push_back(audio::algo::drain::biQuadType_highShelf); | 	m_listType.pushBack(audio::algo::drain::biQuadType_highShelf); | ||||||
| } | } | ||||||
|  |  | ||||||
| void appl::Windows::init() { | void appl::Windows::init() { | ||||||
| 	ewol::widget::Windows::init(); | 	ewol::widget::Windows::init(); | ||||||
| 	setTitle("Drain Equalizer Profiler"); | 	setTitle("Drain Equalizer Profiler"); | ||||||
| 	 | 	 | ||||||
| 	m_gui = ewol::widget::Composer::create(ewol::widget::Composer::file, "DATA:gui.xml"); | 	m_gui = ewol::widget::Composer::create(ewol::widget::Composer::file, "DATA:///gui.xml"); | ||||||
| 	if (m_gui != nullptr) { | 	if (m_gui != null) { | ||||||
| 		setSubWidget(m_gui); | 		setSubWidget(m_gui); | ||||||
| 	} | 	} | ||||||
| 	subBind(ewol::widget::Button, "sample-rate-low", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSampleRateLow); | 	subBind(ewol::widget::Button, "sample-rate-low", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSampleRateLow); | ||||||
| @@ -100,15 +100,15 @@ void appl::Windows::onCallbackSampleRateUp() { | |||||||
| 			} else { | 			} else { | ||||||
| 				m_sampleRate = m_listSampleRate[0]; | 				m_sampleRate = m_listSampleRate[0]; | ||||||
| 			} | 			} | ||||||
| 			ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate)); | 			ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate)); | ||||||
| 			ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::to_string(m_sampleRate/2)); | 			ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::toString(m_sampleRate/2)); | ||||||
| 			onCallbackStart(); | 			onCallbackStart(); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	m_sampleRate = m_listSampleRate[0]; | 	m_sampleRate = m_listSampleRate[0]; | ||||||
| 	ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate)); | 	ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate)); | ||||||
| 	ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::to_string(m_sampleRate/2)); | 	ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::toString(m_sampleRate/2)); | ||||||
| 	onCallbackStart(); | 	onCallbackStart(); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -121,15 +121,15 @@ void appl::Windows::onCallbackSampleRateLow() { | |||||||
| 			} else { | 			} else { | ||||||
| 				m_sampleRate = m_listSampleRate[m_listSampleRate.size()-1]; | 				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)); | ||||||
| 			ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::to_string(m_sampleRate/2)); | 			ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::toString(m_sampleRate/2)); | ||||||
| 			onCallbackStart(); | 			onCallbackStart(); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	m_sampleRate = m_listSampleRate[0]; | 	m_sampleRate = m_listSampleRate[0]; | ||||||
| 	ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::to_string(m_sampleRate)); | 	ewol::parameterSetOnObjectNamed("sample-rate", "value", etk::toString(m_sampleRate)); | ||||||
| 	ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::to_string(m_sampleRate/2)); | 	ewol::parameterSetOnObjectNamed("frequency-slider", "max", etk::toString(m_sampleRate/2)); | ||||||
| 	onCallbackStart(); | 	onCallbackStart(); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -142,13 +142,13 @@ void appl::Windows::onCallbackTypeUp() { | |||||||
| 			} else { | 			} else { | ||||||
| 				m_type = m_listType[0]; | 				m_type = m_listType[0]; | ||||||
| 			} | 			} | ||||||
| 			ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type)); | 			ewol::parameterSetOnObjectNamed("type", "value", etk::toString(m_type)); | ||||||
| 			onCallbackStart(); | 			onCallbackStart(); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	m_type = m_listType[0]; | 	m_type = m_listType[0]; | ||||||
| 	ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type)); | 	ewol::parameterSetOnObjectNamed("type", "value", etk::toString(m_type)); | ||||||
| 	onCallbackStart(); | 	onCallbackStart(); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -161,79 +161,79 @@ void appl::Windows::onCallbackTypeLow() { | |||||||
| 			} else { | 			} else { | ||||||
| 				m_type = m_listType[m_listType.size()-1]; | 				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(); | 			onCallbackStart(); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	m_type = m_listType[0]; | 	m_type = m_listType[0]; | ||||||
| 	ewol::parameterSetOnObjectNamed("type", "value", etk::to_string(m_type)); | 	ewol::parameterSetOnObjectNamed("type", "value", etk::toString(m_type)); | ||||||
| 	onCallbackStart(); | 	onCallbackStart(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void appl::Windows::onCallbackGain(const std::string& _value) { | void appl::Windows::onCallbackGain(const etk::String& _value) { | ||||||
| 	m_gain = etk::string_to_float(_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); | 	APPL_INFO("Gain " << m_gain); | ||||||
| 	onCallbackStart(); | 	onCallbackStart(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void appl::Windows::onCallbackGainSlider(const float& _value) { | void appl::Windows::onCallbackGainSlider(const float& _value) { | ||||||
| 	m_gain = _value; | 	m_gain = _value; | ||||||
| 	ewol::parameterSetOnObjectNamed("gain", "value", etk::to_string(_value)); | 	ewol::parameterSetOnObjectNamed("gain", "value", etk::toString(_value)); | ||||||
| 	APPL_INFO("Gain " << m_gain); | 	APPL_INFO("Gain " << m_gain); | ||||||
| 	onCallbackStart(); | 	onCallbackStart(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| void appl::Windows::onCallbackQuality(const std::string& _value) { | void appl::Windows::onCallbackQuality(const etk::String& _value) { | ||||||
| 	m_quality = etk::string_to_float(_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); | 	APPL_INFO("quality " << m_quality); | ||||||
| 	onCallbackStart(); | 	onCallbackStart(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void appl::Windows::onCallbackQualitySlider(const float& _value) { | void appl::Windows::onCallbackQualitySlider(const float& _value) { | ||||||
| 	m_quality = _value; | 	m_quality = _value; | ||||||
| 	ewol::parameterSetOnObjectNamed("quality", "value", etk::to_string(_value)); | 	ewol::parameterSetOnObjectNamed("quality", "value", etk::toString(_value)); | ||||||
| 	APPL_INFO("quality " << m_quality); | 	APPL_INFO("quality " << m_quality); | ||||||
| 	onCallbackStart(); | 	onCallbackStart(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void appl::Windows::onCallbackFrequency(const std::string& _value) { | void appl::Windows::onCallbackFrequency(const etk::String& _value) { | ||||||
| 	m_cutFrequency = etk::string_to_float(_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); | 	APPL_INFO("cut frequency " << m_cutFrequency); | ||||||
| 	onCallbackStart(); | 	onCallbackStart(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void appl::Windows::onCallbackFrequencySlider(const float& _value) { | void appl::Windows::onCallbackFrequencySlider(const float& _value) { | ||||||
| 	m_cutFrequency = _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); | 	APPL_INFO("cut frequency " << m_cutFrequency); | ||||||
| 	onCallbackStart(); | 	onCallbackStart(); | ||||||
| } | } | ||||||
|  |  | ||||||
| #include <appl/debug.h> | #include <appl/debug.hpp> | ||||||
| #include <audio/algo/drain/BiQuad.h> | #include <audio/algo/drain/BiQuad.hpp> | ||||||
| #include <audio/float_t.h> | #include <audio/float_t.hpp> | ||||||
| #include <audio/int16_16_t.h> | #include <audio/int16_16_t.hpp> | ||||||
|  |  | ||||||
| void appl::Windows::onCallbackStart() { | void appl::Windows::onCallbackStart() { | ||||||
| 	APPL_INFO("start "); | 	APPL_INFO("start "); | ||||||
| 	int32_t iii = 10; | 	int32_t iii = 10; | ||||||
| 	std::vector<audio::channel> map; | 	etk::Vector<audio::channel> map; | ||||||
| 	map.push_back(audio::channel_frontCenter); | 	map.pushBack(audio::channel_frontCenter); | ||||||
| 	// audio::drain::IOFormatInterface format(map, audio::format_int16, m_sampleRate); | 	// audio::drain::IOFormatInterface format(map, audio::format_int16, m_sampleRate); | ||||||
| 	// audio::drain::IOFormatInterface format(map, audio::format_float, m_sampleRate); | 	// audio::drain::IOFormatInterface format(map, audio::format_float, m_sampleRate); | ||||||
| 	// create biquad | 	// create biquad | ||||||
| 	audio::algo::drain::BiQuad<audio::float_t> bq; | 	audio::algo::drain::BiQuad<audio::float_t> bq; | ||||||
| 	// configure parameter | 	// configure parameter | ||||||
| 	bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate); | 	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->clear(); | ||||||
| 	m_displayer->setValue(theory); | 	m_displayer->setValue(theory); | ||||||
| } | } | ||||||
| @@ -245,7 +245,7 @@ void appl::Windows::onCallbackStart16() { | |||||||
| 	audio::algo::drain::BiQuad<audio::int16_16_t> bq; | 	audio::algo::drain::BiQuad<audio::int16_16_t> bq; | ||||||
| 	// configure parameter | 	// configure parameter | ||||||
| 	bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate); | 	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; | 	size_t len = 512; | ||||||
| 	for (size_t iii=1; iii < len; iii++) { | 	for (size_t iii=1; iii < len; iii++) { | ||||||
| 		float freq = iii / (len - 1.0) * m_sampleRate / 2.0; | 		float freq = iii / (len - 1.0) * m_sampleRate / 2.0; | ||||||
| @@ -254,7 +254,7 @@ void appl::Windows::onCallbackStart16() { | |||||||
| 		double m_phase = 0; | 		double m_phase = 0; | ||||||
| 		double baseCycle = 2.0*M_PI/double(m_sampleRate) * double(freq); | 		double baseCycle = 2.0*M_PI/double(m_sampleRate) * double(freq); | ||||||
| 		float gain = 0; | 		float gain = 0; | ||||||
| 		std::vector<audio::int16_16_t> data; | 		etk::Vector<audio::int16_16_t> data; | ||||||
| 		// create sinus | 		// create sinus | ||||||
| 		data.resize(16000, 0); | 		data.resize(16000, 0); | ||||||
| 		for (int32_t iii=0; iii<data.size(); iii++) { | 		for (int32_t iii=0; iii<data.size(); iii++) { | ||||||
| @@ -265,19 +265,19 @@ void appl::Windows::onCallbackStart16() { | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		// process | 		// process | ||||||
| 		int16_t* output = nullptr; | 		int16_t* output = null; | ||||||
| 		void* outputVoid = nullptr; | 		void* outputVoid = null; | ||||||
| 		size_t outputNbChunk = 0; | 		size_t outputNbChunk = 0; | ||||||
| 		APPL_SAVE_FILE_MACRO(int16_t,"aaa_test_INPUT_16.raw",&data[0],data.size()); | 		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); | 		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()); | 		APPL_SAVE_FILE_MACRO(int16_t,"aaa_test_OUTPUT_16.raw",&data[0],data.size()); | ||||||
| 		audio::int16_16_t value = 0; | 		audio::int16_16_t value = 0; | ||||||
| 		for (size_t iii=800; iii<data.size()-200; ++iii) { | 		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); | 		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); | 	m_displayer->setValue(pratic); | ||||||
| } | } | ||||||
| @@ -288,7 +288,7 @@ void appl::Windows::onCallbackStartFloat() { | |||||||
| 	audio::algo::drain::BiQuad<audio::float_t> bq; | 	audio::algo::drain::BiQuad<audio::float_t> bq; | ||||||
| 	// configure parameter | 	// configure parameter | ||||||
| 	bq.setBiquad(m_type, m_cutFrequency, m_quality, m_gain, m_sampleRate); | 	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; | 	size_t len = 512; | ||||||
| 	for (size_t iii=1; iii < len; iii++) { | 	for (size_t iii=1; iii < len; iii++) { | ||||||
| 		float freq = iii / (len - 1.0) * m_sampleRate / 2.0; | 		float freq = iii / (len - 1.0) * m_sampleRate / 2.0; | ||||||
| @@ -297,7 +297,7 @@ void appl::Windows::onCallbackStartFloat() { | |||||||
| 		double m_phase = 0; | 		double m_phase = 0; | ||||||
| 		double baseCycle = 2.0*M_PI/double(m_sampleRate) * double(freq); | 		double baseCycle = 2.0*M_PI/double(m_sampleRate) * double(freq); | ||||||
| 		float gain = 0; | 		float gain = 0; | ||||||
| 		std::vector<audio::float_t> data; | 		etk::Vector<audio::float_t> data; | ||||||
| 		// create sinus | 		// create sinus | ||||||
| 		data.resize(16000, 0); | 		data.resize(16000, 0); | ||||||
| 		for (int32_t iii=0; iii<data.size(); iii++) { | 		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()); | 		APPL_SAVE_FILE_MACRO(float,"aaa_test_OUTPUT_F.raw",&data[0],data.size()); | ||||||
| 		audio::float_t value = 0.0f; | 		audio::float_t value = 0.0f; | ||||||
| 		for (size_t iii=800; iii<data.size()-200; ++iii) { | 		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); | 		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); | 	m_displayer->setValue(pratic); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,15 +1,15 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <ewol/widget/Windows.h> | #include <ewol/widget/Windows.hpp> | ||||||
| #include <ewol/widget/Layer.h> | #include <ewol/widget/Layer.hpp> | ||||||
| #include <ewol/widget/Composer.h> | #include <ewol/widget/Composer.hpp> | ||||||
| #include <audio/algo/drain/BiQuadType.h> | #include <audio/algo/drain/BiQuadType.hpp> | ||||||
| #include <appl/widget/DisplayFrequency.h> | #include <appl/widget/DisplayFrequency.hpp> | ||||||
| 
 | 
 | ||||||
| namespace appl { | namespace appl { | ||||||
| 	class Windows : public ewol::widget::Windows { | 	class Windows : public ewol::widget::Windows { | ||||||
| @@ -25,20 +25,20 @@ namespace appl { | |||||||
| 			void onCallbackSampleRateUp(); | 			void onCallbackSampleRateUp(); | ||||||
| 			void onCallbackTypeUp(); | 			void onCallbackTypeUp(); | ||||||
| 			void onCallbackTypeLow(); | 			void onCallbackTypeLow(); | ||||||
| 			void onCallbackGain(const std::string& _value); | 			void onCallbackGain(const etk::String& _value); | ||||||
| 			void onCallbackGainSlider(const float& _value); | 			void onCallbackGainSlider(const float& _value); | ||||||
| 			void onCallbackFrequency(const std::string& _value); | 			void onCallbackFrequency(const etk::String& _value); | ||||||
| 			void onCallbackFrequencySlider(const float& _value); | 			void onCallbackFrequencySlider(const float& _value); | ||||||
| 			void onCallbackQuality(const std::string& _value); | 			void onCallbackQuality(const etk::String& _value); | ||||||
| 			void onCallbackQualitySlider(const float& _value); | 			void onCallbackQualitySlider(const float& _value); | ||||||
| 			void onCallbackStart(); | 			void onCallbackStart(); | ||||||
| 			void onCallbackStart16(); | 			void onCallbackStart16(); | ||||||
| 			void onCallbackStartFloat(); | 			void onCallbackStartFloat(); | ||||||
| 		protected: | 		protected: | ||||||
| 			int32_t m_sampleRate; | 			int32_t m_sampleRate; | ||||||
| 			std::vector<int32_t> m_listSampleRate; | 			etk::Vector<int32_t> m_listSampleRate; | ||||||
| 			enum audio::algo::drain::biQuadType m_type; | 			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_cutFrequency; | ||||||
| 			float m_gain; | 			float m_gain; | ||||||
| 			float m_quality; | 			float m_quality; | ||||||
| @@ -1,11 +1,11 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|  |  | ||||||
| #include <appl/debug.h> | #include <appl/debug.hpp> | ||||||
|  |  | ||||||
| int32_t appl::getLogId() { | int32_t appl::getLogId() { | ||||||
| 	static int32_t g_val = elog::registerInstance("drain-equalizer"); | 	static int32_t g_val = elog::registerInstance("drain-equalizer"); | ||||||
|   | |||||||
| @@ -1,11 +1,11 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <elog/log.h> | #include <elog/log.hpp> | ||||||
| 
 | 
 | ||||||
| namespace appl { | namespace appl { | ||||||
| 	int32_t getLogId(); | 	int32_t getLogId(); | ||||||
| @@ -1,20 +1,20 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|  |  | ||||||
| #include <etk/types.h> | #include <etk/types.hpp> | ||||||
| #include <ewol/ewol.h> | #include <ewol/ewol.hpp> | ||||||
| #include <gale/context/commandLine.h> | #include <gale/context/commandLine.hpp> | ||||||
|  |  | ||||||
| #include <appl/debug.h> | #include <appl/debug.hpp> | ||||||
| #include <appl/Windows.h> | #include <appl/Windows.hpp> | ||||||
| #include <ewol/object/Object.h> | #include <ewol/object/Object.hpp> | ||||||
| #include <ewol/widget/Manager.h> | #include <ewol/widget/Manager.hpp> | ||||||
| #include <ewol/context/Context.h> | #include <ewol/context/Context.hpp> | ||||||
| #include <appl/widget/DisplayFrequency.h> | #include <appl/widget/DisplayFrequency.hpp> | ||||||
|  |  | ||||||
|  |  | ||||||
| class MainApplication : public ewol::context::Application { | class MainApplication : public ewol::context::Application { | ||||||
| @@ -52,7 +52,7 @@ class MainApplication : public ewol::context::Application { | |||||||
|  * @return std IO |  * @return std IO | ||||||
|  */ |  */ | ||||||
| int main(int _argc, const char *_argv[]) { | int main(int _argc, const char *_argv[]) { | ||||||
| 	return ewol::run(new MainApplication(), _argc, _argv); | 	return ewol::run(ETK_NEW(MainApplication), _argc, _argv); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| @@ -1,12 +1,12 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @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.h> | #include <appl/widget/DisplayFrequency.hpp> | ||||||
| #include <appl/debug.h> | #include <appl/debug.hpp> | ||||||
| #include <etk/tool.h> | #include <etk/tool.hpp> | ||||||
|  |  | ||||||
| appl::widget::DisplayFrequency::DisplayFrequency() : | appl::widget::DisplayFrequency::DisplayFrequency() : | ||||||
|   m_gainMin(0.0f), |   m_gainMin(0.0f), | ||||||
| @@ -28,8 +28,8 @@ appl::widget::DisplayFrequency::~DisplayFrequency() { | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void appl::widget::DisplayFrequency::setValue(const std::vector<std::pair<float,float> >& _data) { | void appl::widget::DisplayFrequency::setValue(const etk::Vector<etk::Pair<float,float> >& _data) { | ||||||
| 	m_data.push_back(_data); | 	m_data.pushBack(_data); | ||||||
| 	markToRedraw(); | 	markToRedraw(); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -83,23 +83,23 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() { | |||||||
| 	bool displayLog = true; | 	bool displayLog = true; | ||||||
| 	for (size_t kkk=0; kkk<m_data.size(); kkk++) { | 	for (size_t kkk=0; kkk<m_data.size(); kkk++) { | ||||||
| 		for (size_t iii=0; iii<m_data[kkk].size(); ++iii) { | 		for (size_t iii=0; iii<m_data[kkk].size(); ++iii) { | ||||||
| 			if (std::abs(m_data[kkk][iii].second) != std::numeric_limits<float>::infinity()) { | 			if (isinf(etk::abs(m_data[kkk][iii].second)) == false) { | ||||||
| 				m_gainMax = std::max(m_gainMax, m_data[kkk][iii].second); | 				m_gainMax = etk::max(m_gainMax, m_data[kkk][iii].second); | ||||||
| 				m_gainMin = std::min(m_gainMin, m_data[kkk][iii].second); | 				m_gainMin = etk::min(m_gainMin, m_data[kkk][iii].second); | ||||||
| 			} | 			} | ||||||
| 			if (displayLog == false) { | 			if (displayLog == false) { | ||||||
| 				if (std::abs(m_data[kkk][iii].first) != std::numeric_limits<float>::infinity()) { | 				if (isinf(etk::abs(m_data[kkk][iii].first)) == false) { | ||||||
| 					m_frequencyMax = std::max(m_frequencyMax, m_data[kkk][iii].first); | 					m_frequencyMax = etk::max(m_frequencyMax, m_data[kkk][iii].first); | ||||||
| 					m_frequencyMin = std::min(m_frequencyMin, m_data[kkk][iii].first); | 					m_frequencyMin = etk::min(m_frequencyMin, m_data[kkk][iii].first); | ||||||
| 				} | 				} | ||||||
| 			} else { | 			} 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) { | 					if (m_data[kkk][iii].first == 0) { | ||||||
| 						continue; | 						continue; | ||||||
| 					} | 					} | ||||||
| 					m_frequencyMax = std::max(m_frequencyMax, std::log(m_data[kkk][iii].first)); | 					m_frequencyMax = etk::max(m_frequencyMax, etk::log(m_data[kkk][iii].first)); | ||||||
| 					m_frequencyMin = std::min(m_frequencyMin, std::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 << " " << std::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 { | 		} else { | ||||||
| 			m_draw.setPos(   m_borderSize | 			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))); | 			                      ratioY*(m_data[kkk][0].second - m_gainMin))); | ||||||
| 			float baseX = 0; | 			float baseX = 0; | ||||||
| 			for (size_t iii=1; iii<m_data[kkk].size(); ++iii) { | 			for (size_t iii=1; iii<m_data[kkk].size(); ++iii) { | ||||||
| 				m_draw.lineTo(   m_borderSize | 				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))); | 				                      ratioY*(m_data[kkk][iii].second - m_gainMin))); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	m_text.setDefaultColorFg(etk::color::green); | 	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); | 	vec3 size = m_text.calculateSize(textToDisplay); | ||||||
| 	m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y()-size.y())); | 	m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y()-size.y())); | ||||||
| 	m_text.print(textToDisplay); | 	m_text.print(textToDisplay); | ||||||
| 	 | 	 | ||||||
| 	textToDisplay = etk::to_string(m_frequencyMax) + " Hz"; | 	textToDisplay = etk::toString(m_frequencyMax) + " Hz"; | ||||||
| 	size = m_text.calculateSize(textToDisplay); | 	size = m_text.calculateSize(textToDisplay); | ||||||
| 	m_text.setPos(vec2(m_size.x()-m_borderSize.x()-size.x(), m_borderSize.y()-size.y())); | 	m_text.setPos(vec2(m_size.x()-m_borderSize.x()-size.x(), m_borderSize.y()-size.y())); | ||||||
| 	m_text.print(textToDisplay); | 	m_text.print(textToDisplay); | ||||||
| 	 | 	 | ||||||
| 	textToDisplay = etk::to_string(m_gainMin) + " dB"; | 	textToDisplay = etk::toString(m_gainMin) + " dB"; | ||||||
| 	size = m_text.calculateSize(textToDisplay); | 	size = m_text.calculateSize(textToDisplay); | ||||||
| 	m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y())); | 	m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y())); | ||||||
| 	m_text.print(textToDisplay); | 	m_text.print(textToDisplay); | ||||||
| 	 | 	 | ||||||
| 	textToDisplay = etk::to_string(m_gainMax) + " dB"; | 	textToDisplay = etk::toString(m_gainMax) + " dB"; | ||||||
| 	size = m_text.calculateSize(textToDisplay); | 	size = m_text.calculateSize(textToDisplay); | ||||||
| 	m_text.setPos(vec2(m_borderSize.x(), m_size.y() - m_borderSize.y())); | 	m_text.setPos(vec2(m_borderSize.x(), m_size.y() - m_borderSize.y())); | ||||||
| 	m_text.print(textToDisplay); | 	m_text.print(textToDisplay); | ||||||
|   | |||||||
| @@ -1,14 +1,14 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <ewol/widget/Widget.h> | #include <ewol/widget/Widget.hpp> | ||||||
| #include <ewol/compositing/Drawing.h> | #include <ewol/compositing/Drawing.hpp> | ||||||
| #include <ewol/compositing/Text.h> | #include <ewol/compositing/Text.hpp> | ||||||
| #include <ewol/widget/Manager.h> | #include <ewol/widget/Manager.hpp> | ||||||
| 
 | 
 | ||||||
| namespace appl { | namespace appl { | ||||||
| 	namespace widget { | 	namespace widget { | ||||||
| @@ -25,12 +25,12 @@ namespace appl { | |||||||
| 				//! @brief destructor
 | 				//! @brief destructor
 | ||||||
| 				virtual ~DisplayFrequency(); | 				virtual ~DisplayFrequency(); | ||||||
| 			private: | 			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: | 			public: | ||||||
| 				void clear() { | 				void clear() { | ||||||
| 					m_data.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: | 			private: | ||||||
| 				float m_gainMin; //!< display minimum gain value
 | 				float m_gainMin; //!< display minimum gain value
 | ||||||
| 				float m_gainMax; //!< display maximum gain value
 | 				float m_gainMax; //!< display maximum gain value
 | ||||||
| @@ -1,5 +1,5 @@ | |||||||
| #!/usr/bin/python | #!/usr/bin/python | ||||||
| import lutin.module as module | import realog.debug as debug | ||||||
| import lutin.tools as tools | import lutin.tools as tools | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -13,7 +13,7 @@ def get_desc(): | |||||||
| 	return "basic test and profiling of equalizer work or not" | 	return "basic test and profiling of equalizer work or not" | ||||||
|  |  | ||||||
| def get_licence(): | def get_licence(): | ||||||
| 	return "APACHE-2" | 	return "MPL-2" | ||||||
|  |  | ||||||
| def get_compagny_type(): | def get_compagny_type(): | ||||||
| 	return "com" | 	return "com" | ||||||
| @@ -24,21 +24,24 @@ def get_compagny_name(): | |||||||
| def get_maintainer(): | def get_maintainer(): | ||||||
| 	return ["Mr DUPIN Edouard <yui.heero@gmail.com>"] | 	return ["Mr DUPIN Edouard <yui.heero@gmail.com>"] | ||||||
|  |  | ||||||
| def create(target, module_name): | def configure(target, my_module): | ||||||
| 	my_module = module.Module(__file__, module_name, get_type()) |  | ||||||
| 	my_module.add_src_file([ | 	my_module.add_src_file([ | ||||||
| 		'appl/main.cpp', | 	    'appl/main.cpp', | ||||||
| 		'appl/debug.cpp', | 	    'appl/debug.cpp', | ||||||
| 		'appl/Windows.cpp', | 	    'appl/Windows.cpp', | ||||||
| 		'appl/widget/DisplayFrequency.cpp', | 	    'appl/widget/DisplayFrequency.cpp', | ||||||
| 		]) | 	    ]) | ||||||
| 	my_module.add_depend(['ewol', 'audio-drain', 'audio-river']) | 	my_module.add_depend([ | ||||||
|  | 	    'ewol', | ||||||
|  | 	    'audio-drain', | ||||||
|  | 	    'audio-river' | ||||||
|  | 	    ]) | ||||||
| 	my_module.add_flag('c++', [ | 	my_module.add_flag('c++', [ | ||||||
| 		"-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\"" | 	    "-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\"" | ||||||
| 		]) | 	    ]) | ||||||
| 	my_module.add_path(tools.get_current_path(__file__)) | 	my_module.add_path(".") | ||||||
| 	my_module.copy_path("data/*") | 	my_module.copy_path("data/*") | ||||||
| 	return my_module | 	return True | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,31 +1,31 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <ewol/ewol.h> | #include <ewol/ewol.hpp> | ||||||
| #include <appl/debug.h> | #include <appl/debug.hpp> | ||||||
| #include <appl/Windows.h> | #include <appl/Windows.hpp> | ||||||
| #include <ewol/widget/Label.h> | #include <ewol/widget/Label.hpp> | ||||||
| #include <ewol/widget/Entry.h> | #include <ewol/widget/Entry.hpp> | ||||||
| #include <ewol/widget/Button.h> | #include <ewol/widget/Button.hpp> | ||||||
| #include <ewol/widget/Slider.h> | #include <ewol/widget/Slider.hpp> | ||||||
|  |  | ||||||
| #define APPL_SAVE_FILE_MACRO(type,fileName,dataPointer,nbElement) \ | #define APPL_SAVE_FILE_MACRO(type,fileName,dataPointer,nbElement) \ | ||||||
| 	do { \ | 	do { \ | ||||||
| 		static FILE *pointerOnFile = nullptr; \ | 		static FILE *pointerOnFile = null; \ | ||||||
| 		static bool errorOpen = false; \ | 		static bool errorOpen = false; \ | ||||||
| 		if (pointerOnFile == nullptr) { \ | 		if (pointerOnFile == null) { \ | ||||||
| 			APPL_WARNING("open file '" << fileName << "' type=" << #type); \ | 			APPL_WARNING("open file '" << fileName << "' type=" << #type); \ | ||||||
| 			pointerOnFile = fopen(fileName,"w"); \ | 			pointerOnFile = fopen(fileName,"w"); \ | ||||||
| 			if (    errorOpen == false \ | 			if (    errorOpen == false \ | ||||||
| 			     && pointerOnFile == nullptr) { \ | 			     && pointerOnFile == null) { \ | ||||||
| 				APPL_ERROR("ERROR OPEN file ... '" << fileName << "' type=" << #type); \ | 				APPL_ERROR("ERROR OPEN file ... '" << fileName << "' type=" << #type); \ | ||||||
| 				errorOpen=true; \ | 				errorOpen=true; \ | ||||||
| 			} \ | 			} \ | ||||||
| 		} \ | 		} \ | ||||||
| 		if (pointerOnFile != nullptr) { \ | 		if (pointerOnFile != null) { \ | ||||||
| 			fwrite((dataPointer), sizeof(type), (nbElement), pointerOnFile); \ | 			fwrite((dataPointer), sizeof(type), (nbElement), pointerOnFile); \ | ||||||
| 			/* fflush(pointerOnFile);*/ \ | 			/* fflush(pointerOnFile);*/ \ | ||||||
| 		} \ | 		} \ | ||||||
| @@ -34,18 +34,18 @@ | |||||||
| appl::Windows::Windows() : | appl::Windows::Windows() : | ||||||
|   m_sampleRate(48000) { |   m_sampleRate(48000) { | ||||||
| 	addObjectType("appl::Windows"); | 	addObjectType("appl::Windows"); | ||||||
| 	m_listSampleRate.push_back(192000); | 	m_listSampleRate.pushBack(192000); | ||||||
| 	m_listSampleRate.push_back(176400); | 	m_listSampleRate.pushBack(176400); | ||||||
| 	m_listSampleRate.push_back(96000); | 	m_listSampleRate.pushBack(96000); | ||||||
| 	m_listSampleRate.push_back(88200); | 	m_listSampleRate.pushBack(88200); | ||||||
| 	m_listSampleRate.push_back(48000); | 	m_listSampleRate.pushBack(48000); | ||||||
| 	m_listSampleRate.push_back(44100); | 	m_listSampleRate.pushBack(44100); | ||||||
| 	m_listSampleRate.push_back(32000); | 	m_listSampleRate.pushBack(32000); | ||||||
| 	m_listSampleRate.push_back(22050); | 	m_listSampleRate.pushBack(22050); | ||||||
| 	m_listSampleRate.push_back(16000); | 	m_listSampleRate.pushBack(16000); | ||||||
| 	m_listSampleRate.push_back(11025); | 	m_listSampleRate.pushBack(11025); | ||||||
| 	m_listSampleRate.push_back(8000); | 	m_listSampleRate.pushBack(8000); | ||||||
| 	m_listSampleRate.push_back(4000); | 	m_listSampleRate.pushBack(4000); | ||||||
| 	m_listGain.resize(10, 0.0f); | 	m_listGain.resize(10, 0.0f); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -53,8 +53,8 @@ void appl::Windows::init() { | |||||||
| 	ewol::widget::Windows::init(); | 	ewol::widget::Windows::init(); | ||||||
| 	setTitle("Drain Equalizer Profiler"); | 	setTitle("Drain Equalizer Profiler"); | ||||||
| 	 | 	 | ||||||
| 	m_gui = ewol::widget::Composer::create(ewol::widget::Composer::file, "DATA:gui.xml"); | 	m_gui = ewol::widget::Composer::create(ewol::widget::Composer::file, "DATA:///gui.xml"); | ||||||
| 	if (m_gui != nullptr) { | 	if (m_gui != null) { | ||||||
| 		setSubWidget(m_gui); | 		setSubWidget(m_gui); | ||||||
| 	} | 	} | ||||||
| 	subBind(ewol::widget::Button, "sample-rate-low", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSampleRateLow); | 	subBind(ewol::widget::Button, "sample-rate-low", signalPressed, sharedFromThis(), &appl::Windows::onCallbackSampleRateLow); | ||||||
| @@ -87,13 +87,13 @@ void appl::Windows::onCallbackSampleRateUp() { | |||||||
| 			} else { | 			} else { | ||||||
| 				m_sampleRate = m_listSampleRate[0]; | 				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(); | 			onCallbackStart(); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	m_sampleRate = m_listSampleRate[0]; | 	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(); | 	onCallbackStart(); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -106,13 +106,13 @@ void appl::Windows::onCallbackSampleRateLow() { | |||||||
| 			} else { | 			} else { | ||||||
| 				m_sampleRate = m_listSampleRate[m_listSampleRate.size()-1]; | 				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(); | 			onCallbackStart(); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	m_sampleRate = m_listSampleRate[0]; | 	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(); | 	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) { | ememory::SharedPtr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum audio::format _format) { | ||||||
| 	std::vector<audio::channel> map; | 	etk::Vector<audio::channel> map; | ||||||
| 	map.push_back(audio::channel_frontCenter); | 	map.pushBack(audio::channel_frontCenter); | ||||||
| 	audio::drain::IOFormatInterface format(map, _format, m_sampleRate); | 	audio::drain::IOFormatInterface format(map, _format, m_sampleRate); | ||||||
| 	// create equalizer | 	// create equalizer | ||||||
| 	ememory::SharedPtr<audio::drain::Equalizer> out = audio::drain::Equalizer::create(); | 	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 | 	// configure output | ||||||
| 	out->setOutputFormat(format); | 	out->setOutputFormat(format); | ||||||
| 	// create ejson: | 	// create ejson: | ||||||
| 	std::string conf; | 	etk::String conf; | ||||||
| 	conf += "{\n"; | 	conf += "{\n"; | ||||||
| 	conf += "	global: [\n"; | 	conf += "	global: [\n"; | ||||||
| 	for (size_t iii=3; iii<m_listGain.size(); ++iii) { | 	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 += "		{\n"; | ||||||
| 		conf += "			type:'peak',\n"; | 		conf += "			type:'peak',\n"; | ||||||
| 		conf += "			quality:2,\n"; | 		conf += "			quality:2,\n"; | ||||||
| 		conf += "			cut-frequency:" + etk::to_string(cutFrequency) + ",\n"; | 		conf += "			cut-frequency:" + etk::toString(cutFrequency) + ",\n"; | ||||||
| 		conf += "			gain:" + etk::to_string(m_listGain[iii]) + "\n"; | 		conf += "			gain:" + etk::toString(m_listGain[iii]) + "\n"; | ||||||
| 		conf += "		}\n"; | 		conf += "		}\n"; | ||||||
| 	} | 	} | ||||||
| 	conf += "	]\n"; | 	conf += "	]\n"; | ||||||
| @@ -172,7 +172,7 @@ ememory::SharedPtr<audio::drain::Equalizer> appl::Windows::createEqualizer(enum | |||||||
| void appl::Windows::onCallbackStart() { | void appl::Windows::onCallbackStart() { | ||||||
| 	APPL_INFO("start "); | 	APPL_INFO("start "); | ||||||
| 	ememory::SharedPtr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer(); | 	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->clear(); | ||||||
| 	m_displayer->setValue(theory); | 	m_displayer->setValue(theory); | ||||||
| } | } | ||||||
| @@ -181,9 +181,9 @@ void appl::Windows::onCallbackStart() { | |||||||
| void appl::Windows::onCallbackStart16() { | void appl::Windows::onCallbackStart16() { | ||||||
| 	APPL_INFO("start "); | 	APPL_INFO("start "); | ||||||
| 	ememory::SharedPtr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer(audio::format_int16); | 	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; | 	size_t len = 512; | ||||||
| 	std::vector<int16_t> data; | 	etk::Vector<int16_t> data; | ||||||
| 	data.resize(16000, 0); | 	data.resize(16000, 0); | ||||||
| 	for (size_t iii=1; iii < len; iii++) { | 	for (size_t iii=1; iii < len; iii++) { | ||||||
| 		float freq = iii / (len - 1.0) * m_sampleRate / 2.0; | 		float freq = iii / (len - 1.0) * m_sampleRate / 2.0; | ||||||
| @@ -200,8 +200,8 @@ void appl::Windows::onCallbackStart16() { | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		// process | 		// process | ||||||
| 		int16_t* output = nullptr; | 		int16_t* output = null; | ||||||
| 		void* outputVoid = nullptr; | 		void* outputVoid = null; | ||||||
| 		size_t outputNbChunk = 0; | 		size_t outputNbChunk = 0; | ||||||
| 		audio::Time time; | 		audio::Time time; | ||||||
| 		APPL_SAVE_FILE_MACRO(int16_t, "aaa_test_INPUT.raw", &data[0], data.size()); | 		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); | 		APPL_SAVE_FILE_MACRO(int16_t, "aaa_test_OUTPUT.raw", output, outputNbChunk); | ||||||
| 		int16_t value = 0; | 		int16_t value = 0; | ||||||
| 		for (size_t iii=800; iii<outputNbChunk-200; ++iii) { | 		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); | 		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); | 	m_displayer->setValue(pratic); | ||||||
| } | } | ||||||
| @@ -222,9 +222,9 @@ void appl::Windows::onCallbackStart16() { | |||||||
| void appl::Windows::onCallbackStartFloat() { | void appl::Windows::onCallbackStartFloat() { | ||||||
| 	APPL_INFO("start "); | 	APPL_INFO("start "); | ||||||
| 	ememory::SharedPtr<audio::drain::Equalizer> eq = appl::Windows::createEqualizer(audio::format_float); | 	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; | 	size_t len = 512; | ||||||
| 	std::vector<float> data; | 	etk::Vector<float> data; | ||||||
| 	data.resize(16000, 0); | 	data.resize(16000, 0); | ||||||
| 	for (size_t iii=1; iii < len; iii++) { | 	for (size_t iii=1; iii < len; iii++) { | ||||||
| 		float freq = iii / (len - 1.0) * m_sampleRate / 2.0; | 		float freq = iii / (len - 1.0) * m_sampleRate / 2.0; | ||||||
| @@ -241,8 +241,8 @@ void appl::Windows::onCallbackStartFloat() { | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		// process | 		// process | ||||||
| 		float* output = nullptr; | 		float* output = null; | ||||||
| 		void* outputVoid = nullptr; | 		void* outputVoid = null; | ||||||
| 		size_t outputNbChunk = 0; | 		size_t outputNbChunk = 0; | ||||||
| 		audio::Time time; | 		audio::Time time; | ||||||
| 		APPL_SAVE_FILE_MACRO(int16_t,"aaa_test_INPUT_F.raw",&data[0],data.size()); | 		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); | 		APPL_SAVE_FILE_MACRO(int16_t,"aaa_test_OUTPUT_F.raw",output, outputNbChunk); | ||||||
| 		float value = 0; | 		float value = 0; | ||||||
| 		for (size_t iii=800; iii<outputNbChunk-200; ++iii) { | 		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); | 		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); | 	m_displayer->setValue(pratic); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,15 +1,15 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <ewol/widget/Windows.h> | #include <ewol/widget/Windows.hpp> | ||||||
| #include <ewol/widget/Layer.h> | #include <ewol/widget/Layer.hpp> | ||||||
| #include <ewol/widget/Composer.h> | #include <ewol/widget/Composer.hpp> | ||||||
| #include <audio/drain/Equalizer.h> | #include <audio/drain/Equalizer.hpp> | ||||||
| #include <appl/widget/DisplayFrequency.h> | #include <appl/widget/DisplayFrequency.hpp> | ||||||
| 
 | 
 | ||||||
| namespace appl { | namespace appl { | ||||||
| 	class Windows : public ewol::widget::Windows { | 	class Windows : public ewol::widget::Windows { | ||||||
| @@ -59,9 +59,9 @@ namespace appl { | |||||||
| 			void onCallbackStartFloat(); | 			void onCallbackStartFloat(); | ||||||
| 		protected: | 		protected: | ||||||
| 			int32_t m_sampleRate; | 			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); | 			ememory::SharedPtr<audio::drain::Equalizer> createEqualizer(enum audio::format _format = audio::format_float); | ||||||
| 	}; | 	}; | ||||||
| } | } | ||||||
| @@ -1,11 +1,11 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|  |  | ||||||
| #include <appl/debug.h> | #include <appl/debug.hpp> | ||||||
|  |  | ||||||
| int32_t appl::getLogId() { | int32_t appl::getLogId() { | ||||||
| 	static int32_t g_val = elog::registerInstance("drain-equalizer"); | 	static int32_t g_val = elog::registerInstance("drain-equalizer"); | ||||||
|   | |||||||
| @@ -1,11 +1,11 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <elog/log.h> | #include <elog/log.hpp> | ||||||
| 
 | 
 | ||||||
| namespace appl { | namespace appl { | ||||||
| 	int32_t getLogId(); | 	int32_t getLogId(); | ||||||
| @@ -1,20 +1,20 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|  |  | ||||||
| #include <etk/types.h> | #include <etk/types.hpp> | ||||||
| #include <ewol/ewol.h> | #include <ewol/ewol.hpp> | ||||||
| #include <gale/context/commandLine.h> | #include <gale/context/commandLine.hpp> | ||||||
|  |  | ||||||
| #include <appl/debug.h> | #include <appl/debug.hpp> | ||||||
| #include <appl/Windows.h> | #include <appl/Windows.hpp> | ||||||
| #include <ewol/object/Object.h> | #include <ewol/object/Object.hpp> | ||||||
| #include <ewol/widget/Manager.h> | #include <ewol/widget/Manager.hpp> | ||||||
| #include <ewol/context/Context.h> | #include <ewol/context/Context.hpp> | ||||||
| #include <appl/widget/DisplayFrequency.h> | #include <appl/widget/DisplayFrequency.hpp> | ||||||
|  |  | ||||||
|  |  | ||||||
| class MainApplication : public ewol::context::Application { | class MainApplication : public ewol::context::Application { | ||||||
| @@ -52,7 +52,7 @@ class MainApplication : public ewol::context::Application { | |||||||
|  * @return std IO |  * @return std IO | ||||||
|  */ |  */ | ||||||
| int main(int _argc, const char *_argv[]) { | int main(int _argc, const char *_argv[]) { | ||||||
| 	return ewol::run(new MainApplication(), _argc, _argv); | 	return ewol::run(ETK_NEW(MainApplication), _argc, _argv); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| @@ -1,12 +1,12 @@ | |||||||
| /** @file | /** @file | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @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.h> | #include <appl/widget/DisplayFrequency.hpp> | ||||||
| #include <appl/debug.h> | #include <appl/debug.hpp> | ||||||
| #include <etk/tool.h> | #include <etk/tool.hpp> | ||||||
|  |  | ||||||
| appl::widget::DisplayFrequency::DisplayFrequency() : | appl::widget::DisplayFrequency::DisplayFrequency() : | ||||||
|   m_gainMin(0.0f), |   m_gainMin(0.0f), | ||||||
| @@ -28,8 +28,8 @@ appl::widget::DisplayFrequency::~DisplayFrequency() { | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void appl::widget::DisplayFrequency::setValue(const std::vector<std::pair<float,float> >& _data) { | void appl::widget::DisplayFrequency::setValue(const etk::Vector<etk::Pair<float,float> >& _data) { | ||||||
| 	m_data.push_back(_data); | 	m_data.pushBack(_data); | ||||||
| 	markToRedraw(); | 	markToRedraw(); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -83,24 +83,24 @@ void appl::widget::DisplayFrequency::onRegenerateDisplay() { | |||||||
| 	bool displayLog = true; | 	bool displayLog = true; | ||||||
| 	for (size_t kkk=0; kkk<m_data.size(); kkk++) { | 	for (size_t kkk=0; kkk<m_data.size(); kkk++) { | ||||||
| 		for (size_t iii=0; iii<m_data[kkk].size(); ++iii) { | 		for (size_t iii=0; iii<m_data[kkk].size(); ++iii) { | ||||||
| 			if (std::abs(m_data[kkk][iii].second) != std::numeric_limits<float>::infinity()) { | 			if (isinf(etk::abs(m_data[kkk][iii].second)) == false) { | ||||||
| 				m_gainMax = std::max(m_gainMax, m_data[kkk][iii].second); | 				m_gainMax = etk::max(m_gainMax, m_data[kkk][iii].second); | ||||||
| 				m_gainMin = std::min(m_gainMin, m_data[kkk][iii].second); | 				m_gainMin = etk::min(m_gainMin, m_data[kkk][iii].second); | ||||||
| 				//APPL_INFO("plop " << m_data[kkk][iii].second); | 				//APPL_INFO("plop " << m_data[kkk][iii].second); | ||||||
| 			} | 			} | ||||||
| 			if (displayLog == false) { | 			if (displayLog == false) { | ||||||
| 				if (std::abs(m_data[kkk][iii].first) != std::numeric_limits<float>::infinity()) { | 				if (isinf(etk::abs(m_data[kkk][iii].first)) == false) { | ||||||
| 					m_frequencyMax = std::max(m_frequencyMax, m_data[kkk][iii].first); | 					m_frequencyMax = etk::max(m_frequencyMax, m_data[kkk][iii].first); | ||||||
| 					m_frequencyMin = std::min(m_frequencyMin, m_data[kkk][iii].first); | 					m_frequencyMin = etk::min(m_frequencyMin, m_data[kkk][iii].first); | ||||||
| 				} | 				} | ||||||
| 			} else { | 			} 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) { | 					if (m_data[kkk][iii].first == 0) { | ||||||
| 						continue; | 						continue; | ||||||
| 					} | 					} | ||||||
| 					m_frequencyMax = std::max(m_frequencyMax, std::log(m_data[kkk][iii].first)); | 					m_frequencyMax = etk::max(m_frequencyMax, etk::log(m_data[kkk][iii].first)); | ||||||
| 					m_frequencyMin = std::min(m_frequencyMin, std::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 << " " << std::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 { | 		} else { | ||||||
| 			m_draw.setPos(   m_borderSize | 			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))); | 			                      ratioY*(m_data[kkk][0].second - m_gainMin))); | ||||||
| 			float baseX = 0; | 			float baseX = 0; | ||||||
| 			for (size_t iii=1; iii<m_data[kkk].size(); ++iii) { | 			for (size_t iii=1; iii<m_data[kkk].size(); ++iii) { | ||||||
| 				m_draw.lineTo(   m_borderSize | 				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))); | 				                      ratioY*(m_data[kkk][iii].second - m_gainMin))); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	m_text.setDefaultColorFg(etk::color::green); | 	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); | 	vec3 size = m_text.calculateSize(textToDisplay); | ||||||
| 	m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y()-size.y())); | 	m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y()-size.y())); | ||||||
| 	m_text.print(textToDisplay); | 	m_text.print(textToDisplay); | ||||||
| 	 | 	 | ||||||
| 	textToDisplay = etk::to_string(m_frequencyMax) + " Hz"; | 	textToDisplay = etk::toString(m_frequencyMax) + " Hz"; | ||||||
| 	size = m_text.calculateSize(textToDisplay); | 	size = m_text.calculateSize(textToDisplay); | ||||||
| 	m_text.setPos(vec2(m_size.x()-m_borderSize.x()-size.x(), m_borderSize.y()-size.y())); | 	m_text.setPos(vec2(m_size.x()-m_borderSize.x()-size.x(), m_borderSize.y()-size.y())); | ||||||
| 	m_text.print(textToDisplay); | 	m_text.print(textToDisplay); | ||||||
| 	 | 	 | ||||||
| 	textToDisplay = etk::to_string(m_gainMin) + " dB"; | 	textToDisplay = etk::toString(m_gainMin) + " dB"; | ||||||
| 	size = m_text.calculateSize(textToDisplay); | 	size = m_text.calculateSize(textToDisplay); | ||||||
| 	m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y())); | 	m_text.setPos(vec2(m_borderSize.x(), m_borderSize.y())); | ||||||
| 	m_text.print(textToDisplay); | 	m_text.print(textToDisplay); | ||||||
| 	 | 	 | ||||||
| 	textToDisplay = etk::to_string(m_gainMax) + " dB"; | 	textToDisplay = etk::toString(m_gainMax) + " dB"; | ||||||
| 	size = m_text.calculateSize(textToDisplay); | 	size = m_text.calculateSize(textToDisplay); | ||||||
| 	m_text.setPos(vec2(m_borderSize.x(), m_size.y() - m_borderSize.y())); | 	m_text.setPos(vec2(m_borderSize.x(), m_size.y() - m_borderSize.y())); | ||||||
| 	m_text.print(textToDisplay); | 	m_text.print(textToDisplay); | ||||||
|   | |||||||
| @@ -1,14 +1,14 @@ | |||||||
| /** @file
 | /** @file
 | ||||||
|  * @author Edouard DUPIN  |  * @author Edouard DUPIN  | ||||||
|  * @copyright 2011, Edouard DUPIN, all right reserved |  * @copyright 2011, Edouard DUPIN, all right reserved | ||||||
|  * @license APACHE v2.0 (see license file) |  * @license MPL v2.0 (see license file) | ||||||
|  */ |  */ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <ewol/widget/Widget.h> | #include <ewol/widget/Widget.hpp> | ||||||
| #include <ewol/compositing/Drawing.h> | #include <ewol/compositing/Drawing.hpp> | ||||||
| #include <ewol/compositing/Text.h> | #include <ewol/compositing/Text.hpp> | ||||||
| #include <ewol/widget/Manager.h> | #include <ewol/widget/Manager.hpp> | ||||||
| 
 | 
 | ||||||
| namespace appl { | namespace appl { | ||||||
| 	namespace widget { | 	namespace widget { | ||||||
| @@ -25,12 +25,12 @@ namespace appl { | |||||||
| 				//! @brief destructor
 | 				//! @brief destructor
 | ||||||
| 				virtual ~DisplayFrequency(); | 				virtual ~DisplayFrequency(); | ||||||
| 			private: | 			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: | 			public: | ||||||
| 				void clear() { | 				void clear() { | ||||||
| 					m_data.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: | 			private: | ||||||
| 				float m_gainMin; //!< display minimum gain value
 | 				float m_gainMin; //!< display minimum gain value
 | ||||||
| 				float m_gainMax; //!< display maximum gain value
 | 				float m_gainMax; //!< display maximum gain value
 | ||||||
| @@ -1,5 +1,5 @@ | |||||||
| #!/usr/bin/python | #!/usr/bin/python | ||||||
| import lutin.module as module | import realog.debug as debug | ||||||
| import lutin.tools as tools | import lutin.tools as tools | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -13,7 +13,7 @@ def get_desc(): | |||||||
| 	return "basic test and profiling of equalizer work or not" | 	return "basic test and profiling of equalizer work or not" | ||||||
|  |  | ||||||
| def get_licence(): | def get_licence(): | ||||||
| 	return "APACHE-2" | 	return "MPL-2" | ||||||
|  |  | ||||||
| def get_compagny_type(): | def get_compagny_type(): | ||||||
| 	return "com" | 	return "com" | ||||||
| @@ -24,21 +24,24 @@ def get_compagny_name(): | |||||||
| def get_maintainer(): | def get_maintainer(): | ||||||
| 	return ["Mr DUPIN Edouard <yui.heero@gmail.com>"] | 	return ["Mr DUPIN Edouard <yui.heero@gmail.com>"] | ||||||
|  |  | ||||||
| def create(target, module_name): | def configure(target, my_module): | ||||||
| 	my_module = module.Module(__file__, module_name, get_type()) |  | ||||||
| 	my_module.add_src_file([ | 	my_module.add_src_file([ | ||||||
| 		'appl/main.cpp', | 	    'appl/main.cpp', | ||||||
| 		'appl/debug.cpp', | 	    'appl/debug.cpp', | ||||||
| 		'appl/Windows.cpp', | 	    'appl/Windows.cpp', | ||||||
| 		'appl/widget/DisplayFrequency.cpp', | 	    'appl/widget/DisplayFrequency.cpp', | ||||||
| 		]) | 	    ]) | ||||||
| 	my_module.add_depend(['ewol', 'audio-drain', 'audio-river']) | 	my_module.add_depend([ | ||||||
|  | 	    'ewol', | ||||||
|  | 	    'audio-drain', | ||||||
|  | 	    'audio-river' | ||||||
|  | 	    ]) | ||||||
| 	my_module.add_flag('c++', [ | 	my_module.add_flag('c++', [ | ||||||
| 		"-DPROJECT_NAME=\"\\\""+my_module.name+"\\\"\"" | 	    "-DPROJECT_NAME=\"\\\""+my_module.get_name()+"\\\"\"" | ||||||
| 		]) | 	    ]) | ||||||
| 	my_module.add_path(tools.get_current_path(__file__)) | 	my_module.add_path(".") | ||||||
| 	my_module.copy_path("data/*") | 	my_module.copy_path("data/*") | ||||||
| 	return my_module | 	return True | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1 +1 @@ | |||||||
| 0.2.1 | 1.0.0 | ||||||
		Reference in New Issue
	
	Block a user