Major - Adds FMOD audio library - V13.0.0
Adds precompiled FMOD audio library binaries for various platforms (x86, x64, arm64) and build configurations (Debug, Release). Also adds a basic audio component header file.
This commit is contained in:
35
enginecustom/src/inc/system/ecs/components/audio_component.h
Normal file
35
enginecustom/src/inc/system/ecs/components/audio_component.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// AudioComponent.h
|
||||
#pragma once
|
||||
#include "ecs/component.h"
|
||||
#include <Fmod/core/inc/fmod.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace ecs {
|
||||
class AudioComponent : public Component {
|
||||
public:
|
||||
AudioComponent() : m_system(nullptr), m_sound(nullptr), m_channel(nullptr) {}
|
||||
~AudioComponent() override {
|
||||
if (m_sound) m_sound->release();
|
||||
}
|
||||
|
||||
bool Load(FMOD::System* system, const std::string& path) {
|
||||
m_system = system;
|
||||
return m_system->createSound(path.c_str(), FMOD_DEFAULT, nullptr, &m_sound) == FMOD_OK;
|
||||
}
|
||||
|
||||
void Play() {
|
||||
if (m_system && m_sound)
|
||||
m_system->playSound(m_sound, nullptr, false, &m_channel);
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
if (m_channel)
|
||||
m_channel->stop();
|
||||
}
|
||||
|
||||
private:
|
||||
FMOD::System* m_system;
|
||||
FMOD::Sound* m_sound;
|
||||
FMOD::Channel* m_channel;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user