sfml-audio-0.7.0.1816/0000755000000000000000000000000011770572147012355 5ustar0000000000000000sfml-audio-0.7.0.1816/sfml-audio.cabal0000644000000000000000000000725211770572147015407 0ustar0000000000000000Name: sfml-audio Version: 0.7.0.1816 Synopsis: minimal bindings to the audio module of sfml Description: Provides a very minimal interface to the audio module of sfml. Currently, only the playing of sounds is covered. Playing background music is not yet supported, but planned. (sfml is a multimedia library: ) Homepage: http://patch-tag.com/r/shahn/sfml-audio License: OtherLicense License-file: LICENSE Author: Sönke Hahn Maintainer: shahn@joyridelabs.de Stability: Beta Category: Sound Build-type: Simple Cabal-version: >=1.6 -- headers used for compiling the cabal-package extra-source-files: -- sfml dependencies/sfml2/include/SFML/*.hpp dependencies/sfml2/include/SFML/Audio/*.hpp dependencies/sfml2/include/SFML/System/*.hpp dependencies/sfml2/include/SFML/System/*.inl dependencies/sfml2/src/SFML/Audio/*.hpp dependencies/sfml2/src/SFML/System/*.hpp dependencies/sfml2/src/SFML/System/Unix/*.hpp dependencies/sfml2/src/SFML/System/Win32/*.hpp -- csfml dependencies/sfml2/bindings/c/include/SFML/Audio/*.h dependencies/sfml2/bindings/c/include/SFML/*.h dependencies/sfml2/bindings/c/src/SFML/Audio/*.h dependencies/sfml2/bindings/c/src/SFML/*.h source-repository head type: darcs location: http://patch-tag.com/r/shahn/sfml-audio Library Exposed-modules: Sound.SFML, Sound.SFML.LowLevel hs-source-dirs: src -- Packages needed in order to build this package. Build-depends: base >= 4 && < 5 extra-libraries: stdc++, sndfile if os(linux) extra-libraries: openal, pthread if os(mingw32) extra-libraries: openal32 if os(darwin) frameworks: OpenAL includes: al.h sndfile.h cc-options: -O3 -DNDEBUG -DSFML_EXPORTS -DSFML_SYSTEM_EXPORTS -DSFML_AUDIO_EXPORTS -DCSFML_EXPORTS if os(darwin) cc-options: -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 ld-options: -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 include-dirs: dependencies/sfml2/include dependencies/sfml2/src dependencies/sfml2/bindings/c/include dependencies/sfml2/bindings/c/src -- sfml audio c-sources: dependencies/sfml2/src/SFML/Audio/ALCheck.cpp dependencies/sfml2/src/SFML/Audio/AudioDevice.cpp dependencies/sfml2/src/SFML/Audio/Music.cpp dependencies/sfml2/src/SFML/Audio/SoundBuffer.cpp dependencies/sfml2/src/SFML/Audio/Sound.cpp dependencies/sfml2/src/SFML/Audio/SoundFile.cpp dependencies/sfml2/src/SFML/Audio/SoundSource.cpp dependencies/sfml2/src/SFML/Audio/SoundStream.cpp -- sfml system c-sources: dependencies/sfml2/src/SFML/System/Err.cpp dependencies/sfml2/src/SFML/System/Lock.cpp dependencies/sfml2/src/SFML/System/Mutex.cpp dependencies/sfml2/src/SFML/System/Sleep.cpp dependencies/sfml2/src/SFML/System/Thread.cpp if os(linux) || os(darwin) c-sources: dependencies/sfml2/src/SFML/System/Unix/MutexImpl.cpp dependencies/sfml2/src/SFML/System/Unix/Platform.cpp dependencies/sfml2/src/SFML/System/Unix/ThreadImpl.cpp if os(mingw32) c-sources: dependencies/sfml2/src/SFML/System/Win32/MutexImpl.cpp dependencies/sfml2/src/SFML/System/Win32/Platform.cpp dependencies/sfml2/src/SFML/System/Win32/ThreadImpl.cpp -- csfml audio c-sources: dependencies/sfml2/bindings/c/src/SFML/Audio/Music.cpp dependencies/sfml2/bindings/c/src/SFML/Audio/SoundBuffer.cpp dependencies/sfml2/bindings/c/src/SFML/Audio/Sound.cpp sfml-audio-0.7.0.1816/LICENSE0000644000000000000000000000245311770572147013366 0ustar0000000000000000sfml-audio are haskell bindings to a small subset of the API of the audio module of SFML2 (http://www.sfml-dev.org/). The source code (and other content) of SFML2 (svn checkout, revision 1816, currently in https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2) is partially included in sfml-audio (in the "dependencies" directory). sfml-audio is provided under the same terms as SFML2. SFML's license: ============== 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. sfml-audio-0.7.0.1816/Setup.hs0000644000000000000000000000010611770572147014006 0ustar0000000000000000#!/usr/bin/runhaskell import Distribution.Simple main = defaultMain sfml-audio-0.7.0.1816/src/0000755000000000000000000000000011770572147013144 5ustar0000000000000000sfml-audio-0.7.0.1816/src/Sound/0000755000000000000000000000000011770572147014234 5ustar0000000000000000sfml-audio-0.7.0.1816/src/Sound/SFML.hs0000644000000000000000000001226011770572147015332 0ustar0000000000000000 -- High level api for playing sounds (and background music) module Sound.SFML ( -- * PolySounds PolySound, newPolySound, freePolySound, triggerPolySound, -- * LoopedSounds LoopedSound, newLoopedSound, freeLoopedSound, startLoopedSound, stopLoopedSound, -- * background music playMusic, playMusicLooped, stopMusic, pauseMusic, ) where import Prelude hiding (mapM_) import Data.Maybe import Data.IORef import Data.Foldable (forM_, mapM_) import Data.Traversable (forM) import Control.Monad (when) import Control.Concurrent.MVar import System.IO.Unsafe import Foreign.Ptr import Sound.SFML.LowLevel -- * PolySounds -- | A PolySound allows you to trigger one sound multiple times. -- The played sounds will then overlap. -- (Internally, there will be multiple sound instances, that will -- be triggered one after the other. If there are not enough internal -- instances, sounds will be cut.) data PolySound = PolySound FilePath (Ptr SoundBuffer) [Ptr Sound] (IORef Int) instance Show PolySound where show (PolySound file _ _ _) = "PolySound " ++ show file -- | Loads a sound into memory. newPolySound :: FilePath -- ^ soundfile -> Int -- ^ number of internal sound instances. -> IO PolySound newPolySound path numberOfVoices = do buffer <- sfSoundBuffer_CreateFromFile path sounds <- forM [1 .. numberOfVoices] $ \ _ -> do sound <- sfSound_Create sfSound_SetBuffer sound buffer return sound ref <- newIORef 0 return $ PolySound path buffer sounds ref -- | Frees the memory allocated by a sound. Don't use the PolySound afterwards. freePolySound :: PolySound -> IO () freePolySound (PolySound _ buffer sounds _) = do sfSoundBuffer_Destroy buffer mapM_ sfSound_Destroy sounds -- | Trigger a sound triggerPolySound :: PolySound -> Maybe Float -> IO () triggerPolySound (PolySound _ _ sounds ref) volume = do i <- readIORef ref let sound = sounds !! i status <- getSoundStatus sound when (status == Stopped) $ do writeIORef ref ((i + 1) `mod` length sounds) sfSound_SetVolume sound ((fromMaybe 1 volume) * 100) sfSound_Play sound -- * LoopedSounds -- | LoopedSounds are sounds that will always loop. -- They can just be switched on and off. newtype LoopedSound = LoopedSound (Ptr Sound) deriving Show -- | Loads a sound into memory. newLoopedSound :: FilePath -> IO LoopedSound newLoopedSound path = do buffer <- sfSoundBuffer_CreateFromFile path sound <- sfSound_Create sfSound_SetBuffer sound buffer sfSound_SetLoop sound True return $ LoopedSound sound -- | Releases the allocated memory of a LoopedSound. -- Don't use the LoopedSound afterwards. freeLoopedSound :: LoopedSound -> IO () freeLoopedSound (LoopedSound ptr) = sfSound_Destroy ptr -- | Starts a looped sound. startLoopedSound :: Maybe Float -> LoopedSound -> IO () startLoopedSound volume (LoopedSound ptr) = do sfSound_SetVolume ptr ((fromMaybe 1 volume) * 100) sfSound_Play ptr -- | Stops a looped sound. stopLoopedSound :: LoopedSound -> IO () stopLoopedSound (LoopedSound ptr) = sfSound_Stop ptr -- * Music -- There is always only one music being played at a single point in time. -- | Loads and plays a music file once in a background thread. -- Stops other music that is playing. -- If the current music is Paused and the given file is the same as the one playing, -- the music is continued. -- The volume is set again in any case. playMusic :: FilePath -> Maybe Float -> IO () playMusic = _playMusic False -- |Like 'playMusic', but looping. playMusicLooped :: FilePath -> Maybe Float -> IO () playMusicLooped = _playMusic True _playMusic :: Bool -> FilePath -> Maybe Float -> IO () _playMusic looped file volume = modifyMVar_ _globalMusic $ \ mOldMusic -> do case mOldMusic of Just (oldFile, oldMusic) -> do status <- getMusicStatus oldMusic case status of Paused | file == oldFile -> do sfMusic_SetLoop oldMusic looped sfMusic_SetVolume oldMusic ((fromMaybe 1 volume) * 100) sfMusic_Play oldMusic return $ Just (file, oldMusic) _ -> do sfMusic_Stop oldMusic sfMusic_Destroy oldMusic startNewMusic Nothing -> startNewMusic where startNewMusic = do music <- sfMusic_CreateFromFile file sfMusic_SetLoop music looped sfMusic_SetVolume music ((fromMaybe 1 volume) * 100) sfMusic_Play music return $ Just (file, music) -- | Stops any background music that is playing. stopMusic :: IO () stopMusic = modifyMVar_ _globalMusic $ \ mOldMusic -> do forM_ mOldMusic $ \ (_, oldMusic) -> do sfMusic_Stop oldMusic sfMusic_Destroy oldMusic return Nothing -- | Pauses the current music. pauseMusic :: IO () pauseMusic = modifyMVar_ _globalMusic $ \ mMusic -> do mapM_ (sfMusic_Pause . snd) mMusic return mMusic {-# noinline _globalMusic #-} -- all music-related functions are synchronized by this global MVar. _globalMusic :: MVar (Maybe (FilePath, Ptr Music)) _globalMusic = unsafePerformIO $ newMVar Nothing sfml-audio-0.7.0.1816/src/Sound/SFML/0000755000000000000000000000000011770572147014775 5ustar0000000000000000sfml-audio-0.7.0.1816/src/Sound/SFML/LowLevel.hs0000644000000000000000000000405011770572147017061 0ustar0000000000000000{-# language ForeignFunctionInterface, EmptyDataDecls #-} module Sound.SFML.LowLevel where import Control.Applicative import Foreign.Ptr import Foreign.C.String -- * Common toStatus :: Int -> Status toStatus = toEnum data Status = Stopped | Paused | Playing deriving (Eq, Enum, Show) -- * SoundBuffer data SoundBuffer sfSoundBuffer_CreateFromFile :: FilePath -> IO (Ptr SoundBuffer) sfSoundBuffer_CreateFromFile path = withCString path c__sfSoundBuffer_CreateFromFile foreign import ccall "sfSoundBuffer_CreateFromFile" c__sfSoundBuffer_CreateFromFile :: CString -> IO (Ptr SoundBuffer) foreign import ccall sfSoundBuffer_Destroy :: Ptr SoundBuffer -> IO () -- * Sound data Sound foreign import ccall sfSound_Create :: IO (Ptr Sound) foreign import ccall sfSound_SetBuffer :: Ptr Sound -> Ptr SoundBuffer -> IO () foreign import ccall sfSound_Play :: Ptr Sound -> IO () foreign import ccall sfSound_Stop :: Ptr Sound -> IO () foreign import ccall sfSound_Destroy :: Ptr Sound -> IO () foreign import ccall sfSound_SetLoop :: Ptr Sound -> Bool -> IO () foreign import ccall sfSound_SetVolume :: Ptr Sound -> Float -> IO () foreign import ccall sfSound_GetStatus :: Ptr Sound -> IO Int getSoundStatus s = toStatus <$> sfSound_GetStatus s -- * Music data Music sfMusic_CreateFromFile :: FilePath -> IO (Ptr Music) sfMusic_CreateFromFile path = withCString path c__sfMusic_CreateFromFile foreign import ccall "sfMusic_CreateFromFile" c__sfMusic_CreateFromFile :: CString -> IO (Ptr Music) foreign import ccall sfMusic_Destroy :: Ptr Music -> IO () foreign import ccall sfMusic_Play :: Ptr Music -> IO () foreign import ccall sfMusic_Stop :: Ptr Music -> IO () foreign import ccall sfMusic_Pause :: Ptr Music -> IO () foreign import ccall sfMusic_SetLoop :: Ptr Music -> Bool -> IO () foreign import ccall sfMusic_SetVolume :: Ptr Music -> Float -> IO () foreign import ccall sfMusic_GetDuration :: Ptr Music -> IO Float foreign import ccall sfMusic_GetStatus :: Ptr Music -> IO Int getMusicStatus s = toStatus <$> sfMusic_GetStatus s sfml-audio-0.7.0.1816/dependencies/0000755000000000000000000000000011770572147015003 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/0000755000000000000000000000000011770572147016026 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/src/0000755000000000000000000000000011770572147016615 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/0000755000000000000000000000000011770572147017356 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/0000755000000000000000000000000011770572147020642 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Thread.cpp0000644000000000000000000000436011770572147022560 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #if defined(SFML_SYSTEM_WINDOWS) #include #else #include #endif namespace sf { //////////////////////////////////////////////////////////// Thread::~Thread() { Wait(); delete myFunction; } //////////////////////////////////////////////////////////// void Thread::Launch() { Wait(); myImpl = new priv::ThreadImpl(this); } //////////////////////////////////////////////////////////// void Thread::Wait() { if (myImpl) { myImpl->Wait(); delete myImpl; myImpl = NULL; } } //////////////////////////////////////////////////////////// void Thread::Terminate() { if (myImpl) { myImpl->Terminate(); delete myImpl; myImpl = NULL; } } //////////////////////////////////////////////////////////// void Thread::Run() { myFunction->Run(); } } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Sleep.cpp0000644000000000000000000000300611770572147022415 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { //////////////////////////////////////////////////////////// void Sleep(float duration) { if (duration >= 0) priv::Platform::Sleep(duration); } } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Mutex.cpp0000644000000000000000000000367111770572147022457 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #if defined(SFML_SYSTEM_WINDOWS) #include #else #include #endif namespace sf { //////////////////////////////////////////////////////////// Mutex::Mutex() { myMutexImpl = new priv::MutexImpl; } //////////////////////////////////////////////////////////// Mutex::~Mutex() { delete myMutexImpl; } //////////////////////////////////////////////////////////// void Mutex::Lock() { myMutexImpl->Lock(); } //////////////////////////////////////////////////////////// void Mutex::Unlock() { myMutexImpl->Unlock(); } } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Lock.cpp0000644000000000000000000000312311770572147022235 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { //////////////////////////////////////////////////////////// Lock::Lock(Mutex& mutex) : myMutex(mutex) { myMutex.Lock(); } //////////////////////////////////////////////////////////// Lock::~Lock() { myMutex.Unlock(); } } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Platform.hpp0000644000000000000000000000300211770572147023132 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_PLATFORM_HPP #define SFML_PLATFORM_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #if defined(SFML_SYSTEM_WINDOWS) #include #else #include #endif #endif // SFML_PLATFORM_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Err.cpp0000644000000000000000000000641211770572147022101 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include //////////////////////////////////////////////////////////// // Private data //////////////////////////////////////////////////////////// namespace { // This class will be used as the default streambuf of sf::Err, // it outputs to stderr by default (to keep the default beaviour) class DefaultErrStreamBuf : public std::streambuf { public : DefaultErrStreamBuf() { // Allocate the write buffer static const int size = 64; char* buffer = new char[size]; setp(buffer, buffer + size); } ~DefaultErrStreamBuf() { // Synchronize sync(); // Delete the write buffer delete[] pbase(); } private : virtual int overflow(int character) { if ((character != EOF) && (pptr() != epptr())) { // Valid character return sputc(static_cast(character)); } else if (character != EOF) { // Not enough space in the buffer: synchronize output and try again sync(); return overflow(character); } else { // Invalid character: synchronize output return sync(); } } virtual int sync() { // Check if there is something into the write buffer if (pbase() != pptr()) { // Print the contents of the write buffer into the standard error output std::size_t size = static_cast(pptr() - pbase()); fwrite(pbase(), 1, size, stderr); // Reset the pointer position to the beginning of the write buffer setp(pbase(), epptr()); } return 0; } }; } namespace sf { //////////////////////////////////////////////////////////// std::ostream& Err() { static DefaultErrStreamBuf buffer; static std::ostream stream(&buffer); return stream; } } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/0000755000000000000000000000000011770572147021565 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/MutexImpl.cpp0000644000000000000000000000361011770572147024215 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// MutexImpl::MutexImpl() { pthread_mutex_init(&myMutex, NULL); } //////////////////////////////////////////////////////////// MutexImpl::~MutexImpl() { pthread_mutex_destroy(&myMutex); } //////////////////////////////////////////////////////////// void MutexImpl::Lock() { pthread_mutex_lock(&myMutex); } //////////////////////////////////////////////////////////// void MutexImpl::Unlock() { pthread_mutex_unlock(&myMutex); } } // namespace priv } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/ThreadLocalImpl.hpp0000644000000000000000000000574611770572147025316 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_THREADLOCALIMPL_HPP #define SFML_THREADLOCALIMPL_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// /// \brief Unix implementation of thread-local storage //////////////////////////////////////////////////////////// class ThreadLocalImpl : NonCopyable { public : //////////////////////////////////////////////////////////// /// \brief Default constructor -- allocate the storage /// //////////////////////////////////////////////////////////// ThreadLocalImpl(); //////////////////////////////////////////////////////////// /// \brief Destructor -- free the storage /// //////////////////////////////////////////////////////////// ~ThreadLocalImpl(); //////////////////////////////////////////////////////////// /// \brief Set the thread-specific value of the variable /// /// \param value Value of the variable for this thread /// //////////////////////////////////////////////////////////// void SetValue(void* value); //////////////////////////////////////////////////////////// /// \brief Retrieve the thread-specific value of the variable /// /// \return Value of the variable for this thread /// //////////////////////////////////////////////////////////// void* GetValue() const; private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// pthread_key_t myKey; ///< Index of our thread-local storage slot }; } // namespace priv } // namespace sf #endif // SFML_THREADLOCALIMPL_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/Platform.cpp0000644000000000000000000000342211770572147024056 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // Copyright (C) 2007 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// double Platform::GetSystemTime() { timeval time = {0, 0}; gettimeofday(&time, NULL); return time.tv_sec + time.tv_usec / 1000000.; } //////////////////////////////////////////////////////////// void Platform::Sleep(float time) { usleep(static_cast(time * 1000000)); } } // namespace priv } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/ThreadImpl.cpp0000644000000000000000000000467111770572147024332 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// ThreadImpl::ThreadImpl(Thread* owner) : myIsActive(true) { myIsActive = pthread_create(&myThread, NULL, &ThreadImpl::EntryPoint, owner) == 0; if (!myIsActive) std::cerr << "Failed to create thread" << std::endl; } //////////////////////////////////////////////////////////// void ThreadImpl::Wait() { if (myIsActive) pthread_join(myThread, NULL); } //////////////////////////////////////////////////////////// void ThreadImpl::Terminate() { if (myIsActive) pthread_cancel(myThread); } //////////////////////////////////////////////////////////// void* ThreadImpl::EntryPoint(void* userData) { // The Thread instance is stored in the user data Thread* owner = static_cast(userData); // Tell the thread to handle cancel requests immediatly pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); // Forward to the owner owner->Run(); return NULL; } } // namespace priv } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/Platform.hpp0000644000000000000000000000440411770572147024064 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // Copyright (C) 2007 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. // //////////////////////////////////////////////////////////// #ifndef SFML_PLATFORMUNIX_HPP #define SFML_PLATFORMUNIX_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// /// \brief Give access to some system-specific low-level functions //////////////////////////////////////////////////////////// class Platform { public : //////////////////////////////////////////////////////////// /// \brief Get the current system time /// /// \return System time, in seconds /// //////////////////////////////////////////////////////////// static double GetSystemTime(); //////////////////////////////////////////////////////////// /// \brief Suspend the execution of the current thread for a specified time /// /// \param time Time to sleep, in seconds /// //////////////////////////////////////////////////////////// static void Sleep(float time); }; } // namespace priv } // namespace sf #endif // SFML_PLATFORMUNIX_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/MutexImpl.hpp0000644000000000000000000000524411770572147024227 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_MUTEXIMPL_HPP #define SFML_MUTEXIMPL_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// /// \brief Unix implementation of mutexes //////////////////////////////////////////////////////////// class MutexImpl : NonCopyable { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// //////////////////////////////////////////////////////////// MutexImpl(); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~MutexImpl(); //////////////////////////////////////////////////////////// /// \brief Lock the mutex /// //////////////////////////////////////////////////////////// void Lock(); //////////////////////////////////////////////////////////// /// \brief Unlock the mutex /// //////////////////////////////////////////////////////////// void Unlock(); private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// pthread_mutex_t myMutex; ///< pthread handle of the mutex }; } // namespace priv } // namespace sf #endif // SFML_MUTEXIMPL_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/ThreadImpl.hpp0000644000000000000000000000603511770572147024333 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_THREADIMPL_HPP #define SFML_THREADIMPL_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { class Thread; namespace priv { //////////////////////////////////////////////////////////// /// \brief Unix implementation of threads //////////////////////////////////////////////////////////// class ThreadImpl : NonCopyable { public : //////////////////////////////////////////////////////////// /// \brief Default constructor, launch the thread /// /// \param owner The Thread instance to run /// //////////////////////////////////////////////////////////// ThreadImpl(Thread* owner); //////////////////////////////////////////////////////////// /// \brief Wait until the thread finishes /// //////////////////////////////////////////////////////////// void Wait(); //////////////////////////////////////////////////////////// /// \brief Terminate the thread /// //////////////////////////////////////////////////////////// void Terminate(); private : //////////////////////////////////////////////////////////// /// \brief Global entry point for all threads /// /// \param userData User-defined data (contains the Thread instance) /// /// \return Os specific error code /// //////////////////////////////////////////////////////////// static void* EntryPoint(void* userData); //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// pthread_t myThread; ///< pthread thread instance bool myIsActive; ///< Thread state (active or inactive) }; } // namespace priv } // namespace sf #endif // SFML_THREADIMPL_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/0000755000000000000000000000000011770572147021544 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/MutexImpl.cpp0000644000000000000000000000361411770572147024200 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// MutexImpl::MutexImpl() { InitializeCriticalSection(&myMutex); } //////////////////////////////////////////////////////////// MutexImpl::~MutexImpl() { DeleteCriticalSection(&myMutex); } //////////////////////////////////////////////////////////// void MutexImpl::Lock() { EnterCriticalSection(&myMutex); } //////////////////////////////////////////////////////////// void MutexImpl::Unlock() { LeaveCriticalSection(&myMutex); } } // namespace priv } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/ThreadLocalImpl.hpp0000644000000000000000000000574311770572147025272 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_THREADLOCALIMPL_HPP #define SFML_THREADLOCALIMPL_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// /// \brief Windows implementation of thread-local storage //////////////////////////////////////////////////////////// class ThreadLocalImpl : NonCopyable { public : //////////////////////////////////////////////////////////// /// \brief Default constructor -- allocate the storage /// //////////////////////////////////////////////////////////// ThreadLocalImpl(); //////////////////////////////////////////////////////////// /// \brief Destructor -- free the storage /// //////////////////////////////////////////////////////////// ~ThreadLocalImpl(); //////////////////////////////////////////////////////////// /// \brief Set the thread-specific value of the variable /// /// \param value Value of the variable for this thread /// //////////////////////////////////////////////////////////// void SetValue(void* value); //////////////////////////////////////////////////////////// /// \brief Retrieve the thread-specific value of the variable /// /// \return Value of the variable for this thread /// //////////////////////////////////////////////////////////// void* GetValue() const; private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// DWORD myIndex; ///< Index of our thread-local storage slot }; } // namespace priv } // namespace sf #endif // SFML_THREADLOCALIMPL_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/Platform.cpp0000644000000000000000000000425411770572147024041 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// double Platform::GetSystemTime() { static LARGE_INTEGER frequency; static BOOL useHighPerformanceTimer = QueryPerformanceFrequency(&frequency); if (useHighPerformanceTimer) { // High performance counter available : use it LARGE_INTEGER currentTime; QueryPerformanceCounter(¤tTime); return static_cast(currentTime.QuadPart) / frequency.QuadPart; } else { // High performance counter not available: use GetTickCount (less accurate) return GetTickCount() * 0.001; } } //////////////////////////////////////////////////////////// void Platform::Sleep(float time) { ::Sleep(static_cast(time * 1000)); } } // namespace priv } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/ThreadImpl.cpp0000644000000000000000000000510211770572147024277 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// ThreadImpl::ThreadImpl(Thread* owner) { myThread = reinterpret_cast(_beginthreadex(NULL, 0, &ThreadImpl::EntryPoint, owner, 0, NULL)); if (!myThread) Err() << "Failed to create thread" << std::endl; } //////////////////////////////////////////////////////////// ThreadImpl::~ThreadImpl() { if (myThread) CloseHandle(myThread); } //////////////////////////////////////////////////////////// void ThreadImpl::Wait() { if (myThread) WaitForSingleObject(myThread, INFINITE); } //////////////////////////////////////////////////////////// void ThreadImpl::Terminate() { if (myThread) TerminateThread(myThread, 0); } //////////////////////////////////////////////////////////// unsigned int __stdcall ThreadImpl::EntryPoint(void* userData) { // The Thread instance is stored in the user data Thread* owner = static_cast(userData); // Forward to the owner owner->Run(); // Optional, but it is cleaner _endthreadex(0); return 0; } } // namespace priv } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/Platform.hpp0000644000000000000000000000442211770572147024043 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_PLATFORMWIN32_HPP #define SFML_PLATFORMWIN32_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// /// \brief Gives access to some system-specific low-level functions /// //////////////////////////////////////////////////////////// class Platform { public : //////////////////////////////////////////////////////////// /// \brief Get the current system time /// /// \return System time, in seconds /// //////////////////////////////////////////////////////////// static double GetSystemTime(); //////////////////////////////////////////////////////////// /// \brief Suspend the execution of the current thread for a specified time /// /// \param time Time to sleep, in seconds /// //////////////////////////////////////////////////////////// static void Sleep(float time); }; } // namespace priv } // namespace sf #endif // SFML_PLATFORMWIN32_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/MutexImpl.hpp0000644000000000000000000000524611770572147024210 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_MUTEXIMPL_HPP #define SFML_MUTEXIMPL_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// /// \brief Windows implementation of mutexes //////////////////////////////////////////////////////////// class MutexImpl : NonCopyable { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// //////////////////////////////////////////////////////////// MutexImpl(); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~MutexImpl(); //////////////////////////////////////////////////////////// /// \brief Lock the mutex /// //////////////////////////////////////////////////////////// void Lock(); //////////////////////////////////////////////////////////// /// \brief Unlock the mutex /// //////////////////////////////////////////////////////////// void Unlock(); private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// CRITICAL_SECTION myMutex; ///< Win32 handle of the mutex }; } // namespace priv } // namespace sf #endif // SFML_MUTEXIMPL_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/ThreadImpl.hpp0000644000000000000000000000624411770572147024314 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_THREADIMPL_HPP #define SFML_THREADIMPL_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { class Thread; namespace priv { //////////////////////////////////////////////////////////// /// \brief Windows implementation of threads //////////////////////////////////////////////////////////// class ThreadImpl : NonCopyable { public : //////////////////////////////////////////////////////////// /// \brief Default constructor, launch the thread /// /// \param owner The Thread instance to run /// //////////////////////////////////////////////////////////// ThreadImpl(Thread* owner); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~ThreadImpl(); //////////////////////////////////////////////////////////// /// \brief Wait until the thread finishes /// //////////////////////////////////////////////////////////// void Wait(); //////////////////////////////////////////////////////////// /// \brief Terminate the thread /// //////////////////////////////////////////////////////////// void Terminate(); private : //////////////////////////////////////////////////////////// /// \brief Global entry point for all threads /// /// \param userData User-defined data (contains the Thread instance) /// /// \return OS specific error code /// //////////////////////////////////////////////////////////// static unsigned int __stdcall EntryPoint(void* userData); //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// HANDLE myThread; ///< Win32 thread handle }; } // namespace priv } // namespace sf #endif // SFML_THREADIMPL_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/0000755000000000000000000000000011770572147020417 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/AudioDevice.cpp0000644000000000000000000000725411770572147023314 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include //////////////////////////////////////////////////////////// // Private data //////////////////////////////////////////////////////////// namespace { ALCdevice* audioDevice = NULL; ALCcontext* audioContext = NULL; } namespace sf { namespace priv { //////////////////////////////////////////////////////////// AudioDevice::AudioDevice() { // Create the device audioDevice = alcOpenDevice(NULL); if (audioDevice) { // Create the context audioContext = alcCreateContext(audioDevice, NULL); if (audioContext) { // Set the context as the current one (we'll only need one) alcMakeContextCurrent(audioContext); } else { Err() << "Failed to create the audio context" << std::endl; } } else { Err() << "Failed to open the audio device" << std::endl; } } //////////////////////////////////////////////////////////// AudioDevice::~AudioDevice() { // Destroy the context alcMakeContextCurrent(NULL); if (audioContext) alcDestroyContext(audioContext); // Destroy the device if (audioDevice) alcCloseDevice(audioDevice); } //////////////////////////////////////////////////////////// bool AudioDevice::IsExtensionSupported(const std::string& extension) { EnsureALInit(); if ((extension.length() > 2) && (extension.substr(0, 3) == "ALC")) return alcIsExtensionPresent(audioDevice, extension.c_str()) != AL_FALSE; else return alIsExtensionPresent(extension.c_str()) != AL_FALSE; } //////////////////////////////////////////////////////////// int AudioDevice::GetFormatFromChannelsCount(unsigned int channelsCount) { EnsureALInit(); // Find the good format according to the number of channels switch (channelsCount) { case 1 : return AL_FORMAT_MONO16; case 2 : return AL_FORMAT_STEREO16; case 4 : return alGetEnumValue("AL_FORMAT_QUAD16"); case 6 : return alGetEnumValue("AL_FORMAT_51CHN16"); case 7 : return alGetEnumValue("AL_FORMAT_61CHN16"); case 8 : return alGetEnumValue("AL_FORMAT_71CHN16"); default : return 0; } } } // namespace priv } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/Sound.cpp0000644000000000000000000001207411770572147022217 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include namespace sf { //////////////////////////////////////////////////////////// Sound::Sound() { } //////////////////////////////////////////////////////////// Sound::Sound(const SoundBuffer& buffer, bool loop, float pitch, float volume, const Vector3f& position) : myBuffer(NULL) { SetBuffer(buffer); SetLoop(loop); SetPitch(pitch); SetVolume(volume); SetPosition(position); } //////////////////////////////////////////////////////////// Sound::Sound(const Sound& copy) : SoundSource(copy), myBuffer (NULL) { if (copy.myBuffer) SetBuffer(*copy.myBuffer); SetLoop(copy.GetLoop()); } //////////////////////////////////////////////////////////// Sound::~Sound() { Stop(); if (myBuffer) myBuffer->DetachSound(this); } //////////////////////////////////////////////////////////// void Sound::Play() { ALCheck(alSourcePlay(mySource)); } //////////////////////////////////////////////////////////// void Sound::Pause() { ALCheck(alSourcePause(mySource)); } //////////////////////////////////////////////////////////// void Sound::Stop() { ALCheck(alSourceStop(mySource)); } //////////////////////////////////////////////////////////// void Sound::SetBuffer(const SoundBuffer& buffer) { // First detach from the previous buffer if (myBuffer) { Stop(); myBuffer->DetachSound(this); } // Assign and use the new buffer myBuffer = &buffer; myBuffer->AttachSound(this); ALCheck(alSourcei(mySource, AL_BUFFER, myBuffer->myBuffer)); } //////////////////////////////////////////////////////////// void Sound::SetLoop(bool Loop) { ALCheck(alSourcei(mySource, AL_LOOPING, Loop)); } //////////////////////////////////////////////////////////// void Sound::SetPlayingOffset(float timeOffset) { ALCheck(alSourcef(mySource, AL_SEC_OFFSET, timeOffset)); } //////////////////////////////////////////////////////////// const SoundBuffer* Sound::GetBuffer() const { return myBuffer; } //////////////////////////////////////////////////////////// bool Sound::GetLoop() const { ALint loop; ALCheck(alGetSourcei(mySource, AL_LOOPING, &loop)); return loop != 0; } //////////////////////////////////////////////////////////// float Sound::GetPlayingOffset() const { ALfloat seconds = 0.f; ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &seconds)); return seconds; } //////////////////////////////////////////////////////////// Sound::Status Sound::GetStatus() const { return SoundSource::GetStatus(); } //////////////////////////////////////////////////////////// Sound& Sound::operator =(const Sound& right) { // Here we don't use the copy-and-swap idiom, because it would mess up // the list of sound instances contained in the buffers // Detach the sound instance from the previous buffer (if any) if (myBuffer) { Stop(); myBuffer->DetachSound(this); myBuffer = NULL; } // Copy the sound attributes if (right.myBuffer) SetBuffer(*right.myBuffer); SetLoop(right.GetLoop()); SetPitch(right.GetPitch()); SetVolume(right.GetVolume()); SetPosition(right.GetPosition()); SetRelativeToListener(right.IsRelativeToListener()); SetMinDistance(right.GetMinDistance()); SetAttenuation(right.GetAttenuation()); return *this; } //////////////////////////////////////////////////////////// void Sound::ResetBuffer() { // First stop the sound in case it is playing Stop(); // Detach the buffer ALCheck(alSourcei(mySource, AL_BUFFER, 0)); myBuffer = NULL; } } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/ALCheck.hpp0000644000000000000000000000475511770572147022375 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_ALCHECK_HPP #define SFML_ALCHECK_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// /// Let's define a macro to quickly check every OpenAL /// API calls //////////////////////////////////////////////////////////// #ifdef SFML_DEBUG // If in debug mode, perform a test on every call #define ALCheck(Func) ((Func), priv::ALCheckError(__FILE__, __LINE__)) #else // Else, we don't add any overhead #define ALCheck(Func) (Func) #endif //////////////////////////////////////////////////////////// /// Check the last OpenAL error /// /// \param file Source file where the call is located /// \param line Line number of the source file where the call is located /// //////////////////////////////////////////////////////////// void ALCheckError(const std::string& file, unsigned int line); //////////////////////////////////////////////////////////// /// Make sure that OpenAL is initialized /// //////////////////////////////////////////////////////////// void EnsureALInit(); } // namespace priv } // namespace sf #endif // SFML_ALCHECK_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/SoundFile.cpp0000644000000000000000000002520111770572147023013 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// SoundFile::SoundFile() : myFile (NULL), myNbSamples (0), myChannelsCount(0), mySampleRate (0) { } //////////////////////////////////////////////////////////// SoundFile::~SoundFile() { if (myFile) sf_close(myFile); } //////////////////////////////////////////////////////////// std::size_t SoundFile::GetSamplesCount() const { return myNbSamples; } //////////////////////////////////////////////////////////// unsigned int SoundFile::GetChannelsCount() const { return myChannelsCount; } //////////////////////////////////////////////////////////// unsigned int SoundFile::GetSampleRate() const { return mySampleRate; } //////////////////////////////////////////////////////////// bool SoundFile::OpenRead(const std::string& filename) { // If the file is already opened, first close it if (myFile) sf_close(myFile); // Open the sound file SF_INFO fileInfos; myFile = sf_open(filename.c_str(), SFM_READ, &fileInfos); if (!myFile) { Err() << "Failed to read sound file \"" << filename << "\" (" << sf_strerror(myFile) << ")" << std::endl; return false; } // Set the sound parameters myChannelsCount = fileInfos.channels; mySampleRate = fileInfos.samplerate; myNbSamples = static_cast(fileInfos.frames) * myChannelsCount; return true; } //////////////////////////////////////////////////////////// bool SoundFile::OpenRead(const void* data, std::size_t sizeInBytes) { // If the file is already opened, first close it if (myFile) sf_close(myFile); // Prepare the memory I/O structure SF_VIRTUAL_IO io = myMemoryIO.Prepare(data, sizeInBytes); // Open the sound file SF_INFO fileInfos; myFile = sf_open_virtual(&io, SFM_READ, &fileInfos, &myMemoryIO); if (!myFile) { Err() << "Failed to read sound file from memory (" << sf_strerror(myFile) << ")" << std::endl; return false; } // Set the sound parameters myChannelsCount = fileInfos.channels; mySampleRate = fileInfos.samplerate; myNbSamples = static_cast(fileInfos.frames) * myChannelsCount; return true; } //////////////////////////////////////////////////////////// bool SoundFile::OpenWrite(const std::string& filename, unsigned int channelsCount, unsigned int sampleRate) { // If the file is already opened, first close it if (myFile) sf_close(myFile); // Find the right format according to the file extension int format = GetFormatFromFilename(filename); if (format == -1) { // Error : unrecognized extension Err() << "Failed to create sound file \"" << filename << "\" (unknown format)" << std::endl; return false; } // Fill the sound infos with parameters SF_INFO fileInfos; fileInfos.channels = channelsCount; fileInfos.samplerate = sampleRate; fileInfos.format = format | (format == SF_FORMAT_OGG ? SF_FORMAT_VORBIS : SF_FORMAT_PCM_16); // Open the sound file for writing myFile = sf_open(filename.c_str(), SFM_WRITE, &fileInfos); if (!myFile) { Err() << "Failed to create sound file \"" << filename << "\" (" << sf_strerror(myFile) << ")" << std::endl; return false; } // Set the sound parameters myChannelsCount = channelsCount; mySampleRate = sampleRate; myNbSamples = 0; return true; } //////////////////////////////////////////////////////////// std::size_t SoundFile::Read(Int16* data, std::size_t nbSamples) { if (myFile && data && nbSamples) return static_cast(sf_read_short(myFile, data, nbSamples)); else return 0; } //////////////////////////////////////////////////////////// void SoundFile::Write(const Int16* data, std::size_t nbSamples) { if (myFile && data && nbSamples) { // Write small chunks instead of everything at once, // to avoid a stack overflow in libsndfile (happens only with OGG format) while (nbSamples > 0) { std::size_t count = nbSamples > 10000 ? 10000 : nbSamples; sf_write_short(myFile, data, count); data += count; nbSamples -= count; } } } //////////////////////////////////////////////////////////// void SoundFile::Seek(float timeOffset) { if (myFile) { sf_count_t frameOffset = static_cast(timeOffset * mySampleRate); sf_seek(myFile, frameOffset, SEEK_SET); } } //////////////////////////////////////////////////////////// int SoundFile::GetFormatFromFilename(const std::string& filename) { // Extract the extension std::string ext = "wav"; std::string::size_type pos = filename.find_last_of("."); if (pos != std::string::npos) ext = filename.substr(pos + 1); // Match every supported extension with its format constant if (ext == "wav" || ext == "WAV" ) return SF_FORMAT_WAV; if (ext == "aif" || ext == "AIF" ) return SF_FORMAT_AIFF; if (ext == "aiff" || ext == "AIFF") return SF_FORMAT_AIFF; if (ext == "au" || ext == "AU" ) return SF_FORMAT_AU; if (ext == "raw" || ext == "RAW" ) return SF_FORMAT_RAW; if (ext == "paf" || ext == "PAF" ) return SF_FORMAT_PAF; if (ext == "svx" || ext == "SVX" ) return SF_FORMAT_SVX; if (ext == "nist" || ext == "NIST") return SF_FORMAT_NIST; if (ext == "voc" || ext == "VOC" ) return SF_FORMAT_VOC; if (ext == "sf" || ext == "SF" ) return SF_FORMAT_IRCAM; if (ext == "w64" || ext == "W64" ) return SF_FORMAT_W64; if (ext == "mat4" || ext == "MAT4") return SF_FORMAT_MAT4; if (ext == "mat5" || ext == "MAT5") return SF_FORMAT_MAT5; if (ext == "pvf" || ext == "PVF" ) return SF_FORMAT_PVF; if (ext == "xi" || ext == "XI" ) return SF_FORMAT_XI; if (ext == "htk" || ext == "HTK" ) return SF_FORMAT_HTK; if (ext == "sds" || ext == "SDS" ) return SF_FORMAT_SDS; if (ext == "avr" || ext == "AVR" ) return SF_FORMAT_AVR; if (ext == "sd2" || ext == "SD2" ) return SF_FORMAT_SD2; if (ext == "flac" || ext == "FLAC") return SF_FORMAT_FLAC; if (ext == "caf" || ext == "CAF" ) return SF_FORMAT_CAF; if (ext == "wve" || ext == "WVE" ) return SF_FORMAT_WVE; if (ext == "ogg" || ext == "OGG") return SF_FORMAT_OGG; if (ext == "mpc2k" || ext == "MPC2K") return SF_FORMAT_MPC2K; if (ext == "rf64" || ext == "RF64") return SF_FORMAT_RF64; return -1; } //////////////////////////////////////////////////////////// SF_VIRTUAL_IO SoundFile::MemoryIO::Prepare(const void* data, std::size_t sizeInBytes) { // Setup the I/O functions SF_VIRTUAL_IO io; io.get_filelen = &SoundFile::MemoryIO::GetLength; io.read = &SoundFile::MemoryIO::Read; io.seek = &SoundFile::MemoryIO::Seek; io.tell = &SoundFile::MemoryIO::Tell; io.write = &SoundFile::MemoryIO::Write; // Initialize the memory data myDataStart = static_cast(data); myDataPtr = myDataStart; myTotalSize = sizeInBytes; return io; } //////////////////////////////////////////////////////////// sf_count_t SoundFile::MemoryIO::GetLength(void* userData) { MemoryIO* self = static_cast(userData); return self->myTotalSize; } //////////////////////////////////////////////////////////// sf_count_t SoundFile::MemoryIO::Read(void* ptr, sf_count_t count, void* userData) { MemoryIO* self = static_cast(userData); sf_count_t position = self->myDataPtr - self->myDataStart; if (position + count >= self->myTotalSize) count = self->myTotalSize - position; std::memcpy(ptr, self->myDataPtr, static_cast(count)); self->myDataPtr += count; return count; } //////////////////////////////////////////////////////////// sf_count_t SoundFile::MemoryIO::Seek(sf_count_t offset, int whence, void* userData) { MemoryIO* self = static_cast(userData); sf_count_t position = 0; switch (whence) { case SEEK_SET : position = offset; break; case SEEK_CUR : position = self->myDataPtr - self->myDataStart + offset; break; case SEEK_END : position = self->myTotalSize - offset; break; default : position = 0; break; } if (position >= self->myTotalSize) position = self->myTotalSize - 1; else if (position < 0) position = 0; self->myDataPtr = self->myDataStart + position; return position; } //////////////////////////////////////////////////////////// sf_count_t SoundFile::MemoryIO::Tell(void* userData) { MemoryIO* self = static_cast(userData); return self->myDataPtr - self->myDataStart; } //////////////////////////////////////////////////////////// sf_count_t SoundFile::MemoryIO::Write(const void*, sf_count_t, void*) { return 0; } } // namespace priv } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/SoundStream.cpp0000644000000000000000000002370711770572147023400 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include #include #ifdef _MSC_VER #pragma warning(disable : 4355) // 'this' used in base member initializer list #endif namespace sf { //////////////////////////////////////////////////////////// SoundStream::SoundStream() : myThread (&SoundStream::Stream, this), myIsStreaming (false), myChannelsCount (0), mySampleRate (0), myFormat (0), myLoop (false), mySamplesProcessed(0) { } //////////////////////////////////////////////////////////// SoundStream::~SoundStream() { // Stop the sound if it was playing Stop(); } //////////////////////////////////////////////////////////// void SoundStream::Initialize(unsigned int channelsCount, unsigned int sampleRate) { myChannelsCount = channelsCount; mySampleRate = sampleRate; // Deduce the format from the number of channels myFormat = priv::AudioDevice::GetFormatFromChannelsCount(channelsCount); // Check if the format is valid if (myFormat == 0) { myChannelsCount = 0; mySampleRate = 0; Err() << "Unsupported number of channels (" << myChannelsCount << ")" << std::endl; } } //////////////////////////////////////////////////////////// void SoundStream::Play() { // Check if the sound parameters have been set if (myFormat == 0) { Err() << "Failed to play audio stream: sound parameters have not been initialized (call Initialize first)" << std::endl; return; } // If the sound is already playing (probably paused), just resume it if (myIsStreaming) { ALCheck(alSourcePlay(mySource)); return; } // Move to the beginning OnSeek(0); // Start updating the stream in a separate thread to avoid blocking the application mySamplesProcessed = 0; myIsStreaming = true; myThread.Launch(); } //////////////////////////////////////////////////////////// void SoundStream::Pause() { ALCheck(alSourcePause(mySource)); } //////////////////////////////////////////////////////////// void SoundStream::Stop() { // Wait for the thread to terminate myIsStreaming = false; myThread.Wait(); } //////////////////////////////////////////////////////////// unsigned int SoundStream::GetChannelsCount() const { return myChannelsCount; } //////////////////////////////////////////////////////////// unsigned int SoundStream::GetSampleRate() const { return mySampleRate; } //////////////////////////////////////////////////////////// SoundStream::Status SoundStream::GetStatus() const { Status status = SoundSource::GetStatus(); // To compensate for the lag between Play() and alSourcePlay() if ((status == Stopped) && myIsStreaming) status = Playing; return status; } //////////////////////////////////////////////////////////// void SoundStream::SetPlayingOffset(float timeOffset) { // Stop the stream Stop(); // Let the derived class update the current position OnSeek(timeOffset); // Restart streaming mySamplesProcessed = static_cast(timeOffset * mySampleRate * myChannelsCount); myIsStreaming = true; myThread.Launch(); } //////////////////////////////////////////////////////////// float SoundStream::GetPlayingOffset() const { ALfloat seconds = 0.f; ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &seconds)); return seconds + static_cast(mySamplesProcessed) / mySampleRate / myChannelsCount; } //////////////////////////////////////////////////////////// void SoundStream::SetLoop(bool loop) { myLoop = loop; } //////////////////////////////////////////////////////////// bool SoundStream::GetLoop() const { return myLoop; } //////////////////////////////////////////////////////////// void SoundStream::Stream() { // Create the buffers ALCheck(alGenBuffers(BuffersCount, myBuffers)); for (int i = 0; i < BuffersCount; ++i) myEndBuffers[i] = false; // Fill the queue bool requestStop = FillQueue(); // Play the sound ALCheck(alSourcePlay(mySource)); while (myIsStreaming) { // The stream has been interrupted! if (SoundSource::GetStatus() == Stopped) { if (!requestStop) { // Just continue ALCheck(alSourcePlay(mySource)); } else { // End streaming myIsStreaming = false; } } // Get the number of buffers that have been processed (ie. ready for reuse) ALint nbProcessed = 0; ALCheck(alGetSourcei(mySource, AL_BUFFERS_PROCESSED, &nbProcessed)); while (nbProcessed--) { // Pop the first unused buffer from the queue ALuint buffer; ALCheck(alSourceUnqueueBuffers(mySource, 1, &buffer)); // Find its number unsigned int bufferNum = 0; for (int i = 0; i < BuffersCount; ++i) if (myBuffers[i] == buffer) { bufferNum = i; break; } // Retrieve its size and add it to the samples count if (myEndBuffers[bufferNum]) { // This was the last buffer: reset the sample count mySamplesProcessed = 0; myEndBuffers[bufferNum] = false; } else { ALint size, bits; ALCheck(alGetBufferi(buffer, AL_SIZE, &size)); ALCheck(alGetBufferi(buffer, AL_BITS, &bits)); mySamplesProcessed += size / (bits / 8); } // Fill it and push it back into the playing queue if (!requestStop) { if (FillAndPushBuffer(bufferNum)) requestStop = true; } } // Leave some time for the other threads if the stream is still playing if (SoundSource::GetStatus() != Stopped) Sleep(0.01f); } // Stop the playback ALCheck(alSourceStop(mySource)); // Unqueue any buffer left in the queue ClearQueue(); // Delete the buffers ALCheck(alSourcei(mySource, AL_BUFFER, 0)); ALCheck(alDeleteBuffers(BuffersCount, myBuffers)); } //////////////////////////////////////////////////////////// bool SoundStream::FillAndPushBuffer(unsigned int bufferNum) { bool requestStop = false; // Acquire audio data Chunk data = {NULL, 0}; if (!OnGetData(data)) { // Mark the buffer as the last one (so that we know when to reset the playing position) myEndBuffers[bufferNum] = true; // Check if the stream must loop or stop if (myLoop) { // Return to the beginning of the stream source OnSeek(0); // If we previously had no data, try to fill the buffer once again if (!data.Samples || (data.NbSamples == 0)) { return FillAndPushBuffer(bufferNum); } } else { // Not looping: request stop requestStop = true; } } // Fill the buffer if some data was returned if (data.Samples && data.NbSamples) { unsigned int buffer = myBuffers[bufferNum]; // Fill the buffer ALsizei size = static_cast(data.NbSamples) * sizeof(Int16); ALCheck(alBufferData(buffer, myFormat, data.Samples, size, mySampleRate)); // Push it into the sound queue ALCheck(alSourceQueueBuffers(mySource, 1, &buffer)); } return requestStop; } //////////////////////////////////////////////////////////// bool SoundStream::FillQueue() { // Fill and enqueue all the available buffers bool requestStop = false; for (int i = 0; (i < BuffersCount) && !requestStop; ++i) { if (FillAndPushBuffer(i)) requestStop = true; } return requestStop; } //////////////////////////////////////////////////////////// void SoundStream::ClearQueue() { // Get the number of buffers still in the queue ALint nbQueued; ALCheck(alGetSourcei(mySource, AL_BUFFERS_QUEUED, &nbQueued)); // Unqueue them all ALuint buffer; for (ALint i = 0; i < nbQueued; ++i) ALCheck(alSourceUnqueueBuffers(mySource, 1, &buffer)); } } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/AudioDevice.hpp0000644000000000000000000000615411770572147023317 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_AUDIODEVICE_HPP #define SFML_AUDIODEVICE_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// /// \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 AudioDevice { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// //////////////////////////////////////////////////////////// AudioDevice(); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~AudioDevice(); //////////////////////////////////////////////////////////// /// \brief Check if an OpenAL extension is supported /// /// This functions automatically finds whether it /// is an AL or ALC extension, and calls the corresponding /// function. /// /// \param extension Name of the extension to test /// /// \return True if the extension is supported, false if not /// //////////////////////////////////////////////////////////// static bool IsExtensionSupported(const std::string& extension); //////////////////////////////////////////////////////////// /// \brief Get the OpenAL format that matches the given number of channels /// /// \param channelsCount Number of channels /// /// \return Corresponding format /// //////////////////////////////////////////////////////////// static int GetFormatFromChannelsCount(unsigned int channelsCount); }; } // namespace priv } // namespace sf #endif // SFML_AUDIODEVICE_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/SoundFile.hpp0000644000000000000000000001627011770572147023026 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDFILE_HPP #define SFML_SOUNDFILE_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// /// \brief Provide read and write access to sound files /// //////////////////////////////////////////////////////////// class SoundFile : NonCopyable { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// //////////////////////////////////////////////////////////// SoundFile(); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~SoundFile(); //////////////////////////////////////////////////////////// /// \brief Get the total number of audio samples in the file /// /// \return Number of samples /// //////////////////////////////////////////////////////////// std::size_t GetSamplesCount() const; //////////////////////////////////////////////////////////// /// \brief Get the number of channels used by the sound /// /// \return Number of channels (1 = mono, 2 = stereo) /// //////////////////////////////////////////////////////////// unsigned int GetChannelsCount() const; //////////////////////////////////////////////////////////// /// \brief Get the sample rate of the sound /// /// \return Sample rate, in samples per second /// //////////////////////////////////////////////////////////// unsigned int GetSampleRate() const; //////////////////////////////////////////////////////////// /// \brief Open a sound file for reading /// /// \param filename Path of the sound file to load /// /// \return True if the file was successfully opened /// //////////////////////////////////////////////////////////// bool OpenRead(const std::string& filename); //////////////////////////////////////////////////////////// /// \brief Open a sound file in memory for reading /// /// \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 OpenRead(const void* data, std::size_t sizeInBytes); //////////////////////////////////////////////////////////// /// \brief a the sound file for writing /// /// \param filename Path of the sound file to write /// \param channelsCount Number of channels in the sound /// \param sampleRate Sample rate of the sound /// /// \return True if the file was successfully opened /// //////////////////////////////////////////////////////////// bool OpenWrite(const std::string& filename, unsigned int channelsCount, unsigned int sampleRate); //////////////////////////////////////////////////////////// /// \brief Read audio samples from the loaded sound /// /// \param data Pointer to the samples array to fill /// \param nbSamples Number of samples to read /// /// \return Number of samples actually read (may be less than \a nbSamples) /// //////////////////////////////////////////////////////////// std::size_t Read(Int16* data, std::size_t nbSamples); //////////////////////////////////////////////////////////// /// \brief Write audio samples to the file /// /// \param data Pointer to the samples array to write /// \param nbSamples Number of samples to write /// //////////////////////////////////////////////////////////// void Write(const Int16* data, std::size_t nbSamples); //////////////////////////////////////////////////////////// /// \brief Change the current read position in the file /// /// \param timeOffset New read position, in seconds /// //////////////////////////////////////////////////////////// void Seek(float timeOffset); private : //////////////////////////////////////////////////////////// /// \brief Get the internal format of an audio file according to /// its filename extension /// /// \param filename Filename to check /// /// \return Internal format matching the filename (-1 if no match) /// //////////////////////////////////////////////////////////// static int GetFormatFromFilename(const std::string& filename); //////////////////////////////////////////////////////////// /// \brief Provide I/O functions for manipulating files in memory /// //////////////////////////////////////////////////////////// class MemoryIO { public : SF_VIRTUAL_IO Prepare(const void* data, std::size_t sizeInBytes); private : static sf_count_t GetLength(void* userData); static sf_count_t Read(void* ptr, sf_count_t count, void* userData); static sf_count_t Seek(sf_count_t offset, int whence, void* userData); static sf_count_t Tell(void* userData); static sf_count_t Write(const void* ptr, sf_count_t count, void* userData); const char* myDataStart; const char* myDataPtr; sf_count_t myTotalSize; }; //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// SNDFILE* myFile; ///< File descriptor MemoryIO myMemoryIO; ///< Memory read / write data std::size_t myNbSamples; ///< Total number of samples in the file unsigned int myChannelsCount; ///< Number of channels used by the sound unsigned int mySampleRate; ///< Number of samples per second }; } // namespace priv } // namespace sf #endif // SFML_SOUNDFILE_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/Music.cpp0000644000000000000000000001037211770572147022206 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include #include #include namespace sf { //////////////////////////////////////////////////////////// Music::Music() : myFile (new priv::SoundFile), myDuration(0.f) { } //////////////////////////////////////////////////////////// Music::~Music() { // We must stop before destroying the file :) Stop(); delete myFile; } //////////////////////////////////////////////////////////// bool Music::OpenFromFile(const std::string& filename) { // First stop the music if it was already running Stop(); // Create the sound file implementation, and open it in read mode if (!myFile->OpenRead(filename)) { Err() << "Failed to open \"" << filename << "\" for reading" << std::endl; return false; } // Compute the duration myDuration = static_cast(myFile->GetSamplesCount()) / myFile->GetSampleRate() / myFile->GetChannelsCount(); // Resize the internal buffer so that it can contain 1 second of audio samples mySamples.resize(myFile->GetSampleRate() * myFile->GetChannelsCount()); // Initialize the stream Initialize(myFile->GetChannelsCount(), myFile->GetSampleRate()); return true; } //////////////////////////////////////////////////////////// bool Music::OpenFromMemory(const void* data, std::size_t sizeInBytes) { // First stop the music if it was already running Stop(); // Create the sound file implementation, and open it in read mode if (!myFile->OpenRead(data, sizeInBytes)) { Err() << "Failed to open music from memory for reading" << std::endl; return false; } // Compute the duration myDuration = static_cast(myFile->GetSamplesCount()) / myFile->GetSampleRate() / myFile->GetChannelsCount(); // Resize the internal buffer so that it can contain 1 second of audio samples mySamples.resize(myFile->GetSampleRate() * myFile->GetChannelsCount()); // Initialize the stream Initialize(myFile->GetChannelsCount(), myFile->GetSampleRate()); return true; } //////////////////////////////////////////////////////////// float Music::GetDuration() const { return myDuration; } //////////////////////////////////////////////////////////// bool Music::OnGetData(SoundStream::Chunk& data) { Lock lock(myMutex); // Fill the chunk parameters data.Samples = &mySamples[0]; data.NbSamples = myFile->Read(&mySamples[0], mySamples.size()); // Check if we have reached the end of the audio file return data.NbSamples == mySamples.size(); } //////////////////////////////////////////////////////////// /// /see SoundStream::OnSeek //////////////////////////////////////////////////////////// void Music::OnSeek(float timeOffset) { Lock lock(myMutex); myFile->Seek(timeOffset); } } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/SoundSource.cpp0000644000000000000000000001240111770572147023372 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { //////////////////////////////////////////////////////////// SoundSource::SoundSource() { priv::EnsureALInit(); ALCheck(alGenSources(1, &mySource)); ALCheck(alSourcei(mySource, AL_BUFFER, 0)); } //////////////////////////////////////////////////////////// SoundSource::SoundSource(const SoundSource& copy) { priv::EnsureALInit(); ALCheck(alGenSources(1, &mySource)); ALCheck(alSourcei(mySource, AL_BUFFER, 0)); SetPitch(copy.GetPitch()); SetVolume(copy.GetVolume()); SetPosition(copy.GetPosition()); SetRelativeToListener(copy.IsRelativeToListener()); SetMinDistance(copy.GetMinDistance()); SetAttenuation(copy.GetAttenuation()); } //////////////////////////////////////////////////////////// SoundSource::~SoundSource() { ALCheck(alSourcei(mySource, AL_BUFFER, 0)); ALCheck(alDeleteSources(1, &mySource)); } //////////////////////////////////////////////////////////// void SoundSource::SetPitch(float pitch) { ALCheck(alSourcef(mySource, AL_PITCH, pitch)); } //////////////////////////////////////////////////////////// void SoundSource::SetVolume(float volume) { ALCheck(alSourcef(mySource, AL_GAIN, volume * 0.01f)); } //////////////////////////////////////////////////////////// void SoundSource::SetPosition(float x, float y, float z) { ALCheck(alSource3f(mySource, AL_POSITION, x, y, z)); } //////////////////////////////////////////////////////////// void SoundSource::SetPosition(const Vector3f& position) { SetPosition(position.x, position.y, position.z); } //////////////////////////////////////////////////////////// void SoundSource::SetRelativeToListener(bool relative) { ALCheck(alSourcei(mySource, AL_SOURCE_RELATIVE, relative)); } //////////////////////////////////////////////////////////// void SoundSource::SetMinDistance(float distance) { ALCheck(alSourcef(mySource, AL_REFERENCE_DISTANCE, distance)); } //////////////////////////////////////////////////////////// void SoundSource::SetAttenuation(float attenuation) { ALCheck(alSourcef(mySource, AL_ROLLOFF_FACTOR, attenuation)); } //////////////////////////////////////////////////////////// float SoundSource::GetPitch() const { ALfloat pitch; ALCheck(alGetSourcef(mySource, AL_PITCH, &pitch)); return pitch; } //////////////////////////////////////////////////////////// float SoundSource::GetVolume() const { ALfloat gain; ALCheck(alGetSourcef(mySource, AL_GAIN, &gain)); return gain * 100.f; } //////////////////////////////////////////////////////////// Vector3f SoundSource::GetPosition() const { Vector3f position; ALCheck(alGetSource3f(mySource, AL_POSITION, &position.x, &position.y, &position.z)); return position; } //////////////////////////////////////////////////////////// bool SoundSource::IsRelativeToListener() const { ALint relative; ALCheck(alGetSourcei(mySource, AL_SOURCE_RELATIVE, &relative)); return relative != 0; } //////////////////////////////////////////////////////////// float SoundSource::GetMinDistance() const { ALfloat distance; ALCheck(alGetSourcef(mySource, AL_REFERENCE_DISTANCE, &distance)); return distance; } //////////////////////////////////////////////////////////// float SoundSource::GetAttenuation() const { ALfloat attenuation; ALCheck(alGetSourcef(mySource, AL_ROLLOFF_FACTOR, &attenuation)); return attenuation; } //////////////////////////////////////////////////////////// SoundSource::Status SoundSource::GetStatus() const { ALint status; ALCheck(alGetSourcei(mySource, AL_SOURCE_STATE, &status)); switch (status) { case AL_INITIAL : case AL_STOPPED : return Stopped; case AL_PAUSED : return Paused; case AL_PLAYING : return Playing; } return Stopped; } } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/ALCheck.cpp0000644000000000000000000000705111770572147022360 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include namespace sf { namespace priv { //////////////////////////////////////////////////////////// void ALCheckError(const std::string& file, unsigned int line) { // Get the last error ALenum errorCode = alGetError(); if (errorCode != AL_NO_ERROR) { std::string error, description; // Decode the error code switch (errorCode) { case AL_INVALID_NAME : { error = "AL_INVALID_NAME"; description = "an unacceptable name has been specified"; break; } case AL_INVALID_ENUM : { error = "AL_INVALID_ENUM"; description = "an unacceptable value has been specified for an enumerated argument"; break; } case AL_INVALID_VALUE : { error = "AL_INVALID_VALUE"; description = "a numeric argument is out of range"; break; } case AL_INVALID_OPERATION : { error = "AL_INVALID_OPERATION"; description = "the specified operation is not allowed in the current state"; break; } case AL_OUT_OF_MEMORY : { error = "AL_OUT_OF_MEMORY"; description = "there is not enough memory left to execute the command"; break; } } // Log the error Err() << "An internal OpenAL call failed in " << file.substr(file.find_last_of("\\/") + 1) << " (" << line << ") : " << error << ", " << description << std::endl; } } //////////////////////////////////////////////////////////// /// Make sure that OpenAL is initialized //////////////////////////////////////////////////////////// void EnsureALInit() { // The audio device is instanciated on demand rather than at global startup, // which solves a lot of weird crashes and errors. // It is destroyed at global exit which is fine. static AudioDevice globalDevice; } } // namespace priv } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/SoundBuffer.cpp0000644000000000000000000002031511770572147023346 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include #include #include #include namespace sf { //////////////////////////////////////////////////////////// SoundBuffer::SoundBuffer() : myBuffer (0), myDuration(0.f) { priv::EnsureALInit(); // Create the buffer ALCheck(alGenBuffers(1, &myBuffer)); } //////////////////////////////////////////////////////////// SoundBuffer::SoundBuffer(const SoundBuffer& copy) : Resource(), myBuffer (0), mySamples (copy.mySamples), myDuration (copy.myDuration), mySounds () // don't copy the attached sounds { // Create the buffer ALCheck(alGenBuffers(1, &myBuffer)); // Update the internal buffer with the new samples Update(copy.GetChannelsCount(), copy.GetSampleRate()); } //////////////////////////////////////////////////////////// SoundBuffer::~SoundBuffer() { // First detach the buffer from the sounds that use it (to avoid OpenAL errors) for (SoundList::const_iterator it = mySounds.begin(); it != mySounds.end(); ++it) (*it)->ResetBuffer(); // Destroy the buffer if (myBuffer) ALCheck(alDeleteBuffers(1, &myBuffer)); } //////////////////////////////////////////////////////////// bool SoundBuffer::LoadFromFile(const std::string& filename) { // Open the sound file priv::SoundFile file; if (file.OpenRead(filename)) { // Get the sound parameters std::size_t nbSamples = file.GetSamplesCount(); unsigned int channelsCount = file.GetChannelsCount(); unsigned int sampleRate = file.GetSampleRate(); // Read the samples from the opened file mySamples.resize(nbSamples); if (file.Read(&mySamples[0], nbSamples) == nbSamples) { // Update the internal buffer with the new samples return Update(channelsCount, sampleRate); } else { return false; } } else { return false; } } //////////////////////////////////////////////////////////// bool SoundBuffer::LoadFromMemory(const void* data, std::size_t sizeInBytes) { // Open the sound file priv::SoundFile file; if (file.OpenRead(data, sizeInBytes)) { // Get the sound parameters std::size_t nbSamples = file.GetSamplesCount(); unsigned int channelsCount = file.GetChannelsCount(); unsigned int sampleRate = file.GetSampleRate(); // Read the samples from the opened file mySamples.resize(nbSamples); if (file.Read(&mySamples[0], nbSamples) == nbSamples) { // Update the internal buffer with the new samples return Update(channelsCount, sampleRate); } else { return false; } } else { return false; } } //////////////////////////////////////////////////////////// bool SoundBuffer::LoadFromSamples(const Int16* samples, std::size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate) { if (samples && samplesCount && channelsCount && sampleRate) { // Copy the new audio samples mySamples.assign(samples, samples + samplesCount); // Update the internal buffer with the new samples return Update(channelsCount, sampleRate); } else { // Error... Err() << "Failed to load sound buffer from memory (" << "Samples : " << samples << ", " << "Samples count : " << samplesCount << ", " << "Channels count : " << channelsCount << ", " << "Sample rate : " << sampleRate << ")" << std::endl; return false; } } //////////////////////////////////////////////////////////// bool SoundBuffer::SaveToFile(const std::string& filename) const { // Create the sound file in write mode priv::SoundFile file; if (file.OpenWrite(filename, GetChannelsCount(), GetSampleRate())) { // Write the samples to the opened file file.Write(&mySamples[0], mySamples.size()); return true; } else { return false; } } //////////////////////////////////////////////////////////// const Int16* SoundBuffer::GetSamples() const { return mySamples.empty() ? NULL : &mySamples[0]; } //////////////////////////////////////////////////////////// std::size_t SoundBuffer::GetSamplesCount() const { return mySamples.size(); } //////////////////////////////////////////////////////////// unsigned int SoundBuffer::GetSampleRate() const { ALint sampleRate; ALCheck(alGetBufferi(myBuffer, AL_FREQUENCY, &sampleRate)); return sampleRate; } //////////////////////////////////////////////////////////// unsigned int SoundBuffer::GetChannelsCount() const { ALint channelsCount; ALCheck(alGetBufferi(myBuffer, AL_CHANNELS, &channelsCount)); return channelsCount; } //////////////////////////////////////////////////////////// float SoundBuffer::GetDuration() const { return myDuration; } //////////////////////////////////////////////////////////// SoundBuffer& SoundBuffer::operator =(const SoundBuffer& right) { SoundBuffer temp(right); std::swap(mySamples, temp.mySamples); std::swap(myBuffer, temp.myBuffer); std::swap(myDuration, temp.myDuration); std::swap(mySounds, temp.mySounds); // swap sounds too, so that they are detached when temp is destroyed return *this; } //////////////////////////////////////////////////////////// bool SoundBuffer::Update(unsigned int channelsCount, unsigned int sampleRate) { // Check parameters if (!channelsCount || !sampleRate || mySamples.empty()) return false; // Find the good format according to the number of channels ALenum format = priv::AudioDevice::GetFormatFromChannelsCount(channelsCount); // Check if the format is valid if (format == 0) { Err() << "Unsupported number of channels (" << channelsCount << ")" << std::endl; return false; } // Fill the buffer ALsizei size = static_cast(mySamples.size()) * sizeof(Int16); ALCheck(alBufferData(myBuffer, format, &mySamples[0], size, sampleRate)); // Compute the duration myDuration = static_cast(mySamples.size()) / sampleRate / channelsCount; return true; } //////////////////////////////////////////////////////////// void SoundBuffer::AttachSound(Sound* sound) const { mySounds.insert(sound); } //////////////////////////////////////////////////////////// void SoundBuffer::DetachSound(Sound* sound) const { mySounds.erase(sound); } } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/include/0000755000000000000000000000000011770572147017451 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/0000755000000000000000000000000011770572147020212 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/Config.hpp0000644000000000000000000001222111770572147022126 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_CONFIG_HPP #define SFML_CONFIG_HPP //////////////////////////////////////////////////////////// // Define the SFML version //////////////////////////////////////////////////////////// #define SFML_VERSION_MAJOR 2 #define SFML_VERSION_MINOR 0 //////////////////////////////////////////////////////////// // Identify the operating system //////////////////////////////////////////////////////////// #if defined(_WIN32) || defined(__WIN32__) // Windows #define SFML_SYSTEM_WINDOWS #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #ifndef NOMINMAX #define NOMINMAX #endif #elif defined(linux) || defined(__linux) // Linux #define SFML_SYSTEM_LINUX #elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh) // MacOS #define SFML_SYSTEM_MACOS #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) // FreeBSD #define SFML_SYSTEM_FREEBSD #else // Unsupported system #error This operating system is not supported by SFML library #endif //////////////////////////////////////////////////////////// // Identify the endianess //////////////////////////////////////////////////////////// #if defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || (defined(__MIPS__) && defined(__MISPEB__)) || \ defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || defined(__sparc__) || defined(__hppa__) // Big endian #define SFML_ENDIAN_BIG #else // Little endian #define SFML_ENDIAN_LITTLE #endif //////////////////////////////////////////////////////////// // Define a portable debug macro //////////////////////////////////////////////////////////// #if !defined(NDEBUG) #define SFML_DEBUG #endif //////////////////////////////////////////////////////////// // Define portable import / export macros //////////////////////////////////////////////////////////// #if defined(SFML_SYSTEM_WINDOWS) && !defined(SFML_STATIC) #ifdef SFML_EXPORTS // From DLL side, we must export #define SFML_API __declspec(dllexport) #else // From client application side, we must import #define SFML_API __declspec(dllimport) #endif // For Visual C++ compilers, we also need to turn off this annoying C4251 warning. // You can read lots ot different things about it, but the point is the code will // just work fine, and so the simplest way to get rid of this warning is to disable it #ifdef _MSC_VER #pragma warning(disable : 4251) #endif #else // Other platforms and static build don't need these export macros #define SFML_API #endif //////////////////////////////////////////////////////////// // Define portable fixed-size types //////////////////////////////////////////////////////////// #include namespace sf { // 8 bits integer types #if UCHAR_MAX == 0xFF typedef signed char Int8; typedef unsigned char Uint8; #else #error No 8 bits integer type for this platform #endif // 16 bits integer types #if USHRT_MAX == 0xFFFF typedef signed short Int16; typedef unsigned short Uint16; #elif UINT_MAX == 0xFFFF typedef signed int Int16; typedef unsigned int Uint16; #elif ULONG_MAX == 0xFFFF typedef signed long Int16; typedef unsigned long Uint16; #else #error No 16 bits integer type for this platform #endif // 32 bits integer types #if USHRT_MAX == 0xFFFFFFFF typedef signed short Int32; typedef unsigned short Uint32; #elif UINT_MAX == 0xFFFFFFFF typedef signed int Int32; typedef unsigned int Uint32; #elif ULONG_MAX == 0xFFFFFFFF typedef signed long Int32; typedef unsigned long Uint32; #else #error No 32 bits integer type for this platform #endif } // namespace sf #endif // SFML_CONFIG_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/0000755000000000000000000000000011770572147021476 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/ThreadLocalPtr.inl0000644000000000000000000000436011770572147025055 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// namespace sf { //////////////////////////////////////////////////////////// template ThreadLocalPtr::ThreadLocalPtr(T* value) : ThreadLocal(value) { } //////////////////////////////////////////////////////////// template T& ThreadLocalPtr::operator *() const { return *static_cast(GetValue()); } //////////////////////////////////////////////////////////// template T* ThreadLocalPtr::operator ->() const { return static_cast(GetValue()); } //////////////////////////////////////////////////////////// template ThreadLocalPtr::operator T*() const { return static_cast(GetValue()); } //////////////////////////////////////////////////////////// template ThreadLocalPtr& ThreadLocalPtr::operator =(T* value) { SetValue(value); return *this; } //////////////////////////////////////////////////////////// template ThreadLocalPtr& ThreadLocalPtr::operator =(const ThreadLocalPtr& right) { SetValue(right.GetValue()); return *this; } } // namespace sf sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/String.hpp0000644000000000000000000005034011770572147023457 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_STRING_HPP #define SFML_STRING_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include namespace sf { //////////////////////////////////////////////////////////// /// \brief Utility string class that automatically handles /// conversions between types and encodings /// //////////////////////////////////////////////////////////// class SFML_API String { public : //////////////////////////////////////////////////////////// // Types //////////////////////////////////////////////////////////// typedef std::basic_string::iterator Iterator; ///< Iterator type typedef std::basic_string::const_iterator ConstIterator; ///< Constant iterator type //////////////////////////////////////////////////////////// // Static member data //////////////////////////////////////////////////////////// static const std::size_t InvalidPos; ///< Represents an invalid position in the string //////////////////////////////////////////////////////////// /// \brief Default constructor /// /// This constructor creates an empty string. /// //////////////////////////////////////////////////////////// String(); //////////////////////////////////////////////////////////// /// \brief Construct from a single ANSI character and a locale /// /// The source character is converted to UTF-32 according /// to the given locale. /// /// \param ansiChar ANSI character to convert /// \param locale Locale to use for conversion /// //////////////////////////////////////////////////////////// String(char ansiChar, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Construct from single wide character /// /// \param wideChar Wide character to convert /// //////////////////////////////////////////////////////////// String(wchar_t wideChar); //////////////////////////////////////////////////////////// /// \brief Construct from single UTF-32 character /// /// \param utf32Char UTF-32 character to convert /// //////////////////////////////////////////////////////////// String(Uint32 utf32Char); //////////////////////////////////////////////////////////// /// \brief Construct from a null-terminated C-style ANSI string and a locale /// /// The source string is converted to UTF-32 according /// to the given locale. /// /// \param ansiString ANSI string to convert /// \param locale Locale to use for conversion /// //////////////////////////////////////////////////////////// String(const char* ansiString, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Construct from an ANSI string and a locale /// /// The source string is converted to UTF-32 according /// to the given locale. /// /// \param ansiString ANSI string to convert /// \param locale Locale to use for conversion /// //////////////////////////////////////////////////////////// String(const std::string& ansiString, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Construct from null-terminated C-style wide string /// /// \param wideString Wide string to convert /// //////////////////////////////////////////////////////////// String(const wchar_t* wideString); //////////////////////////////////////////////////////////// /// \brief Construct from a wide string /// /// \param wideString Wide string to convert /// //////////////////////////////////////////////////////////// String(const std::wstring& wideString); //////////////////////////////////////////////////////////// /// \brief Construct from a null-terminated C-style UTF-32 string /// /// \param utf32String UTF-32 string to assign /// //////////////////////////////////////////////////////////// String(const Uint32* utf32String); //////////////////////////////////////////////////////////// /// \brief Construct from an UTF-32 string /// /// \param utf32String UTF-32 string to assign /// //////////////////////////////////////////////////////////// String(const std::basic_string& utf32String); //////////////////////////////////////////////////////////// /// \brief Copy constructor /// /// \param copy Instance to copy /// //////////////////////////////////////////////////////////// String(const String& copy); //////////////////////////////////////////////////////////// /// \brief Implicit cast operator to std::string (ANSI string) /// /// The current global locale is used for conversion. If you /// want to explicitely specify a locale, see ToAnsiString. /// Characters that do not fit in the target encoding are /// discarded from the returned string. /// This operator is defined for convenience, and is equivalent /// to calling ToAnsiString(). /// /// \return Converted ANSI string /// /// \see ToAnsiString, operator std::wstring /// //////////////////////////////////////////////////////////// operator std::string() const; //////////////////////////////////////////////////////////// /// \brief Implicit cast operator to std::wstring (wide string) /// /// Characters that do not fit in the target encoding are /// discarded from the returned string. /// This operator is defined for convenience, and is equivalent /// to calling ToWideString(). /// /// \return Converted wide string /// /// \see ToWideString, operator std::string /// //////////////////////////////////////////////////////////// operator std::wstring() const; //////////////////////////////////////////////////////////// /// \brief Convert the unicode string to an ANSI string /// /// The UTF-32 string is converted to an ANSI string in /// the encoding defined by \a locale. /// Characters that do not fit in the target encoding are /// discarded from the returned string. /// /// \param locale Locale to use for conversion /// /// \return Converted ANSI string /// /// \see ToWideString, operator std::string /// //////////////////////////////////////////////////////////// std::string ToAnsiString(const std::locale& locale = std::locale()) const; //////////////////////////////////////////////////////////// /// \brief Convert the unicode string to a wide string /// /// Characters that do not fit in the target encoding are /// discarded from the returned string. /// /// \return Converted wide string /// /// \see ToAnsiString, operator std::wstring /// //////////////////////////////////////////////////////////// std::wstring ToWideString() const; //////////////////////////////////////////////////////////// /// \brief Overload of assignment operator /// /// \param right Instance to assign /// /// \return Reference to self /// //////////////////////////////////////////////////////////// String& operator =(const String& right); //////////////////////////////////////////////////////////// /// \brief Overload of += operator to append an UTF-32 string /// /// \param right String to append /// /// \return Reference to self /// //////////////////////////////////////////////////////////// String& operator +=(const String& right); //////////////////////////////////////////////////////////// /// \brief Overload of [] operator to access a character by its position /// /// This function provides read-only access to characters. /// Note: this function doesn't throw if \a index is out of range. /// /// \param index Index of the character to get /// /// \return Character at position \a index /// //////////////////////////////////////////////////////////// Uint32 operator [](std::size_t index) const; //////////////////////////////////////////////////////////// /// \brief Overload of [] operator to access a character by its position /// /// This function provides read and write access to characters. /// Note: this function doesn't throw if \a index is out of range. /// /// \param index Index of the character to get /// /// \return Reference to the character at position \a index /// //////////////////////////////////////////////////////////// Uint32& operator [](std::size_t index); //////////////////////////////////////////////////////////// /// \brief Clear the string /// /// This function removes all the characters from the string. /// /// \see IsEmpty, Erase /// //////////////////////////////////////////////////////////// void Clear(); //////////////////////////////////////////////////////////// /// \brief Get the size of the string /// /// \return Number of characters in the string /// /// \see IsEmpty /// //////////////////////////////////////////////////////////// std::size_t GetSize() const; //////////////////////////////////////////////////////////// /// \brief Check whether the string is empty or not /// /// \return True if the string is empty (i.e. contains no character) /// /// \see Clear, GetSize /// //////////////////////////////////////////////////////////// bool IsEmpty() const; //////////////////////////////////////////////////////////// /// \brief Erase one or more characters from the string /// /// This function removes a sequence of \a count characters /// starting from \a position. /// /// \param position Position of the first character to erase /// \param count Number of characters to erase /// //////////////////////////////////////////////////////////// void Erase(std::size_t position, std::size_t count = 1); //////////////////////////////////////////////////////////// /// \brief Insert one or more characters into the string /// /// This function inserts the characters of \a str /// into the string, starting from \a position. /// /// \param position Position of insertion /// \param str Characters to insert /// //////////////////////////////////////////////////////////// void Insert(std::size_t position, const String& str); //////////////////////////////////////////////////////////// /// \brief Find a sequence of one or more characters in the string /// /// This function searches for the characters of \a str /// into the string, starting from \a start. /// /// \param str Characters to find /// \param start Where to begin searching /// /// \return Position of \a str in the string, or String::InvalidPos if not found /// //////////////////////////////////////////////////////////// std::size_t Find(const String& str, std::size_t start = 0) const; //////////////////////////////////////////////////////////// /// \brief Get a pointer to the C-style array of characters /// /// This functions provides a read-only access to a /// null-terminated C-style representation of the string. /// The returned pointer is temporary and is meant only for /// immediate use, thus it is not recommended to store it. /// /// \return Read-only pointer to the array of characters /// //////////////////////////////////////////////////////////// const Uint32* GetData() const; //////////////////////////////////////////////////////////// /// \brief Return an iterator to the beginning of the string /// /// \return Read-write iterator to the beginning of the string characters /// /// \see End /// //////////////////////////////////////////////////////////// Iterator Begin(); //////////////////////////////////////////////////////////// /// \brief Return an iterator to the beginning of the string /// /// \return Read-only iterator to the beginning of the string characters /// /// \see End /// //////////////////////////////////////////////////////////// ConstIterator Begin() const; //////////////////////////////////////////////////////////// /// \brief Return an iterator to the beginning of the string /// /// The end iterator refers to 1 position past the last character; /// thus it represents an invalid character and should never be /// accessed. /// /// \return Read-write iterator to the end of the string characters /// /// \see Begin /// //////////////////////////////////////////////////////////// Iterator End(); //////////////////////////////////////////////////////////// /// \brief Return an iterator to the beginning of the string /// /// The end iterator refers to 1 position past the last character; /// thus it represents an invalid character and should never be /// accessed. /// /// \return Read-only iterator to the end of the string characters /// /// \see Begin /// //////////////////////////////////////////////////////////// ConstIterator End() const; private : friend SFML_API bool operator ==(const String& left, const String& right); friend SFML_API bool operator <(const String& left, const String& right); //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// std::basic_string myString; ///< Internal string of UTF-32 characters }; //////////////////////////////////////////////////////////// /// \relates String /// \brief Overload of == operator to compare two UTF-32 strings /// /// \param left Left operand (a string) /// \param right Right operand (a string) /// /// \return True if both strings are equal /// //////////////////////////////////////////////////////////// SFML_API bool operator ==(const String& left, const String& right); //////////////////////////////////////////////////////////// /// \relates String /// \brief Overload of != operator to compare two UTF-32 strings /// /// \param left Left operand (a string) /// \param right Right operand (a string) /// /// \return True if both strings are different /// //////////////////////////////////////////////////////////// SFML_API bool operator !=(const String& left, const String& right); //////////////////////////////////////////////////////////// /// \relates String /// \brief Overload of < operator to compare two UTF-32 strings /// /// \param left Left operand (a string) /// \param right Right operand (a string) /// /// \return True if \a left is alphabetically lesser than \a right /// //////////////////////////////////////////////////////////// SFML_API bool operator <(const String& left, const String& right); //////////////////////////////////////////////////////////// /// \relates String /// \brief Overload of > operator to compare two UTF-32 strings /// /// \param left Left operand (a string) /// \param right Right operand (a string) /// /// \return True if \a left is alphabetically greater than \a right /// //////////////////////////////////////////////////////////// SFML_API bool operator >(const String& left, const String& right); //////////////////////////////////////////////////////////// /// \relates String /// \brief Overload of <= operator to compare two UTF-32 strings /// /// \param left Left operand (a string) /// \param right Right operand (a string) /// /// \return True if \a left is alphabetically lesser or equal than \a right /// //////////////////////////////////////////////////////////// SFML_API bool operator <=(const String& left, const String& right); //////////////////////////////////////////////////////////// /// \relates String /// \brief Overload of >= operator to compare two UTF-32 strings /// /// \param left Left operand (a string) /// \param right Right operand (a string) /// /// \return True if \a left is alphabetically greater or equal than \a right /// //////////////////////////////////////////////////////////// SFML_API bool operator >=(const String& left, const String& right); //////////////////////////////////////////////////////////// /// \relates String /// \brief Overload of binary + operator to concatenate two strings /// /// \param left Left operand (a string) /// \param right Right operand (a string) /// /// \return Concatenated string /// //////////////////////////////////////////////////////////// SFML_API String operator +(const String& left, const String& right); } // namespace sf #endif // SFML_STRING_HPP //////////////////////////////////////////////////////////// /// \class sf::String /// \ingroup system /// /// sf::String is a utility string class defined mainly for /// convenience. It is a Unicode string (implemented using /// UTF-32), thus it can store any character in the world /// (european, chinese, arabic, hebrew, etc.). /// /// It automatically handles conversions from/to ANSI and /// wide strings, so that you can work with standard string /// classes and still be compatible with functions taking a /// sf::String. /// /// \code /// sf::String s; /// /// std::string s1 = s; // automatically converted to ANSI string /// std::wstring s2 = s; // automatically converted to wide string /// s = "hello"; // automatically converted from ANSI string /// s = L"hello"; // automatically converted from wide string /// s += 'a'; // automatically converted from ANSI string /// s += L'a'; // automatically converted from wide string /// \endcode /// /// Conversions involving ANSI strings use the default user locale. However /// it is possible to use a custom locale if necessary: /// \code /// std::locale locale; /// sf::String s; /// ... /// std::string s1 = s.ToAnsiString(locale); /// s = sf::String("hello", locale); /// \endcode /// /// sf::String defines the most important functions of the /// standard std::string class: removing, random access, iterating, /// appending, comparing, etc. However it is a simple class /// provided for convenience, and you may have to consider using /// a more optimized class if your program requires complex string /// handling. The automatic conversion functions will then take /// care of converting your string to sf::String whenever SFML /// requires it. /// /// Please note that SFML also defines a low-level, generic /// interface for Unicode handling, see the sf::Utf classes. /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/ThreadLocal.hpp0000644000000000000000000000666211770572147024403 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_THREADLOCAL_HPP #define SFML_THREADLOCAL_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include namespace sf { namespace priv { class ThreadLocalImpl; } //////////////////////////////////////////////////////////// /// \brief Defines variables with thread-local storage /// //////////////////////////////////////////////////////////// class SFML_API ThreadLocal : NonCopyable { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// /// \param value Optional value to initalize the variable /// //////////////////////////////////////////////////////////// ThreadLocal(void* value = NULL); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~ThreadLocal(); //////////////////////////////////////////////////////////// /// \brief Set the thread-specific value of the variable /// /// \param value Value of the variable for the current thread /// //////////////////////////////////////////////////////////// void SetValue(void* value); //////////////////////////////////////////////////////////// /// \brief Retrieve the thread-specific value of the variable /// /// \return Value of the variable for the current thread /// //////////////////////////////////////////////////////////// void* GetValue() const; private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// priv::ThreadLocalImpl* myImpl; ///< Pointer to the OS specific implementation }; } // namespace sf #endif // SFML_THREADLOCAL_HPP //////////////////////////////////////////////////////////// /// \class sf::ThreadLocal /// \ingroup system /// /// This class manipulates void* parameters and thus is not /// appropriate for strongly-typed variables. You should rather /// use the sf::ThreadLocalPtr template class. /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Vector3.hpp0000644000000000000000000002251511770572147023541 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_VECTOR3_HPP #define SFML_VECTOR3_HPP namespace sf { //////////////////////////////////////////////////////////// /// \brief Utility template class for manipulating /// 3-dimensional vectors /// //////////////////////////////////////////////////////////// template class Vector3 { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// /// Creates a Vector3(0, 0, 0). /// //////////////////////////////////////////////////////////// Vector3(); //////////////////////////////////////////////////////////// /// \brief Construct the vector from its coordinates /// /// \param X X coordinate /// \param Y Y coordinate /// \param Z Z coordinate /// //////////////////////////////////////////////////////////// Vector3(T X, T Y, T Z); //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// T x; ///< X coordinate of the vector T y; ///< Y coordinate of the vector T z; ///< Z coordinate of the vector }; //////////////////////////////////////////////////////////// /// \relates Vector3 /// \brief Overload of unary operator - /// /// \param right Vector to negate /// /// \return Memberwise opposite of the vector /// //////////////////////////////////////////////////////////// template Vector3 operator -(const Vector3& left); //////////////////////////////////////////////////////////// /// \relates Vector3 /// \brief Overload of binary operator += /// /// This operator performs a memberwise addition of both vectors, /// and assigns the result to \a left. /// /// \param left Left operand (a vector) /// \param right Right operand (a vector) /// /// \return Reference to \a left /// //////////////////////////////////////////////////////////// template Vector3& operator +=(Vector3& left, const Vector3& right); //////////////////////////////////////////////////////////// /// \relates Vector3 /// \brief Overload of binary operator -= /// /// This operator performs a memberwise subtraction of both vectors, /// and assigns the result to \a left. /// /// \param left Left operand (a vector) /// \param right Right operand (a vector) /// /// \return Reference to \a left /// //////////////////////////////////////////////////////////// template Vector3& operator -=(Vector3& left, const Vector3& right); //////////////////////////////////////////////////////////// /// \relates Vector3 /// \brief Overload of binary operator + /// /// \param left Left operand (a vector) /// \param right Right operand (a vector) /// /// \return Memberwise addition of both vectors /// //////////////////////////////////////////////////////////// template Vector3 operator +(const Vector3& left, const Vector3& right); //////////////////////////////////////////////////////////// /// \relates Vector3 /// \brief Overload of binary operator - /// /// \param left Left operand (a vector) /// \param right Right operand (a vector) /// /// \return Memberwise subtraction of both vectors /// //////////////////////////////////////////////////////////// template Vector3 operator -(const Vector3& left, const Vector3& right); //////////////////////////////////////////////////////////// /// \relates Vector3 /// \brief Overload of binary operator * /// /// \param left Left operand (a vector) /// \param right Right operand (a scalar value) /// /// \return Memberwise multiplication by \a right /// //////////////////////////////////////////////////////////// template Vector3 operator *(const Vector3& left, T right); //////////////////////////////////////////////////////////// /// \relates Vector3 /// \brief Overload of binary operator * /// /// \param left Left operand (a scalar value) /// \param right Right operand (a vector) /// /// \return Memberwise multiplication by \a left /// //////////////////////////////////////////////////////////// template Vector3 operator *(T left, const Vector3& right); //////////////////////////////////////////////////////////// /// \relates Vector3 /// \brief Overload of binary operator *= /// /// This operator performs a memberwise multiplication by \a right, /// and assigns the result to \a left. /// /// \param left Left operand (a vector) /// \param right Right operand (a scalar value) /// /// \return Reference to \a left /// //////////////////////////////////////////////////////////// template Vector3& operator *=(Vector3& left, T right); //////////////////////////////////////////////////////////// /// \relates Vector3 /// \brief Overload of binary operator / /// /// \param left Left operand (a scalar value) /// \param right Right operand (a vector) /// /// \return Memberwise division by \a right /// //////////////////////////////////////////////////////////// template Vector3 operator /(const Vector3& left, T right); //////////////////////////////////////////////////////////// /// \relates Vector3 /// \brief Overload of binary operator /= /// /// This operator performs a memberwise division by \a right, /// and assigns the result to \a left. /// /// \param left Left operand (a vector) /// \param right Right operand (a scalar value) /// /// \return Reference to \a left /// //////////////////////////////////////////////////////////// template Vector3& operator /=(Vector3& left, T right); //////////////////////////////////////////////////////////// /// \relates Vector3 /// \brief Overload of binary operator == /// /// This operator compares strict equality between two vectors. /// /// \param left Left operand (a vector) /// \param right Right operand (a vector) /// /// \return True if \a left is equal to \a right /// //////////////////////////////////////////////////////////// template bool operator ==(const Vector3& left, const Vector3& right); //////////////////////////////////////////////////////////// /// \relates Vector3 /// \brief Overload of binary operator != /// /// This operator compares strict difference between two vectors. /// /// \param left Left operand (a vector) /// \param right Right operand (a vector) /// /// \return True if \a left is not equal to \a right /// //////////////////////////////////////////////////////////// template bool operator !=(const Vector3& left, const Vector3& right); #include // Define the most common types typedef Vector3 Vector3i; typedef Vector3 Vector3f; } // namespace sf #endif // SFML_VECTOR3_HPP //////////////////////////////////////////////////////////// /// \class sf::Vector3 /// \ingroup system /// /// sf::Vector3 is a simple class that defines a mathematical /// vector with three coordinates (x, y and z). It can be used to /// represent anything that has three dimensions: a size, a point, /// a velocity, etc. /// /// The template parameter T is the type of the coordinates. It /// can be any type that supports arithmetic operations (+, -, /, *) /// and comparisons (==, !=), for example int or float. /// /// You generally don't have to care about the templated form (sf::Vector3), /// the two most common specializations have special typedefs: /// \li sf::Vector3 is sf::Vector3f /// \li sf::Vector3 is sf::Vector3i /// /// The sf::Vector3 class has a small and simple interface, its x and y members /// can be accessed directly (there's no accessor like SetX(), GetX()) and it /// contains no mathematical function like dot product, cross product, length, etc. /// /// Usage example: /// \code /// sf::Vector3f v1(16.5f, 24.f, -8.2f); /// v1.x = 18.2f; /// float y = v1.y; /// float z = v1.z; /// /// sf::Vector3f v2 = v1 * 5.f; /// sf::Vector3f v3; /// v3 = v1 + v2; /// /// bool different = (v2 != v3); /// \endcode /// /// Note: for 2-dimensional vectors, see sf::Vector2. /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/ResourcePtr.inl0000644000000000000000000000627311770572147024467 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // Copyright (C) 2007 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// template ResourcePtr::ResourcePtr() : myResource(NULL) { } //////////////////////////////////////////////////////////// template ResourcePtr::ResourcePtr(const T* resource) : myResource(resource) { if (myResource) myResource->Connect(*this); } //////////////////////////////////////////////////////////// template ResourcePtr::ResourcePtr(const ResourcePtr& copy) : myResource(copy.myResource) { if (myResource) myResource->Connect(*this); } //////////////////////////////////////////////////////////// template ResourcePtr::~ResourcePtr() { if (myResource) myResource->Disconnect(*this); } //////////////////////////////////////////////////////////// template ResourcePtr& ResourcePtr::operator =(const ResourcePtr& right) { if (myResource) myResource->Disconnect(*this); myResource = right.myResource; if (myResource) myResource->Connect(*this); return *this; } //////////////////////////////////////////////////////////// template ResourcePtr& ResourcePtr::operator =(const T* resource) { if (myResource) myResource->Disconnect(*this); myResource = resource; if (myResource) myResource->Connect(*this); return *this; } //////////////////////////////////////////////////////////// template ResourcePtr::operator const T*() const { return myResource; } //////////////////////////////////////////////////////////// template const T& ResourcePtr::operator *() const { return *myResource; } //////////////////////////////////////////////////////////// template const T* ResourcePtr::operator ->() const { return myResource; } //////////////////////////////////////////////////////////// template void ResourcePtr::OnResourceDestroyed() { myResource = NULL; } sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Err.hpp0000644000000000000000000000510511770572147022740 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_ERR_HPP #define SFML_ERR_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { //////////////////////////////////////////////////////////// /// \brief Standard stream used by SFML to output warnings and errors /// //////////////////////////////////////////////////////////// SFML_API std::ostream& Err(); } // namespace sf #endif // SFML_ERR_HPP //////////////////////////////////////////////////////////// /// \fn sf::Err /// \ingroup system /// /// By default, sf::Err() outputs to the same location as std::cerr, /// (-> the stderr descriptor) which is the console if there's /// one available. /// /// It is a standard std::ostream instance, so it supports all the /// insertion operations defined by the STL /// (operator <<, manipulators, etc.). /// /// sf::Err() can be redirected to write to another output, independantly /// of std::cerr, by using the rdbuf() function provided by the /// std::ostream class. /// /// Example: /// \code /// // Redirect to a file /// std::ofstream file("sfml-log.txt"); /// std::streambuf* previous = sf::Err().rdbuf(file.rdbuf()); /// /// // Redirect to nothing /// sf::Err().rdbuf(NULL); /// /// // Restore the original output /// sf::Err().rdbuf(previous); /// \endcode /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Vector2.inl0000644000000000000000000000776711770572147023547 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// template inline Vector2::Vector2() : x(0), y(0) { } //////////////////////////////////////////////////////////// template inline Vector2::Vector2(T X, T Y) : x(X), y(Y) { } //////////////////////////////////////////////////////////// template inline Vector2 operator -(const Vector2& right) { return Vector2(-right.x, -right.y); } //////////////////////////////////////////////////////////// template inline Vector2& operator +=(Vector2& left, const Vector2& right) { left.x += right.x; left.y += right.y; return left; } //////////////////////////////////////////////////////////// template inline Vector2& operator -=(Vector2& left, const Vector2& right) { left.x -= right.x; left.y -= right.y; return left; } //////////////////////////////////////////////////////////// template inline Vector2 operator +(const Vector2& left, const Vector2& right) { return Vector2(left.x + right.x, left.y + right.y); } //////////////////////////////////////////////////////////// template inline Vector2 operator -(const Vector2& left, const Vector2& right) { return Vector2(left.x - right.x, left.y - right.y); } //////////////////////////////////////////////////////////// template inline Vector2 operator *(const Vector2& left, T right) { return Vector2(left.x * right, left.y * right); } //////////////////////////////////////////////////////////// template inline Vector2 operator *(T left, const Vector2& right) { return Vector2(right.x * left, right.y * left); } //////////////////////////////////////////////////////////// template inline Vector2& operator *=(Vector2& left, T right) { left.x *= right; left.y *= right; return left; } //////////////////////////////////////////////////////////// template inline Vector2 operator /(const Vector2& left, T right) { return Vector2(left.x / right, left.y / right); } //////////////////////////////////////////////////////////// template inline Vector2& operator /=(Vector2& left, T right) { left.x /= right; left.y /= right; return left; } //////////////////////////////////////////////////////////// template inline bool operator ==(const Vector2& left, const Vector2& right) { return (left.x == right.x) && (left.y == right.y); } //////////////////////////////////////////////////////////// template inline bool operator !=(const Vector2& left, const Vector2& right) { return (left.x != right.x) || (left.y != right.y); } sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Utf.inl0000644000000000000000000005401611770572147022746 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // References : // // http://www.unicode.org/ // http://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c // http://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.h // http://people.w3.org/rishida/scripts/uniview/conversion // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// template In Utf<8>::Decode(In begin, In end, Uint32& output, Uint32 replacement) { // Some useful precomputed data static const int trailing[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 }; static const Uint32 offsets[6] = { 0x00000000, 0x00003080, 0x000E2080, 0x03C82080, 0xFA082080, 0x82082080 }; // Decode the character int trailingBytes = trailing[static_cast(*begin)]; if (begin + trailingBytes < end) { output = 0; switch (trailingBytes) { case 5 : output += static_cast(*begin++); output <<= 6; case 4 : output += static_cast(*begin++); output <<= 6; case 3 : output += static_cast(*begin++); output <<= 6; case 2 : output += static_cast(*begin++); output <<= 6; case 1 : output += static_cast(*begin++); output <<= 6; case 0 : output += static_cast(*begin++); } output -= offsets[trailingBytes]; } else { // Incomplete character begin = end; output = replacement; } return begin; } //////////////////////////////////////////////////////////// template Out Utf<8>::Encode(Uint32 input, Out output, Uint8 replacement) { // Some useful precomputed data static const Uint8 firstBytes[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; // Encode the character if ((input > 0x0010FFFF) || ((input >= 0xD800) && (input <= 0xDBFF))) { // Invalid character if (replacement) *output++ = replacement; } else { // Valid character // Get the number of bytes to write int bytesToWrite = 1; if (input < 0x80) bytesToWrite = 1; else if (input < 0x800) bytesToWrite = 2; else if (input < 0x10000) bytesToWrite = 3; else if (input <= 0x0010FFFF) bytesToWrite = 4; // Extract the bytes to write Uint8 bytes[4]; switch (bytesToWrite) { case 4 : bytes[3] = static_cast((input | 0x80) & 0xBF); input >>= 6; case 3 : bytes[2] = static_cast((input | 0x80) & 0xBF); input >>= 6; case 2 : bytes[1] = static_cast((input | 0x80) & 0xBF); input >>= 6; case 1 : bytes[0] = static_cast (input | firstBytes[bytesToWrite]); } // Add them to the output const Uint8* currentByte = bytes; switch (bytesToWrite) { case 4 : *output++ = *currentByte++; case 3 : *output++ = *currentByte++; case 2 : *output++ = *currentByte++; case 1 : *output++ = *currentByte++; } } return output; } //////////////////////////////////////////////////////////// template In Utf<8>::Next(In begin, In end) { Uint32 codepoint; return Decode(begin, end, codepoint); } //////////////////////////////////////////////////////////// template std::size_t Utf<8>::Count(In begin, In end) { std::size_t length = 0; while (begin < end) { begin = Next(begin, end); ++length; } return length; } //////////////////////////////////////////////////////////// template Out Utf<8>::FromAnsi(In begin, In end, Out output, const std::locale& locale) { while (begin < end) { Uint32 codepoint = Utf<32>::DecodeAnsi(*begin++, locale); output = Encode(codepoint, output); } return output; } //////////////////////////////////////////////////////////// template Out Utf<8>::FromWide(In begin, In end, Out output) { while (begin < end) { Uint32 codepoint = Utf<32>::DecodeWide(*begin++); output = Encode(codepoint, output); } return output; } //////////////////////////////////////////////////////////// template Out Utf<8>::FromLatin1(In begin, In end, Out output) { // Latin-1 is directly compatible with Unicode encodings, // and can thus be treated as (a sub-range of) UTF-32 while (begin < end) output = Encode(*begin++, output); return output; } //////////////////////////////////////////////////////////// template Out Utf<8>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale) { while (begin < end) { Uint32 codepoint; begin = Decode(begin, end, codepoint); output = Utf<32>::EncodeAnsi(codepoint, output, replacement, locale); } return output; } //////////////////////////////////////////////////////////// template Out Utf<8>::ToWide(In begin, In end, Out output, wchar_t replacement) { while (begin < end) { Uint32 codepoint; begin = Decode(begin, end, codepoint); output = Utf<32>::EncodeWide(codepoint, output, replacement); } return output; } //////////////////////////////////////////////////////////// template Out Utf<8>::ToLatin1(In begin, In end, Out output, char replacement) { // Latin-1 is directly compatible with Unicode encodings, // and can thus be treated as (a sub-range of) UTF-32 while (begin < end) { Uint32 codepoint; begin = Decode(begin, end, codepoint); *output++ = codepoint < 256 ? static_cast(codepoint) : replacement; } return output; } //////////////////////////////////////////////////////////// template Out Utf<8>::ToUtf8(In begin, In end, Out output) { while (begin < end) *output++ = *begin++; return output; } //////////////////////////////////////////////////////////// template Out Utf<8>::ToUtf16(In begin, In end, Out output) { while (begin < end) { Uint32 codepoint; begin = Decode(begin, end, codepoint); output = Utf<16>::Encode(codepoint, output); } return output; } //////////////////////////////////////////////////////////// template Out Utf<8>::ToUtf32(In begin, In end, Out output) { while (begin < end) { Uint32 codepoint; begin = Decode(begin, end, codepoint); *output++ = codepoint; } return output; } //////////////////////////////////////////////////////////// template In Utf<16>::Decode(In begin, In end, Uint32& output, Uint32 replacement) { Uint16 first = *begin++; // If it's a surrogate pair, first convert to a single UTF-32 character if ((first >= 0xD800) && (first <= 0xDBFF)) { if (begin < end) { Uint32 second = *begin++; if ((second >= 0xDC00) && (second <= 0xDFFF)) { // The second element is valid: convert the two elements to a UTF-32 character output = static_cast(((first - 0xD800) << 10) + (second - 0xDC00) + 0x0010000); } else { // Invalid character output = replacement; } } else { // Invalid character begin = end; output = replacement; } } else { // We can make a direct copy output = first; } return begin; } //////////////////////////////////////////////////////////// template Out Utf<16>::Encode(Uint32 input, Out output, Uint16 replacement) { if (input < 0xFFFF) { // The character can be copied directly, we just need to check if it's in the valid range if ((input >= 0xD800) && (input <= 0xDFFF)) { // Invalid character (this range is reserved) if (replacement) *output++ = replacement; } else { // Valid character directly convertible to a single UTF-16 character *output++ = static_cast(input); } } else if (input > 0x0010FFFF) { // Invalid character (greater than the maximum unicode value) if (replacement) *output++ = replacement; } else { // The input character will be converted to two UTF-16 elements input -= 0x0010000; *output++ = static_cast((input >> 10) + 0xD800); *output++ = static_cast((input & 0x3FFUL) + 0xDC00); } return output; } //////////////////////////////////////////////////////////// template In Utf<16>::Next(In begin, In end) { Uint32 codepoint; return Decode(begin, end, codepoint); } //////////////////////////////////////////////////////////// template std::size_t Utf<16>::Count(In begin, In end) { std::size_t length = 0; while (begin < end) { begin = Next(begin, end); ++length; } return length; } //////////////////////////////////////////////////////////// template Out Utf<16>::FromAnsi(In begin, In end, Out output, const std::locale& locale) { while (begin < end) { Uint32 codepoint = Utf<32>::DecodeAnsi(*begin++, locale); output = Encode(codepoint, output); } return output; } //////////////////////////////////////////////////////////// template Out Utf<16>::FromWide(In begin, In end, Out output) { while (begin < end) { Uint32 codepoint = Utf<32>::DecodeWide(*begin++); output = Encode(codepoint, output); } return output; } //////////////////////////////////////////////////////////// template Out Utf<16>::FromLatin1(In begin, In end, Out output) { // Latin-1 is directly compatible with Unicode encodings, // and can thus be treated as (a sub-range of) UTF-32 while (begin < end) *output++ = *begin++; return output; } //////////////////////////////////////////////////////////// template Out Utf<16>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale) { while (begin < end) { Uint32 codepoint; begin = Decode(begin, end, codepoint); output = Utf<32>::EncodeAnsi(codepoint, output, replacement, locale); } return output; } //////////////////////////////////////////////////////////// template Out Utf<16>::ToWide(In begin, In end, Out output, wchar_t replacement) { while (begin < end) { Uint32 codepoint; begin = Decode(begin, end, codepoint); output = Utf<32>::EncodeWide(codepoint, output, replacement); } return output; } //////////////////////////////////////////////////////////// template Out Utf<16>::ToLatin1(In begin, In end, Out output, char replacement) { // Latin-1 is directly compatible with Unicode encodings, // and can thus be treated as (a sub-range of) UTF-32 while (begin < end) { *output++ = *begin < 256 ? static_cast(*begin) : replacement; begin++; } return output; } //////////////////////////////////////////////////////////// template Out Utf<16>::ToUtf8(In begin, In end, Out output) { while (begin < end) { Uint32 codepoint; begin = Decode(begin, end, codepoint); output = Utf<8>::Encode(codepoint, output); } return output; } //////////////////////////////////////////////////////////// template Out Utf<16>::ToUtf16(In begin, In end, Out output) { while (begin < end) *output++ = *begin++; return output; } //////////////////////////////////////////////////////////// template Out Utf<16>::ToUtf32(In begin, In end, Out output) { while (begin < end) { Uint32 codepoint; begin = Decode(begin, end, codepoint); *output++ = codepoint; } return output; } //////////////////////////////////////////////////////////// template In Utf<32>::Decode(In begin, In end, Uint32& output, Uint32) { output = *begin++; return begin; } //////////////////////////////////////////////////////////// template Out Utf<32>::Encode(Uint32 input, Out output, Uint32 replacement) { *output++ = input; return output; } //////////////////////////////////////////////////////////// template In Utf<32>::Next(In begin, In end) { return ++begin; } //////////////////////////////////////////////////////////// template std::size_t Utf<32>::Count(In begin, In end) { return begin - end; } //////////////////////////////////////////////////////////// template Out Utf<32>::FromAnsi(In begin, In end, Out output, const std::locale& locale) { while (begin < end) *output++ = DecodeAnsi(*begin++, locale); return output; } //////////////////////////////////////////////////////////// template Out Utf<32>::FromWide(In begin, In end, Out output) { while (begin < end) *output++ = DecodeWide(*begin++); return output; } //////////////////////////////////////////////////////////// template Out Utf<32>::FromLatin1(In begin, In end, Out output) { // Latin-1 is directly compatible with Unicode encodings, // and can thus be treated as (a sub-range of) UTF-32 while (begin < end) *output++ = *begin++; return output; } //////////////////////////////////////////////////////////// template Out Utf<32>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale) { while (begin < end) output = EncodeAnsi(*begin++, output, replacement, locale); return output; } //////////////////////////////////////////////////////////// template Out Utf<32>::ToWide(In begin, In end, Out output, wchar_t replacement) { while (begin < end) output = EncodeWide(*begin++, output, replacement); return output; } //////////////////////////////////////////////////////////// template Out Utf<32>::ToLatin1(In begin, In end, Out output, char replacement) { // Latin-1 is directly compatible with Unicode encodings, // and can thus be treated as (a sub-range of) UTF-32 while (begin < end) { *output++ = *begin < 256 ? static_cast(*begin) : replacement; begin++; } return output; } //////////////////////////////////////////////////////////// template Out Utf<32>::ToUtf8(In begin, In end, Out output) { while (begin < end) output = Utf<8>::Encode(*begin++, output); return output; } //////////////////////////////////////////////////////////// template Out Utf<32>::ToUtf16(In begin, In end, Out output) { while (begin < end) output = Utf<16>::Encode(*begin++, output); return output; } //////////////////////////////////////////////////////////// template Out Utf<32>::ToUtf32(In begin, In end, Out output) { while (begin < end) *output++ = *begin++; return output; } //////////////////////////////////////////////////////////// template Uint32 Utf<32>::DecodeAnsi(In input, const std::locale& locale) { // On Windows, gcc's standard library (glibc++) has almost // no support for Unicode stuff. As a consequence, in this // context we can only use the default locale and ignore // the one passed as parameter. #if defined(SFML_SYSTEM_WINDOWS) && /* if Windows ... */ \ (defined(__GLIBCPP__) || defined (__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \ !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */ wchar_t character = 0; mbtowc(&character, &input, 1); return static_cast(character); #else // Get the facet of the locale which deals with character conversion const std::ctype& facet = std::use_facet< std::ctype >(locale); // Use the facet to convert each character of the input string return static_cast(facet.widen(input)); #endif } //////////////////////////////////////////////////////////// template Uint32 Utf<32>::DecodeWide(In input) { // The encoding of wide characters is not well defined and is left to the system; // however we can safely assume that it is UCS-2 on Windows and // UCS-4 on Unix systems. // In both cases, a simple copy is enough (UCS-2 is a subset of UCS-4, // and UCS-4 *is* UTF-32). return input; } //////////////////////////////////////////////////////////// template Out Utf<32>::EncodeAnsi(Uint32 codepoint, Out output, char replacement, const std::locale& locale) { // On Windows, gcc's standard library (glibc++) has almost // no support for Unicode stuff. As a consequence, in this // context we can only use the default locale and ignore // the one passed as parameter. #if defined(SFML_SYSTEM_WINDOWS) && /* if Windows ... */ \ (defined(__GLIBCPP__) || defined (__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \ !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */ char character = 0; if (wctomb(&character, static_cast(codepoint)) >= 0) *output++ = character; else if (replacement) *output++ = replacement; return output; #else // Get the facet of the locale which deals with character conversion const std::ctype& facet = std::use_facet< std::ctype >(locale); // Use the facet to convert each character of the input string *output++ = facet.narrow(static_cast(codepoint), replacement); return output; #endif } //////////////////////////////////////////////////////////// template Out Utf<32>::EncodeWide(Uint32 codepoint, Out output, wchar_t replacement) { // The encoding of wide characters is not well defined and is left to the system; // however we can safely assume that it is UCS-2 on Windows and // UCS-4 on Unix systems. // For UCS-2 we need to check if the source characters fits in (UCS-2 is a subset of UCS-4). // For UCS-4 we can do a direct copy (UCS-4 *is* UTF-32). switch (sizeof(wchar_t)) { case 4: { *output++ = static_cast(codepoint); break; } default: { if ((codepoint <= 0xFFFF) && ((codepoint < 0xD800) || (codepoint > 0xDFFF))) { *output++ = static_cast(codepoint); } else if (replacement) { *output++ = replacement; } break; } } return output; } sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Vector2.hpp0000644000000000000000000002233211770572147023535 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_VECTOR2_HPP #define SFML_VECTOR2_HPP namespace sf { //////////////////////////////////////////////////////////// /// \brief Utility template class for manipulating /// 2-dimensional vectors /// //////////////////////////////////////////////////////////// template class Vector2 { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// /// Creates a Vector2(0, 0). /// //////////////////////////////////////////////////////////// Vector2(); //////////////////////////////////////////////////////////// /// \brief Construct the vector from its coordinates /// /// \param X X coordinate /// \param Y Y coordinate /// //////////////////////////////////////////////////////////// Vector2(T X, T Y); //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// T x; ///< X coordinate of the vector T y; ///< Y coordinate of the vector }; //////////////////////////////////////////////////////////// /// \relates Vector2 /// \brief Overload of unary operator - /// /// \param right Vector to negate /// /// \return Memberwise opposite of the vector /// //////////////////////////////////////////////////////////// template Vector2 operator -(const Vector2& right); //////////////////////////////////////////////////////////// /// \relates Vector2 /// \brief Overload of binary operator += /// /// This operator performs a memberwise addition of both vectors, /// and assigns the result to \a left. /// /// \param left Left operand (a vector) /// \param right Right operand (a vector) /// /// \return Reference to \a left /// //////////////////////////////////////////////////////////// template Vector2& operator +=(Vector2& left, const Vector2& right); //////////////////////////////////////////////////////////// /// \relates Vector2 /// \brief Overload of binary operator -= /// /// This operator performs a memberwise subtraction of both vectors, /// and assigns the result to \a left. /// /// \param left Left operand (a vector) /// \param right Right operand (a vector) /// /// \return Reference to \a left /// //////////////////////////////////////////////////////////// template Vector2& operator -=(Vector2& left, const Vector2& right); //////////////////////////////////////////////////////////// /// \relates Vector2 /// \brief Overload of binary operator + /// /// \param left Left operand (a vector) /// \param right Right operand (a vector) /// /// \return Memberwise addition of both vectors /// //////////////////////////////////////////////////////////// template Vector2 operator +(const Vector2& left, const Vector2& right); //////////////////////////////////////////////////////////// /// \relates Vector2 /// \brief Overload of binary operator - /// /// \param left Left operand (a vector) /// \param right Right operand (a vector) /// /// \return Memberwise subtraction of both vectors /// //////////////////////////////////////////////////////////// template Vector2 operator -(const Vector2& left, const Vector2& right); //////////////////////////////////////////////////////////// /// \relates Vector2 /// \brief Overload of binary operator * /// /// \param left Left operand (a vector) /// \param right Right operand (a scalar value) /// /// \return Memberwise multiplication by \a right /// //////////////////////////////////////////////////////////// template Vector2 operator *(const Vector2& left, T right); //////////////////////////////////////////////////////////// /// \relates Vector2 /// \brief Overload of binary operator * /// /// \param left Left operand (a scalar value) /// \param right Right operand (a vector) /// /// \return Memberwise multiplication by \a left /// //////////////////////////////////////////////////////////// template Vector2 operator *(T left, const Vector2& right); //////////////////////////////////////////////////////////// /// \relates Vector2 /// \brief Overload of binary operator *= /// /// This operator performs a memberwise multiplication by \a right, /// and assigns the result to \a left. /// /// \param left Left operand (a vector) /// \param right Right operand (a scalar value) /// /// \return Reference to \a left /// //////////////////////////////////////////////////////////// template Vector2& operator *=(Vector2& left, T right); //////////////////////////////////////////////////////////// /// \relates Vector2 /// \brief Overload of binary operator / /// /// \param left Left operand (a scalar value) /// \param right Right operand (a vector) /// /// \return Memberwise division by \a right /// //////////////////////////////////////////////////////////// template Vector2 operator /(const Vector2& left, T right); //////////////////////////////////////////////////////////// /// \relates Vector2 /// \brief Overload of binary operator /= /// /// This operator performs a memberwise division by \a right, /// and assigns the result to \a left. /// /// \param left Left operand (a vector) /// \param right Right operand (a scalar value) /// /// \return Reference to \a left /// //////////////////////////////////////////////////////////// template Vector2& operator /=(Vector2& left, T right); //////////////////////////////////////////////////////////// /// \relates Vector2 /// \brief Overload of binary operator == /// /// This operator compares strict equality between two vectors. /// /// \param left Left operand (a vector) /// \param right Right operand (a vector) /// /// \return True if \a left is equal to \a right /// //////////////////////////////////////////////////////////// template bool operator ==(const Vector2& left, const Vector2& right); //////////////////////////////////////////////////////////// /// \relates Vector2 /// \brief Overload of binary operator != /// /// This operator compares strict difference between two vectors. /// /// \param left Left operand (a vector) /// \param right Right operand (a vector) /// /// \return True if \a left is not equal to \a right /// //////////////////////////////////////////////////////////// template bool operator !=(const Vector2& left, const Vector2& right); #include // Define the most common types typedef Vector2 Vector2i; typedef Vector2 Vector2f; } // namespace sf #endif // SFML_VECTOR2_HPP //////////////////////////////////////////////////////////// /// \class sf::Vector2 /// \ingroup system /// /// sf::Vector2 is a simple class that defines a mathematical /// vector with two coordinates (x and y). It can be used to /// represent anything that has two dimensions: a size, a point, /// a velocity, etc. /// /// The template parameter T is the type of the coordinates. It /// can be any type that supports arithmetic operations (+, -, /, *) /// and comparisons (==, !=), for example int or float. /// /// You generally don't have to care about the templated form (sf::Vector2), /// the two most common specializations have special typedefs: /// \li sf::Vector2 is sf::Vector2f /// \li sf::Vector2 is sf::Vector2i /// /// The sf::Vector2 class has a small and simple interface, its x and y members /// can be accessed directly (there's no accessor like SetX(), GetX()) and it /// contains no mathematical function like dot product, cross product, length, etc. /// /// Usage example: /// \code /// sf::Vector2f v1(16.5f, 24.f); /// v1.x = 18.2f; /// float y = v1.y; /// /// sf::Vector2f v2 = v1 * 5.f; /// sf::Vector2f v3; /// v3 = v1 + v2; /// /// bool different = (v2 != v3); /// \endcode /// /// Note: for 3-dimensional vectors, see sf::Vector3. /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/ThreadLocalPtr.hpp0000644000000000000000000001202411770572147025056 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_THREADLOCALPTR_HPP #define SFML_THREADLOCALPTR_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include namespace sf { //////////////////////////////////////////////////////////// /// \brief Pointer to a thread-local variable /// //////////////////////////////////////////////////////////// template class ThreadLocalPtr : private ThreadLocal { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// /// \param value Optional value to initalize the variable /// //////////////////////////////////////////////////////////// ThreadLocalPtr(T* value = NULL); //////////////////////////////////////////////////////////// /// \brief Overload of unary operator * /// /// Like raw pointers, applying the * operator returns a /// reference to the pointed object. /// /// \return Reference to the pointed object /// //////////////////////////////////////////////////////////// T& operator *() const; //////////////////////////////////////////////////////////// /// \brief Overload of operator -> /// /// Like raw pointers, applying the -> operator returns the /// pointed object. /// /// \return Pointed object /// //////////////////////////////////////////////////////////// T* operator ->() const; //////////////////////////////////////////////////////////// /// \brief Cast operator to implicitely convert the /// pointer to its raw pointer type (T*) /// /// \return Pointer to the actual object /// //////////////////////////////////////////////////////////// operator T*() const; //////////////////////////////////////////////////////////// /// \brief Assignment operator for a raw pointer parameter /// /// \param value Pointer to assign /// /// \return Reference to self /// //////////////////////////////////////////////////////////// ThreadLocalPtr& operator =(T* value); //////////////////////////////////////////////////////////// /// \brief Assignment operator for a ThreadLocalPtr parameter /// /// \param right ThreadLocalPtr to assign /// /// \return Reference to self /// //////////////////////////////////////////////////////////// ThreadLocalPtr& operator =(const ThreadLocalPtr& right); }; } // namespace sf #include #endif // SFML_THREADLOCALPTR_HPP //////////////////////////////////////////////////////////// /// \class sf::ThreadLocalPtr /// \ingroup system /// /// sf::ThreadLocalPtr is a type-safe wrapper for storing /// pointers to thread-local variables. A thread-local /// variable holds a different value for each different /// thread, unlike normal variable that are shared. /// /// Its usage is completely transparent, so that it is similar /// to manipulating the raw pointer directly (like any smart pointer). /// /// Usage example: /// \code /// MyClass object1; /// MyClass object2; /// sf::ThreadLocalPtr objectPtr; /// /// void Thread1(void*) /// { /// objectPtr = &object1; // doesn't impact Thread2 /// ... /// } /// /// void Thread1(void*) /// { /// objectPtr = &object2; // doesn't impact Thread1 /// ... /// } /// /// int main() /// { /// // Create and launch the two threads /// sf::Thread thread1(&Thread1); /// sf::Thread thread2(&Thread2); /// thread1.Launch(); /// thread2.Launch(); /// /// return 0; /// } /// \endcode /// /// ThreadLocalPtr is designed for internal use; however you /// can use it if you feel like it fits well your implementation. /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Lock.hpp0000644000000000000000000001037111770572147023101 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_LOCK_HPP #define SFML_LOCK_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include namespace sf { class Mutex; //////////////////////////////////////////////////////////// /// \brief Automatic wrapper for locking and unlocking mutexes /// //////////////////////////////////////////////////////////// class SFML_API Lock : NonCopyable { public : //////////////////////////////////////////////////////////// /// \brief Construct the lock with a target mutex /// /// The mutex passed to sf::Lock is automatically locked. /// /// \param mutex Mutex to lock /// //////////////////////////////////////////////////////////// Lock(Mutex& mutex); //////////////////////////////////////////////////////////// /// \brief Destructor /// /// The destructor of sf::Lock automatically unlocks its mutex. /// //////////////////////////////////////////////////////////// ~Lock(); private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// Mutex& myMutex; ///< Mutex to lock / unlock }; } // namespace sf #endif // SFML_LOCK_HPP //////////////////////////////////////////////////////////// /// \class sf::Lock /// \ingroup system /// /// sf::Lock is a RAII wrapper for sf::Mutex. By unlocking /// it in its destructor, it ensures that the mutex will /// always be released when the current scope (most likely /// a function) ends. /// This is even more important when an exception or an early /// return statement can interrupt the execution flow of the /// function. /// /// For maximum robustness, sf::Lock should always be used /// to lock/unlock a mutex. /// /// Usage example: /// \code /// sf::Mutex mutex; /// /// void function() /// { /// sf::Lock lock(mutex); // mutex is now locked /// /// functionThatMayThrowAnException(); // mutex is unlocked if this function throws /// /// if (someCondition) /// return; // mutex is unlocked /// /// } // mutex is unlocked /// \endcode /// /// Because the mutex is not explicitely unlocked in the code, /// it may remain locked longer than needed. If the region /// of the code that needs to be protected by the mutex is /// not the entire function, a good practice is to create a /// smaller, inner scope so that the lock is limited to this /// part of the code. /// /// \code /// sf::Mutex mutex; /// /// void function() /// { /// { /// sf::Lock lock(mutex); /// codeThatRequiresProtection(); /// /// } // mutex is unlocked here /// /// codeThatDoesntCareAboutTheMutex(); /// } /// \endcode /// /// Having a mutex locked longer than required is a bad practice /// which can lead to bad performances. Don't forget that when /// a mutex is locked, other threads may be waiting doing nothing /// until it is released. /// /// \see sf::Mutex /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Resource.inl0000644000000000000000000000460511770572147023776 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // Copyright (C) 2007 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// template Resource::Resource() { // Nothing to do } //////////////////////////////////////////////////////////// template Resource::Resource(const Resource&) { // Nothing to do, we don't want to copy observers } //////////////////////////////////////////////////////////// template Resource::~Resource() { // Notify all observers for (typename std::set*>::iterator i = myObservers.begin(); i != myObservers.end(); ++i) { (*i)->OnResourceDestroyed(); } } //////////////////////////////////////////////////////////// template Resource& Resource::operator =(const Resource&) { // Nothing to do, we don't want to copy observers return *this; } //////////////////////////////////////////////////////////// template void Resource::Connect(ResourcePtr& observer) const { sf::Lock lock(myMutex); myObservers.insert(&observer); } //////////////////////////////////////////////////////////// template void Resource::Disconnect(ResourcePtr& observer) const { sf::Lock lock(myMutex); myObservers.erase(&observer); } sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Vector3.inl0000644000000000000000000001035611770572147023534 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// template inline Vector3::Vector3() : x(0), y(0), z(0) { } //////////////////////////////////////////////////////////// template inline Vector3::Vector3(T X, T Y, T Z) : x(X), y(Y), z(Z) { } //////////////////////////////////////////////////////////// template inline Vector3 operator -(const Vector3& left) { return Vector3(-left.x, -left.y, -left.z); } //////////////////////////////////////////////////////////// template inline Vector3& operator +=(Vector3& left, const Vector3& right) { left.x += right.x; left.y += right.y; left.z += right.z; return left; } //////////////////////////////////////////////////////////// template inline Vector3& operator -=(Vector3& left, const Vector3& right) { left.x -= right.x; left.y -= right.y; left.z -= right.z; return left; } //////////////////////////////////////////////////////////// template inline Vector3 operator +(const Vector3& left, const Vector3& right) { return Vector3(left.x + right.x, left.y + right.y, left.z + right.z); } //////////////////////////////////////////////////////////// template inline Vector3 operator -(const Vector3& left, const Vector3& right) { return Vector3(left.x - right.x, left.y - right.y, left.z - right.z); } //////////////////////////////////////////////////////////// template inline Vector3 operator *(const Vector3& left, T right) { return Vector3(left.x * right, left.y * right, left.z * right); } //////////////////////////////////////////////////////////// template inline Vector3 operator *(T left, const Vector3& right) { return Vector3(right.x * left, right.y * left, right.z * left); } //////////////////////////////////////////////////////////// template inline Vector3& operator *=(Vector3& left, T right) { left.x *= right; left.y *= right; left.z *= right; return left; } //////////////////////////////////////////////////////////// template inline Vector3 operator /(const Vector3& left, T right) { return Vector3(left.x / right, left.y / right, left.z / right); } //////////////////////////////////////////////////////////// template inline Vector3& operator /=(Vector3& left, T right) { left.x /= right; left.y /= right; left.z /= right; return left; } //////////////////////////////////////////////////////////// template inline bool operator ==(const Vector3& left, const Vector3& right) { return (left.x == right.x) && (left.y == right.y) && (left.z == right.z); } //////////////////////////////////////////////////////////// template inline bool operator !=(const Vector3& left, const Vector3& right) { return (left.x != right.x) || (left.y != right.y) || (left.z != right.z); } sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Utf.hpp0000644000000000000000000010713211770572147022751 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_UTF_HPP #define SFML_UTF_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include #include namespace sf { template class Utf; //////////////////////////////////////////////////////////// /// \brief Specialization of the Utf template for UTF-8 /// //////////////////////////////////////////////////////////// template <> class Utf<8> { public : //////////////////////////////////////////////////////////// /// \brief Decode a single UTF-8 character /// /// Decoding a character means finding its unique 32-bits /// code (called the codepoint) in the Unicode standard. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Codepoint of the decoded UTF-8 character /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid /// /// \return Iterator pointing to one past the last read element of the input sequence /// //////////////////////////////////////////////////////////// template static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0); //////////////////////////////////////////////////////////// /// \brief Encode a single UTF-8 character /// /// Encoding a character means converting a unique 32-bits /// code (called the codepoint) in the target encoding, UTF-8. /// /// \param input Codepoint to encode as UTF-8 /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement for characters not convertible to UTF-8 (use 0 to skip them) /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out Encode(Uint32 input, Out output, Uint8 replacement = 0); //////////////////////////////////////////////////////////// /// \brief Advance to the next UTF-8 character /// /// This function is necessary for multi-elements encodings, as /// a single character may use more than 1 storage element. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// /// \return Iterator pointing to one past the last read element of the input sequence /// //////////////////////////////////////////////////////////// template static In Next(In begin, In end); //////////////////////////////////////////////////////////// /// \brief Count the number of characters of a UTF-8 sequence /// /// This function is necessary for multi-elements encodings, as /// a single character may use more than 1 storage element, thus the /// total size can be different from (begin - end). /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// /// \return Iterator pointing to one past the last read element of the input sequence /// //////////////////////////////////////////////////////////// template static std::size_t Count(In begin, In end); //////////////////////////////////////////////////////////// /// \brief Convert an ANSI characters range to UTF-8 /// /// The current global locale will be used by default, unless you /// pass a custom one in the \a locale parameter. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param locale Locale to use for conversion /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Convert a wide characters range to UTF-8 /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out FromWide(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-8 /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param locale Locale to use for conversion /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out FromLatin1(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Convert an UTF-8 characters range to ANSI characters /// /// The current global locale will be used by default, unless you /// pass a custom one in the \a locale parameter. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them) /// \param locale Locale to use for conversion /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Convert an UTF-8 characters range to wide characters /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0); //////////////////////////////////////////////////////////// /// \brief Convert an UTF-8 characters range to latin-1 (ISO-5589-1) characters /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToLatin1(In begin, In end, Out output, char replacement = 0); //////////////////////////////////////////////////////////// /// \brief Convert a UTF-8 characters range to UTF-8 /// /// This functions does nothing more than a direct copy; /// it is defined only to provide the same interface as other /// specializations of the sf::Utf<> template, and allow /// generic code to be written on top of it. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToUtf8(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Convert a UTF-8 characters range to UTF-16 /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToUtf16(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Convert a UTF-8 characters range to UTF-32 /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToUtf32(In begin, In end, Out output); }; //////////////////////////////////////////////////////////// /// \brief Specialization of the Utf template for UTF-16 /// //////////////////////////////////////////////////////////// template <> class Utf<16> { public : //////////////////////////////////////////////////////////// /// \brief Decode a single UTF-16 character /// /// Decoding a character means finding its unique 32-bits /// code (called the codepoint) in the Unicode standard. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Codepoint of the decoded UTF-16 character /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid /// /// \return Iterator pointing to one past the last read element of the input sequence /// //////////////////////////////////////////////////////////// template static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0); //////////////////////////////////////////////////////////// /// \brief Encode a single UTF-16 character /// /// Encoding a character means converting a unique 32-bits /// code (called the codepoint) in the target encoding, UTF-16. /// /// \param input Codepoint to encode as UTF-16 /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement for characters not convertible to UTF-16 (use 0 to skip them) /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out Encode(Uint32 input, Out output, Uint16 replacement = 0); //////////////////////////////////////////////////////////// /// \brief Advance to the next UTF-16 character /// /// This function is necessary for multi-elements encodings, as /// a single character may use more than 1 storage element. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// /// \return Iterator pointing to one past the last read element of the input sequence /// //////////////////////////////////////////////////////////// template static In Next(In begin, In end); //////////////////////////////////////////////////////////// /// \brief Count the number of characters of a UTF-16 sequence /// /// This function is necessary for multi-elements encodings, as /// a single character may use more than 1 storage element, thus the /// total size can be different from (begin - end). /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// /// \return Iterator pointing to one past the last read element of the input sequence /// //////////////////////////////////////////////////////////// template static std::size_t Count(In begin, In end); //////////////////////////////////////////////////////////// /// \brief Convert an ANSI characters range to UTF-16 /// /// The current global locale will be used by default, unless you /// pass a custom one in the \a locale parameter. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param locale Locale to use for conversion /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Convert a wide characters range to UTF-16 /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out FromWide(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-16 /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param locale Locale to use for conversion /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out FromLatin1(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Convert an UTF-16 characters range to ANSI characters /// /// The current global locale will be used by default, unless you /// pass a custom one in the \a locale parameter. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them) /// \param locale Locale to use for conversion /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Convert an UTF-16 characters range to wide characters /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0); //////////////////////////////////////////////////////////// /// \brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToLatin1(In begin, In end, Out output, char replacement = 0); //////////////////////////////////////////////////////////// /// \brief Convert a UTF-16 characters range to UTF-8 /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToUtf8(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Convert a UTF-16 characters range to UTF-16 /// /// This functions does nothing more than a direct copy; /// it is defined only to provide the same interface as other /// specializations of the sf::Utf<> template, and allow /// generic code to be written on top of it. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToUtf16(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Convert a UTF-16 characters range to UTF-32 /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToUtf32(In begin, In end, Out output); }; //////////////////////////////////////////////////////////// /// \brief Specialization of the Utf template for UTF-32 /// //////////////////////////////////////////////////////////// template <> class Utf<32> { public : //////////////////////////////////////////////////////////// /// \brief Decode a single UTF-32 character /// /// Decoding a character means finding its unique 32-bits /// code (called the codepoint) in the Unicode standard. /// For UTF-32, the character value is the same as the codepoint. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Codepoint of the decoded UTF-32 character /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid /// /// \return Iterator pointing to one past the last read element of the input sequence /// //////////////////////////////////////////////////////////// template static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0); //////////////////////////////////////////////////////////// /// \brief Encode a single UTF-32 character /// /// Encoding a character means converting a unique 32-bits /// code (called the codepoint) in the target encoding, UTF-32. /// For UTF-32, the codepoint is the same as the character value. /// /// \param input Codepoint to encode as UTF-32 /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement for characters not convertible to UTF-32 (use 0 to skip them) /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out Encode(Uint32 input, Out output, Uint32 replacement = 0); //////////////////////////////////////////////////////////// /// \brief Advance to the next UTF-32 character /// /// This function is trivial for UTF-32, which can store /// every character in a single storage element. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// /// \return Iterator pointing to one past the last read element of the input sequence /// //////////////////////////////////////////////////////////// template static In Next(In begin, In end); //////////////////////////////////////////////////////////// /// \brief Count the number of characters of a UTF-32 sequence /// /// This function is trivial for UTF-32, which can store /// every character in a single storage element. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// /// \return Iterator pointing to one past the last read element of the input sequence /// //////////////////////////////////////////////////////////// template static std::size_t Count(In begin, In end); //////////////////////////////////////////////////////////// /// \brief Convert an ANSI characters range to UTF-32 /// /// The current global locale will be used by default, unless you /// pass a custom one in the \a locale parameter. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param locale Locale to use for conversion /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Convert a wide characters range to UTF-32 /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out FromWide(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-32 /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param locale Locale to use for conversion /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out FromLatin1(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Convert an UTF-32 characters range to ANSI characters /// /// The current global locale will be used by default, unless you /// pass a custom one in the \a locale parameter. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them) /// \param locale Locale to use for conversion /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Convert an UTF-32 characters range to wide characters /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0); //////////////////////////////////////////////////////////// /// \brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToLatin1(In begin, In end, Out output, char replacement = 0); //////////////////////////////////////////////////////////// /// \brief Convert a UTF-32 characters range to UTF-8 /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToUtf8(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Convert a UTF-32 characters range to UTF-16 /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToUtf16(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Convert a UTF-32 characters range to UTF-32 /// /// This functions does nothing more than a direct copy; /// it is defined only to provide the same interface as other /// specializations of the sf::Utf<> template, and allow /// generic code to be written on top of it. /// /// \param begin Iterator pointing to the beginning of the input sequence /// \param end Iterator pointing to the end of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out ToUtf32(In begin, In end, Out output); //////////////////////////////////////////////////////////// /// \brief Decode a single ANSI character to UTF-32 /// /// This function does not exist in other specializations /// of sf::Utf<>, it is defined for convenience (it is used by /// several other conversion functions). /// /// \param input Input ANSI character /// \param locale Locale to use for conversion /// /// \return Converted character /// //////////////////////////////////////////////////////////// template static Uint32 DecodeAnsi(In input, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Decode a single wide character to UTF-32 /// /// This function does not exist in other specializations /// of sf::Utf<>, it is defined for convenience (it is used by /// several other conversion functions). /// /// \param input Input wide character /// /// \return Converted character /// //////////////////////////////////////////////////////////// template static Uint32 DecodeWide(In input); //////////////////////////////////////////////////////////// /// \brief Encode a single UTF-32 character to ANSI /// /// This function does not exist in other specializations /// of sf::Utf<>, it is defined for convenience (it is used by /// several other conversion functions). /// /// \param codepoint Iterator pointing to the beginning of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement if the input character is not convertible to ANSI (use 0 to skip it) /// \param locale Locale to use for conversion /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out EncodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale()); //////////////////////////////////////////////////////////// /// \brief Encode a single UTF-32 character to wide /// /// This function does not exist in other specializations /// of sf::Utf<>, it is defined for convenience (it is used by /// several other conversion functions). /// /// \param codepoint Iterator pointing to the beginning of the input sequence /// \param output Iterator pointing to the beginning of the output sequence /// \param replacement Replacement if the input character is not convertible to wide (use 0 to skip it) /// /// \return Iterator to the end of the output sequence which has been written /// //////////////////////////////////////////////////////////// template static Out EncodeWide(Uint32 codepoint, Out output, wchar_t replacement = 0); }; #include // Make typedefs to get rid of the template syntax typedef Utf<8> Utf8; typedef Utf<16> Utf16; typedef Utf<32> Utf32; } // namespace sf #endif // SFML_UTF_HPP //////////////////////////////////////////////////////////// /// \class sf::Utf /// \ingroup system /// /// Utility class providing generic functions for UTF conversions. /// /// sf::Utf is a low-level, generic interface for counting, iterating, /// encoding and decoding Unicode characters and strings. It is able /// to handle ANSI, wide, UTF-8, UTF-16 and UTF-32 encodings. /// /// sf::Utf functions are all static, these classes are not meant to /// be instanciated. All the functions are template, so that you /// can use any character / string type for a given encoding. /// /// It has 3 specializations: /// \li sf::Utf<8> (typedef'd to sf::Utf8) /// \li sf::Utf<16> (typedef'd to sf::Utf16) /// \li sf::Utf<32> (typedef'd to sf::Utf32) /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Mutex.hpp0000644000000000000000000001114011770572147023306 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_MUTEX_HPP #define SFML_MUTEX_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { namespace priv { class MutexImpl; } //////////////////////////////////////////////////////////// /// \brief Blocks concurrent access to shared resources /// from multiple threads /// //////////////////////////////////////////////////////////// class SFML_API Mutex : NonCopyable { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// //////////////////////////////////////////////////////////// Mutex(); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~Mutex(); //////////////////////////////////////////////////////////// /// \brief Lock the mutex /// /// If the mutex is already locked in another thread, /// this call will block the execution until the mutex /// is released. /// /// \see Unlock /// //////////////////////////////////////////////////////////// void Lock(); //////////////////////////////////////////////////////////// /// \brief Unlock the mutex /// /// \see Lock /// //////////////////////////////////////////////////////////// void Unlock(); private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// priv::MutexImpl* myMutexImpl; ///< OS-specific implementation }; } // namespace sf #endif // SFML_MUTEX_HPP //////////////////////////////////////////////////////////// /// \class sf::Mutex /// \ingroup system /// /// Mutex stands for "MUTual EXclusion". A mutex is a /// synchronization object, used when multiple threads are involved. /// /// When you want to protect a part of the code from being accessed /// simultaneously by multiple threads, you typically use a /// mutex. When a thread is locked by a mutex, any other thread /// trying to lock it will be blocked until the mutex is released /// by the thread that locked it. This way, you can allow only /// one thread at a time to access a critical region of your code. /// /// Usage example: /// \code /// Database db; // this is a critical resource that needs some protection /// sf::Mutex mutex; /// /// void thread1() /// { /// mutex.Lock(); // this call will block the thread if the mutex is already locked by thread2 /// db.write(...); /// mutex.Unlock(); // if thread2 was waiting, it will now be unblocked /// } /// /// void thread2() /// { /// mutex.Lock(); // this call will block the thread if the mutex is already locked by thread1 /// db.write(...); /// mutex.Unlock(); // if thread1 was waiting, it will now be unblocked /// } /// \endcode /// /// Be very careful with mutexes. A bad usage can lead to bad problems, /// like deadlocks (two threads are waiting for each other and the /// application is stuck). /// /// To make the usage of mutexes more robust, particularly in /// environments where exceptions can be thrown, you should /// use the helper class sf::Lock to lock/unlock mutexes. /// /// \see sf::Lock /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Sleep.hpp0000644000000000000000000000347711770572147023272 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SLEEP_HPP #define SFML_SLEEP_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include namespace sf { //////////////////////////////////////////////////////////// /// \ingroup system /// \brief Make the current thread sleep for a given time /// /// sf::Sleep is the best way to block a program or one of its /// threads, as it doesn't consume any CPU power. /// /// \param duration Time to sleep, in seconds (must be positive) /// //////////////////////////////////////////////////////////// void SFML_API Sleep(float duration); } // namespace sf #endif // SFML_SLEEP_HPP sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Thread.inl0000644000000000000000000000544711770572147023423 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// namespace priv { // Base class for abstract thread functions struct ThreadFunc { virtual ~ThreadFunc() {} virtual void Run() = 0; }; // Specialization using a functor (including free functions) with no argument template struct ThreadFunctor : ThreadFunc { ThreadFunctor(T functor) : myFunctor(functor) {} virtual void Run() {myFunctor();} T myFunctor; }; // Specialization using a functor (including free functions) with one argument template struct ThreadFunctorWithArg : ThreadFunc { ThreadFunctorWithArg(F function, A arg) : myFunction(function), myArg(arg) {} virtual void Run() {myFunction(myArg);} F myFunction; A myArg; }; // Specialization using a member function template struct ThreadMemberFunc : ThreadFunc { ThreadMemberFunc(void(C::*function)(), C* object) : myFunction(function), myObject(object) {} virtual void Run() {(myObject->*myFunction)();} void(C::*myFunction)(); C* myObject; }; } // namespace priv //////////////////////////////////////////////////////////// template Thread::Thread(F functor) : myImpl (NULL), myFunction(new priv::ThreadFunctor(functor)) { } //////////////////////////////////////////////////////////// template Thread::Thread(F function, A argument) : myImpl (NULL), myFunction(new priv::ThreadFunctorWithArg(function, argument)) { } //////////////////////////////////////////////////////////// template Thread::Thread(void(C::*function)(), C* object) : myImpl (NULL), myFunction(new priv::ThreadMemberFunc(function, object)) { } sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Clock.hpp0000644000000000000000000000645311770572147023252 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_CLOCK_HPP #define SFML_CLOCK_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include namespace sf { //////////////////////////////////////////////////////////// /// \brief Utility class for manipulating time /// //////////////////////////////////////////////////////////// class SFML_API Clock { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// /// The clock starts automatically after being constructed. /// //////////////////////////////////////////////////////////// Clock(); //////////////////////////////////////////////////////////// /// \brief Get the time elapsed /// /// This function returns the time elapsed since the last call /// to Reset() (or the construction of the instance if Reset() /// has not been called) in seconds. /// /// \return Time elapsed, in seconds /// //////////////////////////////////////////////////////////// float GetElapsedTime() const; //////////////////////////////////////////////////////////// /// \brief Restart the timer /// /// This function puts the time counter back to zero. /// //////////////////////////////////////////////////////////// void Reset(); private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// double myStartTime; ///< Time of last reset }; } // namespace sf #endif // SFML_CLOCK_HPP //////////////////////////////////////////////////////////// /// \class sf::Clock /// \ingroup system /// /// sf::Clock is a lightweight class for measuring time. /// Its resolution depends on the underlying OS, but you can generally /// expect a 1 ms resolution. /// /// Usage example: /// \code /// sf::Clock clock; /// ... /// float time1 = clock.GetElapsedTime(); /// clock.Reset(); /// ... /// float time2 = clock.GetElapsedTime(); /// \endcode /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Resource.hpp0000644000000000000000000002360611770572147024005 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // Copyright (C) 2007 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. // //////////////////////////////////////////////////////////// #ifndef SFML_RESOURCE_HPP #define SFML_RESOURCE_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include namespace sf { //////////////////////////////////////////////////////////// // These two classes are defined in the same header because // they depend on each other. And as they're template classes, // they must be entirely defined in header files, which // prevents from proper separate compiling //////////////////////////////////////////////////////////// template class ResourcePtr; //////////////////////////////////////////////////////////// /// \brief Base class for resources that need to notify /// dependent classes about their destruction /// //////////////////////////////////////////////////////////// template class Resource { protected : //////////////////////////////////////////////////////////// /// \brief Default constructor /// //////////////////////////////////////////////////////////// Resource(); //////////////////////////////////////////////////////////// /// \brief Copy constructor /// /// \param copy Instance to copy /// //////////////////////////////////////////////////////////// Resource(const Resource& copy); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~Resource(); //////////////////////////////////////////////////////////// /// \brief Assignment operator /// /// \param right Instance to assign /// /// \return Reference to self /// //////////////////////////////////////////////////////////// Resource& operator =(const Resource& right); private : friend class ResourcePtr; //////////////////////////////////////////////////////////// /// \brief Connect a ResourcePtr to this resource /// /// A connected ResourcePtr will be notified of the /// destruction of this instance. /// /// \param observer ResourcePtr to connect /// //////////////////////////////////////////////////////////// void Connect(ResourcePtr& observer) const; //////////////////////////////////////////////////////////// /// \brief Disconnect a ResourcePtr from this resource /// /// The disconnected ResourcePtr will no longer be notified /// if this instance is destroyed. /// /// \param observer ResourcePtr to disconnect /// //////////////////////////////////////////////////////////// void Disconnect(ResourcePtr& observer) const; //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// mutable std::set*> myObservers; ///< List of pointers to this resource mutable Mutex myMutex; ///< Mutex for preventing concurrent access to the pointer list }; //////////////////////////////////////////////////////////// /// \brief Safe pointer to a sf::Resource /// //////////////////////////////////////////////////////////// template class ResourcePtr { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// /// A default constructed ResourcePtr is empty (null). /// //////////////////////////////////////////////////////////// ResourcePtr(); //////////////////////////////////////////////////////////// /// \brief Construct from a raw pointer /// /// \param resource Raw pointer to the resource to wrap /// //////////////////////////////////////////////////////////// ResourcePtr(const T* resource); //////////////////////////////////////////////////////////// /// \brief Copy constructor /// /// The new ResourcePtr will share the same resource as \a copy. /// /// \param copy Instance to copy /// //////////////////////////////////////////////////////////// ResourcePtr(const ResourcePtr& copy); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~ResourcePtr(); //////////////////////////////////////////////////////////// /// \brief Assignment operator for a ResourcePtr parameter /// /// \param right Instance to assign /// /// \return Reference to self /// //////////////////////////////////////////////////////////// ResourcePtr& operator =(const ResourcePtr& right); //////////////////////////////////////////////////////////// /// \brief Assignment operator for a raw pointer parameter /// /// \param resource Resource to assign /// /// \return Reference to self /// //////////////////////////////////////////////////////////// ResourcePtr& operator =(const T* resource); //////////////////////////////////////////////////////////// /// \brief Cast operator to implicitely convert the resource /// pointer to its raw pointer type (T*) /// /// This might be dangerous in the general case, but in this context /// it is safe enough to define this operator. /// /// \return Read-only pointer to the actual resource /// //////////////////////////////////////////////////////////// operator const T*() const; //////////////////////////////////////////////////////////// /// \brief Overload of unary operator * /// /// Like raw pointers, applying the * operator returns a /// reference to the pointed object. /// /// \return Reference to the pointed resource /// //////////////////////////////////////////////////////////// const T& operator *() const; //////////////////////////////////////////////////////////// /// \brief Overload of operator -> /// /// Like raw pointers, applying the -> operator returns the /// pointed object. /// /// \return Pointed resource /// //////////////////////////////////////////////////////////// const T* operator ->() const; //////////////////////////////////////////////////////////// /// \brief Function called when the observed resource /// is about to be destroyed /// /// This functions is called by the destructor of the pointed /// resource. It allows this instance to reset its internal pointer /// when the resource is destroyed, and avoid dangling pointers. /// //////////////////////////////////////////////////////////// void OnResourceDestroyed(); private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// const T* myResource; /// Pointer to the actual resource }; #include #include } // namespace sf #endif // SFML_RESOURCE_HPP //////////////////////////////////////////////////////////// /// \class sf::Resource /// \ingroup system /// /// sf::Resource is a base for classes that want to be /// compatible with the sf::ResourcePtr safe pointer. /// /// See sf::ResourcePtr for a complete explanation. /// /// \see sf::ResourcePtr /// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /// \class sf::ResourcePtr /// \ingroup system /// /// sf::ResourcePtr is a special kind of smart pointer for /// resources. Its main feature is to automatically /// reset its internal pointer to 0 when the resource /// gets destroyed, so that pointers to a resource never /// become invalid when the resource is destroyed. Instead, /// it properly returns 0 when the resource no longer exists. /// /// Its usage is completely transparent, so that it is similar /// to manipulating the raw resource directly (like any smart pointer). /// /// For sf::ResourcePtr to work, T must inherit from /// the sf::Resource class. /// /// These two classes are heavily used internally in SFML /// to safely handle resources and the classes that use them: /// \li sf::Image / sf::Sprite /// \li sf::Font / sf::String /// \li sf::SoundBuffer / sf::Sound /// /// sf::Resource and sf::ResourcePtr are designed for internal use, /// but if you feel like they would fit well in your implementation /// there's no problem to use them. /// /// \see sf::Resource /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Randomizer.hpp0000644000000000000000000001046511770572147024327 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_RANDOMIZER_HPP #define SFML_RANDOMIZER_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include namespace sf { //////////////////////////////////////////////////////////// /// \brief Utility class for generating pseudo-random numbers /// //////////////////////////////////////////////////////////// class SFML_API Randomizer { public : //////////////////////////////////////////////////////////// /// \brief Set a new seed for the generator /// /// Using a known seed allows you to reproduce the same /// sequence of random numbers. /// /// \param seed Number to use as the seed /// //////////////////////////////////////////////////////////// static void SetSeed(unsigned int seed); //////////////////////////////////////////////////////////// /// \brief Get the current seed of the generator /// /// \return Current seed /// //////////////////////////////////////////////////////////// static unsigned int GetSeed(); //////////////////////////////////////////////////////////// /// \brief Get a random float number in a given range /// /// \param begin Beginning of the range /// \param end End of the range /// /// \return Random number in [begin, end] /// //////////////////////////////////////////////////////////// static float Random(float begin, float end); //////////////////////////////////////////////////////////// /// \brief Get a random integer number in a given range /// /// \param begin Beginning of the range /// \param end End of the range /// /// \return Random number in [begin, end] /// //////////////////////////////////////////////////////////// static int Random(int begin, int end); }; } // namespace sf #endif // SFML_RANDOMIZER_HPP //////////////////////////////////////////////////////////// /// \class sf::Randomizer /// \ingroup system /// /// sf::Randomizer generates pseudo-random numbers using the /// standard library. /// /// Usage example: /// \code /// int x1 = sf::Randomizer::Random(0, 6); /// float x2 = sf::Randomizer::Random(0.f, 1.f); /// \endcode /// /// Note that, unlike the standard rand() function, you don't /// have to initialize the seed before using this class. SFML does /// it for you, so that you will automatically get different results /// for every execution of the program. /// /// The SetSeed and GetSeed functions are provided mainly for being /// able to reproduce the same set of numbers in a recorded /// sequence. This is useful when implementing replays, for example. /// /// The technique used by sf::Randomizer for getting random numbers /// is not the most accurate: some numbers may have a slightly higher /// probability than others, under certain circumstancies. /// This doesn't matter in 99.9% of situations, but if you really /// need a generator which is mathematically more robust /// you should use another library for that part (see boost.random). /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Thread.hpp0000644000000000000000000002224511770572147023423 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_THREAD_HPP #define SFML_THREAD_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include namespace sf { namespace priv { class ThreadImpl; struct ThreadFunc; } //////////////////////////////////////////////////////////// /// \brief Utility class to manipulate threads /// //////////////////////////////////////////////////////////// class SFML_API Thread : NonCopyable { public : //////////////////////////////////////////////////////////// /// \brief Construct the thread from a functor with no argument /// /// This constructor works for function objects, as well /// as free function. /// /// Use this constructor for this kind of function: /// \code /// void function(); /// /// // --- or ---- /// /// struct Functor /// { /// void operator()(); /// }; /// \endcode /// Note: this does *not* run the thread, use Run(). /// /// \param function Functor or free function to use as the entry point of the thread /// //////////////////////////////////////////////////////////// template Thread(F function); //////////////////////////////////////////////////////////// /// \brief Construct the thread from a functor with an argument /// /// This constructor works for function objects, as well /// as free function. /// It is a template, which means that the argument can /// have any type (int, std::string, void*, Toto, ...). /// /// Use this constructor for this kind of function: /// \code /// void function(int arg); /// /// // --- or ---- /// /// struct Functor /// { /// void operator()(std::string arg); /// }; /// \endcode /// Note: this does *not* run the thread, use Run(). /// /// \param function Functor or free function to use as the entry point of the thread /// \param argument argument to forward to the function /// //////////////////////////////////////////////////////////// template Thread(F function, A argument); //////////////////////////////////////////////////////////// /// \brief Construct the thread from a member function and an object /// /// This constructor is template, which means that you can /// use it with any class. /// Use this constructor for this kind of function: /// \code /// class MyClass /// { /// public : /// /// void function(); /// }; /// \endcode /// Note: this does *not* run the thread, use Run(). /// /// \param function Entry point of the thread /// \param object Pointer to the object to use /// //////////////////////////////////////////////////////////// template Thread(void(C::*function)(), C* object); //////////////////////////////////////////////////////////// /// \brief Destructor /// /// This destructor calls Wait(), so that the internal thread /// cannot survive after its sf::Thread instance is destroyed. /// //////////////////////////////////////////////////////////// ~Thread(); //////////////////////////////////////////////////////////// /// \brief Run the thread /// /// This function starts the entry point passed to the /// thread's constructor, and returns immediately. /// After this function returns, the thread's function is /// running in parallel to the calling code. /// //////////////////////////////////////////////////////////// void Launch(); //////////////////////////////////////////////////////////// /// \brief Wait until the thread finishes /// /// This function will block the execution until the /// thread's function ends. /// Warning: if the thread function never ends, the calling /// thread will block forever. /// //////////////////////////////////////////////////////////// void Wait(); //////////////////////////////////////////////////////////// /// \brief Terminate the thread /// /// This function immediately stops the thread, without waiting /// for its function to finish. /// Terminating a thread with this function is not safe, /// and can lead to local variables not being destroyed /// on some operating systems. You should rather try to make /// the thread function terminate by itself. /// //////////////////////////////////////////////////////////// void Terminate(); private : friend class priv::ThreadImpl; //////////////////////////////////////////////////////////// /// \brief Internal entry point of the thread /// /// This function is called by the thread implementation. /// //////////////////////////////////////////////////////////// void Run(); //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// priv::ThreadImpl* myImpl; ///< OS-specific implementation of the thread priv::ThreadFunc* myFunction; ///< Abstraction of the function to run }; #include } // namespace sf #endif // SFML_THREAD_HPP //////////////////////////////////////////////////////////// /// \class sf::Thread /// \ingroup system /// /// Threads provide a way to run multiple parts of the code /// in parallel. When you launch a new thread, the execution /// is split and both the new thread and the caller run /// in parallel. /// /// To use a sf::Thread, you construct it directly with the /// function to execute as the entry point of the thread. /// sf::Thread has multiple template constructors, which means /// that you can use several types of entry points: /// \li non-member functions with no argument /// \li non-member functions with one argument of any type /// \li functors with no argument (this one is particularly useful for compatibility with boost/std::bind) /// \li functors with one argument of any type /// \li member functions from any class with no argument /// /// The function argument, if any, is copied in the sf::Thread /// instance, as well as the functor (if the corresponding /// constructor is used). Class instances, however, are passed /// by pointer to you must make sure that the object won't be /// destroyed while the thread is still using it. /// /// The thread ends when its function is terminated. If the /// owner sf::Thread instance is destroyed before the /// thread is finished, the destructor will wait (see Wait()) /// /// Usage examples: /// \code /// // example 1: non member function with one argument /// /// void ThreadFunc(int argument) /// { /// ... /// } /// /// sf::Thread thread(&ThreadFunc, 5); /// thread.Launch(); // start the thread (internally calls ThreadFunc(5)) /// \endcode /// /// \code /// // example 2: member function /// /// class Task /// { /// public : /// void Run() /// { /// ... /// } /// }; /// /// Task task; /// sf::Thread thread(&Task::Run, &task); /// thread.Launch(); // start the thread (internally calls task.run()) /// \endcode /// /// \code /// // example 3: functor /// /// struct Task /// { /// void operator()() /// { /// ... /// } /// }; /// /// sf::Thread thread(Task()); /// thread.Launch(); // start the thread (internally calls operator() on the Task instance) /// \endcode /// /// Creating parallel threads of execution can be dangerous: /// all threads inside the same process share the same memory space, /// which means that you may end up accessing the same variable /// from multiple threads at the same time. To prevent this /// kind of situations, you can use mutexes (see sf::Mutex). /// /// \see sf::Mutex /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/NonCopyable.hpp0000644000000000000000000001047311770572147024425 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_NONCOPYABLE_HPP #define SFML_NONCOPYABLE_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include namespace sf { //////////////////////////////////////////////////////////// /// \brief Utility class that makes any derived /// class non-copyable /// //////////////////////////////////////////////////////////// class SFML_API NonCopyable { protected : //////////////////////////////////////////////////////////// /// \brief Default constructor /// /// Because this class has a copy constructor, the compiler /// will not automatically generate the default constructor. /// That's why we must define it explicitely. /// //////////////////////////////////////////////////////////// NonCopyable() {} private : //////////////////////////////////////////////////////////// /// \brief Disabled copy constructor /// /// By making the copy constructor private, the compiler will /// trigger an error if anyone outside tries to use it. /// To prevent NonCopyable or friend classes from using it, /// we also give no definition, so that the linker will /// produce an error if the first protection was inefficient. /// //////////////////////////////////////////////////////////// NonCopyable(const NonCopyable&); //////////////////////////////////////////////////////////// /// \brief Disabled assignment operator /// /// By making the assignment operator private, the compiler will /// trigger an error if anyone outside tries to use it. /// To prevent NonCopyable or friend classes from using it, /// we also give no definition, so that the linker will /// produce an error if the first protection was inefficient. /// //////////////////////////////////////////////////////////// NonCopyable& operator =(const NonCopyable&); }; } // namespace sf #endif // SFML_NONCOPYABLE_HPP //////////////////////////////////////////////////////////// /// \class sf::NonCopyable /// \ingroup system /// /// This class makes its instances non-copyable, by explicitely /// disabling its copy constructor and its assignment operator. /// /// To create a non-copyable class, simply inherit from /// sf::NonCopyable. /// /// The type of inheritance (public or private) doesn't matter, /// the copy constructor and assignment operator are declared private /// in sf::NonCopyable so they will end up being inaccessible in both /// cases. Thus you can use a shorter syntax for inheriting from it /// see below). /// /// Usage example: /// \code /// class MyNonCopyableClass : sf::NonCopyable /// { /// ... /// }; /// \endcode /// /// Deciding whether the instances of a class can be copied /// or not is a very important design choice. You are strongly /// encouraged to think about it before writing a class, /// and to use sf::NonCopyable when necessary to prevent /// many potential future errors when using it. This is also /// a very important indication to users of your class. /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/Audio/0000755000000000000000000000000011770572147021253 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/Audio/Sound.hpp0000644000000000000000000002267611770572147023071 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUND_HPP #define SFML_SOUND_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include namespace sf { class SoundBuffer; //////////////////////////////////////////////////////////// /// \brief Regular sound that can be played in the audio environment /// //////////////////////////////////////////////////////////// class SFML_API Sound : public SoundSource { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// //////////////////////////////////////////////////////////// Sound(); //////////////////////////////////////////////////////////// /// \brief Construct the sound with parameters /// /// \param buffer Sound buffer containing the audio data to play with the sound /// \param loop Should the sound loop? /// \param pitch Pitch of the sound /// \param volume Volume of the sound, in the range [0, 100] /// \param position 3D position of the sound source in the audio scene /// //////////////////////////////////////////////////////////// Sound(const SoundBuffer& buffer, bool loop = false, float pitch = 1.f, float volume = 100.f, const Vector3f& position = Vector3f(0, 0, 0)); //////////////////////////////////////////////////////////// /// \brief Copy constructor /// /// \param copy Instance to copy /// //////////////////////////////////////////////////////////// Sound(const Sound& copy); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~Sound(); //////////////////////////////////////////////////////////// /// \brief Start or resume playing the sound /// /// This function starts the stream if it was stopped, resumes /// it if it was paused, and restarts it from beginning if it /// was it already playing. /// This function uses its own thread so that it doesn't block /// the rest of the program while the sound is played. /// /// \see Pause, Stop /// //////////////////////////////////////////////////////////// void Play(); //////////////////////////////////////////////////////////// /// \brief Pause the sound /// /// This function pauses the sound if it was playing, /// otherwise (sound already paused or stopped) it has no effect. /// /// \see Play, Stop /// //////////////////////////////////////////////////////////// void Pause(); //////////////////////////////////////////////////////////// /// \brief Stop playing the sound /// /// This function stops the sound if it was playing or paused, /// and does nothing if it was already stopped. /// It also resets the playing position (unlike Pause()). /// /// \see Play, Pause /// //////////////////////////////////////////////////////////// void Stop(); //////////////////////////////////////////////////////////// /// \brief Set the source buffer containing the audio data to play /// /// It is important to note that the sound buffer is not copied, /// thus the sf::SoundBuffer instance must remain alive as long /// as it is attached to the sound. /// /// \param buffer Sound buffer to attach to the sound /// /// \see GetBuffer /// //////////////////////////////////////////////////////////// void SetBuffer(const SoundBuffer& buffer); //////////////////////////////////////////////////////////// /// \brief Set whether or not the sound should loop after reaching the end /// /// If set, the sound will restart from beginning after /// reaching the end and so on, until it is stopped or /// SetLoop(false) is called. /// The default looping state for sound is false. /// /// \param loop True to play in loop, false to play once /// /// \see GetLoop /// //////////////////////////////////////////////////////////// void SetLoop(bool loop); //////////////////////////////////////////////////////////// /// \brief Change the current playing position of the sound /// /// The playing position can be changed when the sound is /// either paused or playing. /// /// \param timeOffset New playing position, in seconds /// /// \see GetPlayingOffset /// //////////////////////////////////////////////////////////// void SetPlayingOffset(float timeOffset); //////////////////////////////////////////////////////////// /// \brief Get the audio buffer attached to the sound /// /// \return Sound buffer attached to the sound (can be NULL) /// //////////////////////////////////////////////////////////// const SoundBuffer* GetBuffer() const; //////////////////////////////////////////////////////////// /// \brief Tell whether or not the sound is in loop mode /// /// \return True if the sound is looping, false otherwise /// /// \see SetLoop /// //////////////////////////////////////////////////////////// bool GetLoop() const; //////////////////////////////////////////////////////////// /// \brief Get the current playing position of the sound /// /// \return Current playing position, in seconds /// /// \see SetPlayingOffset /// //////////////////////////////////////////////////////////// float GetPlayingOffset() const; //////////////////////////////////////////////////////////// /// \brief Get the current status of the sound (stopped, paused, playing) /// /// \return Current status of the sound /// //////////////////////////////////////////////////////////// Status GetStatus() const; //////////////////////////////////////////////////////////// /// \brief Overload of assignment operator /// /// \param right Instance to assign /// /// \return Reference to self /// //////////////////////////////////////////////////////////// Sound& operator =(const Sound& right); //////////////////////////////////////////////////////////// /// \brief Reset the internal buffer of the sound /// /// This function is for internal use only, you don't have /// to use it. It is called by the sf::SoundBuffer that /// this sound uses, when it is destroyed in order to prevent /// the sound from using a dead buffer. /// //////////////////////////////////////////////////////////// void ResetBuffer(); private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// ResourcePtr myBuffer; ///< Sound buffer bound to the source }; } // namespace sf #endif // SFML_SOUND_HPP //////////////////////////////////////////////////////////// /// \class sf::Sound /// \ingroup audio /// /// sf::Sound is the class to use to play sounds. /// It provides: /// \li Control (play, pause, stop) /// \li Ability to modify output parameters in real-time (pitch, volume, ...) /// \li 3D spatial features (position, attenuation, ...). /// /// sf::Sound is perfect for playing short sounds that can /// fit in memory and require no latency, like foot steps or /// gun shots. For longer sounds, like background musics /// or long speeches, rather see sf::Music (which is based /// on streaming). /// /// In order to work, a sound must be given a buffer of audio /// data to play. Audio data (samples) is stored in sf::SoundBuffer, /// and attached to a sound with the SetBuffer() function. /// The buffer object attached to a sound must remain alive /// as long as the sound uses it. Note that multiple sounds /// can use the same sound buffer at the same time. /// /// Usage example: /// \code /// sf::SoundBuffer buffer; /// buffer.LoadFromFile("sound.wav"); /// /// sf::Sound sound; /// sound.SetBuffer(buffer); /// sound.Play(); /// \endcode /// /// \see sf::SoundBuffer, sf::Music /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/Audio/SoundSource.hpp0000644000000000000000000002456311770572147024247 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDSOURCE_HPP #define SFML_SOUNDSOURCE_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { //////////////////////////////////////////////////////////// /// \brief Base class defining a sound's properties /// //////////////////////////////////////////////////////////// class SFML_API SoundSource { public : //////////////////////////////////////////////////////////// /// \brief Enumeration of the sound source states /// //////////////////////////////////////////////////////////// enum Status { Stopped, ///< Sound is not playing Paused, ///< Sound is paused Playing ///< Sound is playing }; //////////////////////////////////////////////////////////// /// \brief Copy constructor /// /// \param copy Instance to copy /// //////////////////////////////////////////////////////////// SoundSource(const SoundSource& copy); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// virtual ~SoundSource(); //////////////////////////////////////////////////////////// /// \brief Set the pitch of the sound /// /// The pitch represents the perceived fundamental frequency /// of a sound; thus you can make a sound more acute or grave /// by changing its pitch. A side effect of changing the pitch /// is to modify the playing speed of the sound as well. /// The default value for the pitch is 1. /// /// \param pitch New pitch to apply to the sound /// /// \see GetPitch /// //////////////////////////////////////////////////////////// void SetPitch(float pitch); //////////////////////////////////////////////////////////// /// \brief Set the volume of the sound /// /// The volume is a value between 0 (mute) and 100 (full volume). /// The default value for the volume is 100. /// /// \param volume Volume of the sound /// /// \see GetVolume /// //////////////////////////////////////////////////////////// void SetVolume(float volume); //////////////////////////////////////////////////////////// /// \brief Set the 3D position of the sound in the audio scene /// /// Only sounds with one channel (mono sounds) can be /// spatialized. /// The default position of a sound is (0, 0, 0). /// /// \param x X coordinate of the position of the sound in the scene /// \param y Y coordinate of the position of the sound in the scene /// \param z Z coordinate of the position of the sound in the scene /// /// \see GetPosition /// //////////////////////////////////////////////////////////// void SetPosition(float x, float y, float z); //////////////////////////////////////////////////////////// /// \brief Set the 3D position of the sound in the audio scene /// /// Only sounds with one channel (mono sounds) can be /// spatialized. /// The default position of a sound is (0, 0, 0). /// /// \param position Position of the sound in the scene /// /// \see GetPosition /// //////////////////////////////////////////////////////////// void SetPosition(const Vector3f& position); //////////////////////////////////////////////////////////// /// \brief Make the sound's position relative to the listener or absolute /// /// Making a sound relative to the listener will ensure that it will always /// be played the same way regardless the position of the listener. /// This can be useful for non-spatialized sounds, sounds that are /// produced by the listener, or sounds attached to it. /// The default value is false (position is absolute). /// /// \param relative True to set the position relative, false to set it absolute /// /// \see IsRelativeToListener /// //////////////////////////////////////////////////////////// void SetRelativeToListener(bool relative); //////////////////////////////////////////////////////////// /// \brief Set the minimum distance of the sound /// /// The "minimum distance" of a sound is the maximum /// distance at which it is heard at its maximum volume. Further /// than the minimum distance, it will start to fade out according /// to its attenuation factor. A value of 0 ("inside the head /// of the listener") is an invalid value and is forbidden. /// The default value of the minimum distance is 1. /// /// \param distance New minimum distance of the sound /// /// \see GetMinDistance, SetAttenuation /// //////////////////////////////////////////////////////////// void SetMinDistance(float distance); //////////////////////////////////////////////////////////// /// \brief Set the attenuation factor of the sound /// /// The attenuation is a multiplicative factor which makes /// the sound more or less loud according to its distance /// from the listener. An attenuation of 0 will produce a /// non-attenuated sound, i.e. its volume will always be the same /// whether it is heard from near or from far. On the other hand, /// an attenuation value such as 100 will make the sound fade out /// very quickly as it gets further from the listener. /// The default value of the attenuation is 1. /// /// \param attenuation New attenuation factor of the sound /// /// \see GetAttenuation, SetMinDistance /// //////////////////////////////////////////////////////////// void SetAttenuation(float attenuation); //////////////////////////////////////////////////////////// /// \brief Get the pitch of the sound /// /// \return Pitch of the sound /// /// \see SetPitch /// //////////////////////////////////////////////////////////// float GetPitch() const; //////////////////////////////////////////////////////////// /// \brief Get the volume of the sound /// /// \return Volume of the sound, in the range [0, 100] /// /// \see SetVolume /// //////////////////////////////////////////////////////////// float GetVolume() const; //////////////////////////////////////////////////////////// /// \brief Get the 3D position of the sound in the audio scene /// /// \return Position of the sound /// /// \see SetPosition /// //////////////////////////////////////////////////////////// Vector3f GetPosition() const; //////////////////////////////////////////////////////////// /// \brief Tell whether the sound's position is relative to the /// listener or is absolute /// /// \return True if the position is relative, false if it's absolute /// /// \see SetRelativeToListener /// //////////////////////////////////////////////////////////// bool IsRelativeToListener() const; //////////////////////////////////////////////////////////// /// \brief Get the minimum distance of the sound /// /// \return Minimum distance of the sound /// /// \see SetMinDistance, GetAttenuation /// //////////////////////////////////////////////////////////// float GetMinDistance() const; //////////////////////////////////////////////////////////// /// \brief Get the attenuation factor of the sound /// /// \return Attenuation factor of the sound /// /// \see SetAttenuation, GetMinDistance /// //////////////////////////////////////////////////////////// float GetAttenuation() const; protected : //////////////////////////////////////////////////////////// /// \brief Default constructor /// /// This constructor is meant ot be called by derived classes only. /// //////////////////////////////////////////////////////////// SoundSource(); //////////////////////////////////////////////////////////// /// \brief Get the current status of the sound (stopped, paused, playing) /// /// \return Current status of the sound /// //////////////////////////////////////////////////////////// Status GetStatus() const; //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// unsigned int mySource; ///< OpenAL source identifier }; } // namespace sf #endif // SFML_SOUNDSOURCE_HPP //////////////////////////////////////////////////////////// /// \class sf::SoundSource /// \ingroup audio /// /// sf::SoundSource is not meant to be used directly, it /// only serves as a common base for all audio objects /// that can live in the audio environment. /// /// It defines several properties for the sound: pitch, /// volume, position, attenuation, etc. All of them can be /// changed at any time with no impact on performances. /// /// \see sf::Sound, sf::SoundStream /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/Audio/Listener.hpp0000644000000000000000000001520011770572147023547 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_LISTENER_HPP #define SFML_LISTENER_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { //////////////////////////////////////////////////////////// /// \brief The audio listener is the point in the scene /// from where all the sounds are heard /// //////////////////////////////////////////////////////////// class SFML_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 orientation of the listener in the scene /// /// The orientation defines the 3D axes of the listener /// (left, up, front) in the scene. The orientation vector /// doesn't have to be normalized. /// The default listener's orientation is (0, 0, -1). /// /// \param x X coordinate of the listener's orientation /// \param y Y coordinate of the listener's orientation /// \param z Z coordinate of the listener's orientation /// /// \see GetDirection, SetPosition /// //////////////////////////////////////////////////////////// static void SetDirection(float x, float y, float z); //////////////////////////////////////////////////////////// /// \brief Set the orientation of the listener in the scene /// /// The orientation defines the 3D axes of the listener /// (left, up, front) in the scene. The orientation vector /// doesn't have to be normalized. /// The default listener's orientation is (0, 0, -1). /// /// \param direction New listener's orientation /// /// \see GetDirection, SetPosition /// //////////////////////////////////////////////////////////// static void SetDirection(const Vector3f& direction); //////////////////////////////////////////////////////////// /// \brief Get the current orientation of the listener in the scene /// /// \return Listener's orientation /// /// \see SetDirection /// //////////////////////////////////////////////////////////// static Vector3f GetDirection(); }; } // namespace sf #endif // SFML_LISTENER_HPP //////////////////////////////////////////////////////////// /// \class sf::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 sf::View is the eyes of the user, then sf::Listener /// is his ears (by the way, they are often linked together -- /// same position, orientation, etc.). /// /// sf::Listener is a simple interface, which allows to setup the /// listener in the 3D audio environment (position and direction), /// and to adjust the global volume. /// /// Because the listener is unique in the scene, sf::Listener only /// contains static functions and doesn't have to be instanciated. /// /// Usage example: /// \code /// // Move the listener to the position (1, 0, -5) /// sf::Listener::SetPosition(1, 0, -5); /// /// // Make it face the right axis (1, 0, 0) /// sf::Listener::SetDirection(1, 0, 0); /// /// // Reduce the global volume /// sf::Listener::SetGlobalVolume(50); /// \endcode /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/Audio/SoundRecorder.hpp0000644000000000000000000002370511770572147024551 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDRECORDER_HPP #define SFML_SOUNDRECORDER_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include namespace sf { //////////////////////////////////////////////////////////// /// \brief Abstract base class for capturing sound data /// //////////////////////////////////////////////////////////// class SFML_API SoundRecorder { public : //////////////////////////////////////////////////////////// /// \brief destructor /// //////////////////////////////////////////////////////////// virtual ~SoundRecorder(); //////////////////////////////////////////////////////////// /// \brief Start the capture /// /// The \a sampleRate parameter defines the number of audio samples /// captured per second. The higher, the better the quality /// (for example, 44100 samples/sec is CD quality). /// This function uses its own thread so that it doesn't block /// the rest of the program while the capture runs. /// Please note that only one capture can happen at the same time. /// /// \param sampleRate Desired capture rate, in number of samples per second /// /// \see Stop /// //////////////////////////////////////////////////////////// void Start(unsigned int sampleRate = 44100); //////////////////////////////////////////////////////////// /// \brief Stop the capture /// /// \see Start /// //////////////////////////////////////////////////////////// void Stop(); //////////////////////////////////////////////////////////// /// \brief Get the sample rate /// /// The sample rate defines the number of audio samples /// captured per second. The higher, the better the quality /// (for example, 44100 samples/sec is CD quality). /// /// \return Sample rate, in samples per second /// //////////////////////////////////////////////////////////// unsigned int GetSampleRate() const; //////////////////////////////////////////////////////////// /// \brief Check if the system supports audio capture /// /// This function should always be called before using /// the audio capture features. If it returns false, then /// any attempt to use sf::SoundRecorder or one of its derived /// classes will fail. /// /// \return True if audio capture is supported, false otherwise /// //////////////////////////////////////////////////////////// static bool IsAvailable(); protected : //////////////////////////////////////////////////////////// /// \brief Default constructor /// /// This constructor is only meant to be called by derived classes. /// //////////////////////////////////////////////////////////// SoundRecorder(); private : //////////////////////////////////////////////////////////// /// \brief Start capturing audio data /// /// This virtual function may be overriden by a derived class /// if something has to be done every time a new capture /// starts. If not, this function can be ignored; the default /// implementation does nothing. /// /// \return True to start the capture, or false to abort it /// //////////////////////////////////////////////////////////// virtual bool OnStart(); //////////////////////////////////////////////////////////// /// \brief Process a new chunk of recorded samples /// /// This virtual function is called every time a new chunk of /// recorded data is available. The derived class can then do /// whatever it wants with it (storing it, playing it, sending /// it over the network, etc.). /// /// \param samples Pointer to the new chunk of recorded samples /// \param samplesCount Number of samples pointed by \a samples /// /// \return True to continue the capture, or false to stop it /// //////////////////////////////////////////////////////////// virtual bool OnProcessSamples(const Int16* samples, std::size_t samplesCount) = 0; //////////////////////////////////////////////////////////// /// \brief Stop capturing audio data /// /// This virtual function may be overriden by a derived class /// if something has to be done every time the capture /// ends. If not, this function can be ignored; the default /// implementation does nothing. /// //////////////////////////////////////////////////////////// virtual void OnStop(); //////////////////////////////////////////////////////////// /// \brief Function called as the entry point of the thread /// /// This function starts the recording loop, and returns /// only when the capture is stopped. /// //////////////////////////////////////////////////////////// void Record(); //////////////////////////////////////////////////////////// /// \brief Get the new available audio samples and process them /// /// This function is called continuously during the /// capture loop. It retrieves the captured samples and /// forwards them to the derived class. /// //////////////////////////////////////////////////////////// void ProcessCapturedSamples(); //////////////////////////////////////////////////////////// /// \brief Clean up the recorder's internal resources /// /// This function is called when the capture stops. /// //////////////////////////////////////////////////////////// void CleanUp(); //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// Thread myThread; ///< Thread running the background recording task std::vector mySamples; ///< Buffer to store captured samples unsigned int mySampleRate; ///< Sample rate bool myIsCapturing; ///< Capturing state }; } // namespace sf #endif // SFML_SOUNDRECORDER_HPP //////////////////////////////////////////////////////////// /// \class sf::SoundRecorder /// \ingroup audio /// /// sf::SoundBuffer provides a simple interface to access /// the audio recording capabilities of the computer /// (the microphone). As an abstract base class, it only cares /// about capturing sound samples, the task of making something /// useful with them is left to the derived class. Note that /// SFML provides a built-in specialization for saving the /// captured data to a sound buffer (see sf::SoundBufferRecorder). /// /// A derived class has only one virtual function to override: /// \li OnProcessSamples provides the new chunks of audio samples while the capture happens /// /// Moreover, two additionnal virtual functions can be overriden /// as well if necessary: /// \li OnStart is called before the capture happens, to perform custom initializations /// \li OnStop is called after the capture ends, to perform custom cleanup /// /// The audio capture feature may not be supported or activated /// on every platform, thus it is recommended to check its /// availability with the IsAvailable() function. If it returns /// false, then any attempt to use an audio recorder will fail. /// /// It is important to note that the audio capture happens in a /// separate thread, so that it doesn't block the rest of the /// program. In particular, the OnProcessSamples and OnStop /// virtual functions (but not OnStart) will be called /// from this separate thread. It is important to keep this in /// mind, because you may have to take care of synchronization /// issues if you share data between threads. /// /// Usage example: /// \code /// class CustomRecorder : public sf::SoundRecorder /// { /// virtual bool OnStart() // optional /// { /// // Initialize whatever has to be done before the capture starts /// ... /// /// // Return true to start playing /// return true; /// } /// /// virtual bool OnProcessSamples(const Int16* samples, std::size_t samplesCount) /// { /// // Do something with the new chunk of samples (store them, send them, ...) /// ... /// /// // Return true to continue playing /// return true; /// } /// /// virtual void OnStop() // optional /// { /// // Clean up whatever has to be done after the capture ends /// ... /// } /// } /// /// // Usage /// if (CustomRecorder::IsAvailable()) /// { /// CustomRecorder recorder; /// recorder.Start(); /// ... /// recorder.Stop(); /// } /// \endcode /// /// \see sf::SoundBufferRecorder /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/Audio/SoundBuffer.hpp0000644000000000000000000003041711770572147024213 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDBUFFER_HPP #define SFML_SOUNDBUFFER_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include #include namespace sf { class Sound; //////////////////////////////////////////////////////////// /// \brief Storage for audio samples defining a sound /// //////////////////////////////////////////////////////////// class SFML_API SoundBuffer : public Resource { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// //////////////////////////////////////////////////////////// SoundBuffer(); //////////////////////////////////////////////////////////// /// \brief Copy constructor /// /// \param copy Instance to copy /// //////////////////////////////////////////////////////////// SoundBuffer(const SoundBuffer& copy); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~SoundBuffer(); //////////////////////////////////////////////////////////// /// \brief Load the sound buffer from a file /// /// Here is a complete list of all the supported audio formats: /// ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, /// w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. /// /// \param filename Path of the sound file to load /// /// \return True if loading succeeded, false if it failed /// /// \see LoadFromMemory, LoadFromSamples, SaveToFile /// //////////////////////////////////////////////////////////// bool LoadFromFile(const std::string& filename); //////////////////////////////////////////////////////////// /// \brief Load the sound buffer from a file in memory /// /// Here is a complete list of all the supported audio formats: /// ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, /// w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. /// /// \param data Pointer to the file data in memory /// \param sizeInBytes Size of the data to load, in bytes /// /// \return True if loading succeeded, false if it failed /// /// \see LoadFromFile, LoadFromSamples, SaveToFile /// //////////////////////////////////////////////////////////// bool LoadFromMemory(const void* data, std::size_t sizeInBytes); //////////////////////////////////////////////////////////// /// \brief Load the sound buffer from an array of audio samples /// /// The assumed format of the audio samples is 16 bits signed integer /// (sf::Int16). /// /// \param samples Pointer to the array of samples in memory /// \param samplesCount Number of samples in the array /// \param channelsCount Number of channels (1 = mono, 2 = stereo, ...) /// \param sampleRate Sample rate (number of samples to play per second) /// /// \return True if loading succeeded, false if it failed /// /// \see LoadFromFile, LoadFromMemory, SaveToFile /// //////////////////////////////////////////////////////////// bool LoadFromSamples(const Int16* samples, std::size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate); //////////////////////////////////////////////////////////// /// \brief Save the sound buffer to an audio file /// /// Here is a complete list of all the supported audio formats: /// ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, /// w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. /// /// \param filename Path of the sound file to write /// /// \return True if saving succeeded, false if it failed /// /// \see LoadFromFile, LoadFromMemory, LoadFromSamples /// //////////////////////////////////////////////////////////// bool SaveToFile(const std::string& filename) const; //////////////////////////////////////////////////////////// /// \brief Get the array of audio samples stored in the buffer /// /// The format of the returned samples is 16 bits signed integer /// (sf::Int16). The total number of samples in this array /// is given by the GetSamplesCount() function. /// /// \return Read-only pointer to the array of sound samples /// /// \see GetSamplesCount /// //////////////////////////////////////////////////////////// const Int16* GetSamples() const; //////////////////////////////////////////////////////////// /// \brief Get the number of samples stored in the buffer /// /// The array of samples can be accessed with the GetSamples() /// function. /// /// \return Number of samples /// /// \see GetSamples /// //////////////////////////////////////////////////////////// std::size_t GetSamplesCount() const; //////////////////////////////////////////////////////////// /// \brief Get the sample rate of the sound /// /// The sample rate is the number of samples played per second. /// The higher, the better the quality (for example, 44100 /// samples/s is CD quality). /// /// \return Sample rate (number of samples per second) /// /// \see GetChannelsCount, GetDuration /// //////////////////////////////////////////////////////////// unsigned int GetSampleRate() const; //////////////////////////////////////////////////////////// /// \brief Get the number of channels used by the sound /// /// If the sound is mono then the number ofchannels will /// be 1, 2 for stereo, etc. /// /// \return Number of channels /// /// \see GetSampleRate, GetDuration /// //////////////////////////////////////////////////////////// unsigned int GetChannelsCount() const; //////////////////////////////////////////////////////////// /// \brief Get the total duration of the sound /// /// \return Sound duration, in seconds /// /// \see GetSampleRate, GetChannelsCount /// //////////////////////////////////////////////////////////// float GetDuration() const; //////////////////////////////////////////////////////////// /// \brief Overload of assignment operator /// /// \param right Instance to assign /// /// \return Reference to self /// //////////////////////////////////////////////////////////// SoundBuffer& operator =(const SoundBuffer& right); private : friend class Sound; //////////////////////////////////////////////////////////// /// \brief Update the internal buffer with the cached audio samples /// /// \param channelsCount Number of channels /// \param sampleRate Sample rate (number of samples per second) /// /// \return True on success, false if any error happened /// //////////////////////////////////////////////////////////// bool Update(unsigned int channelsCount, unsigned int sampleRate); //////////////////////////////////////////////////////////// /// \brief Add a sound to the list of sounds that use this buffer /// /// \param sound Sound instance to attach /// //////////////////////////////////////////////////////////// void AttachSound(Sound* sound) const; //////////////////////////////////////////////////////////// /// \brief Remove a sound from the list of sounds that use this buffer /// /// \param sound Sound instance to detach /// //////////////////////////////////////////////////////////// void DetachSound(Sound* sound) const; //////////////////////////////////////////////////////////// // Types //////////////////////////////////////////////////////////// typedef std::set SoundList; ///< Set of unique sound instances //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// unsigned int myBuffer; ///< OpenAL buffer identifier std::vector mySamples; ///< Samples buffer float myDuration; ///< Sound duration, in seconds mutable SoundList mySounds; ///< List of sounds that are using this buffer }; } // namespace sf #endif // SFML_SOUNDBUFFER_HPP //////////////////////////////////////////////////////////// /// \class sf::SoundBuffer /// \ingroup audio /// /// A sound buffer holds the data of a sound, which is /// an array of audio samples. A sample is a 16 bits signed integer /// that defines the amplitude of the sound at a given time. /// The sound is then restituted by playing these samples at /// a high rate (for example, 44100 samples per second is the /// standard rate used for playing CDs). In short, audio samples /// are like image pixels, and a sf::SoundBuffer is similar to /// a sf::Image. /// /// A sound buffer can be loaded from a file (see LoadFromFile() /// for the complete list of supported formats), from memory /// or directly from an array of samples. It can also be saved /// back to a file. /// /// Sound buffers alone are not very useful: they hold the audio data /// but cannot be played. To do so, you need to use the sf::Sound class, /// which provides functions to play/pause/stop the sound as well as /// changing the way it is outputted (volume, pitch, 3D position, ...). /// This separation allows more flexibility and better performances: /// indeed a sf::SoundBuffer is a heavy resource, and any operation on it /// is slow (often too slow for real-time applications). On the other /// side, a sf::Sound is a lightweight object, which can use the audio data /// of a sound buffer and change the way it is played without actually /// modifying that data. Note that it is also possible to bind /// several sf::Sound instances to the same sf::SoundBuffer. /// /// It is important to note that the sf::Sound instance doesn't /// copy the buffer that it uses, it only keeps a reference to it. /// Thus, a sf::SoundBuffer must not be destructed while it is /// used by a sf::Sound (i.e. never write a function that /// uses a local sf::SoundBuffer instance for loading a sound). /// /// Usage example: /// \code /// // Declare a new sound buffer /// sf::SoundBuffer buffer; /// /// // Load it from a file /// if (!buffer.LoadFromFile("sound.wav")) /// { /// // error... /// } /// /// // Create a sound source and bind it to the buffer /// sf::Sound sound1; /// sound1.SetBuffer(buffer); /// /// // Play the sound /// sound1.Play(); /// /// // Create another sound source bound to the same buffer /// sf::Sound sound2; /// sound2.SetBuffer(buffer); /// /// // Play it with a higher pitch -- the first sound remains unchanged /// sound2.SetPitch(2); /// sound2.Play(); /// \endcode /// /// \see sf::Sound, sf::SoundBufferRecorder /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/Audio/Music.hpp0000644000000000000000000001522511770572147023051 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_MUSIC_HPP #define SFML_MUSIC_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include namespace sf { namespace priv { class SoundFile; } //////////////////////////////////////////////////////////// /// \brief Streamed music played from an audio file /// //////////////////////////////////////////////////////////// class SFML_API Music : public SoundStream { public : //////////////////////////////////////////////////////////// /// \brief Default constructor /// //////////////////////////////////////////////////////////// Music(); //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// ~Music(); //////////////////////////////////////////////////////////// /// \brief Open a music from an audio file /// /// This function doesn't start playing the music (call Play() /// to do so). /// Here is a complete list of all the supported audio formats: /// ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, /// w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. /// /// \param filename Path of the music file to open /// /// \return True if loading succeeded, false if it failed /// /// \see OpenFromMemory /// //////////////////////////////////////////////////////////// bool OpenFromFile(const std::string& filename); //////////////////////////////////////////////////////////// /// \brief Open a music from an audio file in memory /// /// This function doesn't start playing the music (call Play() /// to do so). /// Here is a complete list of all the supported audio formats: /// ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam, /// w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64. /// /// \param data Pointer to the file data in memory /// \param sizeInBytes Size of the data to load, in bytes /// /// \return True if loading succeeded, false if it failed /// /// \see OpenFromFile /// //////////////////////////////////////////////////////////// bool OpenFromMemory(const void* data, std::size_t sizeInBytes); //////////////////////////////////////////////////////////// /// \brief Get the total duration of the music /// /// \return Music duration, in seconds /// //////////////////////////////////////////////////////////// float GetDuration() const; protected : //////////////////////////////////////////////////////////// /// \brief Request a new chunk of audio samples from the stream source /// /// This function fills the chunk from the next samples /// to read from the audio file. /// /// \param data Chunk of data to fill /// /// \return True to continue playback, false to stop /// //////////////////////////////////////////////////////////// virtual bool OnGetData(Chunk& data); //////////////////////////////////////////////////////////// /// \brief Change the current playing position in the stream source /// /// \param timeOffset New playing position, in seconds /// //////////////////////////////////////////////////////////// virtual void OnSeek(float timeOffset); private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// priv::SoundFile* myFile; ///< Sound file float myDuration; ///< Music duration, in seconds std::vector mySamples; ///< Temporary buffer of samples Mutex myMutex; ///< Mutex protecting the data }; } // namespace sf #endif // SFML_MUSIC_HPP //////////////////////////////////////////////////////////// /// \class sf::Music /// \ingroup audio /// /// Musics are sounds that are streamed rather than completely /// loaded in memory. This is especially useful for compressed /// musics that usually take hundreds of MB when they are /// uncompressed: by streaming it instead of loading it entirely, /// you avoid saturating the memory and have almost no loading delay. /// /// Apart from that, a sf::Music has almost the same features as /// the sf::SoundBuffer / sf::Sound pair: you can play/pause/stop /// it, request its parameters (channels, sample rate), change /// the way it is played (pitch, volume, 3D position, ...), etc. /// /// As a sound stream, a music is played in its own thread in order /// not to block the rest of the program. This means that you can /// leave the music alone after calling Play(), it will manage itself /// very well. /// /// Usage example: /// \code /// // Declare a new music /// sf::Music music; /// /// // Open it from an audio file /// if (!music.OpenFromFile("music.ogg")) /// { /// // error... /// } /// /// // Change some parameters /// music.SetPosition(0, 1, 10); // change its 3D position /// music.SetPitch(2); // increase the pitch /// music.SetVolume(50); // reduce the volume /// music.SetLoop(true); // make it loop /// /// // Play it /// music.Play(); /// \endcode /// /// \see sf::Sound, sf::SoundStream /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/Audio/SoundBufferRecorder.hpp0000644000000000000000000001150211770572147025673 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDBUFFERRECORDER_HPP #define SFML_SOUNDBUFFERRECORDER_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include namespace sf { //////////////////////////////////////////////////////////// /// \brief Specialized SoundRecorder which stores the captured /// audio data into a sound buffer /// //////////////////////////////////////////////////////////// class SFML_API SoundBufferRecorder : public SoundRecorder { public : //////////////////////////////////////////////////////////// /// \brief Get the sound buffer containing the captured audio data /// /// The sound buffer is valid only after the capture has ended. /// This function provides a read-only access to the internal /// sound buffer, but it can be copied if you need to /// make any modification to it. /// /// \return Read-only access to the sound buffer /// //////////////////////////////////////////////////////////// const SoundBuffer& GetBuffer() const; private : //////////////////////////////////////////////////////////// /// \brief Start capturing audio data /// /// \return True to start the capture, or false to abort it /// //////////////////////////////////////////////////////////// virtual bool OnStart(); //////////////////////////////////////////////////////////// /// \brief Process a new chunk of recorded samples /// /// \param samples Pointer to the new chunk of recorded samples /// \param samplesCount Number of samples pointed by \a samples /// /// \return True to continue the capture, or false to stop it /// //////////////////////////////////////////////////////////// virtual bool OnProcessSamples(const Int16* samples, std::size_t samplesCount); //////////////////////////////////////////////////////////// /// \brief Stop capturing audio data /// //////////////////////////////////////////////////////////// virtual void OnStop(); //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// std::vector mySamples; ///< Temporary sample buffer to hold the recorded data SoundBuffer myBuffer; ///< Sound buffer that will contain the recorded data }; } // namespace sf #endif // SFML_SOUNDBUFFERRECORDER_HPP //////////////////////////////////////////////////////////// /// \class sf::SoundBufferRecorder /// \ingroup audio /// /// sf::SoundBufferRecorder allows to access a recorded sound /// through a sf::SoundBuffer, so that it can be played, saved /// to a file, etc. /// /// It has the same simple interface as its base class (Start(), Stop()) /// and adds a function to retrieve the recorded sound buffer /// (GetBuffer()). /// /// As usual, don't forget to call the IsAvailable() function /// before using this class (see sf::SoundRecorder for more details /// about this). /// /// Usage example: /// \code /// if (SoundBufferRecorder::IsAvailable()) /// { /// // Record some audio data /// SoundBufferRecorder recorder; /// recorder.Start(); /// ... /// recorder.Stop(); /// /// // Get the buffer containing the captured audio data /// const sf::SoundBuffer& buffer = recorder.GetBuffer(); /// /// // Save it to a file (for example...) /// buffer.SaveToFile("my_record.ogg"); /// } /// \endcode /// /// \see sf::SoundRecorder /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/Audio/SoundStream.hpp0000644000000000000000000003412711770572147024237 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDSTREAM_HPP #define SFML_SOUNDSTREAM_HPP //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include namespace sf { //////////////////////////////////////////////////////////// /// \brief Abstract base class for streamed audio sources /// //////////////////////////////////////////////////////////// class SFML_API SoundStream : public SoundSource { public : //////////////////////////////////////////////////////////// /// \brief Structure defining a chunk of audio data to stream /// //////////////////////////////////////////////////////////// struct Chunk { const Int16* Samples; ///< Pointer to the audio samples std::size_t NbSamples; ///< Number of samples pointed by Samples }; //////////////////////////////////////////////////////////// /// \brief Destructor /// //////////////////////////////////////////////////////////// virtual ~SoundStream(); //////////////////////////////////////////////////////////// /// \brief Start or resume playing the audio stream /// /// This function starts the stream if it was stopped, resumes /// it if it was paused, and restarts it from beginning if it /// was it already playing. /// This function uses its own thread so that it doesn't block /// the rest of the program while the stream is played. /// /// \see Pause, Stop /// //////////////////////////////////////////////////////////// void Play(); //////////////////////////////////////////////////////////// /// \brief Pause the audio stream /// /// This function pauses the stream if it was playing, /// otherwise (stream already paused or stopped) it has no effect. /// /// \see Play, Stop /// //////////////////////////////////////////////////////////// void Pause(); //////////////////////////////////////////////////////////// /// \brief Stop playing the audio stream /// /// This function stops the stream if it was playing or paused, /// and does nothing if it was already stopped. /// It also resets the playing position (unlike Pause()). /// /// \see Play, Pause /// //////////////////////////////////////////////////////////// void Stop(); //////////////////////////////////////////////////////////// /// \brief Return the number of channels of the stream /// /// 1 channel means a mono sound, 2 means stereo, etc. /// /// \return Number of channels /// //////////////////////////////////////////////////////////// unsigned int GetChannelsCount() const; //////////////////////////////////////////////////////////// /// \brief Get the stream sample rate of the stream /// /// The sample rate is the number of audio samples played per /// second. The higher, the better the quality. /// /// \return Sample rate, in number of samples per second /// //////////////////////////////////////////////////////////// unsigned int GetSampleRate() const; //////////////////////////////////////////////////////////// /// \brief Get the current status of the stream (stopped, paused, playing) /// /// \return Current status /// //////////////////////////////////////////////////////////// Status GetStatus() const; //////////////////////////////////////////////////////////// /// \brief Change the current playing position of the stream /// /// The playing position can be changed when the stream is /// either paused or playing. /// /// \param timeOffset New playing position, in seconds /// /// \see GetPlayingOffset /// //////////////////////////////////////////////////////////// void SetPlayingOffset(float timeOffset); //////////////////////////////////////////////////////////// /// \brief Get the current playing position of the stream /// /// \return Current playing position, in seconds /// /// \see SetPlayingOffset /// //////////////////////////////////////////////////////////// float GetPlayingOffset() const; //////////////////////////////////////////////////////////// /// \brief Set whether or not the stream should loop after reaching the end /// /// If set, the stream will restart from beginning after /// reaching the end and so on, until it is stopped or /// SetLoop(false) is called. /// The default looping state for streams is false. /// /// \param loop True to play in loop, false to play once /// /// \see GetLoop /// //////////////////////////////////////////////////////////// void SetLoop(bool loop); //////////////////////////////////////////////////////////// /// \brief Tell whether or not the stream is in loop mode /// /// \return True if the stream is looping, false otherwise /// /// \see SetLoop /// //////////////////////////////////////////////////////////// bool GetLoop() const; protected : //////////////////////////////////////////////////////////// /// \brief Default constructor /// /// This constructor is only meant to be called by derived classes. /// //////////////////////////////////////////////////////////// SoundStream(); //////////////////////////////////////////////////////////// /// \brief Define the audio stream parameters /// /// This function must be called by derived classes as soon /// as they know the audio settings of the stream to play. /// Any attempt to manipulate the stream (Play(), ...) before /// calling this function will fail. /// It can be called multiple times if the settings of the /// audio stream change, but only when the stream is stopped. /// /// \param channelsCount Number of channels of the stream /// \param sampleRate Sample rate, in samples per second /// //////////////////////////////////////////////////////////// void Initialize(unsigned int channelsCount, unsigned int sampleRate); private : //////////////////////////////////////////////////////////// /// \brief Function called as the entry point of the thread /// /// This function starts the streaming loop, and returns /// only when the sound is stopped. /// //////////////////////////////////////////////////////////// void Stream(); //////////////////////////////////////////////////////////// /// \brief Request a new chunk of audio samples from the stream source /// /// This function must be overriden by derived classes to provide /// the audio samples to play. It is called continuously by the /// streaming loop, in a separate thread. /// The source can choose to stop the streaming loop at any time, by /// returning false to the caller. /// /// \param data Chunk of data to fill /// /// \return True to continue playback, false to stop /// //////////////////////////////////////////////////////////// virtual bool OnGetData(Chunk& data) = 0; //////////////////////////////////////////////////////////// /// \brief Change the current playing position in the stream source /// /// This function must be overriden by derived classes to /// allow random seeking into the stream source. /// /// \param timeOffset New playing position, in seconds /// //////////////////////////////////////////////////////////// virtual void OnSeek(float timeOffset) = 0; //////////////////////////////////////////////////////////// /// \brief Fill a new buffer with audio samples, and append /// it to the playing queue /// /// This function is called as soon as a buffer has been fully /// consumed; it fills it again and inserts it back into the /// playing queue. /// /// \param buffer Number of the buffer to fill (in [0, BuffersCount]) /// /// \return True if the stream source has requested to stop, false otherwise /// //////////////////////////////////////////////////////////// bool FillAndPushBuffer(unsigned int bufferNum); //////////////////////////////////////////////////////////// /// \brief Fill the audio buffers and put them all into the playing queue /// /// This function is called when playing starts and the /// playing queue is empty. /// /// \return True if the derived class has requested to stop, false otherwise /// //////////////////////////////////////////////////////////// bool FillQueue(); //////////////////////////////////////////////////////////// /// \brief Clear all the audio buffers and empty the playing queue /// /// This function is called when the stream is stopped. /// //////////////////////////////////////////////////////////// void ClearQueue(); enum { BuffersCount = 3 ///< Number of audio buffers used by the streaming loop }; //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// Thread myThread; ///< Thread running the background tasks bool myIsStreaming; ///< Streaming state (true = playing, false = stopped) unsigned int myBuffers[BuffersCount]; ///< Sound buffers used to store temporary audio data unsigned int myChannelsCount; ///< Number of channels (1 = mono, 2 = stereo, ...) unsigned int mySampleRate; ///< Frequency (samples / second) unsigned long myFormat; ///< Format of the internal sound buffers bool myLoop; ///< Loop flag (true to loop, false to play once) unsigned int mySamplesProcessed; ///< Number of buffers processed since beginning of the stream bool myEndBuffers[BuffersCount]; ///< Each buffer is marked as "end buffer" or not, for proper duration calculation }; } // namespace sf #endif // SFML_SOUNDSTREAM_HPP //////////////////////////////////////////////////////////// /// \class sf::SoundStream /// \ingroup audio /// /// Unlike audio buffers (see sf::SoundBuffer), audio streams /// are never completely loaded in memory. Instead, the audio /// data is acquired continuously while the stream is playing. /// This behaviour allows to play a sound with no loading delay, /// and keeps the memory consumption very low. /// /// Sound sources that need to be streamed are usually big files /// (compressed audio musics that would eat hundreds of MB in memory) /// or files that would take a lot of time to be received /// (sounds played over the network). /// /// sf::SoundStream is a base class that doesn't care about the /// stream source, which is left to the derived class. SFML provides /// a built-in specialization for big files (see sf::Music). /// No network stream source is provided, but you can write your own /// by combining this class with the network module. /// /// A derived class has to override two virtual functions: /// \li OnGetData fills a new chunk of audio data to be played /// \li OnSeek changes the current playing position in the source /// /// It is important to note that each SoundStream is played in its /// own separate thread, so that the streaming loop doesn't block the /// rest of the program. In particular, the OnGetData and OnSeek /// virtual functions may sometimes be called from this separate thread. /// It is important to keep this in mind, because you may have to take /// care of synchronization issues if you share data between threads. /// /// Usage example: /// \code /// class CustomStream : public sf::SoundStream /// { /// public : /// /// bool Open(const std::string& location) /// { /// // Open the source and get audio settings /// ... /// unsigned int channelsCount = ...; /// unsigned int sampleRate = ...; /// /// // Initialize the stream -- important! /// Initialize(channelsCount, sampleRate); /// } /// /// private : /// /// virtual bool OnGetData(Chunk& data) /// { /// // Fill the chunk with audio data from the stream source /// data.Samples = ...; /// data.NbSamples = ...; /// /// // Return true to continue playing /// return true; /// } /// /// virtual void OnSeek(float timeOffset) /// { /// // Change the current position in the stream source /// ... /// } /// } /// /// // Usage /// CustomStream stream; /// stream.Open("path/to/stream"); /// stream.Play(); /// \endcode /// /// \see sf::Music /// //////////////////////////////////////////////////////////// sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/0000755000000000000000000000000011770572147017623 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/0000755000000000000000000000000011770572147020045 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/0000755000000000000000000000000011770572147020634 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/0000755000000000000000000000000011770572147021375 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/Internal.h0000644000000000000000000000751211770572147023327 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_INTERNAL_H #define SFML_INTERNAL_H //////////////////////////////////////////////////////////// // Define macros to check the validity of CSFML objects // in debug run //////////////////////////////////////////////////////////// #include #ifndef NDEBUG #define CSFML_CHECK(Object) \ if (Object == NULL) \ { \ fprintf(stderr, "SFML warning : trying to use a null " #Object " object\n"); \ return; \ } #define CSFML_CALL(Object, Function) \ if (Object) \ { \ (Object->This.Function); \ } \ else \ { \ fprintf(stderr, "SFML warning : trying to use a null " #Object " object\n"); \ } \ #define CSFML_CALL_PTR(Object, Function) \ if (Object) \ { \ (Object->This->Function); \ } \ else \ { \ fprintf(stderr, "SFML warning : trying to use a null " #Object " object\n"); \ } \ #define CSFML_CHECK_RETURN(Object, Default) \ if (Object == NULL) \ { \ fprintf(stderr, "SFML warning : trying to use a null " #Object " object\n"); \ return Default; \ } #define CSFML_CALL_RETURN(Object, Function, Default) \ if (Object) \ { \ return (Object->This.Function); \ } \ else \ { \ fprintf(stderr, "SFML warning : trying to use a null " #Object " object\n"); \ return Default; \ } \ #define CSFML_CALL_PTR_RETURN(Object, Function, Default) \ if (Object) \ { \ return (Object->This->Function); \ } \ else \ { \ fprintf(stderr, "SFML warning : trying to use a null " #Object " object\n"); \ return Default; \ } \ #else #define CSFML_CHECK(Object) #define CSFML_CALL(Object, Function) (Object->This.Function); #define CSFML_CALL_PTR(Object, Function) (Object->This->Function); #define CSFML_CHECK_RETURN(Object, Default) (void)Default; #define CSFML_CALL_RETURN(Object, Function, Default) (void)Default; return (Object->This.Function); #define CSFML_CALL_PTR_RETURN(Object, Function, Default) (void)Default; return (Object->This->Function); #endif #endif // SFML_INTERNAL_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/ConvertEvent.h0000644000000000000000000000736611770572147024204 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_CONVERTEVENT_H #define SFML_CONVERTEVENT_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include //////////////////////////////////////////////////////////// // Define a function to convert a sf::Event ot a sfEvent //////////////////////////////////////////////////////////// inline void ConvertEvent(const sf::Event& SFMLEvent, sfEvent* event) { // Convert its type event->Type = static_cast(SFMLEvent.Type); // Fill its fields switch (event->Type) { case sfEvtResized : event->Size.Width = SFMLEvent.Size.Width; event->Size.Height = SFMLEvent.Size.Height; break; case sfEvtTextEntered : event->Text.Unicode = SFMLEvent.Text.Unicode; break; case sfEvtKeyReleased : case sfEvtKeyPressed : event->Key.Code = static_cast(SFMLEvent.Key.Code); event->Key.Alt = SFMLEvent.Key.Alt ? sfTrue : sfFalse; event->Key.Control = SFMLEvent.Key.Control ? sfTrue : sfFalse; event->Key.Shift = SFMLEvent.Key.Shift ? sfTrue : sfFalse; break; case sfEvtMouseWheelMoved : event->MouseWheel.Delta = SFMLEvent.MouseWheel.Delta; event->MouseWheel.X = SFMLEvent.MouseWheel.X; event->MouseWheel.Y = SFMLEvent.MouseWheel.Y; break; case sfEvtMouseButtonPressed : case sfEvtMouseButtonReleased : event->MouseButton.Button = static_cast(SFMLEvent.MouseButton.Button); event->MouseButton.X = SFMLEvent.MouseButton.X; event->MouseButton.Y = SFMLEvent.MouseButton.Y; break; case sfEvtMouseMoved : event->MouseMove.X = SFMLEvent.MouseMove.X; event->MouseMove.Y = SFMLEvent.MouseMove.Y; break; case sfEvtJoyButtonPressed : case sfEvtJoyButtonReleased : event->JoyButton.JoystickId = SFMLEvent.JoyButton.JoystickId; event->JoyButton.Button = SFMLEvent.JoyButton.Button; break; case sfEvtJoyMoved : event->JoyMove.JoystickId = SFMLEvent.JoyMove.JoystickId; event->JoyMove.Axis = static_cast(SFMLEvent.JoyMove.Axis); event->JoyMove.Position = SFMLEvent.JoyMove.Position; break; default : break; } } #endif // SFML_CONVERTEVENT_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/Audio/0000755000000000000000000000000011770572147022436 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/Audio/Sound.cpp0000644000000000000000000002114311770572147024233 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include //////////////////////////////////////////////////////////// /// Construct a new sound //////////////////////////////////////////////////////////// sfSound* sfSound_Create(void) { return new sfSound; } //////////////////////////////////////////////////////////// /// Copy an existing sound //////////////////////////////////////////////////////////// sfSound* sfSound_Copy(sfSound* sound) { CSFML_CHECK_RETURN(sound, NULL); return new sfSound(*sound); } //////////////////////////////////////////////////////////// /// Destroy an existing sound //////////////////////////////////////////////////////////// void sfSound_Destroy(sfSound* sound) { delete sound; } //////////////////////////////////////////////////////////// /// Start playing a sound //////////////////////////////////////////////////////////// void sfSound_Play(sfSound* sound) { CSFML_CALL(sound, Play()) } //////////////////////////////////////////////////////////// /// Pause a sound //////////////////////////////////////////////////////////// void sfSound_Pause(sfSound* sound) { CSFML_CALL(sound, Pause()) } //////////////////////////////////////////////////////////// /// Stop playing a sound //////////////////////////////////////////////////////////// void sfSound_Stop(sfSound* sound) { CSFML_CALL(sound, Stop()) } //////////////////////////////////////////////////////////// /// Bind a sound buffer to a sound //////////////////////////////////////////////////////////// void sfSound_SetBuffer(sfSound* sound, const sfSoundBuffer* buffer) { if (buffer) { CSFML_CALL(sound, SetBuffer(buffer->This)) sound->Buffer = buffer; } } //////////////////////////////////////////////////////////// /// Get the sound buffer bound to a sound //////////////////////////////////////////////////////////// const sfSoundBuffer* sfSound_GetBuffer(const sfSound* sound) { CSFML_CHECK_RETURN(sound, NULL) return sound->Buffer; } //////////////////////////////////////////////////////////// /// Set a sound loop state //////////////////////////////////////////////////////////// void sfSound_SetLoop(sfSound* sound, sfBool loop) { CSFML_CALL(sound, SetLoop(loop == sfTrue)) } //////////////////////////////////////////////////////////// /// Tell whether or not a sound is looping //////////////////////////////////////////////////////////// sfBool sfSound_GetLoop(const sfSound* sound) { CSFML_CALL_RETURN(sound, GetLoop(), sfFalse) } //////////////////////////////////////////////////////////// /// Get the status of a sound (stopped, paused, playing) //////////////////////////////////////////////////////////// sfSoundStatus sfSound_GetStatus(const sfSound* sound) { CSFML_CHECK_RETURN(sound, sfStopped); return static_cast(sound->This.GetStatus()); } //////////////////////////////////////////////////////////// /// Set the pitch of a sound //////////////////////////////////////////////////////////// void sfSound_SetPitch(sfSound* sound, float pitch) { CSFML_CALL(sound, SetPitch(pitch)) } //////////////////////////////////////////////////////////// /// Set the volume of a sound //////////////////////////////////////////////////////////// void sfSound_SetVolume(sfSound* sound, float volume) { CSFML_CALL(sound, SetVolume(volume)) } //////////////////////////////////////////////////////////// /// Set the position of a sound //////////////////////////////////////////////////////////// void sfSound_SetPosition(sfSound* sound, float x, float y, float z) { CSFML_CALL(sound, SetPosition(sf::Vector3f(x, y, z))) } //////////////////////////////////////////////////////////// /// Make the sound's position relative to the listener's /// position, or absolute. /// The default value is false (absolute) //////////////////////////////////////////////////////////// void sfSound_SetRelativeToListener(sfSound* sound, sfBool relative) { CSFML_CALL(sound, SetRelativeToListener(relative == sfTrue)); } //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the sound at its maximum volume. /// The default minimum distance is 1.0 //////////////////////////////////////////////////////////// void sfSound_SetMinDistance(sfSound* sound, float distance) { CSFML_CALL(sound, SetMinDistance(distance)); } //////////////////////////////////////////////////////////// /// Set the attenuation factor - the higher the attenuation, the /// more the sound will be attenuated with distance from listener. /// The default attenuation factor is 1.0 //////////////////////////////////////////////////////////// void sfSound_SetAttenuation(sfSound* sound, float attenuation) { CSFML_CALL(sound, SetAttenuation(attenuation)); } //////////////////////////////////////////////////////////// /// Set the current playing position of a sound //////////////////////////////////////////////////////////// void sfSound_SetPlayingOffset(sfSound* sound, float timeOffset) { CSFML_CALL(sound, SetPlayingOffset(timeOffset)); } //////////////////////////////////////////////////////////// /// Get the pitch of a sound //////////////////////////////////////////////////////////// float sfSound_GetPitch(const sfSound* sound) { CSFML_CALL_RETURN(sound, GetPitch(), 0.f) } //////////////////////////////////////////////////////////// /// Get the volume of a sound //////////////////////////////////////////////////////////// float sfSound_GetVolume(const sfSound* sound) { CSFML_CALL_RETURN(sound, GetVolume(), 0.f) } //////////////////////////////////////////////////////////// /// Get the position of a sound //////////////////////////////////////////////////////////// void sfSound_GetPosition(const sfSound* sound, float* x, float* y, float* z) { CSFML_CHECK(sound); sf::Vector3f position = sound->This.GetPosition(); if (x) *x = position.x; if (y) *y = position.y; if (z) *z = position.z; } //////////////////////////////////////////////////////////// /// Tell if the sound's position is relative to the listener's /// position, or if it's absolute //////////////////////////////////////////////////////////// CSFML_API sfBool sfSound_IsRelativeToListener(const sfSound* sound) { CSFML_CALL_RETURN(sound, IsRelativeToListener(), sfFalse); } //////////////////////////////////////////////////////////// /// Get the minimum distance of a sound //////////////////////////////////////////////////////////// float sfSound_GetMinDistance(const sfSound* sound) { CSFML_CALL_RETURN(sound, GetMinDistance(), 0.f); } //////////////////////////////////////////////////////////// /// Get the attenuation factor of a sound //////////////////////////////////////////////////////////// float sfSound_GetAttenuation(const sfSound* sound) { CSFML_CALL_RETURN(sound, GetAttenuation(), 0.f); } //////////////////////////////////////////////////////////// /// Get the current playing position of a sound //////////////////////////////////////////////////////////// float sfSound_GetPlayingOffset(const sfSound* sound) { CSFML_CALL_RETURN(sound, GetPlayingOffset(), 0.f) } sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/Audio/Music.cpp0000644000000000000000000002226011770572147024224 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include //////////////////////////////////////////////////////////// /// Create a new music and load it from a file //////////////////////////////////////////////////////////// sfMusic* sfMusic_CreateFromFile(const char* filename) { sfMusic* music = new sfMusic; if (!music->This.OpenFromFile(filename)) { delete music; music = NULL; } return music; } //////////////////////////////////////////////////////////// /// Create a new music and load it from a file in memory //////////////////////////////////////////////////////////// sfMusic* sfMusic_CreateFromMemory(const void* data, size_t sizeInBytes) { sfMusic* music = new sfMusic; if (!music->This.OpenFromMemory(data, sizeInBytes)) { delete music; music = NULL; } return music; } //////////////////////////////////////////////////////////// /// Destroy an existing music //////////////////////////////////////////////////////////// void sfMusic_Destroy(sfMusic* music) { delete music; } //////////////////////////////////////////////////////////// /// Set a music loop state //////////////////////////////////////////////////////////// void sfMusic_SetLoop(sfMusic* music, sfBool loop) { CSFML_CALL(music, SetLoop(loop != 0)); } //////////////////////////////////////////////////////////// /// Tell whether or not a music is looping //////////////////////////////////////////////////////////// sfBool sfMusic_GetLoop(const sfMusic* music) { CSFML_CALL_RETURN(music, GetLoop(), sfFalse); } //////////////////////////////////////////////////////////// /// Get a music duration //////////////////////////////////////////////////////////// float sfMusic_GetDuration(const sfMusic* music) { CSFML_CALL_RETURN(music, GetDuration(), 0.f); } //////////////////////////////////////////////////////////// /// Start playing a music //////////////////////////////////////////////////////////// void sfMusic_Play(sfMusic* music) { CSFML_CALL(music, Play()); } //////////////////////////////////////////////////////////// /// Pause a music //////////////////////////////////////////////////////////// void sfMusic_Pause(sfMusic* music) { CSFML_CALL(music, Pause()); } //////////////////////////////////////////////////////////// /// Stop playing a music //////////////////////////////////////////////////////////// void sfMusic_Stop(sfMusic* music) { CSFML_CALL(music, Stop()); } //////////////////////////////////////////////////////////// /// Return the number of channels of a music (1 = mono, 2 = stereo) //////////////////////////////////////////////////////////// unsigned int sfMusic_GetChannelsCount(const sfMusic* music) { CSFML_CALL_RETURN(music, GetChannelsCount(), 0); } //////////////////////////////////////////////////////////// /// Get the stream sample rate of a music //////////////////////////////////////////////////////////// unsigned int sfMusic_GetSampleRate(const sfMusic* music) { CSFML_CALL_RETURN(music, GetSampleRate(), 0); } //////////////////////////////////////////////////////////// /// Get the status of a music (stopped, paused, playing) //////////////////////////////////////////////////////////// sfSoundStatus sfMusic_GetStatus(const sfMusic* music) { CSFML_CHECK_RETURN(music, sfStopped); return static_cast(music->This.GetStatus()); } //////////////////////////////////////////////////////////// /// Get the current playing position of a music //////////////////////////////////////////////////////////// float sfMusic_GetPlayingOffset(const sfMusic* music) { CSFML_CALL_RETURN(music, GetPlayingOffset(), 0.f); } //////////////////////////////////////////////////////////// /// Set the pitch of a music //////////////////////////////////////////////////////////// void sfMusic_SetPitch(sfMusic* music, float pitch) { CSFML_CALL(music, SetPitch(pitch)); } //////////////////////////////////////////////////////////// /// Set the volume of a music //////////////////////////////////////////////////////////// void sfMusic_SetVolume(sfMusic* music, float volume) { CSFML_CALL(music, SetVolume(volume)); } //////////////////////////////////////////////////////////// /// Set the position of a music //////////////////////////////////////////////////////////// void sfMusic_SetPosition(sfMusic* music, float x, float y, float z) { CSFML_CALL(music, SetPosition(sf::Vector3f(x, y, z))); } //////////////////////////////////////////////////////////// /// Make the music's position relative to the listener's /// position, or absolute. /// The default value is false (absolute) //////////////////////////////////////////////////////////// void sfMusic_SetRelativeToListener(sfMusic* music, sfBool relative) { CSFML_CALL(music, SetRelativeToListener(relative == sfTrue)); } //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the music at its maximum volume. /// The default minimum distance is 1.0 //////////////////////////////////////////////////////////// void sfMusic_SetMinDistance(sfMusic* music, float distance) { CSFML_CALL(music, SetMinDistance(distance)); } //////////////////////////////////////////////////////////// /// Set the attenuation factor - the higher the attenuation, the /// more the sound will be attenuated with distance from listener. /// The default attenuation factor 1.0 //////////////////////////////////////////////////////////// void sfMusic_SetAttenuation(sfMusic* music, float attenuation) { CSFML_CALL(music, SetAttenuation(attenuation)); } //////////////////////////////////////////////////////////// /// Set the current playing position of a stream //////////////////////////////////////////////////////////// void sfMusic_SetPlayingOffset(sfMusic* music, float timeOffset) { CSFML_CALL(music, SetPlayingOffset(timeOffset)); } //////////////////////////////////////////////////////////// /// Get the pitch of a music //////////////////////////////////////////////////////////// float sfMusic_GetPitch(const sfMusic* music) { CSFML_CALL_RETURN(music, GetPitch(), 0.f); } //////////////////////////////////////////////////////////// /// Get the volume of a music //////////////////////////////////////////////////////////// float sfMusic_GetVolume(const sfMusic* music) { CSFML_CALL_RETURN(music, GetVolume(), 0.f); } //////////////////////////////////////////////////////////// /// Get the position of a music //////////////////////////////////////////////////////////// void sfMusic_GetPosition(const sfMusic* music, float* x, float* y, float* z) { CSFML_CHECK(music); if (x && y && z) { sf::Vector3f position = music->This.GetPosition(); *x = position.x; *y = position.y; *z = position.z; } } //////////////////////////////////////////////////////////// /// Tell if the music's position is relative to the listener's /// position, or if it's absolute //////////////////////////////////////////////////////////// CSFML_API sfBool sfMusic_IsRelativeToListener(const sfMusic* music) { CSFML_CALL_RETURN(music, IsRelativeToListener(), sfFalse); } //////////////////////////////////////////////////////////// /// Get the minimum distance of a music //////////////////////////////////////////////////////////// float sfMusic_GetMinDistance(const sfMusic* music) { CSFML_CALL_RETURN(music, GetMinDistance(), 0.f); } //////////////////////////////////////////////////////////// /// Get the attenuation factor of a music //////////////////////////////////////////////////////////// float sfMusic_GetAttenuation(const sfMusic* music) { CSFML_CALL_RETURN(music, GetAttenuation(), 0.f); } sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/Audio/SoundRecorderStruct.h0000644000000000000000000000661711770572147026604 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDRECORDERSTRUCT_H #define SFML_SOUNDRECORDERSTRUCT_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include //////////////////////////////////////////////////////////// // Helper class implementing the callback forwarding from // C++ to C in sfSoundRecorder //////////////////////////////////////////////////////////// class sfSoundRecorderImpl : public sf::SoundRecorder { public : sfSoundRecorderImpl(sfSoundRecorderStartCallback OnStart, sfSoundRecorderProcessCallback OnProcess, sfSoundRecorderStopCallback OnStop, void* UserData) : myStartCallback (OnStart), myProcessCallback(OnProcess), myStopCallback (OnStop), myUserData (UserData) { } private : virtual bool OnStart() { if (myStartCallback) return myStartCallback(myUserData) == sfTrue; else return true; } virtual bool OnProcessSamples(const sf::Int16* Samples, std::size_t SamplesCount) { if (myProcessCallback) return myProcessCallback(Samples, SamplesCount, myUserData) == sfTrue; else return true; } virtual void OnStop() { if (myStopCallback) myStopCallback(myUserData); } sfSoundRecorderStartCallback myStartCallback; sfSoundRecorderProcessCallback myProcessCallback; sfSoundRecorderStopCallback myStopCallback; void* myUserData; }; //////////////////////////////////////////////////////////// // Internal structure of sfPacket //////////////////////////////////////////////////////////// struct sfSoundRecorder { sfSoundRecorder(sfSoundRecorderStartCallback OnStart, sfSoundRecorderProcessCallback OnProcess, sfSoundRecorderStopCallback OnStop, void* UserData) : This(OnStart, OnProcess, OnStop, UserData) { } sfSoundRecorderImpl This; }; #endif // SFML_SOUNDRECORDERSTRUCT_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/Audio/MusicStruct.h0000644000000000000000000000307611770572147025102 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_MUSICSTRUCT_H #define SFML_MUSICSTRUCT_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include //////////////////////////////////////////////////////////// // Internal structure of sfMusic //////////////////////////////////////////////////////////// struct sfMusic { sf::Music This; }; #endif // SFML_MUSICSTRUCT_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/Audio/SoundStreamStruct.h0000644000000000000000000000647311770572147026272 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDSTREAMSTRUCT_H #define SFML_SOUNDSTREAMSTRUCT_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include //////////////////////////////////////////////////////////// // Helper class implementing the callback forwarding from // C++ to C in sfSoundStream //////////////////////////////////////////////////////////// class sfSoundStreamImpl : public sf::SoundStream { public : sfSoundStreamImpl(sfSoundStreamGetDataCallback OnGetData, sfSoundStreamSeekCallback OnSeek, unsigned int ChannelsCount, unsigned int SampleRate, void* UserData) : myGetDataCallback(OnGetData), mySeekCallback (OnSeek), myUserData (UserData) { Initialize(ChannelsCount, SampleRate); } private : virtual bool OnGetData(Chunk& Data) { sfSoundStreamChunk Chunk = {NULL, 0}; bool Continue = (myGetDataCallback(&Chunk, myUserData) == sfTrue); Data.Samples = Chunk.Samples; Data.NbSamples = Chunk.NbSamples; return Continue; } virtual void OnSeek(float TimeOffset) { if (mySeekCallback) mySeekCallback(TimeOffset, myUserData); } sfSoundStreamGetDataCallback myGetDataCallback; sfSoundStreamSeekCallback mySeekCallback; void* myUserData; }; //////////////////////////////////////////////////////////// // Internal structure of sfSoundStream //////////////////////////////////////////////////////////// struct sfSoundStream { sfSoundStream(sfSoundStreamGetDataCallback OnGetData, sfSoundStreamSeekCallback OnSeek, unsigned int ChannelsCount, unsigned int SampleRate, void* UserData) : This(OnGetData, OnSeek, ChannelsCount, SampleRate, UserData) { } sfSoundStreamImpl This; }; #endif // SFML_SOUNDSTREAMSTRUCT_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/Audio/SoundBufferStruct.h0000644000000000000000000000315011770572147026235 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDBUFFERSTRUCT_H #define SFML_SOUNDBUFFERSTRUCT_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include //////////////////////////////////////////////////////////// // Internal structure of sfSoundBuffer //////////////////////////////////////////////////////////// struct sfSoundBuffer { sf::SoundBuffer This; }; #endif // SFML_SOUNDBUFFERSTRUCT_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/Audio/SoundBufferRecorderStruct.h0000644000000000000000000000336511770572147027733 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDBUFFERRECORDERSTRUCT_H #define SFML_SOUNDBUFFERRECORDERSTRUCT_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include //////////////////////////////////////////////////////////// // Internal structure of sfSoundBufferRecorder //////////////////////////////////////////////////////////// struct sfSoundBufferRecorder { sf::SoundBufferRecorder This; mutable sfSoundBuffer SoundBuffer; }; #endif // SFML_SOUNDBUFFERRECORDERSTRUCT_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/Audio/SoundStruct.h0000644000000000000000000000322611770572147025107 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDSTRUCT_H #define SFML_SOUNDSTRUCT_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include //////////////////////////////////////////////////////////// // Internal structure of sfSound //////////////////////////////////////////////////////////// struct sfSound { sf::Sound This; const sfSoundBuffer* Buffer; }; #endif // SFML_SOUNDSTRUCT_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/src/SFML/Audio/SoundBuffer.cpp0000644000000000000000000001247611770572147025376 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include //////////////////////////////////////////////////////////// /// Create a new sound buffer and load it from a file //////////////////////////////////////////////////////////// sfSoundBuffer* sfSoundBuffer_CreateFromFile(const char* filename) { sfSoundBuffer* buffer = new sfSoundBuffer; if (!buffer->This.LoadFromFile(filename)) { delete buffer; buffer = NULL; } return buffer; } //////////////////////////////////////////////////////////// /// Create a new sound buffer and load it from a file in memory //////////////////////////////////////////////////////////// sfSoundBuffer* sfSoundBuffer_CreateFromMemory(const void* data, size_t sizeInBytes) { sfSoundBuffer* buffer = new sfSoundBuffer; if (!buffer->This.LoadFromMemory(data, sizeInBytes)) { delete buffer; buffer = NULL; } return buffer; } //////////////////////////////////////////////////////////// /// Create a new sound buffer and load it from an array of /// samples in memory - assumed format for samples is /// 16 bits signed integer //////////////////////////////////////////////////////////// sfSoundBuffer* sfSoundBuffer_CreateFromSamples(const sfInt16* samples, size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate) { sfSoundBuffer* buffer = new sfSoundBuffer; if (!buffer->This.LoadFromSamples(samples, samplesCount, channelsCount, sampleRate)) { delete buffer; buffer = NULL; } return buffer; } //////////////////////////////////////////////////////////// /// Copy an existing sound buffer //////////////////////////////////////////////////////////// sfSoundBuffer* sfSoundBuffer_Copy(sfSoundBuffer* soundBuffer) { CSFML_CHECK_RETURN(soundBuffer, NULL); return new sfSoundBuffer(*soundBuffer); } //////////////////////////////////////////////////////////// /// Destroy an existing sound buffer //////////////////////////////////////////////////////////// void sfSoundBuffer_Destroy(sfSoundBuffer* soundBuffer) { delete soundBuffer; } //////////////////////////////////////////////////////////// /// Save a sound buffer to a file //////////////////////////////////////////////////////////// sfBool sfSoundBuffer_SaveToFile(const sfSoundBuffer* soundBuffer, const char* filename) { CSFML_CALL_RETURN(soundBuffer, SaveToFile(filename), sfFalse) } //////////////////////////////////////////////////////////// /// Return the samples contained in a sound buffer //////////////////////////////////////////////////////////// const sfInt16* sfSoundBuffer_GetSamples(const sfSoundBuffer* soundBuffer) { CSFML_CALL_RETURN(soundBuffer, GetSamples(), NULL) } //////////////////////////////////////////////////////////// /// Return the number of samples contained in a sound buffer //////////////////////////////////////////////////////////// size_t sfSoundBuffer_GetSamplesCount(const sfSoundBuffer* soundBuffer) { CSFML_CALL_RETURN(soundBuffer, GetSamplesCount(), 0) } //////////////////////////////////////////////////////////// /// Get the sample rate of a sound buffer //////////////////////////////////////////////////////////// unsigned int sfSoundBuffer_GetSampleRate(const sfSoundBuffer* soundBuffer) { CSFML_CALL_RETURN(soundBuffer, GetSampleRate(), 0) } //////////////////////////////////////////////////////////// /// Return the number of channels of a sound buffer (1 = mono, 2 = stereo, ...) //////////////////////////////////////////////////////////// unsigned int sfSoundBuffer_GetChannelsCount(const sfSoundBuffer* soundBuffer) { CSFML_CALL_RETURN(soundBuffer, GetChannelsCount(), 0) } //////////////////////////////////////////////////////////// /// Get the duration of a sound buffer //////////////////////////////////////////////////////////// float sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer) { CSFML_CALL_RETURN(soundBuffer, GetDuration(), 0.f) } sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/0000755000000000000000000000000011770572147021470 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/0000755000000000000000000000000011770572147022231 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/System.h0000644000000000000000000000300211770572147023661 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SYSTEM_H #define SFML_SYSTEM_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include #include #include #endif // SFML_SYSTEM_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Config.h0000644000000000000000000001012211770572147023603 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_CONFIG_H #define SFML_CONFIG_H //////////////////////////////////////////////////////////// // Define the CSFML version //////////////////////////////////////////////////////////// #define CSFML_VERSION_MAJOR 2 #define CSFML_VERSION_MINOR 0 //////////////////////////////////////////////////////////// // Identify the operating system //////////////////////////////////////////////////////////// #if defined(_WIN32) || defined(__WIN32__) // Windows #define CSFML_SYSTEM_WINDOWS #elif defined(linux) || defined(__linux) // Linux #define CSFML_SYSTEM_LINUX #elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh) // MacOS #define CSFML_SYSTEM_MACOS #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) // FreeBSD #define CSFML_SYSTEM_FREEBSD #else // Unsupported system #error This operating system is not supported by SFML library #endif //////////////////////////////////////////////////////////// // Define portable import / export macros //////////////////////////////////////////////////////////// #if defined(CSFML_SYSTEM_WINDOWS) #ifdef CSFML_EXPORTS // From DLL side, we must export #define CSFML_API extern "C" __declspec(dllexport) #else // From client application side, we must import #define CSFML_API extern __declspec(dllimport) #endif #else #ifdef CSFML_EXPORTS #define CSFML_API extern "C" #else #define CSFML_API extern #endif #endif //////////////////////////////////////////////////////////// // Define a portable boolean type //////////////////////////////////////////////////////////// typedef int sfBool; #define sfFalse 0 #define sfTrue 1 //////////////////////////////////////////////////////////// // Define portable types //////////////////////////////////////////////////////////// #include #include // 8 bits integer types #if UCHAR_MAX == 0xFF typedef signed char sfInt8; typedef unsigned char sfUint8; #else #error No 8 bits integer type for this platform #endif // 16 bits integer types #if USHRT_MAX == 0xFFFF typedef signed short sfInt16; typedef unsigned short sfUint16; #elif UINT_MAX == 0xFFFF typedef signed int sfInt16; typedef unsigned int sfUint16; #elif ULONG_MAX == 0xFFFF typedef signed long sfInt16; typedef unsigned long sfUint16; #else #error No 16 bits integer type for this platform #endif // 32 bits integer types #if USHRT_MAX == 0xFFFFFFFF typedef signed short sfInt32; typedef unsigned short sfUint32; #elif UINT_MAX == 0xFFFFFFFF typedef signed int sfInt32; typedef unsigned int sfUint32; #elif ULONG_MAX == 0xFFFFFFFF typedef signed long sfInt32; typedef unsigned long sfUint32; #else #error No 32 bits integer type for this platform #endif #endif // SFML_CONFIG_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/OpenGL.h0000644000000000000000000000364611770572147023537 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_OPENGL_H #define SFML_OPENGL_H //////////////////////////////////////////////////////////// /// Headers //////////////////////////////////////////////////////////// #include //////////////////////////////////////////////////////////// /// This file just includes the OpenGL (GL and GLU) headers, /// which have actually different paths on each system //////////////////////////////////////////////////////////// #if defined(CSFML_SYSTEM_WINDOWS) #include #include #include #elif defined(CSFML_SYSTEM_LINUX) || defined(CSFML_SYSTEM_FREEBSD) #include #include #elif defined(CSFML_SYSTEM_MACOS) #include #include #endif #endif // SFML_OPENGL_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Window.h0000644000000000000000000000302211770572147023646 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SFML_WINDOW_H #define SFML_SFML_WINDOW_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include #include #include #endif // SFML_SFML_WINDOW_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Network.h0000644000000000000000000000310111770572147024026 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_NETWORK_H #define SFML_NETWORK_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #endif // SFML_NETWORK_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Audio.h0000644000000000000000000000306211770572147023444 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_AUDIO_H #define SFML_AUDIO_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #endif // SFML_AUDIO_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Graphics.h0000644000000000000000000000334311770572147024145 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_GRAPHICS_H #define SFML_GRAPHICS_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #include #include #include #include #include #endif // SFML_GRAPHICS_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Audio/0000755000000000000000000000000011770572147023272 5ustar0000000000000000sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Audio/SoundRecorder.h0000644000000000000000000001104611770572147026223 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDRECORDER_H #define SFML_SOUNDRECORDER_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include typedef sfBool (*sfSoundRecorderStartCallback)(void*); ///< Type of the callback used when starting a capture typedef sfBool (*sfSoundRecorderProcessCallback)(const sfInt16*, size_t, void*); ///< Type of the callback used to process audio data typedef void (*sfSoundRecorderStopCallback)(void*); ///< Type of the callback used when stopping a capture //////////////////////////////////////////////////////////// /// Construct a new sound recorder with callback functions /// for processing captured samples /// /// \param onStart : Callback function which will be called when a new capture starts (can be NULL) /// \param onProcess : Callback function which will be called each time there's audio data to process /// \param onStop : Callback function which will be called when the current capture stops (can be NULL) /// \param userData : Data to pass to the callback function (can be NULL) /// /// \return A new sfSoundRecorder object (NULL if failed) /// //////////////////////////////////////////////////////////// CSFML_API sfSoundRecorder* sfSoundRecorder_Create(sfSoundRecorderStartCallback onStart, sfSoundRecorderProcessCallback onProcess, sfSoundRecorderStopCallback onStop, void* userData); //////////////////////////////////////////////////////////// /// Destroy an existing sound recorder /// /// \param soundRecorder : Sound recorder to delete /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundRecorder_Destroy(sfSoundRecorder* soundRecorder); //////////////////////////////////////////////////////////// /// Start the capture. /// Warning : only one capture can happen at the same time /// /// \param soundRecorder : Sound recorder to start /// \param sampleRate : Sound frequency (the more samples, the higher the quality) /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundRecorder_Start(sfSoundRecorder* soundRecorder, unsigned int sampleRate); //////////////////////////////////////////////////////////// /// Stop the capture /// /// \param soundRecorder : Sound recorder to stop /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundRecorder_Stop(sfSoundRecorder* soundRecorder); //////////////////////////////////////////////////////////// /// Get the sample rate of a sound recorder /// /// \param soundRecorder : Sound recorder to get sample rate from /// /// \return Frequency, in samples per second /// //////////////////////////////////////////////////////////// CSFML_API unsigned int sfSoundRecorder_GetSampleRate(const sfSoundRecorder* soundRecorder); //////////////////////////////////////////////////////////// /// Tell if the system supports sound capture. /// If not, this class won't be usable /// /// \return sfTrue if audio capture is supported /// //////////////////////////////////////////////////////////// CSFML_API sfBool sfSoundRecorder_IsAvailable(void); #endif // SFML_SOUNDRECORDER_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Audio/Listener.h0000644000000000000000000000712111770572147025231 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_LISTENER_H #define SFML_LISTENER_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include //////////////////////////////////////////////////////////// /// Change the global volume of all the sounds /// /// \param volume : New global volume, in the range [0, 100] /// //////////////////////////////////////////////////////////// CSFML_API void sfListener_SetGlobalVolume(float volume); //////////////////////////////////////////////////////////// /// Get the current value of the global volume of all the sounds /// /// \return Current global volume, in the range [0, 100] /// //////////////////////////////////////////////////////////// CSFML_API float sfListener_GetGlobalVolume(void); //////////////////////////////////////////////////////////// /// Change the position of the listener /// /// \param x : X position of the listener in the world /// \param y : Y position of the listener in the world /// \param z : Z position of the listener in the world /// //////////////////////////////////////////////////////////// CSFML_API void sfListener_SetPosition(float x, float y, float z); //////////////////////////////////////////////////////////// /// Get the current position of the listener /// /// \param x : X position of the listener in the world /// \param y : Y position of the listener in the world /// \param z : Z position of the listener in the world /// //////////////////////////////////////////////////////////// CSFML_API void sfListener_GetPosition(float* x, float* y, float* z); //////////////////////////////////////////////////////////// /// Change the orientation of the listener /// /// \param x : X component of the listener's direction /// \param y : Y component of the listener's direction /// \param z : Z component of the listener's direction /// //////////////////////////////////////////////////////////// CSFML_API void sfListener_SetDirection(float x, float y, float z); //////////////////////////////////////////////////////////// /// Get the current orientation of the listener /// /// \param x : X component of the listener's direction /// \param y : Y component of the listener's direction /// \param z : Z component of the listener's direction /// //////////////////////////////////////////////////////////// CSFML_API void sfListener_GetDirection(float* x, float* y, float* z); #endif // SFML_LISTENER_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Audio/Sound.h0000644000000000000000000002363611770572147024545 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUND_H #define SFML_SOUND_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include //////////////////////////////////////////////////////////// /// Construct a new sound /// /// \return A new sfSound object (NULL if failed) /// //////////////////////////////////////////////////////////// CSFML_API sfSound* sfSound_Create(void); //////////////////////////////////////////////////////////// /// Copy an existing sound /// /// \param sound : Sound to copy /// /// \return Copied object /// //////////////////////////////////////////////////////////// CSFML_API sfSound* sfSound_Copy(sfSound* sound); //////////////////////////////////////////////////////////// /// Destroy an existing sound /// /// \param sound : Sound to delete /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_Destroy(sfSound* sound); //////////////////////////////////////////////////////////// /// Start playing a sound /// /// \param sound : Sound to play /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_Play(sfSound* sound); //////////////////////////////////////////////////////////// /// Pause a sound /// /// \param sound : Sound to pause /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_Pause(sfSound* sound); //////////////////////////////////////////////////////////// /// Stop playing a sound /// /// \param sound : Sound to stop /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_Stop(sfSound* sound); //////////////////////////////////////////////////////////// /// Bind a sound buffer to a sound /// /// \param sound : Sound to set the loop state /// \param buffer : Buffer to bind /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_SetBuffer(sfSound* sound, const sfSoundBuffer* buffer); //////////////////////////////////////////////////////////// /// Get the sound buffer bound to a sound /// /// \param sound : Sound to get the buffer from /// /// \return Pointer to the sound's buffer /// //////////////////////////////////////////////////////////// CSFML_API const sfSoundBuffer* sfSound_GetBuffer(const sfSound* sound); //////////////////////////////////////////////////////////// /// Set a sound loop state /// /// \param sound : Sound to set the loop state /// \param loop : sfTrue to play in loop, sfFalse to play once /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_SetLoop(sfSound* sound, sfBool loop); //////////////////////////////////////////////////////////// /// Tell whether or not a sound is looping /// /// \param sound : Sound to get the loop state from /// /// \return sfTrue if the sound is looping, sfFalse otherwise /// //////////////////////////////////////////////////////////// CSFML_API sfBool sfSound_GetLoop(const sfSound* sound); //////////////////////////////////////////////////////////// /// Get the status of a sound (stopped, paused, playing) /// /// \param sound : Sound to get the status from /// /// \return Current status of the sound /// //////////////////////////////////////////////////////////// CSFML_API sfSoundStatus sfSound_GetStatus(const sfSound* sound); //////////////////////////////////////////////////////////// /// Set the pitch of a sound /// /// \param sound : Sound to modify /// \param pitch : New pitch /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_SetPitch(sfSound* sound, float pitch); //////////////////////////////////////////////////////////// /// Set the volume of a sound /// /// \param sound : Sound to modify /// \param volume : Volume (in range [0, 100]) /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_SetVolume(sfSound* sound, float volume); //////////////////////////////////////////////////////////// /// Set the position of a sound /// /// \param sound : Sound to modify /// \param x : X position of the sound in the world /// \param y : Y position of the sound in the world /// \param z : Z position of the sound in the world /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_SetPosition(sfSound* sound, float x, float y, float z); //////////////////////////////////////////////////////////// /// Make the sound's position relative to the listener's /// position, or absolute. /// The default value is false (absolute) /// /// \param sound : Sound to modify /// \param relative : True to set the position relative, false to set it absolute /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_SetRelativeToListener(sfSound* sound, sfBool relative); //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the sound at its maximum volume. /// The default minimum distance is 1.0 /// /// \param sound : Sound to modify /// \param distance : New minimum distance for the sound /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_SetMinDistance(sfSound* sound, float distance); //////////////////////////////////////////////////////////// /// Set the attenuation factor - the higher the attenuation, the /// more the sound will be attenuated with distance from listener. /// The default attenuation factor is 1.0 /// /// \param sound : Sound to modify /// \param attenuation : New attenuation factor for the sound /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_SetAttenuation(sfSound* sound, float attenuation); //////////////////////////////////////////////////////////// /// Set the current playing position of a sound /// /// \param sound : Sound to modify /// \param timeOffset : New playing position, expressed in seconds /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_SetPlayingOffset(sfSound* sound, float timeOffset); //////////////////////////////////////////////////////////// /// Get the pitch of a sound /// /// \param sound : Sound to get the pitch from /// /// \return Pitch value /// //////////////////////////////////////////////////////////// CSFML_API float sfSound_GetPitch(const sfSound* sound); //////////////////////////////////////////////////////////// /// Get the volume of a sound /// /// \param sound : Sound to get the volume from /// /// \return Volume value (in range [1, 100]) /// //////////////////////////////////////////////////////////// CSFML_API float sfSound_GetVolume(const sfSound* sound); //////////////////////////////////////////////////////////// /// Get the position of a sound /// /// \param sound : Sound to get the position from /// \param x : X position of the sound in the world /// \param y : Y position of the sound in the world /// \param z : Z position of the sound in the world /// //////////////////////////////////////////////////////////// CSFML_API void sfSound_GetPosition(const sfSound* sound, float* x, float* y, float* z); //////////////////////////////////////////////////////////// /// Tell if the sound's position is relative to the listener's /// position, or if it's absolute /// /// \param sound : Sound to check /// /// \return sfTrue if the position is relative, sfFalse if it's absolute /// //////////////////////////////////////////////////////////// CSFML_API sfBool sfSound_IsRelativeToListener(const sfSound* sound); //////////////////////////////////////////////////////////// /// Get the minimum distance of a sound /// /// \param sound : Sound to get the minimum distance from /// /// \return Minimum distance for the sound /// //////////////////////////////////////////////////////////// CSFML_API float sfSound_GetMinDistance(const sfSound* sound); //////////////////////////////////////////////////////////// /// Get the attenuation factor of a sound /// /// \param sound : Sound to get the attenuation factor from /// /// \return Attenuation factor for the sound /// //////////////////////////////////////////////////////////// CSFML_API float sfSound_GetAttenuation(const sfSound* sound); //////////////////////////////////////////////////////////// /// Get the current playing position of a sound /// /// \param sound : Sound to get the position from /// /// \return Current playing position, expressed in seconds /// //////////////////////////////////////////////////////////// CSFML_API float sfSound_GetPlayingOffset(const sfSound* sound); #endif // SFML_SOUND_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Audio/SoundStatus.h0000644000000000000000000000303511770572147025740 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDSTATUS_H #define SFML_SOUNDSTATUS_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include typedef enum { sfStopped, ///< Sound / music is not playing sfPaused, ///< Sound / music is paused sfPlaying ///< Sound / music is playing } sfSoundStatus; #endif // SFML_SOUNDSTATUS_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Audio/SoundBuffer.h0000644000000000000000000001367111770572147025675 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDBUFFER_H #define SFML_SOUNDBUFFER_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include //////////////////////////////////////////////////////////// /// Create a new sound buffer and load it from a file /// /// \param filename : Path of the music file to open /// /// \return A new sfSoundBuffer object (NULL if failed) /// //////////////////////////////////////////////////////////// CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromFile(const char* filename); //////////////////////////////////////////////////////////// /// Create a new sound buffer and load it from a file in memory /// /// \param data : Pointer to the file data in memory /// \param sizeInBytes : Size of the data to load, in bytes /// /// \return A new sfSoundBuffer object (NULL if failed) /// //////////////////////////////////////////////////////////// CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromMemory(const void* data, size_t sizeInBytes); //////////////////////////////////////////////////////////// /// Create a new sound buffer and load it from an array of /// samples in memory - assumed format for samples is /// 16 bits signed integer /// /// \param samples : Pointer to the samples in memory /// \param samplesCount : Number of samples pointed by Samples /// \param channelsCount : Number of channels (1 = mono, 2 = stereo, ...) /// \param sampleRate : Frequency (number of samples to play per second) /// /// \return A new sfSoundBuffer object (NULL if failed) /// //////////////////////////////////////////////////////////// CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromSamples(const sfInt16* samples, size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate); //////////////////////////////////////////////////////////// /// Copy an existing sound buffer /// /// \param soundBuffer : Sound buffer to copy /// /// \return Copied object /// //////////////////////////////////////////////////////////// CSFML_API sfSoundBuffer* sfSoundBuffer_Copy(sfSoundBuffer* soundBuffer); //////////////////////////////////////////////////////////// /// Destroy an existing sound buffer /// /// \param soundBuffer : Sound buffer to delete /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundBuffer_Destroy(sfSoundBuffer* soundBuffer); //////////////////////////////////////////////////////////// /// Save a sound buffer to a file /// /// \param soundBuffer : Sound buffer to save /// \param filename : Path of the sound file to write /// /// \return sfTrue if saving has been successful /// //////////////////////////////////////////////////////////// CSFML_API sfBool sfSoundBuffer_SaveToFile(const sfSoundBuffer* soundBuffer, const char* filename); //////////////////////////////////////////////////////////// /// Return the samples contained in a sound buffer /// /// \param soundBuffer : Sound buffer to get samples from /// /// \return Pointer to the array of sound samples, in 16 bits signed integer format /// //////////////////////////////////////////////////////////// CSFML_API const sfInt16* sfSoundBuffer_GetSamples(const sfSoundBuffer* soundBuffer); //////////////////////////////////////////////////////////// /// Return the number of samples contained in a sound buffer /// /// \param soundBuffer : Sound buffer to get samples count from /// /// \return Number of samples /// //////////////////////////////////////////////////////////// CSFML_API size_t sfSoundBuffer_GetSamplesCount(const sfSoundBuffer* soundBuffer); //////////////////////////////////////////////////////////// /// Get the sample rate of a sound buffer /// /// \param soundBuffer : Sound buffer to get sample rate from /// /// \return Sound frequency (number of samples per second) /// //////////////////////////////////////////////////////////// CSFML_API unsigned int sfSoundBuffer_GetSampleRate(const sfSoundBuffer* soundBuffer); //////////////////////////////////////////////////////////// /// Return the number of channels of a sound buffer (1 = mono, 2 = stereo, ...) /// /// \param soundBuffer : Sound buffer to get channels count from /// /// \return Number of channels /// //////////////////////////////////////////////////////////// CSFML_API unsigned int sfSoundBuffer_GetChannelsCount(const sfSoundBuffer* soundBuffer); //////////////////////////////////////////////////////////// /// Get the duration of a sound buffer /// /// \param soundBuffer : Sound buffer to get duration from /// /// \return Sound duration, in seconds /// //////////////////////////////////////////////////////////// CSFML_API float sfSoundBuffer_GetDuration(const sfSoundBuffer* soundBuffer); #endif // SFML_SOUNDBUFFER_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Audio/Music.h0000644000000000000000000002505011770572147024525 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_MUSIC_H #define SFML_MUSIC_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include //////////////////////////////////////////////////////////// /// Create a new music and load it from a file /// /// \param filename : Path of the music file to open /// /// \return A new sfMusic object (NULL if failed) /// //////////////////////////////////////////////////////////// CSFML_API sfMusic* sfMusic_CreateFromFile(const char* filename); //////////////////////////////////////////////////////////// /// Create a new music and load it from a file in memory /// /// \param data : Pointer to the file data in memory /// \param sizeInBytes : Size of the data to load, in bytes /// /// \return A new sfMusic object (NULL if failed) /// //////////////////////////////////////////////////////////// CSFML_API sfMusic* sfMusic_CreateFromMemory(const void* data, size_t sizeInBytes); //////////////////////////////////////////////////////////// /// Destroy an existing music /// /// \param music : Music to delete /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_Destroy(sfMusic* music); //////////////////////////////////////////////////////////// /// Set a music loop state /// /// \param music : Music to set the loop state /// \param loop : sfTrue to play in loop, sfFalse to play once /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_SetLoop(sfMusic* music, sfBool loop); //////////////////////////////////////////////////////////// /// Tell whether or not a music is looping /// /// \param music : Music to get the loop state from /// /// \return sfTrue if the music is looping, sfFalse otherwise /// //////////////////////////////////////////////////////////// CSFML_API sfBool sfMusic_GetLoop(const sfMusic* music); //////////////////////////////////////////////////////////// /// Get a music duration /// /// \param music : Music to get the duration from /// /// \return Music duration, in seconds /// //////////////////////////////////////////////////////////// CSFML_API float sfMusic_GetDuration(const sfMusic* music); //////////////////////////////////////////////////////////// /// Start playing a music /// /// \param music : Music to play /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_Play(sfMusic* music); //////////////////////////////////////////////////////////// /// Pause a music /// /// \param music : Music to pause /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_Pause(sfMusic* music); //////////////////////////////////////////////////////////// /// Stop playing a music /// /// \param music : Music to stop /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_Stop(sfMusic* music); //////////////////////////////////////////////////////////// /// Return the number of channels of a music (1 = mono, 2 = stereo) /// /// \param music : Music to get the channels count from /// /// \return Number of channels /// //////////////////////////////////////////////////////////// CSFML_API unsigned int sfMusic_GetChannelsCount(const sfMusic* music); //////////////////////////////////////////////////////////// /// Get the stream sample rate of a music /// /// \param music : Music to get the sample rate from /// /// \return Stream frequency (number of samples per second) /// //////////////////////////////////////////////////////////// CSFML_API unsigned int sfMusic_GetSampleRate(const sfMusic* music); //////////////////////////////////////////////////////////// /// Get the status of a music (stopped, paused, playing) /// /// \param music : Music to get the status from /// /// \return Current status of the sound /// //////////////////////////////////////////////////////////// CSFML_API sfSoundStatus sfMusic_GetStatus(const sfMusic* music); //////////////////////////////////////////////////////////// /// Get the current playing position of a music /// /// \param music : Music to get the position from /// /// \return Current playing position, expressed in seconds /// //////////////////////////////////////////////////////////// CSFML_API float sfMusic_GetPlayingOffset(const sfMusic* music); //////////////////////////////////////////////////////////// /// Set the pitch of a music /// /// \param music : Music to modify /// \param pitch : New pitch /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_SetPitch(sfMusic* music, float pitch); //////////////////////////////////////////////////////////// /// Set the volume of a music /// /// \param music : Music to modify /// \param volume : Volume (in range [0, 100]) /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_SetVolume(sfMusic* music, float volume); //////////////////////////////////////////////////////////// /// Set the position of a music /// /// \param music : Music to modify /// \param x : X position of the sound in the world /// \param y : Y position of the sound in the world /// \param z : Z position of the sound in the world /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_SetPosition(sfMusic* music, float x, float y, float z); //////////////////////////////////////////////////////////// /// Make the music's position relative to the listener's /// position, or absolute. /// The default value is false (absolute) /// /// \param music : Music to modify /// \param relative : True to set the position relative, false to set it absolute /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_SetRelativeToListener(sfMusic* music, sfBool relative); //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the music at its maximum volume. /// The default minimum distance is 1.0 /// /// \param music : Music to modify /// \param distance : New minimum distance for the music /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_SetMinDistance(sfMusic* music, float distance); //////////////////////////////////////////////////////////// /// Set the attenuation factor - the higher the attenuation, the /// more the sound will be attenuated with distance from listener. /// The default attenuation factor 1.0 /// /// \param music : Music to modify /// \param attenuation : New attenuation factor for the sound /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_SetAttenuation(sfMusic* music, float attenuation); //////////////////////////////////////////////////////////// /// Set the current playing position of a music /// /// \param music : Music to modify /// \param timeOffset : New playing position, expressed in seconds /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_SetPlayingOffset(sfMusic* music, float timeOffset); //////////////////////////////////////////////////////////// /// Get the pitch of a music /// /// \param music : Music to get the pitch from /// /// \return Pitch value /// //////////////////////////////////////////////////////////// CSFML_API float sfMusic_GetPitch(const sfMusic* music); //////////////////////////////////////////////////////////// /// Get the volume of a music /// /// \param music : Music to get the volume from /// /// \return Volume value (in range [1, 100]) /// //////////////////////////////////////////////////////////// CSFML_API float sfMusic_GetVolume(const sfMusic* music); //////////////////////////////////////////////////////////// /// Get the position of a music /// /// \param music : Music to get the position from /// \param x : X position of the sound in the world /// \param y : Y position of the sound in the world /// \param z : Z position of the sound in the world /// //////////////////////////////////////////////////////////// CSFML_API void sfMusic_GetPosition(const sfMusic* music, float* x, float* y, float* z); //////////////////////////////////////////////////////////// /// Tell if the music's position is relative to the listener's /// position, or if it's absolute /// /// \param music : Music to check /// /// \return sfTrue if the position is relative, sfFalse if it's absolute /// //////////////////////////////////////////////////////////// CSFML_API sfBool sfMusic_IsRelativeToListener(const sfMusic* music); //////////////////////////////////////////////////////////// /// Get the minimum distance of a music /// /// \param music : Music to get the minimum distance from /// /// \return Minimum distance for the music /// //////////////////////////////////////////////////////////// CSFML_API float sfMusic_GetMinDistance(const sfMusic* music); //////////////////////////////////////////////////////////// /// Get the attenuation factor of a music /// /// \param music : Music to get the attenuation factor from /// /// \return Attenuation factor for the a music /// //////////////////////////////////////////////////////////// CSFML_API float sfMusic_GetAttenuation(const sfMusic* music); #endif // SFML_MUSIC_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Audio/Types.h0000644000000000000000000000272111770572147024551 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_AUDIO_TYPES_H #define SFML_AUDIO_TYPES_H typedef struct sfMusic sfMusic; typedef struct sfSound sfSound; typedef struct sfSoundBuffer sfSoundBuffer; typedef struct sfSoundBufferRecorder sfSoundBufferRecorder; typedef struct sfSoundRecorder sfSoundRecorder; typedef struct sfSoundStream sfSoundStream; #endif // SFML_AUDIO_TYPES_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Audio/SoundStream.h0000644000000000000000000003010511770572147025706 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDSTREAM_H #define SFML_SOUNDSTREAM_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include #include //////////////////////////////////////////////////////////// /// sfSoundStreamChunk defines the data to fill by the /// OnGetData callback //////////////////////////////////////////////////////////// typedef struct { sfInt16* Samples; ///< Pointer to the audio samples unsigned int NbSamples; ///< Number of samples pointed by Samples } sfSoundStreamChunk; typedef sfBool (*sfSoundStreamGetDataCallback)(sfSoundStreamChunk*, void*); ///< Type of the callback used to get a sound stream data typedef void (*sfSoundStreamSeekCallback)(float, void*); ///< Type of the callback used to seek in a sound stream //////////////////////////////////////////////////////////// /// Construct a new sound stream /// /// \param onGetData : Function called when the stream needs more data (can't be NULL) /// \param onSeek : Function called when the stream seeks (can't be NULL) /// \param channelsCount : Number of channels to use (1 = mono, 2 = stereo) /// \param sampleRate : Sample rate of the sound (44100 = CD quality) /// \param userData : Data to pass to the callback functions /// /// \return A new sfSoundStream object (NULL if failed) /// //////////////////////////////////////////////////////////// CSFML_API sfSoundStream* sfSoundStream_Create(sfSoundStreamGetDataCallback onGetData, sfSoundStreamSeekCallback onSeek, unsigned int channelsCount, unsigned int sampleRate, void* userData); //////////////////////////////////////////////////////////// /// Destroy an existing sound stream /// /// \param soundStream : Sound stream to delete /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_Destroy(sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Start playing a sound stream /// /// \param soundStream : Sound stream to play /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_Play(sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Pause a sound stream /// /// \param soundStream : Sound stream to pause /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_Pause(sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Stop playing a sound stream /// /// \param soundStream : Sound stream to stop /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_Stop(sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Get the status of a sound stream (stopped, paused, playing) /// /// \param soundStream : Sound stream to get the status from /// /// \return Current status of the sound stream /// //////////////////////////////////////////////////////////// CSFML_API sfSoundStatus sfSoundStream_GetStatus(const sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Return the number of channels of a sound stream /// (1 = mono, 2 = stereo) /// /// \param soundStream : Sound stream to get the channels count from /// /// \return Number of channels /// //////////////////////////////////////////////////////////// CSFML_API unsigned int sfSoundStream_GetChannelsCount(const sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Get the sample rate of a sound stream /// /// \param soundStream : Sound stream to get the sample rate from /// /// \return Stream frequency (number of samples per second) /// //////////////////////////////////////////////////////////// CSFML_API unsigned int sfSoundStream_GetSampleRate(const sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Set the pitch of a sound stream /// /// \param soundStream : Sound stream to modify /// \param pitch : New pitch /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_SetPitch(sfSoundStream* soundStream, float pitch); //////////////////////////////////////////////////////////// /// Set the volume of a sound stream /// /// \param soundStream : Sound stream to modify /// \param volume : Volume (in range [0, 100]) /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_SetVolume(sfSoundStream* soundStream, float volume); //////////////////////////////////////////////////////////// /// Set the position of a sound stream /// /// \param soundStream : Sound stream to modify /// \param x : X position of the sound stream in the world /// \param y : Y position of the sound stream in the world /// \param z : Z position of the sound stream in the world /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_SetPosition(sfSoundStream* soundStream, float x, float y, float z); //////////////////////////////////////////////////////////// /// Make the sound stream's position relative to the listener's /// position, or absolute. /// The default value is false (absolute) /// /// \param soundStream : Sound stream to modify /// \param relative : True to set the position relative, false to set it absolute /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_SetRelativeToListener(sfSoundStream* soundStream, sfBool relative); //////////////////////////////////////////////////////////// /// Set the minimum distance - closer than this distance, /// the listener will hear the sound stream at its maximum volume. /// The default minimum distance is 1.0 /// /// \param soundStream : Sound stream to modify /// \param distance : New minimum distance for the sound stream /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_SetMinDistance(sfSoundStream* soundStream, float distance); //////////////////////////////////////////////////////////// /// Set the attenuation factor - the higher the attenuation, the /// more the sound stream will be attenuated with distance from listener. /// The default attenuation factor 1.0 /// /// \param soundStream : Sound stream to modify /// \param attenuation : New attenuation factor for the sound stream /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_SetAttenuation(sfSoundStream* soundStream, float attenuation); //////////////////////////////////////////////////////////// /// Set the current playing position of a stream /// /// \param soundStream : Sound stream to modify /// \param timeOffset : New playing position, expressed in seconds /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_SetPlayingOffset(sfSoundStream* soundStream, float timeOffset); //////////////////////////////////////////////////////////// /// Set a stream loop state /// /// \param soundStream : Stream to set the loop state /// \param loop : sfTrue to play in loop, sfFalse to play once /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_SetLoop(sfSoundStream* soundStream, sfBool loop); //////////////////////////////////////////////////////////// /// Get the pitch of a sound stream /// /// \param soundStream : Sound stream to get the pitch from /// /// \return Pitch value /// //////////////////////////////////////////////////////////// CSFML_API float sfSoundStream_GetPitch(const sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Get the volume of a sound stream /// /// \param soundStream : Sound stream to get the volume from /// /// \return Volume value (in range [1, 100]) /// //////////////////////////////////////////////////////////// CSFML_API float sfSoundStream_GetVolume(const sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Get the position of a sound stream /// /// \param soundStream : Sound stream to get the position from /// \param x : X position of the sound stream in the world /// \param y : Y position of the sound stream in the world /// \param z : Z position of the sound stream in the world /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundStream_GetPosition(const sfSoundStream* soundStream, float* x, float* y, float* z); //////////////////////////////////////////////////////////// /// Tell if the sound stream's position is relative to the listener's /// position, or if it's absolute /// /// \param soundStream : Sound stream to check /// /// \return sfTrue if the position is relative, sfFalse if it's absolute /// //////////////////////////////////////////////////////////// CSFML_API sfBool sfSoundStream_IsRelativeToListener(const sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Get the minimum distance of a sound stream /// /// \param soundStream : Sound stream to get the minimum distance from /// /// \return Minimum distance for the sound stream /// //////////////////////////////////////////////////////////// CSFML_API float sfSoundStream_GetMinDistance(const sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Get the attenuation factor of a sound stream /// /// \param soundStream : Sound stream to get the attenuation factor from /// /// \return Attenuation factor for the sound stream /// //////////////////////////////////////////////////////////// CSFML_API float sfSoundStream_GetAttenuation(const sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Tell whether or not a stream is looping /// /// \param soundStream : Soundstream to get the loop state from /// /// \return sfTrue if the stream is looping, sfFalse otherwise /// //////////////////////////////////////////////////////////// CSFML_API sfBool sfSoundStream_GetLoop(const sfSoundStream* soundStream); //////////////////////////////////////////////////////////// /// Get the current playing position of a sound stream /// /// \param soundStream : Sound stream to get the position from /// /// \return Current playing position, expressed in seconds /// //////////////////////////////////////////////////////////// CSFML_API float sfSoundStream_GetPlayingOffset(const sfSoundStream* soundStream); #endif // SFML_SOUNDSTREAM_H sfml-audio-0.7.0.1816/dependencies/sfml2/bindings/c/include/SFML/Audio/SoundBufferRecorder.h0000644000000000000000000000740411770572147027360 0ustar0000000000000000//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // 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. // //////////////////////////////////////////////////////////// #ifndef SFML_SOUNDBUFFERRECORDER_H #define SFML_SOUNDBUFFERRECORDER_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include #include //////////////////////////////////////////////////////////// /// Construct a new sound buffer recorder /// /// \return A new sfSoundBufferRecorder object (NULL if failed) /// //////////////////////////////////////////////////////////// CSFML_API sfSoundBufferRecorder* sfSoundBufferRecorder_Create(void); //////////////////////////////////////////////////////////// /// Destroy an existing sound buffer recorder /// /// \param soundBufferRecorder : Sound buffer recorder to delete /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundBufferRecorder_Destroy(sfSoundBufferRecorder* soundBufferRecorder); //////////////////////////////////////////////////////////// /// Start the capture. /// Warning : only one capture can happen at the same time /// /// \param soundBufferRecorder : Sound buffer recorder to start /// \param sampleRate : Sound frequency (the more samples, the higher the quality) /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundBufferRecorder_Start(sfSoundBufferRecorder* soundBufferRecorder, unsigned int sampleRate); //////////////////////////////////////////////////////////// /// Stop the capture /// /// \param soundBufferRecorder : Sound buffer recorder to stop /// //////////////////////////////////////////////////////////// CSFML_API void sfSoundBufferRecorder_Stop(sfSoundBufferRecorder* soundBufferRecorder); //////////////////////////////////////////////////////////// /// Get the sample rate of a sound buffer recorder /// /// \param soundBufferRecorder : Sound buffer recorder to get sample rate from /// /// \return Frequency, in samples per second /// //////////////////////////////////////////////////////////// CSFML_API unsigned int sfSoundBufferRecorder_GetSampleRate(const sfSoundBufferRecorder* soundBufferRecorder); //////////////////////////////////////////////////////////// /// Get the sound buffer containing the captured audio data /// of a sound buffer recorder /// /// \param soundBufferRecorder : Sound buffer recorder to get the sound buffer from /// /// \return Pointer to the sound buffer (you don't need to destroy it after use) /// //////////////////////////////////////////////////////////// CSFML_API const sfSoundBuffer* sfSoundBufferRecorder_GetBuffer(const sfSoundBufferRecorder* soundBufferRecorder); #endif // SFML_SOUNDBUFFERRECORDER_H