فهرست منبع

Added skeleton for FMOD audio implementation

BearishSun 9 سال پیش
والد
کامیت
765b0623bc

+ 6 - 6
Source/BansheeEditor/Source/BsEditorApplication.cpp

@@ -38,12 +38,12 @@ namespace BansheeEngine
 
 	START_UP_DESC createStartupDesc()
 	{
-		START_UP_DESC startUpDesc;
-		startUpDesc.renderAPI = BS_RENDER_API_MODULE;
-		startUpDesc.renderer = BS_RENDERER_MODULE;
-		startUpDesc.audio = BS_AUDIO_MODULE;
-		startUpDesc.physics = BS_PHYSICS_MODULE;
-		startUpDesc.input = BS_INPUT_MODULE;
+		START_UP_DESC startUpDesc;
+		startUpDesc.renderAPI = BS_RENDER_API_MODULE;
+		startUpDesc.renderer = BS_RENDERER_MODULE;
+		startUpDesc.audio = BS_AUDIO_MODULE;
+		startUpDesc.physics = BS_PHYSICS_MODULE;
+		startUpDesc.input = BS_INPUT_MODULE;
 
 		startUpDesc.primaryWindowDesc.videoMode = VideoMode(1920, 1080);
 		startUpDesc.primaryWindowDesc.title = "BansheeEditor";

+ 12 - 6
Source/BansheeFMOD/CMakeLists.txt

@@ -1,11 +1,15 @@
 # Source files and their filters
 include(CMakeSources.cmake)
 
+# Packages
+find_package(FMOD)
+
 # Includes
 set(BansheeFMOD_INC 
 	"Include" 
 	"../BansheeUtility/Include" 
-	"../BansheeCore/Include")
+	"../BansheeCore/Include"
+	${FMOD_INCLUDE_DIRS})
 
 include_directories(${BansheeFMOD_INC})	
 	
@@ -15,13 +19,15 @@ add_library(BansheeFMOD SHARED ${BS_BANSHEEFMOD_SRC})
 # Defines
 target_compile_definitions(BansheeFMOD PRIVATE -DBS_FMOD_EXPORTS)
 
-# Options
-set(FMOD_PATH "C:\\Program Files (x86)\\FMOD SoundSystem\\FMOD Studio API Windows" CACHE PATH "Path to the FMOD installation directory.")
-mark_as_advanced(FMOD_PATH)
-
 # Libraries
 ## External libs: FMOD
-# TODO
+add_library(FMOD STATIC IMPORTED)
+
+set_target_properties(FMOD PROPERTIES IMPORTED_LOCATION_DEBUG "${FMOD_LIBRARIES_DEBUG}")
+set_target_properties(FMOD PROPERTIES IMPORTED_LOCATION_OPTIMIZEDDEBUG "${FMOD_LIBRARIES_DEBUG}")
+set_target_properties(FMOD PROPERTIES IMPORTED_LOCATION_RELEASE "${FMOD_LIBRARIES_OPTIMIZED}")	
+
+target_link_libraries(BansheeFMOD PRIVATE FMOD)	
 
 ## Local libs
 target_link_libraries(BansheeFMOD PUBLIC BansheeUtility BansheeCore)

+ 13 - 3
Source/BansheeFMOD/CMakeSources.cmake

@@ -1,15 +1,25 @@
 set(BS_BANSHEEFMOD_INC_NOFILTER
-	""
+	"Include/BsFMODPrerequisites.h"
+	"Include/BsFMODAudio.h"
+	"Include/BsFMODImporter.h"
+	"Include/BsFMODAudioSource.h"
+	"Include/BsFMODAudioListener.h"
+	"Include/BsFMODAudioClip.h"
 )
 
 set(BS_BANSHEEFMOD_SRC_NOFILTER
-	""
+	"Source/BsFMODPlugin.cpp"
+	"Source/BsFMODAudio.cpp"
+	"Source/BsFMODImporter.cpp"
+	"Source/BsFMODAudioSource.cpp"
+	"Source/BsFMODAudioListener.cpp"
+	"Source/BsFMODAudioClip.cpp"
 )
 
 source_group("Header Files" FILES ${BS_BANSHEEFMOD_INC_NOFILTER})
 source_group("Source Files" FILES ${BS_BANSHEEFMOD_SRC_NOFILTER})
 
-set(BS_BANSHEEOPENAUDIO_SRC
+set(BS_BANSHEEFMOD_SRC
 	${BS_BANSHEEFMOD_INC_NOFILTER}
 	${BS_BANSHEEFMOD_SRC_NOFILTER}
 )

+ 70 - 0
Source/BansheeFMOD/Include/BsFMODAudio.h

@@ -0,0 +1,70 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsFMODPrerequisites.h"
+#include "BsAudio.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup FMOD
+	 *  @{
+	 */
+	
+	/** Global manager for the audio implementation using FMOD as the backend. */
+	class BS_FMOD_EXPORT FMODAudio : public Audio
+	{
+	public:
+		FMODAudio();
+		virtual ~FMODAudio();
+
+		/** @copydoc Audio::setVolume */
+		void setVolume(float volume) override;
+
+		/** @copydoc Audio::getVolume */
+		float getVolume() const override;
+
+		/** @copydoc Audio::setPaused */
+		void setPaused(bool paused) override;
+
+		/** @copydoc Audio::isPaused */
+		bool isPaused() const override { return mIsPaused; }
+
+		/** @copydoc Audio::update */
+		void _update() override;
+
+		/** @copydoc Audio::setActiveDevice */
+		void setActiveDevice(const AudioDevice& device) override;
+
+		/** @copydoc Audio::getActiveDevice */
+		AudioDevice getActiveDevice() const override { return mActiveDevice; }
+
+		/** @copydoc Audio::getDefaultDevice */
+		AudioDevice getDefaultDevice() const override { return mDefaultDevice; }
+
+		/** @copydoc Audio::getAllDevices */
+		const Vector<AudioDevice>& getAllDevices() const override { return mAllDevices; };
+	private:
+		/** @copydoc Audio::createClip */
+		SPtr<AudioClip> createClip(const SPtr<DataStream>& samples, UINT32 streamSize, UINT32 numSamples,
+			const AUDIO_CLIP_DESC& desc) override;
+
+		/** @copydoc Audio::createListener */
+		SPtr<AudioListener> createListener() override;
+
+		/** @copydoc Audio::createSource */
+		SPtr<AudioSource> createSource() override;
+
+		float mVolume;
+		bool mIsPaused;
+
+		Vector<AudioDevice> mAllDevices;
+		AudioDevice mDefaultDevice;
+		AudioDevice mActiveDevice;
+	};
+
+	/** Provides easier access to FMODAudio. */
+	FMODAudio& gFMODAudio();
+
+	/** @} */
+}

+ 33 - 0
Source/BansheeFMOD/Include/BsFMODAudioClip.h

@@ -0,0 +1,33 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsFMODPrerequisites.h"
+#include "BsAudioClip.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup FMOD
+	 *  @{
+	 */
+	
+	/** FMOD implementation of an AudioClip. */
+	class BS_FMOD_EXPORT FMODAudioClip : public AudioClip
+	{
+	public:
+		FMODAudioClip(const SPtr<DataStream>& samples, UINT32 streamSize, UINT32 numSamples, const AUDIO_CLIP_DESC& desc);
+		virtual ~FMODAudioClip();
+
+		/** @copydoc AudioClip::getSamples */
+		void getSamples(UINT8* samples, UINT32 offset, UINT32 count) const override;
+
+	protected:
+		/** @copydoc Resource::initialize */
+		void initialize() override;
+
+		/** @copydoc AudioClip::getSourceFormatData */
+		SPtr<DataStream> getSourceStream(UINT32& size) override;
+	};
+
+	/** @} */
+}

+ 35 - 0
Source/BansheeFMOD/Include/BsFMODAudioListener.h

@@ -0,0 +1,35 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsFMODPrerequisites.h"
+#include "BsAudioListener.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup FMOD
+	 *  @{
+	 */
+	
+	/** FMOD implementation of an AudioListener. */
+	class BS_FMOD_EXPORT FMODAudioListener : public AudioListener
+	{
+	public:
+		FMODAudioListener();
+		virtual ~FMODAudioListener();
+
+		/** @copydoc AudioListener::setPosition */
+		void setPosition(const Vector3& position) override;
+
+		/** @copydoc AudioListener::setDirection */
+		void setDirection(const Vector3& direction) override;
+
+		/** @copydoc AudioListener::setUp */
+		void setUp(const Vector3& up) override;
+
+		/** @copydoc AudioListener::setVelocity */
+		void setVelocity(const Vector3& velocity) override;
+	};
+
+	/** @} */
+}

+ 65 - 0
Source/BansheeFMOD/Include/BsFMODAudioSource.h

@@ -0,0 +1,65 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsFMODPrerequisites.h"
+#include "BsAudioSource.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup FMOD
+	 *  @{
+	 */
+	
+	/** FMOD implementation of an AudioSource. */
+	class BS_FMOD_EXPORT FMODAudioSource : public AudioSource
+	{
+	public:
+		FMODAudioSource();
+		virtual ~FMODAudioSource();
+
+		/** @copydoc AudioSource::setClip */
+		void setClip(const HAudioClip& clip) override;
+
+		/** @copydoc AudioSource::setPosition */
+		void setPosition(const Vector3& position) override;
+
+		/** @copydoc AudioSource::setVelocity */
+		void setVelocity(const Vector3& velocity) override;
+
+		/** @copydoc AudioSource::setVolume */
+		void setVolume(float volume) override;
+
+		/** @copydoc AudioSource::setPitch */
+		void setPitch(float pitch) override;
+
+		/** @copydoc AudioSource::setIsLooping */
+		void setIsLooping(bool loop) override;
+
+		/** @copydoc AudioSource::setPriority */
+		void setPriority(UINT32 priority) override;
+
+		/** @copydoc AudioSource::setMinDistance */
+		void setMinDistance(float distance) override;
+
+		/** @copydoc AudioSource::setAttenuation */
+		void setAttenuation(float attenuation) override;
+
+		/** @copydoc AudioSource::setTime */
+		void setTime(float setTime) override;
+
+		/** @copydoc AudioSource::getTime */
+		float getTime() const override;
+
+		/** @copydoc AudioSource::play */
+		void play() override;
+
+		/** @copydoc AudioSource::pause */
+		void pause() override;
+
+		/** @copydoc AudioSource::stop */
+		void stop() override;
+	};
+
+	/** @} */
+}

+ 35 - 0
Source/BansheeFMOD/Include/BsFMODImporter.h

@@ -0,0 +1,35 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsFMODPrerequisites.h"
+#include "BsSpecificImporter.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup FMOD
+	 *  @{
+	 */
+
+	/** Importer using for importing WAV/FLAC/OGGVORBIS audio files. */
+	class BS_FMOD_EXPORT FMODImporter : public SpecificImporter
+	{
+	public:
+		FMODImporter();
+		virtual ~FMODImporter();
+
+		/** @copydoc SpecificImporter::isExtensionSupported */
+		bool isExtensionSupported(const WString& ext) const override;
+
+		/** @copydoc SpecificImporter::isMagicNumberSupported */
+		bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const override;
+
+		/** @copydoc SpecificImporter::import */
+		SPtr<Resource> import(const Path& filePath, SPtr<const ImportOptions> importOptions) override;
+
+		/** @copydoc SpecificImporter::createImportOptions */
+		SPtr<ImportOptions> createImportOptions() const override;
+	};
+
+	/** @} */
+}

+ 43 - 0
Source/BansheeFMOD/Include/BsFMODPrerequisites.h

@@ -0,0 +1,43 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+
+#if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(__MINGW32__)
+#	ifdef BS_FMOD_EXPORTS
+#		define BS_FMOD_EXPORT __declspec(dllexport)
+#	else
+#       if defined( __MINGW32__ )
+#           define BS_FMOD_EXPORT
+#       else
+#    		define BS_FMOD_EXPORT __declspec(dllimport)
+#       endif
+#	endif
+#elif defined (BS_GCC_VISIBILITY)
+#    define BS_FMOD_EXPORT  __attribute__ ((visibility("default")))
+#else
+#    define BS_FMOD_EXPORT
+#endif
+
+namespace BansheeEngine
+{
+	/** Contains data describing an audio file. */
+	struct AudioFileInfo
+	{
+		UINT32 numSamples; /**< Total number of audio samples in the audio data (includes all channels). */
+		UINT32 sampleRate; /**< Number of audio samples per second, per channel. */
+		UINT32 numChannels; /**< Number of channels. Each channel has its own set of samples. */
+		UINT32 bitDepth; /**< Number of bits per sample. */
+	};
+}
+
+/** @addtogroup Plugins
+ *  @{
+ */
+
+/** @defgroup FMOD BansheeFMOD
+ *	Audio system implementation using FMOD.
+ */
+
+/** @} */

+ 74 - 0
Source/BansheeFMOD/Source/BsFMODAudio.cpp

@@ -0,0 +1,74 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsFMODAudio.h"
+#include "BsMath.h"
+
+namespace BansheeEngine
+{
+	FMODAudio::FMODAudio()
+		:mVolume(1.0f), mIsPaused(false)
+	{
+		// TODO - Enumerate devices, init FMOD
+	}
+
+	FMODAudio::~FMODAudio()
+	{
+		// TODO - Shutdown FMOD
+	}
+
+	void FMODAudio::setVolume(float volume)
+	{
+		mVolume = Math::clamp01(volume);
+
+		// TODO
+	}
+
+	float FMODAudio::getVolume() const
+	{
+		return mVolume;
+	}
+
+	void FMODAudio::setPaused(bool paused)
+	{
+		if (mIsPaused == paused)
+			return;
+
+		mIsPaused = paused;
+
+		// TODO
+	}
+
+	void FMODAudio::_update()
+	{
+		// TODO - Call FMOD update, update streaming?
+	}
+
+	void FMODAudio::setActiveDevice(const AudioDevice& device)
+	{
+		// TODO
+	}
+
+	SPtr<AudioClip> FMODAudio::createClip(const SPtr<DataStream>& samples, UINT32 streamSize, UINT32 numSamples,
+		const AUDIO_CLIP_DESC& desc)
+	{
+		// TODO
+		return nullptr;
+	}
+
+	SPtr<AudioListener> FMODAudio::createListener()
+	{
+		// TODO
+		return nullptr;
+	}
+
+	SPtr<AudioSource> FMODAudio::createSource()
+	{
+		// TODO
+		return nullptr;
+	}
+
+	FMODAudio& gFMODAudio()
+	{
+		return static_cast<FMODAudio&>(FMODAudio::instance());
+	}
+}

+ 34 - 0
Source/BansheeFMOD/Source/BsFMODAudioClip.cpp

@@ -0,0 +1,34 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsFMODAudioClip.h"
+#include "BsDataStream.h"
+
+namespace BansheeEngine
+{
+	FMODAudioClip::FMODAudioClip(const SPtr<DataStream>& samples, UINT32 streamSize, UINT32 numSamples, const AUDIO_CLIP_DESC& desc)
+		:AudioClip(samples, streamSize, numSamples, desc)
+	{ }
+
+	FMODAudioClip::~FMODAudioClip()
+	{
+		// TODO
+	}
+
+	void FMODAudioClip::initialize()
+	{
+		// TODO
+
+		AudioClip::initialize();
+	}
+
+	void FMODAudioClip::getSamples(UINT8* samples, UINT32 offset, UINT32 count) const
+	{
+		// TODO
+	}
+
+	SPtr<DataStream> FMODAudioClip::getSourceStream(UINT32& size)
+	{
+		// TODO
+		return nullptr;
+	}
+}

+ 45 - 0
Source/BansheeFMOD/Source/BsFMODAudioListener.cpp

@@ -0,0 +1,45 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsFMODAudioListener.h"
+#include "BsFMODAudio.h"
+
+namespace BansheeEngine
+{
+	FMODAudioListener::FMODAudioListener()
+	{
+		// TODO
+	}
+
+	FMODAudioListener::~FMODAudioListener()
+	{
+		// TODO
+	}
+
+	void FMODAudioListener::setPosition(const Vector3& position)
+	{
+		AudioListener::setPosition(position);
+
+		// TODO
+	}
+
+	void FMODAudioListener::setDirection(const Vector3& direction)
+	{
+		AudioListener::setDirection(direction);
+
+		// TODO
+	}
+
+	void FMODAudioListener::setUp(const Vector3& up)
+	{
+		AudioListener::setUp(up);
+
+		// TODO
+	}
+
+	void FMODAudioListener::setVelocity(const Vector3& velocity)
+	{
+		AudioListener::setVelocity(velocity);
+
+		// TODO
+	}
+}

+ 114 - 0
Source/BansheeFMOD/Source/BsFMODAudioSource.cpp

@@ -0,0 +1,114 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsFMODAudioSource.h"
+#include "BsFMODAudio.h"
+#include "BsFMODAudioClip.h"
+
+namespace BansheeEngine
+{
+	FMODAudioSource::FMODAudioSource()
+	{
+		// TODO
+	}
+
+	FMODAudioSource::~FMODAudioSource()
+	{
+		// TODO
+	}
+
+	void FMODAudioSource::setClip(const HAudioClip& clip)
+	{
+		AudioSource::setClip(clip);
+
+		// TODO
+	}
+
+	void FMODAudioSource::setPosition(const Vector3& position)
+	{
+		AudioSource::setPosition(position);
+
+		// TODO
+	}
+
+	void FMODAudioSource::setVelocity(const Vector3& velocity)
+	{
+		AudioSource::setVelocity(velocity);
+
+		// TODO
+	}
+
+	void FMODAudioSource::setVolume(float volume)
+	{
+		AudioSource::setVolume(volume);
+
+		// TODO
+	}
+
+	void FMODAudioSource::setPitch(float pitch)
+	{
+		AudioSource::setPitch(pitch);
+
+		// TODO
+	}
+
+	void FMODAudioSource::setIsLooping(bool loop)
+	{
+		AudioSource::setIsLooping(loop);
+
+		// TODO
+	}
+
+	void FMODAudioSource::setPriority(UINT32 priority)
+	{
+		AudioSource::setPriority(priority);
+
+		// TODO
+	}
+
+	void FMODAudioSource::setMinDistance(float distance)
+	{
+		AudioSource::setMinDistance(distance);
+
+		// TODO
+	}
+
+	void FMODAudioSource::setAttenuation(float attenuation)
+	{
+		AudioSource::setAttenuation(attenuation);
+
+		// TODO
+	}
+
+	void FMODAudioSource::play()
+	{
+		AudioSource::play();
+
+		// TODO
+	}
+
+	void FMODAudioSource::pause()
+	{
+		AudioSource::pause();
+
+		// TODO
+	}
+
+	void FMODAudioSource::stop()
+	{
+		AudioSource::stop();
+
+		// TODO
+	}
+
+	void FMODAudioSource::setTime(float time)
+	{
+		// TODO
+	}
+
+	float FMODAudioSource::getTime() const
+	{
+		// TODO
+
+		return 0.0f;
+	}
+}

+ 134 - 0
Source/BansheeFMOD/Source/BsFMODImporter.cpp

@@ -0,0 +1,134 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsFMODImporter.h"
+#include "BsDataStream.h"
+#include "BsFileSystem.h"
+#include "BsAudioClipImportOptions.h"
+#include "BsAudioUtility.h"
+
+namespace BansheeEngine
+{
+	FMODImporter::FMODImporter()
+		:SpecificImporter()
+	{
+
+	}
+
+	FMODImporter::~FMODImporter()
+	{
+
+	}
+
+	bool FMODImporter::isExtensionSupported(const WString& ext) const
+	{
+		WString lowerCaseExt = ext;
+		StringUtil::toLowerCase(lowerCaseExt);
+
+		return lowerCaseExt == L"wav" || lowerCaseExt == L"flac" || lowerCaseExt == L"ogg";
+	}
+
+	bool FMODImporter::isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const
+	{
+		// Don't check for magic number, rely on extension
+		return true;
+	}
+
+	SPtr<ImportOptions> FMODImporter::createImportOptions() const
+	{
+		return bs_shared_ptr_new<AudioClipImportOptions>();
+	}
+
+	SPtr<Resource> FMODImporter::import(const Path& filePath, SPtr<const ImportOptions> importOptions)
+	{
+		SPtr<DataStream> stream = FileSystem::openFile(filePath);
+
+		WString extension = filePath.getWExtension();
+		StringUtil::toLowerCase(extension);
+
+		AudioFileInfo info;
+
+
+
+
+		// TODO - Parse audio meta-data
+
+
+
+
+		UINT32 bytesPerSample = info.bitDepth / 8;
+		UINT32 bufferSize = info.numSamples * bytesPerSample;
+		UINT8* sampleBuffer = (UINT8*)bs_alloc(bufferSize);
+		
+
+
+		// TODO - Read audio data
+
+
+		SPtr<const AudioClipImportOptions> clipIO = std::static_pointer_cast<const AudioClipImportOptions>(importOptions);
+
+		// If 3D, convert to mono
+		if (clipIO->getIs3D() && info.numChannels > 1)
+		{
+			UINT32 numSamplesPerChannel = info.numSamples / info.numChannels;
+
+			UINT32 monoBufferSize = numSamplesPerChannel * bytesPerSample;
+			UINT8* monoBuffer = (UINT8*)bs_alloc(monoBufferSize);
+
+			AudioUtility::convertToMono(sampleBuffer, monoBuffer, info.bitDepth, numSamplesPerChannel, info.numChannels);
+
+			info.numSamples = numSamplesPerChannel;
+			info.numChannels = 1;
+
+			bs_free(sampleBuffer);
+
+			sampleBuffer = monoBuffer;
+			bufferSize = monoBufferSize;
+		}
+
+		// Convert bit depth if needed
+		if (clipIO->getBitDepth() != info.bitDepth)
+		{
+			UINT32 outBufferSize = info.numSamples * (clipIO->getBitDepth() / 8);
+			UINT8* outBuffer = (UINT8*)bs_alloc(outBufferSize);
+
+			AudioUtility::convertBitDepth(sampleBuffer, info.bitDepth, outBuffer, clipIO->getBitDepth(), info.numSamples);
+
+			info.bitDepth = clipIO->getBitDepth();
+
+			bs_free(sampleBuffer);
+
+			sampleBuffer = outBuffer;
+			bufferSize = outBufferSize;
+		}
+
+		// Encode to Ogg Vorbis if needed
+		if (clipIO->getFormat() == AudioFormat::VORBIS)
+		{
+
+
+
+			// TODO - Encode to Ogg Vorbis!
+
+
+
+
+		}
+
+		SPtr<MemoryDataStream> sampleStream = bs_shared_ptr_new<MemoryDataStream>(sampleBuffer, bufferSize);
+
+		AUDIO_CLIP_DESC clipDesc;
+		clipDesc.bitDepth = info.bitDepth;
+		clipDesc.format = clipIO->getFormat();
+		clipDesc.frequency = info.sampleRate;
+		clipDesc.numChannels = info.numChannels;
+		clipDesc.readMode = clipIO->getReadMode();
+		clipDesc.is3D = clipIO->getIs3D();
+
+		SPtr<AudioClip> clip = AudioClip::_createPtr(sampleStream, bufferSize, info.numSamples, clipDesc);
+
+		WString fileName = filePath.getWFilename(false);
+		clip->setName(fileName);
+
+		return clip;
+	}
+}

+ 46 - 0
Source/BansheeFMOD/Source/BsFMODPlugin.cpp

@@ -0,0 +1,46 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsFMODPrerequisites.h"
+#include "BsAudioManager.h"
+#include "BsFMODAudio.h"
+#include "BsFMODImporter.h"
+#include "BsImporter.h"
+
+namespace BansheeEngine
+{
+	class BS_FMOD_EXPORT FMODFactory : public AudioFactory
+	{
+	public:
+		void startUp() override
+		{
+			Audio::startUp<FMODAudio>();
+		}
+
+		void shutDown() override
+		{
+			Audio::shutDown();
+		}
+	};
+
+	/**	Returns a name of the plugin. */
+	extern "C" BS_FMOD_EXPORT const char* getPluginName()
+	{
+		static const char* pluginName = "BansheeFMOD";
+		return pluginName;
+	}
+
+	/**	Entry point to the plugin. Called by the engine when the plugin is loaded. */
+	extern "C" BS_FMOD_EXPORT void* loadPlugin()
+	{
+		FMODImporter* importer = bs_new<FMODImporter>();
+		Importer::instance()._registerAssetImporter(importer);
+
+		return bs_new<FMODFactory>();
+	}
+
+	/**	Exit point of the plugin. Called by the engine before the plugin is unloaded. */
+	extern "C" BS_FMOD_EXPORT void unloadPlugin(FMODFactory* instance)
+	{
+		bs_delete(instance);
+	}
+}

+ 43 - 0
Source/CMake/Modules/FindFMOD.cmake

@@ -0,0 +1,43 @@
+# Find FMOD installation
+#
+# This module defines
+#  FMOD_INCLUDE_DIRS
+#  FMOD_LIBRARIES_DEBUG
+#  FMOD_LIBRARIES_OPTIMIZED
+#  FMOD_LIBRARY_DIRS
+#  FMOD_FOUND
+
+# TODO: Set default install paths for mac/unix
+set(FMOD_INSTALL_DIRS "C:/Program Files (x86)/FMOD SoundSystem/FMOD Studio API Windows" CACHE PATH "")
+set(FMOD_INCLUDE_SEARCH_DIRS "${FMOD_INSTALL_DIRS}/api/lowlevel/inc")
+set(FMOD_LIBRARY_SEARCH_DIRS "${FMOD_INSTALL_DIRS}/api/lowlevel/lib")
+
+message(STATUS "Looking for FMOD installation...")
+find_path(FMOD_INCLUDE_DIR fmod.h PATHS ${FMOD_INCLUDE_SEARCH_DIRS})
+
+if(BS_64BIT)
+	find_library(FMOD_LIBRARY_OPTIMIZED NAMES fmod64_vc libfmod PATHS ${FMOD_LIBRARY_SEARCH_DIRS})
+	find_library(FMOD_LIBRARY_DEBUG NAMES fmodL64_vc libfmodL PATHS ${FMOD_LIBRARY_SEARCH_DIRS})
+else()
+	find_library(FMOD_LIBRARY_OPTIMIZED NAMES fmod_vc libfmod PATHS ${FMOD_LIBRARY_SEARCH_DIRS})
+	find_library(FMOD_LIBRARY_DEBUG NAMES fmodL_vc libfmodL PATHS ${FMOD_LIBRARY_SEARCH_DIRS})
+endif()
+
+if(FMOD_INCLUDE_DIR AND FMOD_LIBRARY_OPTIMIZED AND FMOD_LIBRARY_DEBUG)
+	set(FMOD_FOUND TRUE)
+endif()
+
+if(NOT FMOD_FOUND)
+	if(FMOD_FIND_REQUIRED)
+		message(FATAL_ERROR "Cannot find FMOD installation. Try modifying the FMOD_INSTALL_DIRS path.")
+	else()
+		message(WARNING "Cannot find FMOD installation. Try modifying the FMOD_INSTALL_DIRS path.")
+	endif()
+else()
+	message(STATUS "...FMOD OK.")
+endif()
+
+mark_as_advanced(FMOD_INSTALL_DIRS FMOD_INCLUDE_DIR FMOD_LIBRARY_OPTIMIZED FMOD_LIBRARY_DEBUG)
+set(FMOD_INCLUDE_DIRS ${FMOD_INCLUDE_DIR})
+set(FMOD_LIBRARIES_OPTIMIZED ${FMOD_LIBRARY_OPTIMIZED})
+set(FMOD_LIBRARIES_DEBUG ${FMOD_LIBRARY_DEBUG})

+ 42 - 25
Source/CMakeLists.txt

@@ -183,40 +183,37 @@ add_subdirectory(BansheeUtility)
 add_subdirectory(BansheeCore)
 add_subdirectory(BansheeEngine)
 
-#if(BUILD_EDITOR)
+if(BUILD_EDITOR OR MSVC)
 	add_subdirectory(BansheeEditor)
-#endif()
+endif()
 
 ## Plugins
-
-if(RENDER_API_MODULE MATCHES "DirectX 11")
+### If using MSVC include all plugins in the solution (which ones actually build is controlled by dependencies)
+if(MSVC)
 	add_subdirectory(BansheeD3D11RenderAPI)
-	set(RENDER_API_MODULE_LIB BansheeD3D11RenderAPI)
-elseif(RENDER_API_MODULE MATCHES "DirectX 9")
 	add_subdirectory(BansheeD3D9RenderAPI)
-	set(RENDER_API_MODULE_LIB BansheeD3D9RenderAPI)
-else()
 	add_subdirectory(BansheeGLRenderAPI)
-	set(RENDER_API_MODULE_LIB BansheeGLRenderAPI)
+	add_subdirectory(BansheeFMOD)
+	add_subdirectory(BansheeOpenAudio)
+else() # Otherwise include only chosen ones
+	if(RENDER_API_MODULE MATCHES "DirectX 11")
+		add_subdirectory(BansheeD3D11RenderAPI)
+	elseif(RENDER_API_MODULE MATCHES "DirectX 9")
+		add_subdirectory(BansheeD3D9RenderAPI)
+	else()
+		add_subdirectory(BansheeGLRenderAPI)
+	endif()
+
+	if(AUDIO_MODULE MATCHES "FMOD")
+		add_subdirectory(BansheeFMOD)
+	else() # Default to OpenAudio
+		add_subdirectory(BansheeOpenAudio)
+	endif()
 endif()
 
 add_subdirectory(RenderBeast)
-set(RENDERER_MODULE_LIB RenderBeast)
-
 add_subdirectory(BansheeOISInput)
-set(INPUT_MODULE_LIB BansheeOISInput)
-
 add_subdirectory(BansheePhysX)
-set(PHYSICS_MODULE_LIB BansheePhysX)
-
-if(AUDIO_MODULE MATCHES "FMOD")
-	add_subdirectory(BansheeFMOD)
-	set(AUDIO_MODULE_LIB BansheeFMOD)
-else() # Default to OpenAudio
-	add_subdirectory(BansheeOpenAudio)
-	set(AUDIO_MODULE_LIB BansheeOpenAudio)
-endif()
-
 add_subdirectory(BansheeFBXImporter)
 add_subdirectory(BansheeFontImporter)
 add_subdirectory(BansheeFreeImgImporter)
@@ -226,7 +223,7 @@ add_subdirectory(BansheeSL)
 ## Script interop
 add_subdirectory(SBansheeEngine)
 
-if(BUILD_EDITOR)
+if(BUILD_EDITOR OR MSVC)
 	add_subdirectory(SBansheeEditor)
 endif()
 
@@ -234,7 +231,7 @@ endif()
 add_subdirectory(Game)
 add_subdirectory(ExampleProject)
 
-if(BUILD_EDITOR)
+if(BUILD_EDITOR OR MSVC)
 	add_subdirectory(BansheeEditorExec)
 endif()
 
@@ -255,4 +252,24 @@ else()
 endif()
 
 # Config file
+## Set names of libraries used in the config file
+if(RENDER_API_MODULE MATCHES "DirectX 11")
+	set(RENDER_API_MODULE_LIB BansheeD3D11RenderAPI)
+elseif(RENDER_API_MODULE MATCHES "DirectX 9")
+	set(RENDER_API_MODULE_LIB BansheeD3D9RenderAPI)
+else()
+	set(RENDER_API_MODULE_LIB BansheeGLRenderAPI)
+endif()
+
+if(AUDIO_MODULE MATCHES "FMOD")
+	set(AUDIO_MODULE_LIB BansheeFMOD)
+else() # Default to OpenAudio
+	set(AUDIO_MODULE_LIB BansheeOpenAudio)
+endif()
+
+set(RENDERER_MODULE_LIB RenderBeast)
+set(INPUT_MODULE_LIB BansheeOISInput)
+set(PHYSICS_MODULE_LIB BansheePhysX)
+
+## Generate config file
 configure_file("${PROJECT_SOURCE_DIR}/CMake/BsEngineConfig.h.in" "${PROJECT_SOURCE_DIR}/BansheeEngine/Include/BsEngineConfig.h")