| 1 |
#include "SoundInterface.h" |
| 2 |
|
| 3 |
#include <pybind11/pybind11.h> |
| 4 |
|
| 5 |
namespace script |
| 6 |
{ |
| 7 |
|
| 8 |
ScriptSoundShader SoundManagerInterface::getSoundShader(const std::string& shaderName) |
| 9 |
{ |
| 10 |
return ScriptSoundShader(GlobalSoundManager().getSoundShader(shaderName)); |
| 11 |
} |
| 12 |
|
| 13 |
bool SoundManagerInterface::playSound(const std::string& fileName) |
| 14 |
{ |
| 15 |
return GlobalSoundManager().playSound(fileName); |
| 16 |
} |
| 17 |
|
| 18 |
void SoundManagerInterface::stopSound() |
| 19 |
{ |
| 20 |
GlobalSoundManager().stopSound(); |
| 21 |
} |
| 22 |
|
| 23 |
// IScriptInterface implementation |
| 24 |
void SoundManagerInterface::registerInterface(py::module& scope, py::dict& globals) |
| 25 |
{ |
| 26 |
// Add the declaration for SoundRadii |
| 27 |
py::class_<ScriptSoundRadii> radii(scope, "SoundRadii"); |
| 28 |
|
| 29 |
radii.def(py::init<const SoundRadii&>()); |
| 30 |
radii.def("setMin", &ScriptSoundRadii::setMin); |
| 31 |
radii.def("setMax", &ScriptSoundRadii::setMax); |
| 32 |
radii.def("getMin", &ScriptSoundRadii::getMin); |
| 33 |
radii.def("getMax", &ScriptSoundRadii::getMax); |
| 34 |
|
| 35 |
// Add the declaration for a SoundShader |
| 36 |
py::class_<ScriptSoundShader> shader(scope, "SoundShader"); |
| 37 |
|
| 38 |
shader.def(py::init<const ISoundShader::Ptr&>()); |
| 39 |
shader.def("isNull", &ScriptSoundShader::isNull); |
| 40 |
shader.def("getName", &ScriptSoundShader::getName); |
| 41 |
shader.def("getRadii", &ScriptSoundShader::getRadii); |
| 42 |
shader.def("getSoundFileList", &ScriptSoundShader::getSoundFileList); |
| 43 |
shader.def("getShaderFilePath", &ScriptSoundShader::getShaderFilePath); |
| 44 |
shader.def("getDefinition", &ScriptSoundShader::getDefinition); |
| 45 |
|
| 46 |
// Add the module declaration to the given python namespace |
| 47 |
py::class_<SoundManagerInterface> soundManager(scope, "SoundManager"); |
| 48 |
|
| 49 |
soundManager.def("getSoundShader", &SoundManagerInterface::getSoundShader); |
| 50 |
soundManager.def("playSound", &SoundManagerInterface::playSound); |
| 51 |
soundManager.def("stopSound", &SoundManagerInterface::stopSound); |
| 52 |
|
| 53 |
// Now point the Python variable "GlobalSoundManager" to this instance |
| 54 |
globals["GlobalSoundManager"] = this; |
| 55 |
} |
| 56 |
|
| 57 |
} // namespace script |