Skip to content

Commit 85de0dd

Browse files
committed
Renamed 'write_audio_to_buffer' to 'queue_audio'
'write_audio_to_buffer' has been changed to 'queue_audio'. Additionally, rather than accepting a USoundWaveProcedural and a Python buffer object, it has been modified so that it is a function of a Python SoundWaveProcedural object, which takes a single argument (the audio buffer).
1 parent 36a50ff commit 85de0dd

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

Source/UnrealEnginePython/Private/UEPyAudio.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
#include "UnrealEnginePythonPrivatePCH.h"
22
#include "Sound/SoundWaveProcedural.h"
33

4-
PyObject *py_write_audio_to_buffer(ue_PyUObject *self, PyObject * args) {
4+
PyObject *py_queue_procedural_audio(ue_PyUObject *self, PyObject * args) {
55
// Writes from a Python buffer object to a USoundWaveProcedural class
66
ue_py_check(self);
77

8-
PyObject *sound_procedural;
8+
if (!self->ue_object->IsA<USoundWaveProcedural>())
9+
return PyErr_Format(PyExc_Exception, "UObject is not a USoundWaveProcedural.");
10+
11+
USoundWaveProcedural *sound_wave_procedural = (USoundWaveProcedural *)self->ue_object;
912
Py_buffer sound_buffer;
1013

11-
if (!PyArg_ParseTuple(args, "Oy*:write_audio_to_buffer", &sound_procedural, &sound_buffer)) {
14+
if(!PyArg_ParseTuple(args, "y*:write_audio_to_buffer", &sound_buffer)) {
1215
return NULL;
1316
}
1417

15-
// Convert to USoundWaveProcedural
16-
USoundWaveProcedural *sound_wave_procedural = ue_py_check_type<USoundWaveProcedural>(sound_procedural);
17-
if (!sound_wave_procedural)
18-
return PyErr_Format(PyExc_Exception, "Invalid procedural sound wave object.");
19-
2018
// Convert the buffer
2119
uint8 *buffer = (uint8 *)sound_buffer.buf;
22-
if (buffer == nullptr)
20+
if(buffer == nullptr)
2321
return PyErr_Format(PyExc_Exception, "Invalid sound buffer.");
2422

2523
// Add the audio to the Sound Wave's audio buffer
2624
sound_wave_procedural->QueueAudio(buffer, sound_buffer.len);
27-
25+
2826
// Clean up
2927
PyBuffer_Release(&sound_buffer);
3028

Source/UnrealEnginePython/Private/UEPyAudio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
#include "UnrealEnginePython.h"
66

7-
PyObject *py_write_audio_to_buffer(ue_PyUObject *self, PyObject * args);
7+
PyObject *py_queue_procedural_audio(ue_PyUObject *self, PyObject * args);
88
PyObject *py_ue_play_sound_at_location(ue_PyUObject *, PyObject *);

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ static PyMethodDef ue_PyUObject_methods[] = {
524524
{ "get_actor_velocity", (PyCFunction)py_ue_get_actor_velocity, METH_VARARGS, "" },
525525

526526
{ "play_sound_at_location", (PyCFunction)py_ue_play_sound_at_location, METH_VARARGS, "" },
527-
{ "write_audio_to_buffer", (PyCFunction)py_write_audio_to_buffer, METH_VARARGS, "" },
527+
{ "queue_audio", (PyCFunction)py_queue_procedural_audio, METH_VARARGS, "" },
528528

529529
{ "world_tick", (PyCFunction)py_ue_world_tick, METH_VARARGS, "" },
530530

0 commit comments

Comments
 (0)