libcsound 1.0.2__tar.gz → 1.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {libcsound-1.0.2 → libcsound-1.0.3}/PKG-INFO +1 -1
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/api7.py +76 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/common.py +1 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/PKG-INFO +1 -1
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/scm_version.json +2 -2
- {libcsound-1.0.2 → libcsound-1.0.3}/.github/workflows/test.yml +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/AGENTS.md +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/LICENSE +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/MANIFEST.in +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/README.rst +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/cmake/csound-custom-macos.cmake +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/Makefile +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/_static/custom.css +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/conf.py +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/csound7.rst +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/index.rst +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/introduction.rst +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/make.bat +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/01-Introduction.ipynb +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/02-Threading.ipynb +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/no-queue.png +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/no-queue.wav +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/threading-example1.mp3 +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/threading-example2.mp3 +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/with-queue.wav +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks.rst +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/docs/requirements.txt +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/__init__.py +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/_dll.py +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/_install.py +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/_util.py +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/data/getcsound.ps1 +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/data/getcsound.sh +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/py.typed +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/SOURCES.txt +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/dependency_links.txt +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/requires.txt +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/scm_file_list.json +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/top_level.txt +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/pyproject.toml +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/setup.cfg +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/actions-test1.py +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/actionstest.csd +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/bufferInOut.csd +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/check-installer-sync.py +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/linux-install-render.py +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/macos-install-render.py +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/numpfields.csd +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/simple1.csd +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/simple2.csd +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/test-numpfields.py +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/test0.py +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/test1.py +0 -0
- {libcsound-1.0.2 → libcsound-1.0.3}/test/windows-install-render.py +0 -0
|
@@ -551,6 +551,37 @@ _scoreEventToTypenum = {
|
|
|
551
551
|
'e': CS_END_EVENT}
|
|
552
552
|
|
|
553
553
|
|
|
554
|
+
def channelCallbackValue(value_ptr: int, type_ptr: int) -> float | str | None:
|
|
555
|
+
"""Convert a value received in a channel callback to a Python value.
|
|
556
|
+
|
|
557
|
+
This is the module-level counterpart of
|
|
558
|
+
:meth:`Csound.channelCallbackValue` and does not require a
|
|
559
|
+
:class:`Csound` instance: the type of the value is read from the type
|
|
560
|
+
structure pointed to by ``type_ptr``.
|
|
561
|
+
|
|
562
|
+
- control ('k') and init ('i') values are returned as a ``float``
|
|
563
|
+
- string ('S') values are returned as a ``str``
|
|
564
|
+
- any other type (e.g. audio vectors or arrays, which are not passed by
|
|
565
|
+
the ``invalue``/``outvalue`` opcodes) returns ``None``
|
|
566
|
+
|
|
567
|
+
Args:
|
|
568
|
+
value_ptr: the value pointer passed to the callback
|
|
569
|
+
type_ptr: the channel type pointer passed to the callback
|
|
570
|
+
|
|
571
|
+
Returns:
|
|
572
|
+
the value as a Python object, or None if the type is unsupported
|
|
573
|
+
"""
|
|
574
|
+
# CS_TYPE starts with its var type name ("k", "i", "S", ...); read it
|
|
575
|
+
# directly so that no Csound instance / type pool lookup is needed.
|
|
576
|
+
typename = ct.c_char_p.from_address(type_ptr).value
|
|
577
|
+
if typename in (b'k', b'i'):
|
|
578
|
+
return ct.cast(value_ptr, MYFLT_p).contents.value
|
|
579
|
+
if typename == b'S':
|
|
580
|
+
s = ct.cast(value_ptr, ct.c_char_p).value
|
|
581
|
+
return pstring(s) if s else ''
|
|
582
|
+
return None
|
|
583
|
+
|
|
584
|
+
|
|
554
585
|
# --------------------------------------------------------------------------------
|
|
555
586
|
|
|
556
587
|
|
|
@@ -2283,6 +2314,51 @@ class Csound:
|
|
|
2283
2314
|
self._outputChannelCallback = CHANNELFUNC(function)
|
|
2284
2315
|
libcsound.csoundSetOutputChannelCallback(self.cs, self._outputChannelCallback)
|
|
2285
2316
|
|
|
2317
|
+
def channelCallbackValue(self, value_ptr: int, type_ptr: int) -> float | str | None:
|
|
2318
|
+
"""Convert a value received in a channel callback to a Python value.
|
|
2319
|
+
|
|
2320
|
+
The input/output channel callbacks set with
|
|
2321
|
+
:meth:`setInputChannelCallback` / :meth:`setOutputChannelCallback`
|
|
2322
|
+
receive, besides the channel name, a pointer to the value
|
|
2323
|
+
(``value_ptr``) and a pointer to the type of that value
|
|
2324
|
+
(``type_ptr``). This method converts that pair to the corresponding
|
|
2325
|
+
Python value:
|
|
2326
|
+
|
|
2327
|
+
- control ('k') and init ('i') values are returned as a ``float``
|
|
2328
|
+
- string ('S') values are returned as a ``str``
|
|
2329
|
+
|
|
2330
|
+
Any other type (e.g. audio vectors or arrays, which are not passed by
|
|
2331
|
+
the ``invalue``/``outvalue`` opcodes) is not supported and ``None`` is
|
|
2332
|
+
returned.
|
|
2333
|
+
|
|
2334
|
+
Args:
|
|
2335
|
+
value_ptr: the value pointer passed to the callback
|
|
2336
|
+
type_ptr: the channel type pointer passed to the callback
|
|
2337
|
+
|
|
2338
|
+
Returns:
|
|
2339
|
+
the value as a Python object, or None if the type is unsupported
|
|
2340
|
+
|
|
2341
|
+
.. note::
|
|
2342
|
+
|
|
2343
|
+
This is a thin wrapper around the module-level
|
|
2344
|
+
:func:`channelCallbackValue`, which can be used when no
|
|
2345
|
+
:class:`Csound` instance is at hand.
|
|
2346
|
+
|
|
2347
|
+
.. rubric:: Example
|
|
2348
|
+
|
|
2349
|
+
.. code-block:: python
|
|
2350
|
+
|
|
2351
|
+
cs = Csound()
|
|
2352
|
+
cs.compileOrc(...)
|
|
2353
|
+
|
|
2354
|
+
def outvalue(csnd, name, value_ptr, type_ptr):
|
|
2355
|
+
value = cs.channelCallbackValue(value_ptr, type_ptr)
|
|
2356
|
+
print(name.decode(), repr(value))
|
|
2357
|
+
|
|
2358
|
+
cs.setOutputChannelCallback(outvalue)
|
|
2359
|
+
"""
|
|
2360
|
+
return channelCallbackValue(value_ptr, type_ptr)
|
|
2361
|
+
|
|
2286
2362
|
def event(self, kind: str, pfields: _t.Sequence[float] | np.ndarray, block=True) -> None:
|
|
2287
2363
|
"""
|
|
2288
2364
|
Send a new event.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|