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.
Files changed (54) hide show
  1. {libcsound-1.0.2 → libcsound-1.0.3}/PKG-INFO +1 -1
  2. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/api7.py +76 -0
  3. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/common.py +1 -0
  4. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/PKG-INFO +1 -1
  5. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/scm_version.json +2 -2
  6. {libcsound-1.0.2 → libcsound-1.0.3}/.github/workflows/test.yml +0 -0
  7. {libcsound-1.0.2 → libcsound-1.0.3}/AGENTS.md +0 -0
  8. {libcsound-1.0.2 → libcsound-1.0.3}/LICENSE +0 -0
  9. {libcsound-1.0.2 → libcsound-1.0.3}/MANIFEST.in +0 -0
  10. {libcsound-1.0.2 → libcsound-1.0.3}/README.rst +0 -0
  11. {libcsound-1.0.2 → libcsound-1.0.3}/cmake/csound-custom-macos.cmake +0 -0
  12. {libcsound-1.0.2 → libcsound-1.0.3}/docs/Makefile +0 -0
  13. {libcsound-1.0.2 → libcsound-1.0.3}/docs/_static/custom.css +0 -0
  14. {libcsound-1.0.2 → libcsound-1.0.3}/docs/conf.py +0 -0
  15. {libcsound-1.0.2 → libcsound-1.0.3}/docs/csound7.rst +0 -0
  16. {libcsound-1.0.2 → libcsound-1.0.3}/docs/index.rst +0 -0
  17. {libcsound-1.0.2 → libcsound-1.0.3}/docs/introduction.rst +0 -0
  18. {libcsound-1.0.2 → libcsound-1.0.3}/docs/make.bat +0 -0
  19. {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/01-Introduction.ipynb +0 -0
  20. {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/02-Threading.ipynb +0 -0
  21. {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/no-queue.png +0 -0
  22. {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/no-queue.wav +0 -0
  23. {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/threading-example1.mp3 +0 -0
  24. {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/threading-example2.mp3 +0 -0
  25. {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks/with-queue.wav +0 -0
  26. {libcsound-1.0.2 → libcsound-1.0.3}/docs/notebooks.rst +0 -0
  27. {libcsound-1.0.2 → libcsound-1.0.3}/docs/requirements.txt +0 -0
  28. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/__init__.py +0 -0
  29. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/_dll.py +0 -0
  30. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/_install.py +0 -0
  31. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/_util.py +0 -0
  32. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/data/getcsound.ps1 +0 -0
  33. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/data/getcsound.sh +0 -0
  34. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound/py.typed +0 -0
  35. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/SOURCES.txt +0 -0
  36. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/dependency_links.txt +0 -0
  37. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/requires.txt +0 -0
  38. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/scm_file_list.json +0 -0
  39. {libcsound-1.0.2 → libcsound-1.0.3}/libcsound.egg-info/top_level.txt +0 -0
  40. {libcsound-1.0.2 → libcsound-1.0.3}/pyproject.toml +0 -0
  41. {libcsound-1.0.2 → libcsound-1.0.3}/setup.cfg +0 -0
  42. {libcsound-1.0.2 → libcsound-1.0.3}/test/actions-test1.py +0 -0
  43. {libcsound-1.0.2 → libcsound-1.0.3}/test/actionstest.csd +0 -0
  44. {libcsound-1.0.2 → libcsound-1.0.3}/test/bufferInOut.csd +0 -0
  45. {libcsound-1.0.2 → libcsound-1.0.3}/test/check-installer-sync.py +0 -0
  46. {libcsound-1.0.2 → libcsound-1.0.3}/test/linux-install-render.py +0 -0
  47. {libcsound-1.0.2 → libcsound-1.0.3}/test/macos-install-render.py +0 -0
  48. {libcsound-1.0.2 → libcsound-1.0.3}/test/numpfields.csd +0 -0
  49. {libcsound-1.0.2 → libcsound-1.0.3}/test/simple1.csd +0 -0
  50. {libcsound-1.0.2 → libcsound-1.0.3}/test/simple2.csd +0 -0
  51. {libcsound-1.0.2 → libcsound-1.0.3}/test/test-numpfields.py +0 -0
  52. {libcsound-1.0.2 → libcsound-1.0.3}/test/test0.py +0 -0
  53. {libcsound-1.0.2 → libcsound-1.0.3}/test/test1.py +0 -0
  54. {libcsound-1.0.2 → libcsound-1.0.3}/test/windows-install-render.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libcsound
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: Python bindings to the Csound 7 API
5
5
  Author-email: Eduardo Moguillansky <eduardo.moguillansky@gmail.com>
6
6
  License: GNU LESSER GENERAL PUBLIC LICENSE
@@ -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.
@@ -13,6 +13,7 @@ BUILDING_DOCS = 'sphinx' in sys.modules
13
13
 
14
14
 
15
15
  MYFLT = ct.c_double
16
+ MYFLT_p = ct.POINTER(MYFLT)
16
17
 
17
18
  #
18
19
  # Opaque pointers for Csound structs
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libcsound
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: Python bindings to the Csound 7 API
5
5
  Author-email: Eduardo Moguillansky <eduardo.moguillansky@gmail.com>
6
6
  License: GNU LESSER GENERAL PUBLIC LICENSE
@@ -1,7 +1,7 @@
1
1
  {
2
- "tag": "1.0.2",
2
+ "tag": "1.0.3",
3
3
  "distance": 0,
4
- "node": "gd9fc7bc2c60734eea2e07b0c9d838e9c3b8e71bb",
4
+ "node": "gbf08cf5ff838b07f8e89ecf04eb6bfe8dc6097b6",
5
5
  "dirty": false,
6
6
  "branch": "master",
7
7
  "node_date": "2026-10-17"
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