Compare commits
12 Commits
15a027043a
...
37bfdd4fb9
Author | SHA1 | Date | |
---|---|---|---|
37bfdd4fb9 | |||
a981693121 | |||
398828ab6e | |||
06b8d5d65e | |||
393be4ded5 | |||
6a537f714c | |||
457dfe6a06 | |||
6069305dd7 | |||
cf6baea92f | |||
f55fa25f04 | |||
686ab25ed8 | |||
56edf035f8 |
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.
|
@ -8,15 +8,15 @@ Instructions
|
||||
|
||||
To compile and use see 'ewol' or 'edn' project
|
||||
|
||||
License (APACHE v2.0)
|
||||
License (MPL v2.0)
|
||||
=====================
|
||||
Copyright ewolsa Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
Licensed under the Mozilla Public License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
https://www.mozilla.org/MPL/2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
@ -12,17 +12,6 @@
|
||||
#include <audio/ess/decWav.hpp>
|
||||
#include <audio/ess/decOgg.hpp>
|
||||
|
||||
|
||||
#if defined(__TARGET_OS__Android)
|
||||
void* audio::ess::LoadedFile::threadCallback(void* _userData) {
|
||||
audio::ess::LoadedFile* threadHandle = static_cast<audio::ess::LoadedFile*>(_userData);
|
||||
if (threadHandle != nullptr) {
|
||||
threadHandle->threadCall();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
void audio::ess::LoadedFile::threadCall() {
|
||||
decode();
|
||||
}
|
||||
@ -34,15 +23,12 @@ void audio::ess::LoadedFile::decode() {
|
||||
EWOLSA_ERROR("End decode OGG : " << m_file << " size=" << m_nbSamples);
|
||||
}
|
||||
|
||||
audio::ess::LoadedFile::LoadedFile(const std::string& _fileName, int8_t _nbChanRequested) :
|
||||
#if !defined(__TARGET_OS__Android)
|
||||
m_thread(nullptr),
|
||||
#endif
|
||||
audio::ess::LoadedFile::LoadedFile(const etk::String& _fileName, int8_t _nbChanRequested) :
|
||||
m_file(_fileName),
|
||||
m_nbSamples(0),
|
||||
m_nbChanRequested(_nbChanRequested),
|
||||
m_requestedTime(1) {
|
||||
std::string tmpName = etk::tolower(m_file);
|
||||
etk::String tmpName = etk::toLower(m_file);
|
||||
// select the corect Loader :
|
||||
if (etk::end_with(tmpName, ".wav") == true) {
|
||||
m_data = audio::ess::wav::loadAudioFile(m_file, m_nbChanRequested);
|
||||
@ -50,16 +36,12 @@ audio::ess::LoadedFile::LoadedFile(const std::string& _fileName, int8_t _nbChanR
|
||||
} else if (etk::end_with(tmpName, ".ogg") == true) {
|
||||
#if 1
|
||||
EWOLSA_INFO("create thread");
|
||||
#if defined(__TARGET_OS__Android)
|
||||
pthread_create(&m_thread, nullptr, &audio::ess::LoadedFile::threadCallback, this);
|
||||
#else
|
||||
m_thread = ememory::makeShared<std::thread>(&audio::ess::LoadedFile::threadCall, this);
|
||||
if (m_thread == nullptr) {
|
||||
EWOLSA_ERROR("Can not create thread ...");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
m_thread = ememory::makeShared<ethread::Thread>([&](){decode();}, "audioDecoding");
|
||||
if (m_thread == null) {
|
||||
EWOLSA_ERROR("Can not create thread ...");
|
||||
return;
|
||||
}
|
||||
ethread::sleepMilliSeconds((1));
|
||||
#else
|
||||
decode();
|
||||
#endif
|
||||
@ -70,15 +52,10 @@ audio::ess::LoadedFile::LoadedFile(const std::string& _fileName, int8_t _nbChanR
|
||||
}
|
||||
|
||||
audio::ess::LoadedFile::~LoadedFile() {
|
||||
#if defined(__TARGET_OS__Android)
|
||||
void* ret = nullptr;
|
||||
int val = pthread_join(m_thread, &ret);
|
||||
#else
|
||||
if (m_thread != nullptr) {
|
||||
m_thread->join();
|
||||
}
|
||||
m_thread.reset();
|
||||
#endif
|
||||
if (m_thread != null) {
|
||||
m_thread->join();
|
||||
}
|
||||
m_thread.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <thread>
|
||||
#include <ethread/Thread.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
|
||||
namespace audio {
|
||||
@ -19,21 +19,17 @@ namespace audio {
|
||||
return m_uid;
|
||||
}
|
||||
private:
|
||||
#if defined(__TARGET_OS__Android)
|
||||
pthread_t m_thread;
|
||||
#else
|
||||
ememory::SharedPtr<std::thread> m_thread;
|
||||
#endif
|
||||
ememory::SharedPtr<ethread::Thread> m_thread;
|
||||
public:
|
||||
LoadedFile(const std::string& _fileName, int8_t _nbChanRequested=1);
|
||||
LoadedFile(const etk::String& _fileName, int8_t _nbChanRequested=1);
|
||||
~LoadedFile();
|
||||
std::string m_file;
|
||||
etk::String m_file;
|
||||
int32_t m_nbSamples;
|
||||
int32_t m_nbChanRequested;
|
||||
int32_t m_requestedTime;
|
||||
std::vector<float> m_data;
|
||||
etk::Vector<float> m_data;
|
||||
public:
|
||||
const std::string& getName() {
|
||||
const etk::String& getName() {
|
||||
return m_file;
|
||||
};
|
||||
void decode();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <audio/ess/debug.hpp>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
@ -1,34 +1,33 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <audio/ess/debug.hpp>
|
||||
#include <audio/ess/decOgg.hpp>
|
||||
#include <tremor/ivorbiscodec.h>
|
||||
#include <tremor/ivorbisfile.h>
|
||||
#include <memory>
|
||||
#include <ememory/UniquePtr.hpp>
|
||||
|
||||
|
||||
static size_t LocalReadFunc(void *ptr, size_t size, size_t nmemb, void *datasource) {
|
||||
etk::FSNode* file = static_cast<etk::FSNode*>(datasource);
|
||||
return file->fileRead(ptr, size, nmemb);
|
||||
etk::io::Interface* fileIO = static_cast<etk::io::Interface*>(datasource);
|
||||
return fileIO->read(ptr, size, nmemb);
|
||||
}
|
||||
|
||||
static int localSeekFunc(void *datasource, ogg_int64_t offset, int whence) {
|
||||
etk::FSNode* file = static_cast<etk::FSNode*>(datasource);
|
||||
enum etk::seekNode mode = etk::seekNode_start;
|
||||
etk::io::Interface* fileIO = static_cast<etk::io::Interface*>(datasource);
|
||||
etk::io::SeekMode mode = etk::io::SeekMode::Start;
|
||||
if (whence == SEEK_SET) {
|
||||
mode = etk::seekNode_start;
|
||||
mode = etk::io::SeekMode::Start;
|
||||
} else if (whence == SEEK_END) {
|
||||
mode = etk::seekNode_end;
|
||||
mode = etk::io::SeekMode::End;
|
||||
} else if (whence == SEEK_CUR) {
|
||||
mode = etk::seekNode_current;
|
||||
mode = etk::io::SeekMode::Current;
|
||||
}
|
||||
if (file->fileSeek(offset, mode) == true) {
|
||||
if (fileIO->seek(offset, mode) == true) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
@ -36,18 +35,18 @@ static int localSeekFunc(void *datasource, ogg_int64_t offset, int whence) {
|
||||
}
|
||||
|
||||
static int localCloseFunc(void *datasource) {
|
||||
etk::FSNode* file = static_cast<etk::FSNode*>(datasource);
|
||||
file->fileClose();
|
||||
etk::io::Interface* fileIO = static_cast<etk::io::Interface*>(datasource);
|
||||
fileIO->close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long localTellFunc(void *datasource) {
|
||||
etk::FSNode* file = static_cast<etk::FSNode*>(datasource);
|
||||
return file->fileTell();
|
||||
etk::io::Interface* fileIO = static_cast<etk::io::Interface*>(datasource);
|
||||
return fileIO->tell();
|
||||
}
|
||||
|
||||
std::vector<float> audio::ess::ogg::loadAudioFile(const std::string& _filename, int8_t _nbChan) {
|
||||
std::vector<float> out;
|
||||
etk::Vector<float> audio::ess::ogg::loadAudioFile(const etk::Uri& _uri, int8_t _nbChan) {
|
||||
etk::Vector<float> out;
|
||||
OggVorbis_File vf;
|
||||
int32_t eof=0;
|
||||
int32_t current_section;
|
||||
@ -57,24 +56,28 @@ std::vector<float> audio::ess::ogg::loadAudioFile(const std::string& _filename,
|
||||
localCloseFunc,
|
||||
localTellFunc
|
||||
};
|
||||
std::unique_ptr<etk::FSNode> fileAccess = std::unique_ptr<etk::FSNode>(new etk::FSNode(_filename));
|
||||
// Start loading the XML :
|
||||
//EWOLSA_DEBUG("open file (OGG) \"" << fileAccess << "\"");
|
||||
if (false == fileAccess->exist()) {
|
||||
EWOLSA_ERROR("File Does not exist : \"" << *fileAccess << "\"");
|
||||
EWOLSA_DEBUG("open file (OGG) " << _uri);
|
||||
if (etk::uri::exist(_uri) == false) {
|
||||
EWOLSA_ERROR("File Does not exist : " << _uri);
|
||||
return out;
|
||||
}
|
||||
int32_t fileSize = fileAccess->fileSize();
|
||||
if (0 == fileSize) {
|
||||
EWOLSA_ERROR("This file is empty : \"" << *fileAccess << "\"");
|
||||
int32_t fileSize = etk::uri::fileSize(_uri);
|
||||
if (fileSize == 0) {
|
||||
EWOLSA_ERROR("This file is empty : " << _uri);
|
||||
return out;
|
||||
}
|
||||
if (false == fileAccess->fileOpenRead()) {
|
||||
EWOLSA_ERROR("Can not open the file : \"" << *fileAccess << "\"");
|
||||
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(_uri);
|
||||
if (fileIO == null) {
|
||||
EWOLSA_ERROR("CAn not get file interface : " << _uri);
|
||||
return out;
|
||||
}
|
||||
if (ov_open_callbacks(&(*fileAccess), &vf, nullptr, 0, tmpCallback) < 0) {
|
||||
EWOLSA_ERROR("Input does not appear to be an Ogg bitstream.");
|
||||
if (fileIO->open(etk::io::OpenMode::Read) == false) {
|
||||
EWOLSA_ERROR("Can not open the file : " << _uri);
|
||||
return out;
|
||||
}
|
||||
if (ov_open_callbacks(fileIO.get(), &vf, null, 0, tmpCallback) < 0) {
|
||||
EWOLSA_ERROR("Input does not appear to be an Ogg bitstream: " << _uri);
|
||||
return out;
|
||||
}
|
||||
vorbis_info *vi=ov_info(&vf,-1);
|
||||
|
@ -1,16 +1,17 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace ess {
|
||||
namespace ogg {
|
||||
std::vector<float> loadAudioFile(const std::string& _filename, int8_t _nbChan);
|
||||
etk::Vector<float> loadAudioFile(const etk::Uri& _uri, int8_t _nbChan);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <audio/ess/debug.hpp>
|
||||
#include <audio/ess/decWav.hpp>
|
||||
|
||||
@ -57,37 +56,40 @@ typedef struct {
|
||||
#define COMPR_G721 (64)
|
||||
#define COMPR_MPEG (80)
|
||||
|
||||
std::vector<float> audio::ess::wav::loadAudioFile(const std::string& _filename, int8_t _nbChan) {
|
||||
std::vector<float> out;
|
||||
etk::Vector<float> audio::ess::wav::loadAudioFile(const etk::Uri& _uri, int8_t _nbChan) {
|
||||
etk::Vector<float> out;
|
||||
waveHeader myHeader;
|
||||
memset(&myHeader, 0, sizeof(waveHeader));
|
||||
etk::FSNode fileAccess(_filename);
|
||||
// Start loading the XML :
|
||||
EWOLSA_DEBUG("open file (WAV) \"" << fileAccess << "\"");
|
||||
|
||||
if (false == fileAccess.exist()) {
|
||||
EWOLSA_ERROR("File Does not exist : \"" << fileAccess << "\"");
|
||||
EWOLSA_DEBUG("open file (WAV) " << _uri);
|
||||
if (etk::uri::exist(_uri) == false) {
|
||||
EWOLSA_ERROR("File Does not exist : " << _uri);
|
||||
return out;
|
||||
}
|
||||
int32_t fileSize = fileAccess.fileSize();
|
||||
int32_t fileSize = etk::uri::fileSize(_uri);
|
||||
if (0 == fileSize) {
|
||||
EWOLSA_ERROR("This file is empty : \"" << fileAccess << "\"");
|
||||
EWOLSA_ERROR("This file is empty : " << _uri);
|
||||
return out;
|
||||
}
|
||||
if (false == fileAccess.fileOpenRead()) {
|
||||
EWOLSA_ERROR("Can not open the file : \"" << fileAccess << "\"");
|
||||
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(_uri);
|
||||
if (fileIO == null) {
|
||||
EWOLSA_ERROR("CAn not get file interface : " << _uri);
|
||||
return out;
|
||||
}
|
||||
if (fileIO->open(etk::io::OpenMode::Read) == false) {
|
||||
EWOLSA_ERROR("Can not open the file : " << _uri);
|
||||
return out;
|
||||
}
|
||||
// try to find endienness :
|
||||
if (fileSize < (int64_t)sizeof(waveHeader)) {
|
||||
EWOLSA_ERROR("File : \"" << fileAccess << "\" == > has not enouth data inside might be minumum of " << (int32_t)(sizeof(waveHeader)));
|
||||
EWOLSA_ERROR("File : " << _uri << " == > has not enouth data inside might be minumum of " << (int32_t)(sizeof(waveHeader)));
|
||||
return out;
|
||||
}
|
||||
// ----------------------------------------------
|
||||
// read the header :
|
||||
// ----------------------------------------------
|
||||
if (fileAccess.fileRead(&myHeader.riffTag, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : \"" << fileAccess << "\"");
|
||||
if (fileIO->read(&myHeader.riffTag, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : " << _uri);
|
||||
return out;
|
||||
}
|
||||
bool littleEndien = false;
|
||||
@ -99,55 +101,55 @@ std::vector<float> audio::ess::wav::loadAudioFile(const std::string& _filename,
|
||||
littleEndien = true;
|
||||
}
|
||||
} else {
|
||||
EWOLSA_ERROR("file: \"" << fileAccess << "\" Does not start with \"RIF\" " );
|
||||
EWOLSA_ERROR("file: " << _uri << " Does not start with 'RIF' " );
|
||||
return out;
|
||||
}
|
||||
// get the data size :
|
||||
unsigned char tmpData[32];
|
||||
if (fileAccess.fileRead(tmpData, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : \"" << fileAccess << "\"");
|
||||
if (fileIO->read(tmpData, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : " << _uri);
|
||||
return out;
|
||||
}
|
||||
myHeader.size = CONVERT_UINT32(littleEndien, tmpData);
|
||||
|
||||
// get the data size :
|
||||
if (fileAccess.fileRead(&myHeader.waveTag, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : \"" << fileAccess << "\"");
|
||||
if (fileIO->read(&myHeader.waveTag, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : " << _uri);
|
||||
return out;
|
||||
}
|
||||
if( myHeader.waveTag[0] != 'W'
|
||||
|| myHeader.waveTag[1] != 'A'
|
||||
|| myHeader.waveTag[2] != 'V'
|
||||
|| myHeader.waveTag[3] != 'E' ) {
|
||||
EWOLSA_ERROR("file: \"" << fileAccess << "\" This is not a wave file " << myHeader.waveTag[0] << myHeader.waveTag[1] << myHeader.waveTag[2] << myHeader.waveTag[3] );
|
||||
EWOLSA_ERROR("file: " << _uri << " This is not a wave file " << myHeader.waveTag[0] << myHeader.waveTag[1] << myHeader.waveTag[2] << myHeader.waveTag[3] );
|
||||
return out;
|
||||
}
|
||||
|
||||
// get the data size :
|
||||
if (fileAccess.fileRead(&myHeader.fmtTag, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : \"" << fileAccess << "\"");
|
||||
if (fileIO->read(&myHeader.fmtTag, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : " << _uri);
|
||||
return out;
|
||||
}
|
||||
if( myHeader.fmtTag[0] != 'f'
|
||||
|| myHeader.fmtTag[1] != 'm'
|
||||
|| myHeader.fmtTag[2] != 't'
|
||||
|| myHeader.fmtTag[3] != ' ' ) {
|
||||
EWOLSA_ERROR("file: \"" << fileAccess << "\" header error ..." << myHeader.fmtTag[0] << myHeader.fmtTag[1] << myHeader.fmtTag[2] << myHeader.fmtTag[3]);
|
||||
EWOLSA_ERROR("file: " << _uri << " header error ..." << myHeader.fmtTag[0] << myHeader.fmtTag[1] << myHeader.fmtTag[2] << myHeader.fmtTag[3]);
|
||||
return out;
|
||||
}
|
||||
// get the data size :
|
||||
if (fileAccess.fileRead(tmpData, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : \"" << fileAccess << "\"");
|
||||
if (fileIO->read(tmpData, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : " << _uri);
|
||||
return out;
|
||||
}
|
||||
myHeader.waveFormatSize = CONVERT_UINT32(littleEndien, tmpData);
|
||||
|
||||
if (myHeader.waveFormatSize != 16) {
|
||||
EWOLSA_ERROR("file : \"" << fileAccess << "\" == > header error ...");
|
||||
EWOLSA_ERROR("file : " << _uri << " == > header error ...");
|
||||
return out;
|
||||
}
|
||||
if (fileAccess.fileRead(tmpData, 1, 16)!=16) {
|
||||
EWOLSA_ERROR("Can not 16 element in the file : \"" << fileAccess << "\"");
|
||||
if (fileIO->read(tmpData, 1, 16)!=16) {
|
||||
EWOLSA_ERROR("Can not 16 element in the file : " << _uri);
|
||||
return out;
|
||||
}
|
||||
unsigned char * tmppp = tmpData;
|
||||
@ -170,20 +172,20 @@ std::vector<float> audio::ess::wav::loadAudioFile(const std::string& _filename,
|
||||
EWOLSA_DEBUG(" bytesPerFrame : " << myHeader.waveFormat.bytesPerFrame);
|
||||
EWOLSA_DEBUG(" bitsPerSample : " << myHeader.waveFormat.bitsPerSample);
|
||||
// get the data size :
|
||||
if (fileAccess.fileRead(&myHeader.dataTag, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : \"" << fileAccess << "\"");
|
||||
if (fileIO->read(&myHeader.dataTag, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : " << _uri);
|
||||
return out;
|
||||
}
|
||||
if( myHeader.dataTag[0] != 'd'
|
||||
|| myHeader.dataTag[1] != 'a'
|
||||
|| myHeader.dataTag[2] != 't'
|
||||
|| myHeader.dataTag[3] != 'a' ) {
|
||||
EWOLSA_ERROR("file: \"" << fileAccess << "\" header error ..." << myHeader.dataTag[0] << myHeader.dataTag[1] << myHeader.dataTag[2] << myHeader.dataTag[3]);
|
||||
EWOLSA_ERROR("file: " << _uri << " header error ..." << myHeader.dataTag[0] << myHeader.dataTag[1] << myHeader.dataTag[2] << myHeader.dataTag[3]);
|
||||
return out;
|
||||
}
|
||||
// get the data size :
|
||||
if (fileAccess.fileRead(tmpData, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : \"" << fileAccess << "\"");
|
||||
if (fileIO->read(tmpData, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Can not 4 element in the file : " << _uri);
|
||||
return out;
|
||||
}
|
||||
myHeader.dataSize = CONVERT_UINT32(littleEndien, tmpData);
|
||||
@ -194,22 +196,22 @@ std::vector<float> audio::ess::wav::loadAudioFile(const std::string& _filename,
|
||||
|
||||
//Parse the data and transform it if needed ...
|
||||
if (COMPR_PCM != myHeader.waveFormat.type) {
|
||||
EWOLSA_ERROR("File : \"" << fileAccess << "\" == > support only PCM compression ...");
|
||||
EWOLSA_ERROR("File : " << _uri << " == > support only PCM compression ...");
|
||||
return out;
|
||||
}
|
||||
if (myHeader.waveFormat.channelCount == 0 || myHeader.waveFormat.channelCount>2) {
|
||||
EWOLSA_ERROR("File : \"" << fileAccess << "\" == > support only mono or stereo ..." << myHeader.waveFormat.channelCount);
|
||||
EWOLSA_ERROR("File : " << _uri << " == > support only mono or stereo ..." << myHeader.waveFormat.channelCount);
|
||||
return out;
|
||||
}
|
||||
if ( ! ( myHeader.waveFormat.bitsPerSample == 16
|
||||
|| myHeader.waveFormat.bitsPerSample == 24
|
||||
|| myHeader.waveFormat.bitsPerSample == 32 ) ) {
|
||||
EWOLSA_ERROR("File : \"" << fileAccess << "\" == > not supported bit/sample ..." << myHeader.waveFormat.bitsPerSample);
|
||||
EWOLSA_ERROR("File : " << _uri << " == > not supported bit/sample ..." << myHeader.waveFormat.bitsPerSample);
|
||||
return out;
|
||||
}
|
||||
if( ! ( 44100 == myHeader.waveFormat.samplesPerSec
|
||||
|| 48000 == myHeader.waveFormat.samplesPerSec) ) {
|
||||
EWOLSA_ERROR("File : \"" << fileAccess << "\" == > not supported frequency " << myHeader.waveFormat.samplesPerSec << " != 48000");
|
||||
EWOLSA_ERROR("File : " << _uri << " == > not supported frequency " << myHeader.waveFormat.samplesPerSec << " != 48000");
|
||||
return out;
|
||||
}
|
||||
EWOLSA_DEBUG(" dataSize : " << myHeader.dataSize);
|
||||
@ -224,14 +226,14 @@ std::vector<float> audio::ess::wav::loadAudioFile(const std::string& _filename,
|
||||
char audioSample[8];
|
||||
if (myHeader.waveFormat.bitsPerSample == 16) {
|
||||
if (myHeader.waveFormat.channelCount == 1) {
|
||||
if (fileAccess.fileRead(audioSample, 1, 2)!=2) {
|
||||
if (fileIO->read(audioSample, 1, 2)!=2) {
|
||||
EWOLSA_ERROR("Read Error at position : " << iii);
|
||||
return out;
|
||||
}
|
||||
left = ((int32_t)((int16_t)CONVERT_INT16(littleEndien, audioSample))) << 16;
|
||||
right = left;
|
||||
} else {
|
||||
if (fileAccess.fileRead(audioSample, 1, 4)!=4) {
|
||||
if (fileIO->read(audioSample, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Read Error at position : " << iii);
|
||||
return out;
|
||||
}
|
||||
@ -240,14 +242,14 @@ std::vector<float> audio::ess::wav::loadAudioFile(const std::string& _filename,
|
||||
}
|
||||
} else if (myHeader.waveFormat.bitsPerSample == 24) {
|
||||
if (myHeader.waveFormat.channelCount == 1) {
|
||||
if (fileAccess.fileRead(audioSample, 1, 3)!=3) {
|
||||
if (fileIO->read(audioSample, 1, 3)!=3) {
|
||||
EWOLSA_ERROR("Read Error at position : " << iii);
|
||||
return out;
|
||||
}
|
||||
left = CONVERT_INT24(littleEndien, audioSample);
|
||||
right = left;
|
||||
} else {
|
||||
if (fileAccess.fileRead(audioSample, 1, 6)!=6) {
|
||||
if (fileIO->read(audioSample, 1, 6)!=6) {
|
||||
EWOLSA_ERROR("Read Error at position : " << iii);
|
||||
return out;
|
||||
}
|
||||
@ -256,14 +258,14 @@ std::vector<float> audio::ess::wav::loadAudioFile(const std::string& _filename,
|
||||
}
|
||||
} else if (myHeader.waveFormat.bitsPerSample == 32) {
|
||||
if (myHeader.waveFormat.channelCount == 1) {
|
||||
if (fileAccess.fileRead(audioSample, 1, 4)!=4) {
|
||||
if (fileIO->read(audioSample, 1, 4)!=4) {
|
||||
EWOLSA_ERROR("Read Error at position : " << iii);
|
||||
return out;
|
||||
}
|
||||
left = CONVERT_INT32(littleEndien, audioSample);
|
||||
right = left;
|
||||
} else {
|
||||
if (fileAccess.fileRead(audioSample, 1, 8)!=8) {
|
||||
if (fileIO->read(audioSample, 1, 8)!=8) {
|
||||
EWOLSA_ERROR("Read Error at position : " << iii);
|
||||
return out;
|
||||
}
|
||||
@ -280,7 +282,7 @@ std::vector<float> audio::ess::wav::loadAudioFile(const std::string& _filename,
|
||||
}
|
||||
}
|
||||
// close the file:
|
||||
fileAccess.fileClose();
|
||||
fileIO->close();
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace ess {
|
||||
namespace wav {
|
||||
std::vector<float> loadAudioFile(const std::string& _filename, int8_t _nbChan);
|
||||
etk::Vector<float> loadAudioFile(const etk::Uri& _uri, int8_t _nbChan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
@ -14,34 +14,34 @@
|
||||
|
||||
audio::ess::Effects::Effects(const ememory::SharedPtr<audio::river::Manager>& _manager) :
|
||||
m_manager(_manager) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
//Set stereo output:
|
||||
std::vector<audio::channel> channelMap;
|
||||
channelMap.push_back(audio::channel_frontCenter);
|
||||
etk::Vector<audio::channel> channelMap;
|
||||
channelMap.pushBack(audio::channel_frontCenter);
|
||||
m_interface = m_manager->createOutput(48000,
|
||||
channelMap,
|
||||
audio::format_float,
|
||||
"speaker");
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
EWOLSA_ERROR("can not allocate output interface ... ");
|
||||
return;
|
||||
}
|
||||
m_interface->setName("audio::ess::Effects");
|
||||
m_interface->addVolumeGroup("EFFECT");
|
||||
// set callback mode ...
|
||||
m_interface->setOutputCallback(std::bind(&audio::ess::Effects::onDataNeeded,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3,
|
||||
std::placeholders::_4,
|
||||
std::placeholders::_5,
|
||||
std::placeholders::_6));
|
||||
m_interface->setOutputCallback([=] (void* _data,
|
||||
const audio::Time& _playTime,
|
||||
const size_t& _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
const etk::Vector<audio::channel>& _map) {
|
||||
audio::ess::Effects::onDataNeeded(_data, _playTime, _nbChunk, _format, _sampleRate, _map);
|
||||
});
|
||||
m_interface->start();
|
||||
}
|
||||
|
||||
audio::ess::Effects::~Effects() {
|
||||
if (m_interface != nullptr) {
|
||||
if (m_interface != null) {
|
||||
m_interface->stop();
|
||||
}
|
||||
m_interface.reset();
|
||||
@ -52,12 +52,12 @@ audio::ess::Effects::~Effects() {
|
||||
|
||||
|
||||
static bool playData(const ememory::SharedPtr<audio::ess::LoadedFile>& _file, int32_t& _position, float* _bufferInterlace, int32_t _nbSample) {
|
||||
if ( _file == nullptr
|
||||
if ( _file == null
|
||||
|| _file->m_data.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
int32_t processTimeMax = std::min(_nbSample, _file->m_nbSamples - _position);
|
||||
processTimeMax = std::max(0, processTimeMax);
|
||||
int32_t processTimeMax = etk::min(_nbSample, _file->m_nbSamples - _position);
|
||||
processTimeMax = etk::max(0, processTimeMax);
|
||||
float * pointer = _bufferInterlace;
|
||||
const float * newData = &_file->m_data[_position];
|
||||
//EWOLSA_DEBUG("AUDIO : Play slot... nb sample : " << processTimeMax << " playTime=" <<m_playTime << " nbCannels=" << nbChannels);
|
||||
@ -80,11 +80,12 @@ void audio::ess::Effects::onDataNeeded(void* _data,
|
||||
const size_t& _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
const std::vector<audio::channel>& _map){
|
||||
const etk::Vector<audio::channel>& _map){
|
||||
if (_format != audio::format_float) {
|
||||
EWOLSA_ERROR("call wrong type ... (need float)");
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
EWOLSA_VERBOSE(" get data Effect: "<< _nbChunk);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
auto it = m_playing.begin();
|
||||
while (it != m_playing.end()) {
|
||||
bool ret = playData((*it).first, (*it).second, static_cast<float*>(_data), _nbChunk);
|
||||
@ -96,14 +97,14 @@ void audio::ess::Effects::onDataNeeded(void* _data,
|
||||
}
|
||||
}
|
||||
|
||||
void audio::ess::Effects::load(const std::string& _file, const std::string& _name) {
|
||||
void audio::ess::Effects::load(const etk::String& _file, const etk::String& _name) {
|
||||
// load the file:
|
||||
ememory::SharedPtr<audio::ess::LoadedFile> tmp = ememory::makeShared<audio::ess::LoadedFile>(_file, 2);
|
||||
if (tmp == nullptr) {
|
||||
if (tmp == null) {
|
||||
EWOLSA_ERROR("can not load audio Effects = " << _file);
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
int32_t id = -1;
|
||||
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||
if (m_list[iii].first == _name) {
|
||||
@ -112,35 +113,35 @@ void audio::ess::Effects::load(const std::string& _file, const std::string& _nam
|
||||
}
|
||||
}
|
||||
if (-1 <= id) {
|
||||
m_list.push_back(std::pair<std::string,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,tmp));
|
||||
m_list.pushBack(etk::Pair<etk::String,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,tmp));
|
||||
} else {
|
||||
m_list[id].second = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t audio::ess::Effects::getId(const std::string& _name) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
int32_t audio::ess::Effects::getId(const etk::String& _name) {
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||
if (m_list[iii].first == _name) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
m_list.push_back(std::pair<std::string,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,nullptr));
|
||||
m_list.pushBack(etk::Pair<etk::String,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,null));
|
||||
EWOLSA_WARNING("Can not find element name : '" << _name << "' added it ... (empty) ");
|
||||
return m_list.size()-1;
|
||||
}
|
||||
|
||||
void audio::ess::Effects::play(int32_t _id, const vec3& _pos) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
if ( _id < 0
|
||||
|| _id >= m_list.size()) {
|
||||
EWOLSA_ERROR(" Can not play element audio with ID=" << _id << " out of [0.." << m_list.size() << "[");
|
||||
return;
|
||||
}
|
||||
m_playing.push_back(std::pair<ememory::SharedPtr<audio::ess::LoadedFile>, int32_t>(m_list[_id].second, 0));
|
||||
m_playing.pushBack(etk::Pair<ememory::SharedPtr<audio::ess::LoadedFile>, int32_t>(m_list[_id].second, 0));
|
||||
}
|
||||
|
||||
void audio::ess::Effects::play(const std::string& _name, const vec3& _pos) {
|
||||
void audio::ess::Effects::play(const etk::String& _name, const vec3& _pos) {
|
||||
play(getId(_name),_pos);
|
||||
}
|
||||
|
||||
@ -148,12 +149,12 @@ void audio::ess::Effects::stop() {
|
||||
if (m_playing.size() == 0) {
|
||||
EWOLSA_INFO("No current audio is playing");
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
m_playing.clear();
|
||||
}
|
||||
|
||||
void audio::ess::Effects::clear() {
|
||||
stop();
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
m_list.clear();
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -10,13 +10,13 @@
|
||||
#include <audio/river/Interface.hpp>
|
||||
#include <audio/river/Manager.hpp>
|
||||
#include <audio/ess/LoadedFile.hpp>
|
||||
#include <mutex>
|
||||
#include <ethread/Mutex.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace ess {
|
||||
class Effects {
|
||||
private:
|
||||
mutable std::mutex m_mutex;
|
||||
mutable ethread::Mutex m_mutex;
|
||||
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||
public:
|
||||
@ -28,13 +28,13 @@ namespace audio {
|
||||
const size_t& _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
const std::vector<audio::channel>& _map);
|
||||
std::vector<std::pair<ememory::SharedPtr<audio::ess::LoadedFile>, int32_t>> m_playing; //!< current music read
|
||||
std::vector<std::pair<std::string, ememory::SharedPtr<audio::ess::LoadedFile>>> m_list; //!< list of all effect loaded
|
||||
const etk::Vector<audio::channel>& _map);
|
||||
etk::Vector<etk::Pair<ememory::SharedPtr<audio::ess::LoadedFile>, int32_t>> m_playing; //!< current music read
|
||||
etk::Vector<etk::Pair<etk::String, ememory::SharedPtr<audio::ess::LoadedFile>>> m_list; //!< list of all effect loaded
|
||||
public:
|
||||
void load(const std::string& _file, const std::string& _name);
|
||||
int32_t getId(const std::string& _name);
|
||||
void play(const std::string& _name, const vec3& _pos = vec3(0,0,0));
|
||||
void load(const etk::String& _file, const etk::String& _name);
|
||||
int32_t getId(const etk::String& _name);
|
||||
void play(const etk::String& _name, const vec3& _pos = vec3(0,0,0));
|
||||
void play(int32_t _id, const vec3& _pos = vec3(0,0,0));
|
||||
void stop();
|
||||
void clear();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#include <audio/ess/ess.hpp>
|
||||
#include <audio/ess/debug.hpp>
|
||||
#include <ejson/ejson.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
|
||||
ememory::SharedPtr<audio::river::Manager> g_audioManager;
|
||||
ememory::SharedPtr<audio::ess::Effects> g_effects;
|
||||
@ -29,119 +30,121 @@ void audio::ess::unInit() {
|
||||
g_audioManager.reset();
|
||||
}
|
||||
|
||||
void audio::ess::soundSetParse(const std::string& _data) {
|
||||
void audio::ess::soundSetParse(const etk::String& _data) {
|
||||
ejson::Document doc;
|
||||
doc.parse(_data);
|
||||
ejson::Object obj = doc["musics"].toObject();
|
||||
if ( obj.exist() == true
|
||||
&& g_music != nullptr) {
|
||||
&& g_music != null) {
|
||||
for (auto &it : obj.getKeys()) {
|
||||
std::string file = obj[it].toString().get();
|
||||
etk::String file = obj[it].toString().get();
|
||||
EWOLSA_INFO("load Music : '" << it << "' file=" << file);
|
||||
g_music->load(file, it);
|
||||
}
|
||||
}
|
||||
obj = doc["effects"].toObject();
|
||||
if ( obj.exist() == true
|
||||
&& g_effects != nullptr) {
|
||||
&& g_effects != null) {
|
||||
for (auto &it : obj.getKeys()) {
|
||||
std::string file = obj[it].toString().get();
|
||||
etk::String file = obj[it].toString().get();
|
||||
EWOLSA_INFO("load Effect : '" << it << "' file=" << file);
|
||||
g_effects->load(file, it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void audio::ess::soundSetLoad(const std::string& _file) {
|
||||
soundSetParse(etk::FSNodeReadAllData(_file));
|
||||
void audio::ess::soundSetLoad(const etk::Uri& _uri) {
|
||||
etk::String data;
|
||||
etk::uri::readAll(_uri, data);
|
||||
soundSetParse(data);
|
||||
}
|
||||
|
||||
void audio::ess::musicPlay(const std::string& _name) {
|
||||
if (g_music == nullptr) {
|
||||
void audio::ess::musicPlay(const etk::String& _name) {
|
||||
if (g_music == null) {
|
||||
return;
|
||||
}
|
||||
g_music->play(_name);
|
||||
}
|
||||
|
||||
void audio::ess::musicStop() {
|
||||
if (g_music == nullptr) {
|
||||
if (g_music == null) {
|
||||
return;
|
||||
}
|
||||
g_music->stop();
|
||||
}
|
||||
|
||||
void audio::ess::musicSetVolume(float _dB) {
|
||||
if (g_audioManager == nullptr) {
|
||||
if (g_audioManager == null) {
|
||||
return;
|
||||
}
|
||||
g_audioManager->setVolume("MUSIC", _dB);
|
||||
}
|
||||
|
||||
float audio::ess::musicGetVolume() {
|
||||
if (g_audioManager == nullptr) {
|
||||
if (g_audioManager == null) {
|
||||
return 0.0f;
|
||||
}
|
||||
return g_audioManager->getVolume("MUSIC");
|
||||
}
|
||||
|
||||
void audio::ess::musicSetMute(bool _mute) {
|
||||
if (g_audioManager == nullptr) {
|
||||
if (g_audioManager == null) {
|
||||
return;
|
||||
}
|
||||
g_audioManager->setMute("MUSIC", _mute);
|
||||
}
|
||||
|
||||
bool audio::ess::musicGetMute() {
|
||||
if (g_audioManager == nullptr) {
|
||||
if (g_audioManager == null) {
|
||||
return 0.0f;
|
||||
}
|
||||
return g_audioManager->getMute("MUSIC");
|
||||
}
|
||||
|
||||
int32_t audio::ess::effectGetId(const std::string& _name) {
|
||||
if (g_effects == nullptr) {
|
||||
int32_t audio::ess::effectGetId(const etk::String& _name) {
|
||||
if (g_effects == null) {
|
||||
return -1;
|
||||
}
|
||||
return g_effects->getId(_name);
|
||||
}
|
||||
|
||||
void audio::ess::effectPlay(int32_t _id, const vec3& _pos) {
|
||||
if (g_effects == nullptr) {
|
||||
if (g_effects == null) {
|
||||
return;
|
||||
}
|
||||
g_effects->play(_id, _pos);
|
||||
}
|
||||
|
||||
void audio::ess::effectPlay(const std::string& _name, const vec3& _pos) {
|
||||
if (g_effects == nullptr) {
|
||||
void audio::ess::effectPlay(const etk::String& _name, const vec3& _pos) {
|
||||
if (g_effects == null) {
|
||||
return;
|
||||
}
|
||||
g_effects->play(_name, _pos);
|
||||
}
|
||||
|
||||
void audio::ess::effectSetVolume(float _dB) {
|
||||
if (g_audioManager == nullptr) {
|
||||
if (g_audioManager == null) {
|
||||
return;
|
||||
}
|
||||
g_audioManager->setVolume("EFFECT", _dB);
|
||||
}
|
||||
|
||||
float audio::ess::effectGetVolume() {
|
||||
if (g_audioManager == nullptr) {
|
||||
if (g_audioManager == null) {
|
||||
return 0.0f;
|
||||
}
|
||||
return g_audioManager->getVolume("EFFECT");
|
||||
}
|
||||
|
||||
void audio::ess::effectSetMute(bool _mute) {
|
||||
if (g_audioManager == nullptr) {
|
||||
if (g_audioManager == null) {
|
||||
return;
|
||||
}
|
||||
g_audioManager->setMute("EFFECT", _mute);
|
||||
}
|
||||
|
||||
bool audio::ess::effectGetMute() {
|
||||
if (g_audioManager == nullptr) {
|
||||
if (g_audioManager == null) {
|
||||
return 0.0f;
|
||||
}
|
||||
return g_audioManager->getMute("EFFECT");
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -29,18 +29,18 @@ namespace audio {
|
||||
* @brief Parse a JSON configuration data of a soundset
|
||||
* @param[in] _data JSON string data to parse
|
||||
*/
|
||||
void soundSetParse(const std::string& _data);
|
||||
void soundSetParse(const etk::String& _data);
|
||||
/**
|
||||
* @brief Parse a configuration file of a soundset
|
||||
* @param[in] _file JSON file to parse
|
||||
* @param[in] _uri JSON file to parse
|
||||
*/
|
||||
void soundSetLoad(const std::string& _file);
|
||||
void soundSetLoad(const etk::Uri& _uri);
|
||||
|
||||
/**
|
||||
* @brief Play a music with his name
|
||||
* @param[in] _name Name of the music (not the Path)
|
||||
*/
|
||||
void musicPlay(const std::string& _name);
|
||||
void musicPlay(const etk::String& _name);
|
||||
/**
|
||||
* @brief Stop the music played
|
||||
*/
|
||||
@ -72,7 +72,7 @@ namespace audio {
|
||||
* @param[in] _name Name of the effects
|
||||
* @return the effect ID or -1 if it does not exist...
|
||||
*/
|
||||
int32_t effectGetId(const std::string& _name);
|
||||
int32_t effectGetId(const etk::String& _name);
|
||||
/**
|
||||
* @brief Play an effect with his ID
|
||||
* @param[in] _id Id of the effect to play
|
||||
@ -84,7 +84,7 @@ namespace audio {
|
||||
* @param[in] _name Name of the effect to play
|
||||
* @param[in] _pos position of the efffect is played (not used / not implemented)
|
||||
*/
|
||||
void effectPlay(const std::string& _name, const vec3& _pos=vec3(0,0,0));
|
||||
void effectPlay(const etk::String& _name, const vec3& _pos=vec3(0,0,0));
|
||||
/**
|
||||
* @brief Set the effects volume
|
||||
* @param[in] _dB apply decibel volume at the effects [-100..100]
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
@ -15,35 +15,35 @@
|
||||
audio::ess::Music::Music(const ememory::SharedPtr<audio::river::Manager>& _manager) :
|
||||
m_manager(_manager),
|
||||
m_position(0) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
//Set stereo output:
|
||||
std::vector<audio::channel> channelMap;
|
||||
channelMap.push_back(audio::channel_frontLeft);
|
||||
channelMap.push_back(audio::channel_frontRight);
|
||||
etk::Vector<audio::channel> channelMap;
|
||||
channelMap.pushBack(audio::channel_frontLeft);
|
||||
channelMap.pushBack(audio::channel_frontRight);
|
||||
m_interface = m_manager->createOutput(48000,
|
||||
channelMap,
|
||||
audio::format_float,
|
||||
"speaker");
|
||||
if (m_interface == nullptr) {
|
||||
if (m_interface == null) {
|
||||
EWOLSA_ERROR("can not allocate output interface ... ");
|
||||
return;
|
||||
}
|
||||
m_interface->setName("audio::ess::music");
|
||||
m_interface->addVolumeGroup("MUSIC");
|
||||
// set callback mode ...
|
||||
m_interface->setOutputCallback(std::bind(&audio::ess::Music::onDataNeeded,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3,
|
||||
std::placeholders::_4,
|
||||
std::placeholders::_5,
|
||||
std::placeholders::_6));
|
||||
m_interface->setOutputCallback([=] (void* _data,
|
||||
const audio::Time& _playTime,
|
||||
const size_t& _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
const etk::Vector<audio::channel>& _map) {
|
||||
audio::ess::Music::onDataNeeded(_data, _playTime, _nbChunk, _format, _sampleRate, _map);
|
||||
});
|
||||
m_interface->start();
|
||||
}
|
||||
|
||||
audio::ess::Music::~Music() {
|
||||
if (m_interface != nullptr) {
|
||||
if (m_interface != null) {
|
||||
m_interface->stop();
|
||||
}
|
||||
m_interface.reset();
|
||||
@ -59,25 +59,26 @@ void audio::ess::Music::onDataNeeded(void* _data,
|
||||
const size_t& _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
const std::vector<audio::channel>& _map){
|
||||
const etk::Vector<audio::channel>& _map){
|
||||
if (_format != audio::format_float) {
|
||||
EWOLSA_ERROR("call wrong type ... (need float)");
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
EWOLSA_VERBOSE(" get data Music: "<< _nbChunk);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
if (m_current != m_next) {
|
||||
EWOLSA_INFO("change track " << (m_current==nullptr?-1:m_current->getUId()) << " ==> " << (m_next==nullptr?-1:m_next->getUId()));
|
||||
EWOLSA_INFO("change track " << (m_current==null?-1:m_current->getUId()) << " ==> " << (m_next==null?-1:m_next->getUId()));
|
||||
m_current = m_next;
|
||||
m_position = 0;
|
||||
}
|
||||
if (m_current == nullptr) {
|
||||
if (m_current == null) {
|
||||
// nothing to play ...
|
||||
return;
|
||||
}
|
||||
if (m_current->m_data.size() == 0) {
|
||||
return;
|
||||
}
|
||||
int32_t processTimeMax = std::min(int32_t(_nbChunk*_map.size()), int32_t(m_current->m_nbSamples - m_position));
|
||||
processTimeMax = std::max(0, processTimeMax);
|
||||
int32_t processTimeMax = etk::min(int32_t(_nbChunk*_map.size()), int32_t(m_current->m_nbSamples - m_position));
|
||||
processTimeMax = etk::max(0, processTimeMax);
|
||||
float * pointer = static_cast<float*>(_data);
|
||||
float * newData = &m_current->m_data[m_position];
|
||||
EWOLSA_VERBOSE("AUDIO : Play slot... nb sample : " << processTimeMax << " map=" << _map << " _nbChunk=" << _nbChunk);
|
||||
@ -92,21 +93,21 @@ void audio::ess::Music::onDataNeeded(void* _data,
|
||||
}
|
||||
}
|
||||
|
||||
void audio::ess::Music::load(const std::string& _file, const std::string& _name) {
|
||||
void audio::ess::Music::load(const etk::String& _file, const etk::String& _name) {
|
||||
auto it = m_list.find(_name);
|
||||
if (it != m_list.end()) {
|
||||
return;
|
||||
}
|
||||
ememory::SharedPtr<audio::ess::LoadedFile> tmp = ememory::makeShared<audio::ess::LoadedFile>(_file, 2);
|
||||
if (tmp == nullptr) {
|
||||
if (tmp == null) {
|
||||
EWOLSA_ERROR("can not load audio Music = " << _file);
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
m_list.insert(std::pair<std::string,ememory::SharedPtr<audio::ess::LoadedFile>>(_name,tmp));
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
m_list.add(_name, tmp);
|
||||
}
|
||||
|
||||
void audio::ess::Music::play(const std::string& _name) {
|
||||
void audio::ess::Music::play(const etk::String& _name) {
|
||||
auto it = m_list.find(_name);
|
||||
if (it == m_list.end()) {
|
||||
EWOLSA_ERROR("Can not Play music : " << _name);
|
||||
@ -114,16 +115,16 @@ void audio::ess::Music::play(const std::string& _name) {
|
||||
}
|
||||
// in all case we stop the current playing music ...
|
||||
stop();
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
m_next = it->second;
|
||||
EWOLSA_INFO("Playing track " << (m_current==nullptr?-1:m_current->getUId()) << " request next : " << m_next->getUId());
|
||||
EWOLSA_INFO("Playing track " << (m_current==null?-1:m_current->getUId()) << " request next : " << m_next->getUId());
|
||||
}
|
||||
|
||||
void audio::ess::Music::stop() {
|
||||
if (m_current == nullptr) {
|
||||
if (m_current == null) {
|
||||
EWOLSA_INFO("No current audio is playing");
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
ethread::UniqueLock lock(m_mutex);
|
||||
m_current.reset();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
@ -9,15 +9,15 @@
|
||||
#include <audio/river/Interface.hpp>
|
||||
#include <audio/river/Manager.hpp>
|
||||
#include <audio/ess/LoadedFile.hpp>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
#include <ethread/Mutex.hpp>
|
||||
#include <etk/Map.hpp>
|
||||
|
||||
|
||||
namespace audio {
|
||||
namespace ess {
|
||||
class Music {
|
||||
private:
|
||||
mutable std::mutex m_mutex;
|
||||
mutable ethread::Mutex m_mutex;
|
||||
ememory::SharedPtr<audio::river::Manager> m_manager;
|
||||
ememory::SharedPtr<audio::river::Interface> m_interface;
|
||||
public:
|
||||
@ -29,14 +29,14 @@ namespace audio {
|
||||
const size_t& _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
const std::vector<audio::channel>& _map);
|
||||
const etk::Vector<audio::channel>& _map);
|
||||
ememory::SharedPtr<audio::ess::LoadedFile> m_current; //!< current music read
|
||||
int32_t m_position; //!< current position of music read
|
||||
std::map<std::string, ememory::SharedPtr<audio::ess::LoadedFile> > m_list; //!< list of all music loaded
|
||||
etk::Map<etk::String, ememory::SharedPtr<audio::ess::LoadedFile> > m_list; //!< list of all music loaded
|
||||
ememory::SharedPtr<audio::ess::LoadedFile> m_next; //!< next music to read
|
||||
public:
|
||||
void load(const std::string& _file, const std::string& _name);
|
||||
void play(const std::string& _name);
|
||||
void load(const etk::String& _file, const etk::String& _name);
|
||||
void play(const etk::String& _name);
|
||||
void stop();
|
||||
void clear();
|
||||
};
|
||||
|
@ -31,16 +31,16 @@ Are there any licensing restrictions? {#audio_ess_mainpage_license_re
|
||||
AUDIO-ESS is **FREE software** and _all sub-library are FREE and staticly linkable !!!_
|
||||
|
||||
|
||||
License (APACHE-2.0) {#audio_ess_mainpage_license}
|
||||
====================
|
||||
License (MPL v2.0) {#audio_ess_mainpage_license}
|
||||
==================
|
||||
|
||||
Copyright AUDIO-ESS Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
Licensed under the Mozilla Public License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
<http://www.apache.org/licenses/LICENSE-2.0>
|
||||
<https://www.mozilla.org/MPL/2.0>
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
@ -24,14 +24,14 @@ A simple example:
|
||||
```{.json}
|
||||
{
|
||||
musics:{
|
||||
"BG-1":"DATA:audio/Clean Soul.ogg"
|
||||
"BG-22":"DATA:audio/Dark knight.ogg"
|
||||
"BG-1":"DATA:///audio/Clean Soul.ogg"
|
||||
"BG-22":"DATA:///audio/Dark knight.ogg"
|
||||
},
|
||||
effects:{
|
||||
"end":"DATA:audio/end.wav",
|
||||
"error":"DATA:audio/error.wav",
|
||||
"levelup":"DATA:audio/levelup.wav",
|
||||
"ok":"DATA:audio/ok.wav"
|
||||
"end":"DATA:///audio/end.wav",
|
||||
"error":"DATA:///audio/error.wav",
|
||||
"levelup":"DATA:///audio/levelup.wav",
|
||||
"ok":"DATA:///audio/ok.wav"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
13
license.txt
13
license.txt
@ -1,13 +0,0 @@
|
||||
Copyright ewolsa Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
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,6 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.tools as tools
|
||||
import lutin.debug as debug
|
||||
import realog.debug as debug
|
||||
|
||||
|
||||
def get_type():
|
||||
@ -10,7 +10,7 @@ def get_desc():
|
||||
return "ewol sound set interface for 'small game' audio effects"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
|
@ -1 +1 @@
|
||||
0.4.0
|
||||
1.0.0
|
Loading…
x
Reference in New Issue
Block a user