Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Müller <nexyon@gmail.com>2019-04-03 20:56:25 +0300
committerJörg Müller <nexyon@gmail.com>2019-04-03 20:56:25 +0300
commit322abc14285e7722d98d4503c09d032cf2b22f6c (patch)
tree77a3fec162f5e06922a015ca88c67140acf8a7c4 /extern/audaspace/bindings
parentacc20b117da283b6ced52a1bea89ebaea914ab93 (diff)
Audaspace: merging modulator effect from upstream.
Diffstat (limited to 'extern/audaspace/bindings')
-rw-r--r--extern/audaspace/bindings/C/AUD_Sound.cpp16
-rw-r--r--extern/audaspace/bindings/C/AUD_Sound.h8
-rw-r--r--extern/audaspace/bindings/python/PySound.cpp45
3 files changed, 69 insertions, 0 deletions
diff --git a/extern/audaspace/bindings/C/AUD_Sound.cpp b/extern/audaspace/bindings/C/AUD_Sound.cpp
index 1f40f5c608b..00a59f4c67f 100644
--- a/extern/audaspace/bindings/C/AUD_Sound.cpp
+++ b/extern/audaspace/bindings/C/AUD_Sound.cpp
@@ -32,6 +32,7 @@
#include "fx/Limiter.h"
#include "fx/Loop.h"
#include "fx/Lowpass.h"
+#include "fx/Modulator.h"
#include "fx/Pitch.h"
#include "fx/Reverse.h"
#include "fx/Sum.h"
@@ -465,6 +466,21 @@ AUD_API AUD_Sound* AUD_Sound_lowpass(AUD_Sound* sound, float frequency, float Q)
}
}
+AUD_API AUD_Sound* AUD_Sound_modulate(AUD_Sound* first, AUD_Sound* second)
+{
+ assert(first);
+ assert(second);
+
+ try
+ {
+ return new AUD_Sound(new Modulator(*first, *second));
+ }
+ catch(Exception&)
+ {
+ return nullptr;
+ }
+}
+
AUD_API AUD_Sound* AUD_Sound_pitch(AUD_Sound* sound, float factor)
{
assert(sound);
diff --git a/extern/audaspace/bindings/C/AUD_Sound.h b/extern/audaspace/bindings/C/AUD_Sound.h
index b18e3c3a8eb..66d6c53cc37 100644
--- a/extern/audaspace/bindings/C/AUD_Sound.h
+++ b/extern/audaspace/bindings/C/AUD_Sound.h
@@ -247,6 +247,14 @@ extern AUD_API AUD_Sound* AUD_Sound_loop(AUD_Sound* sound, int count);
extern AUD_API AUD_Sound* AUD_Sound_lowpass(AUD_Sound* sound, float frequency, float Q);
/**
+ * Modulates two sound, which means multiplying the sound samples.
+ * \param first The first sound.
+ * \param second The second sound.
+ * \return A handle of the modulated sound.
+ */
+extern AUD_API AUD_Sound* AUD_Sound_modulate(AUD_Sound* first, AUD_Sound* second);
+
+/**
* Changes the pitch of a sound.
* \param sound The sound to change.
* \param factor The factor to change the pitch with.
diff --git a/extern/audaspace/bindings/python/PySound.cpp b/extern/audaspace/bindings/python/PySound.cpp
index 82c6036012b..17fcdbeb938 100644
--- a/extern/audaspace/bindings/python/PySound.cpp
+++ b/extern/audaspace/bindings/python/PySound.cpp
@@ -42,6 +42,7 @@
#include "fx/Limiter.h"
#include "fx/Loop.h"
#include "fx/Lowpass.h"
+#include "fx/Modulator.h"
#include "fx/MutableSound.h"
#include "fx/Pitch.h"
#include "fx/Reverse.h"
@@ -1129,6 +1130,47 @@ Sound_lowpass(Sound* self, PyObject* args)
return (PyObject *)parent;
}
+PyDoc_STRVAR(M_aud_Sound_modulate_doc,
+ "modulate(sound)\n\n"
+ "Modulates two factories.\n\n"
+ ":arg sound: The sound to modulate over the other.\n"
+ ":type sound: :class:`Sound`\n"
+ ":return: The created :class:`Sound` object.\n"
+ ":rtype: :class:`Sound`\n\n"
+ ".. note:: The two factories have to have the same specifications "
+ "(channels and samplerate).");
+
+static PyObject *
+Sound_modulate(Sound* self, PyObject* object)
+{
+ PyTypeObject* type = Py_TYPE(self);
+
+ if(!PyObject_TypeCheck(object, type))
+ {
+ PyErr_SetString(PyExc_TypeError, "Object is not of type Sound!");
+ return nullptr;
+ }
+
+ Sound* parent = (Sound*)type->tp_alloc(type, 0);
+ Sound* child = (Sound*)object;
+
+ if(parent != nullptr)
+ {
+ try
+ {
+ parent->sound = new std::shared_ptr<ISound>(new Modulator(*reinterpret_cast<std::shared_ptr<ISound>*>(self->sound), *reinterpret_cast<std::shared_ptr<ISound>*>(child->sound)));
+ }
+ catch(Exception& e)
+ {
+ Py_DECREF(parent);
+ PyErr_SetString(AUDError, e.what());
+ return nullptr;
+ }
+ }
+
+ return (PyObject *)parent;
+}
+
PyDoc_STRVAR(M_aud_Sound_pitch_doc,
"pitch(factor)\n\n"
"Changes the pitch of a sound with a specific factor.\n\n"
@@ -1791,6 +1833,9 @@ static PyMethodDef Sound_methods[] = {
{"lowpass", (PyCFunction)Sound_lowpass, METH_VARARGS,
M_aud_Sound_lowpass_doc
},
+ {"modulate", (PyCFunction)Sound_modulate, METH_O,
+ M_aud_Sound_modulate_doc
+ },
{"pitch", (PyCFunction)Sound_pitch, METH_VARARGS,
M_aud_Sound_pitch_doc
},