Blender V5.3
bpy_audaspace.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009-2011 Jörg Hermann Müller
2 * SPDX-FileCopyrightText: 2025 Blender Authors
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later */
5
9
10#include "bpy_audaspace.hh"
11
12#ifdef WITH_AUDASPACE_PY
13
14# include "BKE_sound.hh"
15
16# include <python/PyAPI.h>
17# include <python/PySound.h>
18
19namespace blender {
20
21static PyObject *AUD_getSoundFromPointer(PyObject * /*self*/, PyObject *args)
22{
23 PyObject *res = nullptr;
24 if (PyArg_Parse(args,
25 "O" /* `pointer` */
26 ":_sound_from_pointer",
27 &res))
28 {
29 if (res) {
30 AUD_Sound sound = BKE_sound_get_factory(PyLong_AsVoidPtr(res));
31 if (sound) {
32 Sound *obj = (Sound *)Sound_empty();
33 if (obj) {
34 obj->sound = new AUD_Sound(sound);
35 return (PyObject *)obj;
36 }
37 }
38 }
39 }
40 Py_RETURN_NONE;
41}
42
43static PyMethodDef meth_sound_from_pointer[] = {
44 {"_sound_from_pointer",
45 (PyCFunction)AUD_getSoundFromPointer,
46 METH_O,
47 "_sound_from_pointer(pointer)\n\n"
48 "Returns the corresponding :class:`Factory` object.\n\n"
49 ":param pointer: The pointer to the bSound object as long.\n"
50 ":type pointer: long\n"
51 ":return: The corresponding :class:`Factory` object.\n"
52 ":rtype: :class:`Factory`"}};
53
54PyObject *BPyInit_audaspace()
55{
56 PyObject *module = PyInit_aud();
57 if (module == nullptr) {
58 printf("Unable to initialize audio\n");
59 return nullptr;
60 }
61
62 PyModule_AddObject(
63 module, "_sound_from_pointer", PyCFunction_New(meth_sound_from_pointer, nullptr));
64 PyDict_SetItemString(PyImport_GetModuleDict(), "aud", module);
65
66 return module;
67}
68
69} // namespace blender
70
71#endif // WITH_AUDASPACE_PY
std::shared_ptr< void > AUD_Sound
BMesh Iterators.
PyObject * BPyInit_audaspace()
AUD_Sound BKE_sound_get_factory(void *sound)