Skip to content

Commit

Permalink
SoundComponent WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Benualdo committed Sep 15, 2024
1 parent ace3756 commit aaafa62
Show file tree
Hide file tree
Showing 17 changed files with 209 additions and 11 deletions.
24 changes: 22 additions & 2 deletions data/Scenes/Aiguelongue.scene
Original file line number Diff line number Diff line change
Expand Up @@ -2687,7 +2687,7 @@
<Property type="String" name="m_name" value="Debug"/>
<Property type="Uint32" name="m_uid" flags="" value="1949923508"/>
<Property type="Uint32" name="m_originalUID" flags="" value="0"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value="Opened"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value="Opened|Selected"/>
<Property type="EnumFlagsU32" name="m_flags" flags="Bitfield" value=""/>
<Property type="Float4" name="m_color" flags="Color" x="1" y="1" z="1" w="1"/>
<Property type="Float4x4" name="m_local" flags="Flatten" Ix="1" Iy="0" Iz="0" Iw="0" Jx="0" Jy="1" Jz="0" Jw="0" Kx="0" Ky="0" Kz="1" Kw="0" Tx="0" Ty="0" Tz="0" Tw="1"/>
Expand All @@ -2697,7 +2697,7 @@
<Property type="String" name="m_name" value="TestComponent"/>
<Property type="Uint32" name="m_uid" flags="" value="3740073557"/>
<Property type="Uint32" name="m_originalUID" flags="" value="0"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value="Opened|Prefab"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value="Opened|Prefab|Selected"/>
<Property type="EnumFlagsU32" name="m_flags" flags="Bitfield" value="Enabled"/>
<Property type="Float4" name="m_color" flags="Color" x="1" y="1" z="1" w="1"/>
<Property type="Float4x4" name="m_local" flags="Flatten" Ix="1" Iy="0" Iz="0" Iw="0" Jx="0" Jy="1" Jz="0" Jw="0" Kx="0" Ky="0" Kz="1" Kw="0" Tx="0" Ty="0" Tz="0" Tw="1"/>
Expand All @@ -2714,6 +2714,26 @@
</Property>
<Property type="ObjectPtrVector" name="m_dynamicProperties"/>
</Object>
<Object class="GameObject">
<Property type="String" name="m_name" value="TestSound"/>
<Property type="Uint32" name="m_uid" flags="" value="2463671653"/>
<Property type="Uint32" name="m_originalUID" flags="" value="0"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value="Selected"/>
<Property type="EnumFlagsU32" name="m_flags" flags="Bitfield" value="Enabled"/>
<Property type="Float4" name="m_color" flags="Color" x="1" y="1" z="1" w="1"/>
<Property type="Float4x4" name="m_local" flags="Flatten" Ix="1" Iy="0" Iz="0" Iw="0" Jx="0" Jy="1" Jz="0" Jw="0" Kx="0" Ky="0" Kz="1" Kw="0" Tx="0" Ty="0" Tz="0" Tw="1"/>
<Property type="ObjectPtrVector" name="m_components">
<Object class="SoundComponent">
<Property type="String" name="m_name" flags="NotVisible" value="New SoundComponent"/>
<Property type="Uint32" name="m_uid" flags="" value="2213048044"/>
<Property type="Uint32" name="m_originalUID" flags="" value="0"/>
<Property type="EnumFlagsU32" name="m_objectFlags" flags="" value="Opened"/>
<Property type="EnumFlagsU32" name="m_flags" flags="Bitfield" value="Enabled"/>
<Property type="String" name="m_path" value=""/>
</Object>
</Property>
<Property type="ObjectPtrVector" name="m_children" flags="NotVisible"/>
</Object>
</Property>
</Object>
</Property>
Expand Down
8 changes: 4 additions & 4 deletions data/Textures/Soccer/Billboard_Empty.png.meta
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Root>
<Object class="TextureResourceMeta">
<Property type="String" name="m_name" flags="NotVisible" value="Billboard_Empty.png.meta"/>
<Property type="Bool" name="m_importSettings.m_overridePixelFormat" flags="NotVisible" value="false"/>
<Property type="EnumU8" name="m_importSettings.m_pixelFormat" flags="Optional" value="R8G8B8A8_unorm_sRGB"/>
<Property type="Bool" name="m_importSettings.m_overrideDownscale" flags="NotVisible" value="false"/>
<Property type="EnumU8" name="m_importSettings.m_downscale" flags="Optional" value="None"/>
<Property type="EnumU8" name="m_importSettings.m_importerFormat" value="Automatic"/>
<Property type="Bool" name="m_importSettings.m_sRGB" value="false"/>
<Property type="EnumU8" name="m_importSettings.m_mipLevelCount" value="Automatic"/>
<Property type="EnumU8" name="m_importSettings.m_downscale" value="None"/>
</Object>
</Root>
4 changes: 0 additions & 4 deletions src/audio/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ namespace vg::audio

// initialize SoLoud.
m_soloud.init();

// Test
m_testSpeech.setText("VG Framework");
m_soloud.play(m_testSpeech);
}

//--------------------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion src/audio/Audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace vg::audio
private:
AudioCreationParams m_audioCreationParams;
SoLoud::Soloud m_soloud;
SoLoud::Speech m_testSpeech; // A sound source (speech, in this case)
};
}

Expand Down
8 changes: 8 additions & 0 deletions src/audio/Audio_Consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ namespace vg::audio
{

};

vg_enum_class(AudioSourceType, core::u8,
None,
Wav,
Ogg,
Mp3,
Flac
);
}
11 changes: 11 additions & 0 deletions src/audio/ISoundInstance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#include "core/Instance/Instance.h"

namespace vg::audio
{
class ISoundInstance : public core::Instance
{
public:
VG_CLASS_DECL_ABSTRACT(ISoundInstance, core::Instance);
};
}
37 changes: 37 additions & 0 deletions src/audio/Instance/SoundInstance.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "audio/Precomp.h"
#include "SoundInstance.h"

using namespace vg::core;

namespace vg::audio
{
//--------------------------------------------------------------------------------------
VG_REGISTER_OBJECT_CLASS(SoundInstance, "Sound instance");

//--------------------------------------------------------------------------------------
bool SoundInstance::registerProperties(IClassDesc & _desc)
{
super::registerProperties(_desc);

return true;
}

//--------------------------------------------------------------------------------------
SoundInstance::SoundInstance(const string & _name, IObject * _parent) :
super(_name, _parent)
{

}

//--------------------------------------------------------------------------------------
SoundInstance::~SoundInstance()
{
VG_SAFE_DELETE(m_slAudioSource);
}

//--------------------------------------------------------------------------------------
bool SoundInstance::TryGetAABB(AABB & _aabb) const
{
return false;
}
}
21 changes: 21 additions & 0 deletions src/audio/Instance/SoundInstance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#include "audio/ISoundInstance.h"
#include "audio/Audio_Consts.h"

namespace vg::audio
{
class SoundInstance final : public ISoundInstance
{
public:
VG_CLASS_DECL(SoundInstance, ISoundInstance);

SoundInstance(const core::string & _name, core::IObject * _parent);
~SoundInstance();

bool TryGetAABB(core::AABB & _aabb) const;

private:
AudioSourceType m_audioSourceType = AudioSourceType::None;
SoLoud::AudioSource * m_slAudioSource = nullptr;
};
}
3 changes: 3 additions & 0 deletions src/audio/audio.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="Audio.cpp" />
<ClCompile Include="Instance\SoundInstance.cpp" />
<ClCompile Include="Options\AudioOptions.cpp" />
<ClCompile Include="Precomp.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
Expand All @@ -29,6 +30,8 @@
<ClInclude Include="Audio_Consts.h" />
<ClInclude Include="IAudio.h" />
<ClInclude Include="IAudioOptions.h" />
<ClInclude Include="Instance\SoundInstance.h" />
<ClInclude Include="ISoundInstance.h" />
<ClInclude Include="Options\AudioOptions.h" />
<ClInclude Include="Precomp.h" />
<ClInclude Include="SoLoud\SoLoud.h" />
Expand Down
10 changes: 10 additions & 0 deletions src/audio/audio.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<ClCompile Include="SoLoud\SoLoud.cpp">
<Filter>SoLoud</Filter>
</ClCompile>
<ClCompile Include="Instance\SoundInstance.cpp">
<Filter>Instance</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Precomp.h" />
Expand All @@ -22,6 +25,10 @@
<ClInclude Include="SoLoud\SoLoud.h">
<Filter>SoLoud</Filter>
</ClInclude>
<ClInclude Include="Instance\SoundInstance.h">
<Filter>Instance</Filter>
</ClInclude>
<ClInclude Include="ISoundInstance.h" />
</ItemGroup>
<ItemGroup>
<Filter Include="Options">
Expand All @@ -30,6 +37,9 @@
<Filter Include="SoLoud">
<UniqueIdentifier>{c966a61c-4651-4ddf-bf99-8a252580e018}</UniqueIdentifier>
</Filter>
<Filter Include="Instance">
<UniqueIdentifier>{e1dad0fe-8308-478b-b58c-29d2563a9c19}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="Audio.def" />
Expand Down
1 change: 1 addition & 0 deletions src/editor/Editor_Consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ namespace vg::editor
inline static const char * Script = ICON_FA_FILE_LINES;
inline static const char * Shaders = ICON_FA_HAT_WIZARD;
inline static const char * Sliders = ICON_FA_SLIDERS;
inline static const char * Sound = ICON_FA_MUSIC;
inline static const char * Snap = ICON_FA_RULER_COMBINED;
inline static const char * Statistics = ICON_FA_CHART_SIMPLE;
inline static const char * Stop = ICON_FA_STOP;
Expand Down
3 changes: 3 additions & 0 deletions src/engine/Component/Audio/AudioComponent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "engine/Precomp.h"

#include "Sound/SoundComponent.hpp"
24 changes: 24 additions & 0 deletions src/engine/Component/Audio/Sound/SoundComponent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once

#include "engine/ISoundComponent.h"

namespace audio
{
class ISoundInstance;
}

namespace vg::engine
{
class SoundComponent final : public ISoundComponent
{
public:
VG_CLASS_DECL(SoundComponent, ISoundComponent);

SoundComponent(const core::string & _name, IObject * _parent);
~SoundComponent();

private:
core::string m_path;
audio::ISoundInstance * m_soundInstance = nullptr;
};
}
33 changes: 33 additions & 0 deletions src/engine/Component/Audio/Sound/SoundComponent.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "SoundComponent.h"
#include "editor/Editor_Consts.h"
#include "core/Object/Update.h"

using namespace vg::core;

namespace vg::engine
{
VG_REGISTER_COMPONENT_CLASS(SoundComponent, "Sound", "Audio", "Audio sound component", editor::style::icon::Sound, 0);

//--------------------------------------------------------------------------------------
bool SoundComponent::registerProperties(core::IClassDesc & _desc)
{
super::registerProperties(_desc);

registerProperty(SoundComponent, m_path, "Path");

return true;
}

//--------------------------------------------------------------------------------------
SoundComponent::SoundComponent(const core::string & _name, IObject * _parent) :
super(_name, _parent)
{
SetUpdateFlags(UpdateFlags::FixedUpdate | UpdateFlags::Update | UpdateFlags::LateUpdate, false);
}

//--------------------------------------------------------------------------------------
SoundComponent::~SoundComponent()
{

}
}
16 changes: 16 additions & 0 deletions src/engine/Engine.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
<ClCompile Include="Component\Debug\HUD\HUDComponent.cpp">
<Filter>Component\Debug\HUD</Filter>
</ClCompile>
<ClCompile Include="Component\Audio\AudioComponent.cpp">
<Filter>Component\Audio</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Engine.def" />
Expand Down Expand Up @@ -322,6 +325,13 @@
<ClInclude Include="Component\Debug\HUD\HUDComponent.h">
<Filter>Component\Debug\HUD</Filter>
</ClInclude>
<ClInclude Include="Component\Audio\Sound\SoundComponent.h">
<Filter>Component\Audio\Sound</Filter>
</ClInclude>
<ClInclude Include="Component\Audio\Sound\SoundComponent.hpp">
<Filter>Component\Audio\Sound</Filter>
</ClInclude>
<ClInclude Include="ISoundComponent.h" />
</ItemGroup>
<ItemGroup>
<Filter Include="Input">
Expand Down Expand Up @@ -432,5 +442,11 @@
<Filter Include="Component\Debug\TestComponent">
<UniqueIdentifier>{236f90ce-ad64-4e16-b12c-aefafa4ac373}</UniqueIdentifier>
</Filter>
<Filter Include="Component\Audio">
<UniqueIdentifier>{c3948e93-99ef-4d38-95b2-0bb7446dc277}</UniqueIdentifier>
</Filter>
<Filter Include="Component\Audio\Sound">
<UniqueIdentifier>{b310ec75-f637-48ab-85cb-630058b0415d}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions src/engine/ISoundComponent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include "core/Component/Component.h"

namespace vg::engine
{
class ISoundComponent : public core::Component
{
public:
VG_CLASS_DECL_ABSTRACT(ISoundComponent, core::Component);
};
}
4 changes: 4 additions & 0 deletions src/engine/engine.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ClCompile Include="Behaviour\FreeCam\FreeCamBehaviour.cpp" />
<ClCompile Include="Component\Animation\AnimationComponent.cpp" />
<ClCompile Include="Component\Animation\AttachToNodeComponent.cpp" />
<ClCompile Include="Component\Audio\AudioComponent.cpp" />
<ClCompile Include="Component\Camera\CameraComponent.cpp" />
<ClCompile Include="Component\Camera\LightComponent.cpp" />
<ClCompile Include="Component\Debug\HUD\HUDComponent.cpp" />
Expand All @@ -38,6 +39,8 @@
<ClCompile Include="Resource\Resource.cpp" />
<ClCompile Include="Selection\Selection.cpp" />
<ClInclude Include="Component\Animation\AttachToNodeComponent.h" />
<ClInclude Include="Component\Audio\Sound\SoundComponent.h" />
<ClInclude Include="Component\Audio\Sound\SoundComponent.hpp" />
<ClInclude Include="Component\Debug\HUD\HUDComponent.h" />
<ClInclude Include="Component\Debug\TestComponent\TestComponent.h" />
<ClInclude Include="Component\Editor\Snap\SnapComponent.h" />
Expand All @@ -57,6 +60,7 @@
<ClCompile Include="GameObject\Prefab\PrefabGameObject.cpp" />
<ClInclude Include="IPhysicsShapeComponent.h" />
<ClInclude Include="ISnapComponent.h" />
<ClInclude Include="ISoundComponent.h" />
<ClInclude Include="IUITextComponent.h" />
<ClInclude Include="Resource\BaseScene\BaseSceneResource.h" />
<ClInclude Include="Resource\BaseScene\BaseSceneResource.hpp" />
Expand Down

0 comments on commit aaafa62

Please sign in to comment.