-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from SirBob01/feat/rework-jukebox
Rewrite Jukebox subsystem
- Loading branch information
Showing
32 changed files
with
336 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,12 @@ | |
[submodule "submodules/Catch2"] | ||
path = submodules/Catch2 | ||
url = [email protected]:catchorg/Catch2.git | ||
[submodule "submodules/libsndfile"] | ||
path = submodules/libsndfile | ||
url = [email protected]:libsndfile/libsndfile.git | ||
[submodule "submodules/tinyobjloader"] | ||
path = submodules/tinyobjloader | ||
url = [email protected]:tinyobjloader/tinyobjloader.git | ||
[submodule "submodules/spirv-reflect"] | ||
path = submodules/spirv-reflect | ||
url = [email protected]:KhronosGroup/SPIRV-Reflect.git | ||
[submodule "submodules/libsndfile"] | ||
path = submodules/libsndfile | ||
url = [email protected]:libsndfile/libsndfile.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "./Sound.hpp" | ||
#include "../Utils/Log.hpp" | ||
|
||
namespace Dynamo { | ||
Sound::Sound load(const std::string filepath) { | ||
SndfileHandle file(filepath.c_str(), SFM_READ, 0, 1, 0); | ||
if (file.error()) { | ||
Log::error("Could not load sound file `{}`: {}", | ||
filepath, | ||
file.strError()); | ||
} | ||
|
||
unsigned frames = file.frames(); | ||
unsigned channels = file.channels(); | ||
unsigned sample_rate = file.samplerate(); | ||
|
||
// Read the PCM data | ||
Sound::WaveForm interleaved(frames * channels); | ||
file.readf(interleaved.data(), interleaved.size()); | ||
|
||
// De-interleave the data into the final waveform buffer | ||
Sound::WaveForm waveform(frames * channels); | ||
for (unsigned f = 0; f < frames; f++) { | ||
for (unsigned c = 0; c < channels; c++) { | ||
waveform[c * frames + f] = interleaved[f * channels + c]; | ||
} | ||
} | ||
|
||
return Sound::Sound(waveform, channels, sample_rate); | ||
} | ||
} // namespace Dynamo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <sndfile.hh> | ||
|
||
#include "../Sound/Sound.hpp" | ||
|
||
namespace Dynamo { | ||
/** | ||
* @brief Load a sound file. | ||
* | ||
* @param filepath | ||
* @return Sound::Sound | ||
*/ | ||
Sound::Sound load(const std::string filepath); | ||
} // namespace Dynamo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
#include <array> | ||
|
||
#include "./Sound.hpp" | ||
#include "../Sound.hpp" | ||
|
||
namespace Dynamo::Sound { | ||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
|
||
#include "./Listener.hpp" | ||
#include "./Material.hpp" | ||
#include "./Sound.hpp" | ||
|
||
namespace Dynamo::Sound { | ||
/** | ||
* @brief Abstract audio filter node. | ||
* | ||
*/ | ||
class Filter { | ||
public: | ||
virtual ~Filter() = default; | ||
|
||
/** | ||
* @brief Apply the filter to a sound | ||
* | ||
* @param src Source sound buffer | ||
* @param offset Source frame start index | ||
* @param length Length of the chunk to be processed | ||
* @param material Material properties of the sound | ||
* @param listener Listener | ||
* @return Sound& | ||
*/ | ||
virtual const Sound &apply(Sound &src, | ||
const unsigned offset, | ||
const unsigned length, | ||
const Material &material, | ||
const ListenerProperties &listener) = 0; | ||
}; | ||
|
||
/** | ||
* @brief Filter reference. | ||
* | ||
*/ | ||
using FilterRef = std::reference_wrapper<Filter>; | ||
} // namespace Dynamo::Sound |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.