From feeafde0739a9cb63edae3545ba9af7448f51c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sat, 17 Mar 2018 18:50:24 -0300 Subject: [PATCH] Updated Audio module. --HG-- branch : dev --- include/eepp/audio.hpp | 15 +- include/eepp/audio/README | 22 + include/eepp/audio/alresource.hpp | 17 + include/eepp/audio/audiodevice.hpp | 34 - include/eepp/audio/audiolistener.hpp | 41 - include/eepp/audio/base.hpp | 31 - include/eepp/audio/inputsoundfile.hpp | 226 + include/eepp/audio/listener.hpp | 201 + include/eepp/audio/music.hpp | 296 +- include/eepp/audio/outputsoundfile.hpp | 80 + include/eepp/audio/sound.hpp | 273 +- include/eepp/audio/soundbuffer.hpp | 313 +- include/eepp/audio/soundbufferrecorder.hpp | 103 + include/eepp/audio/soundfilefactory.hpp | 150 + include/eepp/audio/soundfilefactory.inl | 62 + include/eepp/audio/soundfilereader.hpp | 129 + include/eepp/audio/soundfilewriter.hpp | 86 + include/eepp/audio/soundloader.hpp | 5 +- include/eepp/audio/soundmanager.hpp | 16 +- include/eepp/audio/soundrecorder.hpp | 370 + include/eepp/audio/soundsource.hpp | 278 + include/eepp/audio/soundstream.hpp | 425 +- include/eepp/system/iostreamfile.hpp | 4 +- premake4.lua | 17 +- .../android-project-ant/AndroidManifest.xml | 35 - projects/android-project-ant/README | 3 - projects/android-project-ant/assets.sh | 4 - projects/android-project-ant/build.properties | 17 - projects/android-project-ant/build.sh | 10 - projects/android-project-ant/build.xml | 85 - projects/android-project-ant/clean.sh | 3 - .../android-project-ant/default.properties | 11 - projects/android-project-ant/jni/Android.mk | 69 - .../android-project-ant/jni/Application.mk | 25 - projects/android-project-ant/jni/eepp.mk | 209 - projects/android-project-ant/local.properties | 12 - .../android-project-ant/res/layout/main.xml | 13 - .../res/mipmap-hdpi/ic_launcher.png | Bin 12468 -> 0 bytes .../res/mipmap-ldpi/ic_launcher.png | Bin 3604 -> 0 bytes .../res/mipmap-mdpi/ic_launcher.png | Bin 6228 -> 0 bytes .../res/mipmap-xhdpi/ic_launcher.png | Bin 20914 -> 0 bytes .../res/mipmap-xxhdpi/ic_launcher.png | Bin 40792 -> 0 bytes .../res/values/strings.xml | 4 - .../src/org/libsdl/app/SDLActivity.java | 1077 -- projects/android-project/app/jni/eepp.mk | 8 +- projects/linux/ee.creator.user | 4 +- projects/linux/ee.files | 796 + projects/linux/ee.includes | 3 + src/eepp/audio/alcheck.cpp | 56 + src/eepp/audio/alcheck.hpp | 28 + src/eepp/audio/alresource.cpp | 47 + src/eepp/audio/audiodevice.cpp | 206 +- src/eepp/audio/audiodevice.hpp | 150 + src/eepp/audio/audiolistener.cpp | 63 - src/eepp/audio/inputsoundfile.cpp | 199 + src/eepp/audio/listener.cpp | 51 + src/eepp/audio/music.cpp | 234 +- src/eepp/audio/openal.cpp | 47 - src/eepp/audio/openal.hpp | 32 - src/eepp/audio/outputsoundfile.cpp | 45 + src/eepp/audio/sound.cpp | 221 +- src/eepp/audio/soundbuffer.cpp | 244 +- src/eepp/audio/soundbufferrecorder.cpp | 34 + src/eepp/audio/soundfile.cpp | 163 - src/eepp/audio/soundfile.hpp | 73 - src/eepp/audio/soundfiledefault.cpp | 278 - src/eepp/audio/soundfiledefault.hpp | 62 - src/eepp/audio/soundfilefactory.cpp | 111 + src/eepp/audio/soundfileogg.cpp | 111 - src/eepp/audio/soundfileogg.hpp | 36 - src/eepp/audio/soundfilereaderogg.cpp | 125 + src/eepp/audio/soundfilereaderogg.hpp | 75 + src/eepp/audio/soundfilereaderwav.cpp | 286 + src/eepp/audio/soundfilereaderwav.hpp | 89 + src/eepp/audio/soundfilewriterogg.cpp | 161 + src/eepp/audio/soundfilewriterogg.hpp | 66 + src/eepp/audio/soundfilewriterwav.cpp | 148 + src/eepp/audio/soundfilewriterwav.hpp | 74 + src/eepp/audio/soundrecorder.cpp | 240 + src/eepp/audio/soundsource.cpp | 122 + src/eepp/audio/soundstream.cpp | 393 +- src/eepp/graphics/console.cpp | 4 +- src/eepp/system/iostreamfile.cpp | 33 +- src/eepp/system/iostreammemory.cpp | 21 +- src/eepp/system/log.cpp | 1 + src/eepp/window/engine.cpp | 1 - src/examples/empty_window/empty_window.cpp | 4 + src/examples/http_request/http_request.cpp | 1 + src/examples/sound/sound.cpp | 21 +- .../libogg/include/ogg/config_types.h | 25 + src/thirdparty/libogg/include/ogg/ogg.h | 210 + src/thirdparty/libogg/include/ogg/os_types.h | 148 + src/thirdparty/libogg/src/bitwise.c | 1088 ++ src/thirdparty/libogg/src/framing.c | 2140 +++ .../libvorbis/include/vorbis/codec.h | 242 + .../libvorbis/include/vorbis/vorbisenc.h | 435 + .../libvorbis/include/vorbis/vorbisfile.h | 205 + src/thirdparty/libvorbis/lib/analysis.c | 119 + src/thirdparty/libvorbis/lib/backends.h | 143 + src/thirdparty/libvorbis/lib/barkmel.c | 63 + src/thirdparty/libvorbis/lib/bitrate.c | 252 + src/thirdparty/libvorbis/lib/bitrate.h | 58 + src/thirdparty/libvorbis/lib/block.c | 1046 + .../lib/books/coupled/res_books_51.h | 12273 ++++++++++++ .../lib/books/coupled/res_books_stereo.h | 15782 ++++++++++++++++ .../libvorbis/lib/books/floor/floor_books.h | 1546 ++ .../lib/books/uncoupled/res_books_uncoupled.h | 7757 ++++++++ src/thirdparty/libvorbis/lib/codebook.c | 461 + src/thirdparty/libvorbis/lib/codebook.h | 117 + src/thirdparty/libvorbis/lib/codec_internal.h | 166 + src/thirdparty/libvorbis/lib/envelope.c | 374 + src/thirdparty/libvorbis/lib/envelope.h | 79 + src/thirdparty/libvorbis/lib/floor0.c | 223 + src/thirdparty/libvorbis/lib/floor1.c | 1086 ++ src/thirdparty/libvorbis/lib/highlevel.h | 57 + src/thirdparty/libvorbis/lib/info.c | 679 + src/thirdparty/libvorbis/lib/lookup.c | 93 + src/thirdparty/libvorbis/lib/lookup.h | 31 + src/thirdparty/libvorbis/lib/lookup_data.h | 191 + src/thirdparty/libvorbis/lib/lpc.c | 159 + src/thirdparty/libvorbis/lib/lpc.h | 28 + src/thirdparty/libvorbis/lib/lsp.c | 453 + src/thirdparty/libvorbis/lib/lsp.h | 27 + src/thirdparty/libvorbis/lib/mapping0.c | 808 + src/thirdparty/libvorbis/lib/masking.h | 784 + src/thirdparty/libvorbis/lib/mdct.c | 562 + src/thirdparty/libvorbis/lib/mdct.h | 70 + src/thirdparty/libvorbis/lib/misc.h | 57 + .../libvorbis/lib/modes/floor_all.h | 259 + src/thirdparty/libvorbis/lib/modes/psych_11.h | 50 + src/thirdparty/libvorbis/lib/modes/psych_16.h | 132 + src/thirdparty/libvorbis/lib/modes/psych_44.h | 641 + src/thirdparty/libvorbis/lib/modes/psych_8.h | 100 + .../libvorbis/lib/modes/residue_16.h | 162 + .../libvorbis/lib/modes/residue_44.h | 291 + .../libvorbis/lib/modes/residue_44p51.h | 450 + .../libvorbis/lib/modes/residue_44u.h | 317 + .../libvorbis/lib/modes/residue_8.h | 108 + src/thirdparty/libvorbis/lib/modes/setup_11.h | 142 + src/thirdparty/libvorbis/lib/modes/setup_16.h | 152 + src/thirdparty/libvorbis/lib/modes/setup_22.h | 127 + src/thirdparty/libvorbis/lib/modes/setup_32.h | 131 + src/thirdparty/libvorbis/lib/modes/setup_44.h | 116 + .../libvorbis/lib/modes/setup_44p51.h | 73 + .../libvorbis/lib/modes/setup_44u.h | 73 + src/thirdparty/libvorbis/lib/modes/setup_8.h | 148 + src/thirdparty/libvorbis/lib/modes/setup_X.h | 224 + src/thirdparty/libvorbis/lib/os.h | 190 + src/thirdparty/libvorbis/lib/psy.c | 1205 ++ src/thirdparty/libvorbis/lib/psy.h | 153 + src/thirdparty/libvorbis/lib/registry.c | 44 + src/thirdparty/libvorbis/lib/registry.h | 31 + src/thirdparty/libvorbis/lib/res0.c | 889 + src/thirdparty/libvorbis/lib/scales.h | 89 + src/thirdparty/libvorbis/lib/sharedbook.c | 595 + src/thirdparty/libvorbis/lib/smallft.c | 1254 ++ src/thirdparty/libvorbis/lib/smallft.h | 33 + src/thirdparty/libvorbis/lib/synthesis.c | 179 + src/thirdparty/libvorbis/lib/tone.c | 54 + src/thirdparty/libvorbis/lib/vorbisenc.c | 1223 ++ src/thirdparty/libvorbis/lib/vorbisfile.c | 2424 +++ src/thirdparty/libvorbis/lib/window.c | 2135 +++ src/thirdparty/libvorbis/lib/window.h | 25 + src/thirdparty/stb_vorbis/stb_vorbis.c | 5010 ----- src/thirdparty/stb_vorbis/stb_vorbis.h | 357 - src/tools/uieditor/uieditor.cpp | 2 - 166 files changed, 70765 insertions(+), 8798 deletions(-) create mode 100644 include/eepp/audio/README create mode 100644 include/eepp/audio/alresource.hpp delete mode 100755 include/eepp/audio/audiodevice.hpp delete mode 100755 include/eepp/audio/audiolistener.hpp delete mode 100644 include/eepp/audio/base.hpp create mode 100644 include/eepp/audio/inputsoundfile.hpp create mode 100644 include/eepp/audio/listener.hpp mode change 100755 => 100644 include/eepp/audio/music.hpp create mode 100644 include/eepp/audio/outputsoundfile.hpp mode change 100755 => 100644 include/eepp/audio/sound.hpp mode change 100755 => 100644 include/eepp/audio/soundbuffer.hpp create mode 100644 include/eepp/audio/soundbufferrecorder.hpp create mode 100644 include/eepp/audio/soundfilefactory.hpp create mode 100644 include/eepp/audio/soundfilefactory.inl create mode 100644 include/eepp/audio/soundfilereader.hpp create mode 100644 include/eepp/audio/soundfilewriter.hpp create mode 100644 include/eepp/audio/soundrecorder.hpp create mode 100644 include/eepp/audio/soundsource.hpp mode change 100755 => 100644 include/eepp/audio/soundstream.hpp delete mode 100644 projects/android-project-ant/AndroidManifest.xml delete mode 100644 projects/android-project-ant/README delete mode 100755 projects/android-project-ant/assets.sh delete mode 100644 projects/android-project-ant/build.properties delete mode 100755 projects/android-project-ant/build.sh delete mode 100644 projects/android-project-ant/build.xml delete mode 100755 projects/android-project-ant/clean.sh delete mode 100644 projects/android-project-ant/default.properties delete mode 100644 projects/android-project-ant/jni/Android.mk delete mode 100644 projects/android-project-ant/jni/Application.mk delete mode 100644 projects/android-project-ant/jni/eepp.mk delete mode 100644 projects/android-project-ant/local.properties delete mode 100644 projects/android-project-ant/res/layout/main.xml delete mode 100644 projects/android-project-ant/res/mipmap-hdpi/ic_launcher.png delete mode 100644 projects/android-project-ant/res/mipmap-ldpi/ic_launcher.png delete mode 100644 projects/android-project-ant/res/mipmap-mdpi/ic_launcher.png delete mode 100644 projects/android-project-ant/res/mipmap-xhdpi/ic_launcher.png delete mode 100644 projects/android-project-ant/res/mipmap-xxhdpi/ic_launcher.png delete mode 100644 projects/android-project-ant/res/values/strings.xml delete mode 100644 projects/android-project-ant/src/org/libsdl/app/SDLActivity.java create mode 100644 src/eepp/audio/alcheck.cpp create mode 100644 src/eepp/audio/alcheck.hpp create mode 100644 src/eepp/audio/alresource.cpp mode change 100755 => 100644 src/eepp/audio/audiodevice.cpp create mode 100644 src/eepp/audio/audiodevice.hpp delete mode 100755 src/eepp/audio/audiolistener.cpp create mode 100644 src/eepp/audio/inputsoundfile.cpp create mode 100644 src/eepp/audio/listener.cpp mode change 100755 => 100644 src/eepp/audio/music.cpp delete mode 100644 src/eepp/audio/openal.cpp delete mode 100755 src/eepp/audio/openal.hpp create mode 100644 src/eepp/audio/outputsoundfile.cpp mode change 100755 => 100644 src/eepp/audio/sound.cpp mode change 100755 => 100644 src/eepp/audio/soundbuffer.cpp create mode 100644 src/eepp/audio/soundbufferrecorder.cpp delete mode 100755 src/eepp/audio/soundfile.cpp delete mode 100755 src/eepp/audio/soundfile.hpp delete mode 100755 src/eepp/audio/soundfiledefault.cpp delete mode 100755 src/eepp/audio/soundfiledefault.hpp create mode 100644 src/eepp/audio/soundfilefactory.cpp delete mode 100755 src/eepp/audio/soundfileogg.cpp delete mode 100755 src/eepp/audio/soundfileogg.hpp create mode 100644 src/eepp/audio/soundfilereaderogg.cpp create mode 100644 src/eepp/audio/soundfilereaderogg.hpp create mode 100644 src/eepp/audio/soundfilereaderwav.cpp create mode 100644 src/eepp/audio/soundfilereaderwav.hpp create mode 100644 src/eepp/audio/soundfilewriterogg.cpp create mode 100644 src/eepp/audio/soundfilewriterogg.hpp create mode 100644 src/eepp/audio/soundfilewriterwav.cpp create mode 100644 src/eepp/audio/soundfilewriterwav.hpp create mode 100644 src/eepp/audio/soundrecorder.cpp create mode 100644 src/eepp/audio/soundsource.cpp mode change 100755 => 100644 src/eepp/audio/soundstream.cpp create mode 100644 src/thirdparty/libogg/include/ogg/config_types.h create mode 100644 src/thirdparty/libogg/include/ogg/ogg.h create mode 100644 src/thirdparty/libogg/include/ogg/os_types.h create mode 100644 src/thirdparty/libogg/src/bitwise.c create mode 100644 src/thirdparty/libogg/src/framing.c create mode 100644 src/thirdparty/libvorbis/include/vorbis/codec.h create mode 100644 src/thirdparty/libvorbis/include/vorbis/vorbisenc.h create mode 100644 src/thirdparty/libvorbis/include/vorbis/vorbisfile.h create mode 100644 src/thirdparty/libvorbis/lib/analysis.c create mode 100644 src/thirdparty/libvorbis/lib/backends.h create mode 100644 src/thirdparty/libvorbis/lib/barkmel.c create mode 100644 src/thirdparty/libvorbis/lib/bitrate.c create mode 100644 src/thirdparty/libvorbis/lib/bitrate.h create mode 100644 src/thirdparty/libvorbis/lib/block.c create mode 100644 src/thirdparty/libvorbis/lib/books/coupled/res_books_51.h create mode 100644 src/thirdparty/libvorbis/lib/books/coupled/res_books_stereo.h create mode 100644 src/thirdparty/libvorbis/lib/books/floor/floor_books.h create mode 100644 src/thirdparty/libvorbis/lib/books/uncoupled/res_books_uncoupled.h create mode 100644 src/thirdparty/libvorbis/lib/codebook.c create mode 100644 src/thirdparty/libvorbis/lib/codebook.h create mode 100644 src/thirdparty/libvorbis/lib/codec_internal.h create mode 100644 src/thirdparty/libvorbis/lib/envelope.c create mode 100644 src/thirdparty/libvorbis/lib/envelope.h create mode 100644 src/thirdparty/libvorbis/lib/floor0.c create mode 100644 src/thirdparty/libvorbis/lib/floor1.c create mode 100644 src/thirdparty/libvorbis/lib/highlevel.h create mode 100644 src/thirdparty/libvorbis/lib/info.c create mode 100644 src/thirdparty/libvorbis/lib/lookup.c create mode 100644 src/thirdparty/libvorbis/lib/lookup.h create mode 100644 src/thirdparty/libvorbis/lib/lookup_data.h create mode 100644 src/thirdparty/libvorbis/lib/lpc.c create mode 100644 src/thirdparty/libvorbis/lib/lpc.h create mode 100644 src/thirdparty/libvorbis/lib/lsp.c create mode 100644 src/thirdparty/libvorbis/lib/lsp.h create mode 100644 src/thirdparty/libvorbis/lib/mapping0.c create mode 100644 src/thirdparty/libvorbis/lib/masking.h create mode 100644 src/thirdparty/libvorbis/lib/mdct.c create mode 100644 src/thirdparty/libvorbis/lib/mdct.h create mode 100644 src/thirdparty/libvorbis/lib/misc.h create mode 100644 src/thirdparty/libvorbis/lib/modes/floor_all.h create mode 100644 src/thirdparty/libvorbis/lib/modes/psych_11.h create mode 100644 src/thirdparty/libvorbis/lib/modes/psych_16.h create mode 100644 src/thirdparty/libvorbis/lib/modes/psych_44.h create mode 100644 src/thirdparty/libvorbis/lib/modes/psych_8.h create mode 100644 src/thirdparty/libvorbis/lib/modes/residue_16.h create mode 100644 src/thirdparty/libvorbis/lib/modes/residue_44.h create mode 100644 src/thirdparty/libvorbis/lib/modes/residue_44p51.h create mode 100644 src/thirdparty/libvorbis/lib/modes/residue_44u.h create mode 100644 src/thirdparty/libvorbis/lib/modes/residue_8.h create mode 100644 src/thirdparty/libvorbis/lib/modes/setup_11.h create mode 100644 src/thirdparty/libvorbis/lib/modes/setup_16.h create mode 100644 src/thirdparty/libvorbis/lib/modes/setup_22.h create mode 100644 src/thirdparty/libvorbis/lib/modes/setup_32.h create mode 100644 src/thirdparty/libvorbis/lib/modes/setup_44.h create mode 100644 src/thirdparty/libvorbis/lib/modes/setup_44p51.h create mode 100644 src/thirdparty/libvorbis/lib/modes/setup_44u.h create mode 100644 src/thirdparty/libvorbis/lib/modes/setup_8.h create mode 100644 src/thirdparty/libvorbis/lib/modes/setup_X.h create mode 100644 src/thirdparty/libvorbis/lib/os.h create mode 100644 src/thirdparty/libvorbis/lib/psy.c create mode 100644 src/thirdparty/libvorbis/lib/psy.h create mode 100644 src/thirdparty/libvorbis/lib/registry.c create mode 100644 src/thirdparty/libvorbis/lib/registry.h create mode 100644 src/thirdparty/libvorbis/lib/res0.c create mode 100644 src/thirdparty/libvorbis/lib/scales.h create mode 100644 src/thirdparty/libvorbis/lib/sharedbook.c create mode 100644 src/thirdparty/libvorbis/lib/smallft.c create mode 100644 src/thirdparty/libvorbis/lib/smallft.h create mode 100644 src/thirdparty/libvorbis/lib/synthesis.c create mode 100644 src/thirdparty/libvorbis/lib/tone.c create mode 100644 src/thirdparty/libvorbis/lib/vorbisenc.c create mode 100644 src/thirdparty/libvorbis/lib/vorbisfile.c create mode 100644 src/thirdparty/libvorbis/lib/window.c create mode 100644 src/thirdparty/libvorbis/lib/window.h delete mode 100644 src/thirdparty/stb_vorbis/stb_vorbis.c delete mode 100644 src/thirdparty/stb_vorbis/stb_vorbis.h diff --git a/include/eepp/audio.hpp b/include/eepp/audio.hpp index c268961ff..f8c02d48c 100644 --- a/include/eepp/audio.hpp +++ b/include/eepp/audio.hpp @@ -1,12 +1,21 @@ #ifndef EEPP_AUDIO_HPP #define EEPP_AUDIO_HPP -#include -#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include #include -#include + #include #include diff --git a/include/eepp/audio/README b/include/eepp/audio/README new file mode 100644 index 000000000..f71eeba69 --- /dev/null +++ b/include/eepp/audio/README @@ -0,0 +1,22 @@ + +This module is an adaptation of the sfml-audio module. + +SFML - Simple and Fast Multimedia Library +Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org) + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it freely, +subject to the following restrictions: + +1. The origin of this software must not be misrepresented; + you must not claim that you wrote the original software. + If you use this software in a product, an acknowledgment + in the product documentation would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, + and must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source distribution. diff --git a/include/eepp/audio/alresource.hpp b/include/eepp/audio/alresource.hpp new file mode 100644 index 000000000..cd8f1e66a --- /dev/null +++ b/include/eepp/audio/alresource.hpp @@ -0,0 +1,17 @@ +#ifndef EE_AUDIO_ALRESOURCE_HPP +#define EE_AUDIO_ALRESOURCE_HPP + +#include + +namespace EE { namespace Audio { + +class EE_API AlResource { + protected: + AlResource(); + + ~AlResource(); +}; + +}} + +#endif diff --git a/include/eepp/audio/audiodevice.hpp b/include/eepp/audio/audiodevice.hpp deleted file mode 100755 index 7a28fd6a2..000000000 --- a/include/eepp/audio/audiodevice.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef EE_AUDIOCAUDIODEVICE_H -#define EE_AUDIOCAUDIODEVICE_H - -#include -#include - -namespace EE { namespace Audio { - -/** - @brief High-level wrapper around the audio API, it manages - the creation and destruction of the audio device and - context and stores the device capabilities -*/ -class EE_API AudioDevice { - public : - AudioDevice(); - - ~AudioDevice(); - - /** Get the OpenAL format that matches the given number of channels */ - static int getFormatFromChannelCount( unsigned int ChannelCount ); - - /** Checks if a AL or ALC extension is supported */ - static bool isExtensionSupported( const std::string& extension ); - - /** @return True if the audio device was initialized */ - static bool isAvailable(); - private : - void printInfo(); -}; - -}} - -#endif diff --git a/include/eepp/audio/audiolistener.hpp b/include/eepp/audio/audiolistener.hpp deleted file mode 100755 index 18219115f..000000000 --- a/include/eepp/audio/audiolistener.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef EE_AUDIOCLISTENER_H -#define EE_AUDIOCLISTENER_H - -#include -using namespace EE::Math; - -namespace EE { namespace Audio { - -/** @brief Listener is a global interface for defining the audio listener properties. */ -class EE_API AudioListener { - public: - /** Change the global volume of all the sounds. ( default 100 ) - * @param Volume New global volume, in the range [0, 100] - */ - static void setGlobalVolume( const float& Volume ); - - /** Get the Global Volume */ - static float getGlobalVolume(); - - /** Change the position of the listener. \n The default position is (0, 0, 0) */ - static void setPosition( const float& X, const float& Y, const float& Z ); - - /** Change the position of the listener from a 3D vector. */ - static void setPosition(const Vector3ff& setPosition); - - /** Get the current position of the listener */ - static Vector3ff getPosition(); - - /** Change the orientation of the listener (the point he must look at). \n The default target is (0, 0, -1). */ - static void setDirection( const float& X, const float& Y, const float& Z ); - - /** Change the orientation of the listener from a 3D vector. */ - static void setDirection(const Vector3ff& setDirection); - - /** Get the current orientation of the listener (the point he's looking at) */ - static Vector3ff getDirection(); -}; - -}} - -#endif diff --git a/include/eepp/audio/base.hpp b/include/eepp/audio/base.hpp deleted file mode 100644 index 568f690cf..000000000 --- a/include/eepp/audio/base.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef EE_AUDIO_BASE -#define EE_AUDIO_BASE - -#include - -/** -This module is based on the sfml-audio module. - -SFML - Copyright (c) 2007-2009 Laurent Gomila - laurent.gom@gmail.com - -This software is provided 'as-is', without any express or -implied warranty. In no event will the authors be held -liable for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute -it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; - you must not claim that you wrote the original software. - If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but - is not required. - -2. Altered source versions must be plainly marked as such, - and must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any - source distribution. -*/ -#endif diff --git a/include/eepp/audio/inputsoundfile.hpp b/include/eepp/audio/inputsoundfile.hpp new file mode 100644 index 000000000..abd97d808 --- /dev/null +++ b/include/eepp/audio/inputsoundfile.hpp @@ -0,0 +1,226 @@ +#ifndef EE_AUDIO_INPUTSOUNDFILE_HPP +#define EE_AUDIO_INPUTSOUNDFILE_HPP + +#include +#include +#include +#include +#include + +namespace EE { namespace System { +class IOStream; +}} + +using namespace EE::System; + +namespace EE { namespace Audio { + +class SoundFileReader; + +/// \brief Provide read access to sound files +class EE_API InputSoundFile : NonCopyable { + public: + + InputSoundFile(); + + ~InputSoundFile(); + + //////////////////////////////////////////////////////////// + /// \brief Open a sound file from the disk for reading + /// + /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. + /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. + /// + /// \param filename Path of the sound file to load + /// + /// \return True if the file was successfully opened + /// + //////////////////////////////////////////////////////////// + bool openFromFile(const std::string& filename); + + //////////////////////////////////////////////////////////// + /// \brief Open a sound file in memory for reading + /// + /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. + /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. + /// + /// \param data Pointer to the file data in memory + /// \param sizeInBytes Size of the data to load, in bytes + /// + /// \return True if the file was successfully opened + /// + //////////////////////////////////////////////////////////// + bool openFromMemory(const void* data, std::size_t sizeInBytes); + + //////////////////////////////////////////////////////////// + /// \brief Open a sound file from a custom stream for reading + /// + /// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. + /// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. + /// + /// \param stream Source stream to read from + /// + /// \return True if the file was successfully opened + /// + //////////////////////////////////////////////////////////// + bool openFromStream(IOStream& stream); + + //////////////////////////////////////////////////////////// + /// \brief Get the total number of audio samples in the file + /// + /// \return Number of samples + /// + //////////////////////////////////////////////////////////// + Uint64 getSampleCount() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the number of channels used by the sound + /// + /// \return Number of channels (1 = mono, 2 = stereo) + /// + //////////////////////////////////////////////////////////// + unsigned int getChannelCount() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the sample rate of the sound + /// + /// \return Sample rate, in samples per second + /// + //////////////////////////////////////////////////////////// + unsigned int getSampleRate() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the total duration of the sound file + /// + /// This function is provided for convenience, the duration is + /// deduced from the other sound file attributes. + /// + /// \return Duration of the sound file + /// + //////////////////////////////////////////////////////////// + Time getDuration() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the read offset of the file in time + /// + /// \return Time position + /// + //////////////////////////////////////////////////////////// + Time getTimeOffset() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the read offset of the file in samples + /// + /// \return Sample position + /// + //////////////////////////////////////////////////////////// + Uint64 getSampleOffset() const; + + //////////////////////////////////////////////////////////// + /// \brief Change the current read position to the given sample offset + /// + /// This function takes a sample offset to provide maximum + /// precision. If you need to jump to a given time, use the + /// other overload. + /// + /// The sample offset takes the channels into account. + /// If you have a time offset instead, you can easily find + /// the corresponding sample offset with the following formula: + /// `timeInSeconds * sampleRate * channelCount` + /// If the given offset exceeds to total number of samples, + /// this function jumps to the end of the sound file. + /// + /// \param sampleOffset Index of the sample to jump to, relative to the beginning + /// + //////////////////////////////////////////////////////////// + void seek(Uint64 sampleOffset); + + //////////////////////////////////////////////////////////// + /// \brief Change the current read position to the given time offset + /// + /// Using a time offset is handy but imprecise. If you need an accurate + /// result, consider using the overload which takes a sample offset. + /// + /// If the given time exceeds to total duration, this function jumps + /// to the end of the sound file. + /// + /// \param timeOffset Time to jump to, relative to the beginning + /// + //////////////////////////////////////////////////////////// + void seek(Time timeOffset); + + //////////////////////////////////////////////////////////// + /// \brief Read audio samples from the open file + /// + /// \param samples Pointer to the sample array to fill + /// \param maxCount Maximum number of samples to read + /// + /// \return Number of samples actually read (may be less than \a maxCount) + /// + //////////////////////////////////////////////////////////// + Uint64 read(Int16* samples, Uint64 maxCount); + + private: + + //////////////////////////////////////////////////////////// + /// \brief Close the current file + /// + //////////////////////////////////////////////////////////// + void close(); + + //////////////////////////////////////////////////////////// + // Member data + //////////////////////////////////////////////////////////// + SoundFileReader * mReader; ///< Reader that handles I/O on the file's format + IOStream* mStream; ///< Input stream used to access the file's data + bool mStreamOwned; ///< Is the stream internal or external? + Uint64 mSampleOffset; ///< Sample Read Position + Uint64 mSampleCount; ///< Total number of samples in the file + unsigned int mChannelCount; ///< Number of channels of the sound + unsigned int mSampleRate; ///< Number of samples per second +}; + +}} + +#endif + +//////////////////////////////////////////////////////////// +/// \class InputSoundFile +/// \ingroup audio +/// +/// This class decodes audio samples from a sound file. It is +/// used internally by higher-level classes such as SoundBuffer +/// and Music, but can also be useful if you want to process +/// or analyze audio files without playing them, or if you want to +/// implement your own version of Music with more specific +/// features. +/// +/// Usage example: +/// \code +/// // Open a sound file +/// InputSoundFile file; +/// if (!file.openFromFile("music.ogg")) +/// /* error */; +/// +/// // Print the sound attributes +/// std::cout << "duration: " << file.getDuration().asSeconds() << std::endl; +/// std::cout << "channels: " << file.getChannelCount() << std::endl; +/// std::cout << "sample rate: " << file.getSampleRate() << std::endl; +/// std::cout << "sample count: " << file.getSampleCount() << std::endl; +/// +/// // Read and process batches of samples until the end of file is reached +/// Int16 samples[1024]; +/// Uint64 count; +/// do +/// { +/// count = file.read(samples, 1024); +/// +/// // process, analyze, play, convert, or whatever +/// // you want to do with the samples... +/// } +/// while (count > 0); +/// \endcode +/// +/// \see SoundFileReader, OutputSoundFile +/// +//////////////////////////////////////////////////////////// diff --git a/include/eepp/audio/listener.hpp b/include/eepp/audio/listener.hpp new file mode 100644 index 000000000..d197dd101 --- /dev/null +++ b/include/eepp/audio/listener.hpp @@ -0,0 +1,201 @@ +#ifndef EE_AUDIO_LISTENER_HPP +#define EE_AUDIO_LISTENER_HPP + +#include +#include +using namespace EE::Math; + +namespace EE { namespace Audio { + +/// \brief The audio listener is the point in the scene +/// from where all the sounds are heard +class EE_API Listener { + public: + + //////////////////////////////////////////////////////////// + /// \brief Change the global volume of all the sounds and musics + /// + /// The volume is a number between 0 and 100; it is combined with + /// the individual volume of each sound / music. + /// The default value for the volume is 100 (maximum). + /// + /// \param volume New global volume, in the range [0, 100] + /// + /// \see getGlobalVolume + /// + //////////////////////////////////////////////////////////// + static void setGlobalVolume(float volume); + + //////////////////////////////////////////////////////////// + /// \brief Get the current value of the global volume + /// + /// \return Current global volume, in the range [0, 100] + /// + /// \see setGlobalVolume + /// + //////////////////////////////////////////////////////////// + static float getGlobalVolume(); + + //////////////////////////////////////////////////////////// + /// \brief Set the position of the listener in the scene + /// + /// The default listener's position is (0, 0, 0). + /// + /// \param x X coordinate of the listener's position + /// \param y Y coordinate of the listener's position + /// \param z Z coordinate of the listener's position + /// + /// \see getPosition, setDirection + /// + //////////////////////////////////////////////////////////// + static void setPosition(float x, float y, float z); + + //////////////////////////////////////////////////////////// + /// \brief Set the position of the listener in the scene + /// + /// The default listener's position is (0, 0, 0). + /// + /// \param position New listener's position + /// + /// \see getPosition, setDirection + /// + //////////////////////////////////////////////////////////// + static void setPosition(const Vector3f& position); + + //////////////////////////////////////////////////////////// + /// \brief Get the current position of the listener in the scene + /// + /// \return Listener's position + /// + /// \see setPosition + /// + //////////////////////////////////////////////////////////// + static Vector3f getPosition(); + + //////////////////////////////////////////////////////////// + /// \brief Set the forward vector of the listener in the scene + /// + /// The direction (also called "at vector") is the vector + /// pointing forward from the listener's perspective. Together + /// with the up vector, it defines the 3D orientation of the + /// listener in the scene. The direction vector doesn't + /// have to be normalized. + /// The default listener's direction is (0, 0, -1). + /// + /// \param x X coordinate of the listener's direction + /// \param y Y coordinate of the listener's direction + /// \param z Z coordinate of the listener's direction + /// + /// \see getDirection, setUpVector, setPosition + /// + //////////////////////////////////////////////////////////// + static void setDirection(float x, float y, float z); + + //////////////////////////////////////////////////////////// + /// \brief Set the forward vector of the listener in the scene + /// + /// The direction (also called "at vector") is the vector + /// pointing forward from the listener's perspective. Together + /// with the up vector, it defines the 3D orientation of the + /// listener in the scene. The direction vector doesn't + /// have to be normalized. + /// The default listener's direction is (0, 0, -1). + /// + /// \param direction New listener's direction + /// + /// \see getDirection, setUpVector, setPosition + /// + //////////////////////////////////////////////////////////// + static void setDirection(const Vector3f& direction); + + //////////////////////////////////////////////////////////// + /// \brief Get the current forward vector of the listener in the scene + /// + /// \return Listener's forward vector (not normalized) + /// + /// \see setDirection + /// + //////////////////////////////////////////////////////////// + static Vector3f getDirection(); + + //////////////////////////////////////////////////////////// + /// \brief Set the upward vector of the listener in the scene + /// + /// The up vector is the vector that points upward from the + /// listener's perspective. Together with the direction, it + /// defines the 3D orientation of the listener in the scene. + /// The up vector doesn't have to be normalized. + /// The default listener's up vector is (0, 1, 0). It is usually + /// not necessary to change it, especially in 2D scenarios. + /// + /// \param x X coordinate of the listener's up vector + /// \param y Y coordinate of the listener's up vector + /// \param z Z coordinate of the listener's up vector + /// + /// \see getUpVector, setDirection, setPosition + /// + //////////////////////////////////////////////////////////// + static void setUpVector(float x, float y, float z); + + //////////////////////////////////////////////////////////// + /// \brief Set the upward vector of the listener in the scene + /// + /// The up vector is the vector that points upward from the + /// listener's perspective. Together with the direction, it + /// defines the 3D orientation of the listener in the scene. + /// The up vector doesn't have to be normalized. + /// The default listener's up vector is (0, 1, 0). It is usually + /// not necessary to change it, especially in 2D scenarios. + /// + /// \param upVector New listener's up vector + /// + /// \see getUpVector, setDirection, setPosition + /// + //////////////////////////////////////////////////////////// + static void setUpVector(const Vector3f& upVector); + + //////////////////////////////////////////////////////////// + /// \brief Get the current upward vector of the listener in the scene + /// + /// \return Listener's upward vector (not normalized) + /// + /// \see setUpVector + /// + //////////////////////////////////////////////////////////// + static Vector3f getUpVector(); +}; + +}} + +#endif + +//////////////////////////////////////////////////////////// +/// \class Listener +/// \ingroup audio +/// +/// The audio listener defines the global properties of the +/// audio environment, it defines where and how sounds and musics +/// are heard. If View is the eyes of the user, then Listener +/// is his ears (by the way, they are often linked together -- +/// same position, orientation, etc.). +/// +/// Listener is a simple interface, which allows to setup the +/// listener in the 3D audio environment (position, direction and +/// up vector), and to adjust the global volume. +/// +/// Because the listener is unique in the scene, Listener only +/// contains static functions and doesn't have to be instantiated. +/// +/// Usage example: +/// \code +/// // Move the listener to the position (1, 0, -5) +/// Listener::setPosition(1, 0, -5); +/// +/// // Make it face the right axis (1, 0, 0) +/// Listener::setDirection(1, 0, 0); +/// +/// // Reduce the global volume +/// Listener::setGlobalVolume(50); +/// \endcode +/// +//////////////////////////////////////////////////////////// diff --git a/include/eepp/audio/music.hpp b/include/eepp/audio/music.hpp old mode 100755 new mode 100644 index 45a15de3e..0d8daf2e9 --- a/include/eepp/audio/music.hpp +++ b/include/eepp/audio/music.hpp @@ -1,45 +1,293 @@ -#ifndef EE_AUDIOCMUSIC_H -#define EE_AUDIOCMUSIC_H +#ifndef EE_AUDIO_MUSIC_HPP +#define EE_AUDIO_MUSIC_HPP -#include +#include #include +#include +#include +#include +#include +#include +#include + +namespace EE { namespace System { +class IOStream; +class Pack; +}} + +using namespace EE::System; namespace EE { namespace Audio { -class SoundFile; +/// \brief Streamed music played from an audio file +class EE_API Music : public SoundStream +{ + public: + /// \brief Structure defining a time range using the template type + template + struct Span + { + Span() + { -/** @brief Streamed music played from an audio file */ -class EE_API Music : public SoundStream { - public : - /** Construct the music with a buffer size */ - Music( std::size_t BufferSize = 48000 ); + } + + /// \brief Initialization constructor + /// \param off Initial Offset + /// \param len Initial Length + Span(T off, T len): + offset(off), + length(len) + { + + } + + T offset; ///< The beginning offset of the time range + T length; ///< The length of the time range + }; + + // Define the relevant Span types + typedef Span