diff options
author | Jörg Müller <nexyon@gmail.com> | 2019-05-11 00:01:04 +0300 |
---|---|---|
committer | Jörg Müller <nexyon@gmail.com> | 2019-05-11 00:01:04 +0300 |
commit | 8096f36796ae07a1a76e99abbaf216ab29260b74 (patch) | |
tree | 64ad4a670f2ea9c44d783cba2b474b0eee320e3a /extern/audaspace/bindings | |
parent | 243fbf1c4bacf82dd30dc9068ac634343d5b6ad6 (diff) |
Audaspace: porting changes from upstream.
- Silence now has an optional sample rate parameter.
- Fix: wrong length reported by modulator and superpose.
- Minor formatting, include and documentation fixes.
Diffstat (limited to 'extern/audaspace/bindings')
-rw-r--r-- | extern/audaspace/bindings/C/AUD_Sound.cpp | 4 | ||||
-rw-r--r-- | extern/audaspace/bindings/C/AUD_Sound.h | 3 | ||||
-rw-r--r-- | extern/audaspace/bindings/C/AUD_Special.cpp | 6 | ||||
-rw-r--r-- | extern/audaspace/bindings/python/PySequence.cpp | 8 | ||||
-rw-r--r-- | extern/audaspace/bindings/python/PySound.cpp | 16 |
5 files changed, 23 insertions, 14 deletions
diff --git a/extern/audaspace/bindings/C/AUD_Sound.cpp b/extern/audaspace/bindings/C/AUD_Sound.cpp index 00a59f4c67f..8c99ce2341f 100644 --- a/extern/audaspace/bindings/C/AUD_Sound.cpp +++ b/extern/audaspace/bindings/C/AUD_Sound.cpp @@ -277,9 +277,9 @@ AUD_API AUD_Sound* AUD_Sound_sawtooth(float frequency, AUD_SampleRate rate) return new AUD_Sound(new Sawtooth(frequency, rate)); } -AUD_API AUD_Sound*AUD_Sound_silence() +AUD_API AUD_Sound* AUD_Sound_silence(AUD_SampleRate rate) { - return new AUD_Sound(new Silence()); + return new AUD_Sound(new Silence(rate)); } AUD_API AUD_Sound* AUD_Sound_sine(float frequency, AUD_SampleRate rate) diff --git a/extern/audaspace/bindings/C/AUD_Sound.h b/extern/audaspace/bindings/C/AUD_Sound.h index 66d6c53cc37..53172616781 100644 --- a/extern/audaspace/bindings/C/AUD_Sound.h +++ b/extern/audaspace/bindings/C/AUD_Sound.h @@ -113,9 +113,10 @@ extern AUD_API AUD_Sound* AUD_Sound_sawtooth(float frequency, AUD_SampleRate rat /** * Creates a quiet sound. + * \param rate The sample rate of the silence sound. * \return A handle of the sound. */ -extern AUD_API AUD_Sound* AUD_Sound_silence(); +extern AUD_API AUD_Sound* AUD_Sound_silence(AUD_SampleRate rate); /** * Creates a sine sound. diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp b/extern/audaspace/bindings/C/AUD_Special.cpp index f8f46651231..30148fa1487 100644 --- a/extern/audaspace/bindings/C/AUD_Special.cpp +++ b/extern/audaspace/bindings/C/AUD_Special.cpp @@ -177,11 +177,11 @@ static void pauseSound(AUD_Handle* handle) AUD_API AUD_Handle* AUD_pauseAfter(AUD_Handle* handle, float seconds) { - std::shared_ptr<ISound> silence = std::shared_ptr<ISound>(new Silence); - std::shared_ptr<ISound> limiter = std::shared_ptr<ISound>(new Limiter(silence, 0, seconds)); - auto device = DeviceManager::getDevice(); + std::shared_ptr<ISound> silence = std::shared_ptr<ISound>(new Silence(device->getSpecs().rate)); + std::shared_ptr<ISound> limiter = std::shared_ptr<ISound>(new Limiter(silence, 0, seconds)); + std::lock_guard<ILockable> lock(*device); try diff --git a/extern/audaspace/bindings/python/PySequence.cpp b/extern/audaspace/bindings/python/PySequence.cpp index d4773c743ee..e574d76bea1 100644 --- a/extern/audaspace/bindings/python/PySequence.cpp +++ b/extern/audaspace/bindings/python/PySequence.cpp @@ -100,7 +100,7 @@ Sequence_new(PyTypeObject* type, PyObject* args, PyObject* kwds) PyDoc_STRVAR(M_aud_Sequence_add_doc, "add()\n\n" - "Adds a new entry to the scene.\n" + "Adds a new entry to the sequence.\n\n" ":arg sound: The sound this entry should play.\n" ":type sound: :class:`Sound`\n" ":arg begin: The start time.\n" @@ -151,8 +151,8 @@ Sequence_add(Sequence* self, PyObject* args, PyObject* kwds) } PyDoc_STRVAR(M_aud_Sequence_remove_doc, - "reomve()\n\n" - "Adds a new entry to the scene.\n" + "remove()\n\n" + "Removes an entry from the sequence.\n\n" ":arg entry: The entry to remove.\n" ":type entry: :class:`SequenceEntry`\n"); @@ -579,7 +579,7 @@ static PyGetSetDef Sequence_properties[] = { }; PyDoc_STRVAR(M_aud_Sequence_doc, - "This sound represents sequenced entries to play a sound scene."); + "This sound represents sequenced entries to play a sound sequence."); extern PyTypeObject SoundType; diff --git a/extern/audaspace/bindings/python/PySound.cpp b/extern/audaspace/bindings/python/PySound.cpp index 17fcdbeb938..c589e7110cb 100644 --- a/extern/audaspace/bindings/python/PySound.cpp +++ b/extern/audaspace/bindings/python/PySound.cpp @@ -470,14 +470,22 @@ Sound_sawtooth(PyTypeObject* type, PyObject* args) } PyDoc_STRVAR(M_aud_Sound_silence_doc, - "silence()\n\n" + "silence(rate=48000)\n\n" "Creates a silence sound which plays simple silence.\n\n" + ":arg rate: The sampling rate in Hz. It's recommended to set this " + "value to the playback device's samling rate to avoid resamping.\n" + ":type rate: int\n" ":return: The created :class:`Sound` object.\n" ":rtype: :class:`Sound`"); static PyObject * -Sound_silence(PyTypeObject* type) +Sound_silence(PyTypeObject* type, PyObject* args) { + double rate = 48000; + + if(!PyArg_ParseTuple(args, "|d:sawtooth", &rate)) + return nullptr; + Sound* self; self = (Sound*)type->tp_alloc(type, 0); @@ -485,7 +493,7 @@ Sound_silence(PyTypeObject* type) { try { - self->sound = new std::shared_ptr<ISound>(new Silence()); + self->sound = new std::shared_ptr<ISound>(new Silence((SampleRate)rate)); } catch(Exception& e) { @@ -1788,7 +1796,7 @@ static PyMethodDef Sound_methods[] = { {"sawtooth", (PyCFunction)Sound_sawtooth, METH_VARARGS | METH_CLASS, M_aud_Sound_sawtooth_doc }, - {"silence", (PyCFunction)Sound_silence, METH_NOARGS | METH_CLASS, + {"silence", (PyCFunction)Sound_silence, METH_VARARGS | METH_CLASS, M_aud_Sound_silence_doc }, {"sine", (PyCFunction)Sound_sine, METH_VARARGS | METH_CLASS, |