1
////////////////////////////////////////////////////////////////////////////////
3
// pySFML - Python bindings for SFML
4
// Copyright 2012-2013, Jonathan De Wachter <dewachter.jonathan@gmail.com>
6
// This software is released under the LGPLv3 license.
7
// You should have received a copy of the GNU Lesser General Public License
8
// along with this program. If not, see <http://www.gnu.org/licenses/>.
10
////////////////////////////////////////////////////////////////////////////////
13
#include "DerivableSoundRecorder.hpp"
16
DerivableSoundRecorder::DerivableSoundRecorder(void* pyobj):
18
m_pyobj (static_cast<PyObject*>(pyobj))
20
import_sfml__audio(); // make sure the audio module is imported
23
bool DerivableSoundRecorder::onStart()
27
static char method[] = "on_start";
28
PyObject* r = PyObject_CallMethod(m_pyobj, method, NULL);
30
return PyObject_IsTrue(r);
33
bool DerivableSoundRecorder::onProcessSamples(const sf::Int16* samples, std::size_t sampleCount)
35
static char method[] = "on_process_samples";
36
static char format[] = "O";
38
PyGILState_STATE gstate;
39
gstate = PyGILState_Ensure();
41
PyObject* pyChunk = (PyObject*)(wrap_chunk((sf::Int16*)samples, sampleCount, false));
42
PyObject* r = PyObject_CallMethod(m_pyobj, method, format, pyChunk);
45
PyGILState_Release(gstate);
47
return PyObject_IsTrue(r);
50
void DerivableSoundRecorder::onStop()
52
PyGILState_STATE gstate;
53
gstate = PyGILState_Ensure();
55
static char method[] = "on_stop";
56
PyObject_CallMethod(m_pyobj, method, NULL);
58
PyGILState_Release(gstate);