{"id":13419405,"url":"https://github.com/marcecj/faust_python","last_synced_at":"2026-01-11T10:40:44.944Z","repository":{"id":149653917,"uuid":"9736641","full_name":"marcecj/faust_python","owner":"marcecj","description":"A Python FAUST wrapper implemented using the CFFI.","archived":false,"fork":false,"pushed_at":"2015-06-20T10:06:20.000Z","size":488,"stargazers_count":31,"open_issues_count":2,"forks_count":6,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-09-22T08:47:45.101Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcecj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-28T21:32:34.000Z","updated_at":"2024-09-04T10:24:21.000Z","dependencies_parsed_at":"2023-04-01T07:09:17.605Z","dependency_job_id":null,"html_url":"https://github.com/marcecj/faust_python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcecj%2Ffaust_python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcecj%2Ffaust_python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcecj%2Ffaust_python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcecj%2Ffaust_python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcecj","download_url":"https://codeload.github.com/marcecj/faust_python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243690113,"owners_count":20331726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:01:15.540Z","updated_at":"2025-03-15T05:31:10.470Z","avatar_url":"https://github.com/marcecj.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# FAUSTPy\nMarc Joliet \u003cmarcec@gmx.de\u003e\n\nA FAUST wrapper for Python.\n\n## Introduction\n\nFAUSTPy is a Python wrapper for the [FAUST](http://faust.grame.fr/) DSP\nlanguage. It is implemented using the [CFFI](https://cffi.readthedocs.org/) and\nhence creates the wrapper dynamically at run-time.\n\n## Installation\n\nFAUSTPy has the following requirements:\n\n- [FAUST](http://faust.grame.fr/), specifically the FAUST2 branch, because\n  FAUSTPy requires the C backend.\n- [CFFI](https://cffi.readthedocs.org/), tested with version 0.6.\n- A C compiler; the default CFLAGS assume a GCC compatible one.\n- [NumPy](http://numpy.scipy.org/), tested with version 1.6.\n\nFAUSTPy works with Python 2.7 and 3.2+.\n\nYou can install FAUSTPy via the provided setup.py script by running\n\n    sudo python setup.py install\n\nor\n\n    python setup.py install --user\n\nAlthough you may want to verify that everything works beforehand by running the\ntest suite first:\n\n    python setup.py test\n\n## Useage\n\nUsing FAUSTPy is fairly simple, the main class is FAUSTPy.FAUST, which takes\ncare of the dirty work.  A typical example:\n\n    dsp = FAUSTPy.FAUST(\"faust_file.dsp\", fs)\n\nThis will create a wrapper that initialises the FAUST DSP with the sampling rate\n`fs` and with `FAUSTFLOAT` set to the default value of `float` (the default\nprecision that is set by the FAUST compiler).  Note that this\n\n1. compiles the FAUST DSP to C,\n2. compiles and links the C code, and\n3. initialises the C objects,\n\nall of which happens in the background, thanks to the CFFI.  Furthermore, this\nwrapper class\n\n1. initialises the UI as a `ui` attribute of the DSP, and\n2. stores the meta-data declared by the DSP as a `metadata` attribute.\n\nTo better match the [NumPy](http://numpy.scipy.org/) default of `double`, you\ncan overload the `faust_float` argument:\n\n    dsp = FAUSTPy.FAUST(\"faust_file.dsp\", fs, \"double\")\n\nTo process an array, simply call:\n\n    # dsp.dsp is a PythonDSP object wrapped by the FAUST object\n    audio = numpy.zeros((dsp.dsp.num_in, count))\n    audio[:,0] = 1\n    out = dsp.compute(audio)\n\nHere the array `audio` is initialised to the number of inputs of the DSP and\n`count` samples; each channel consists of a Kronecker delta, so `out` contains\nthe impulse response of the DSP.  In general `audio` is allowed to have more\nchannels (rows) than the DSP, in which case the first `dsp.dsp.num_in` channels\nare processed, but not less.\n\nYou can also pass in-line FAUST code as the first argument, which will be\nwritten to a temporary file and compiled by FAUST as usual.  In Python 3:\n\n    dsp = FAUSTPy.FAUST(b\"process = _:*(0.5);\", fs)\n\nFinally, below is a simple IPython example (using Python 2) that shows what a\nFAUST object might look like.  It is based on the DSP\n`dattorro_notch_cut_regalia.dsp` included in this repository.\n\n    In [1]: import FAUSTPy\n\n    In [2]: import numpy as np\n\n    In [3]: fs = 48000\n\n    In [4]: dattorro = FAUSTPy.FAUST(\"dattorro_notch_cut_regalia.dsp\", fs, \"double\")\n\n    In [5]: dattorro.\n    dattorro.compute      dattorro.dsp          dattorro.FAUST_PATH\n    dattorro.compute2     dattorro.FAUST_FLAGS\n\n    In [5]: dattorro.dsp.\n    dattorro.dsp.compute     dattorro.dsp.faustfloat  dattorro.dsp.num_out\n    dattorro.dsp.compute2    dattorro.dsp.fs          dattorro.dsp.ui\n    dattorro.dsp.dsp         dattorro.dsp.metadata\n    dattorro.dsp.dtype       dattorro.dsp.num_in\n\n    In [5]: dattorro.dsp.metadata\n    Out[5]:\n    {'author': 'Marc Joliet',\n     'copyright': '(c)Marc Joliet 2013',\n     'filter.lib/author': 'Julius O. Smith (jos at ccrma.stanford.edu)',\n     'filter.lib/copyright': 'Julius O. Smith III',\n     'filter.lib/license': 'STK-4.3',\n     'filter.lib/name': 'Faust Filter Library',\n     'filter.lib/reference': 'https://ccrma.stanford.edu/~jos/filters/',\n     'filter.lib/version': '1.29',\n     'license': 'MIT',\n     'math.lib/author': 'GRAME',\n     'math.lib/copyright': 'GRAME',\n     'math.lib/license': 'LGPL with exception',\n     'math.lib/name': 'Math Library',\n     'math.lib/version': '1.0',\n     'music.lib/author': 'GRAME',\n     'music.lib/copyright': 'GRAME',\n     'music.lib/license': 'LGPL with exception',\n     'music.lib/name': 'Music Library',\n     'music.lib/version': '1.0',\n     'name': 'Dattoro notch filter and resonator (Regalia)',\n     'version': '0.1'}\n\n    In [6]: dattorro.dsp.fs\n    Out[6]: 48000\n\n    In [7]: dattorro.dsp.num_in\n    Out[7]: 2\n\n    In [8]: dattorro.dsp.num_out\n    Out[8]: 2\n\n    In [9]: dattorro.dsp.ui.\n    dattorro.dsp.ui.label          dattorro.dsp.ui.metadata       dattorro.dsp.ui.p_Gain\n    dattorro.dsp.ui.layout         dattorro.dsp.ui.p_Center_Freq  dattorro.dsp.ui.p_Q\n\n    In [9]: dattorro.dsp.ui.label\n    Out[9]: 'dattorro_notch_cut_regalia'\n\n    In [10]: dattorro.dsp.ui.layout\n    Out[10]: 'vertical'\n\n    In [11]: dattorro.dsp.ui.p_Center_Freq\n    Out[11]: \u003cFAUSTPy.python_ui.Param at 0x31617d0\u003e\n\n    In [12]: dattorro.dsp.ui.p_Center_Freq.\n    dattorro.dsp.ui.p_Center_Freq.default   dattorro.dsp.ui.p_Center_Freq.min\n    dattorro.dsp.ui.p_Center_Freq.label     dattorro.dsp.ui.p_Center_Freq.step\n    dattorro.dsp.ui.p_Center_Freq.max       dattorro.dsp.ui.p_Center_Freq.type\n    dattorro.dsp.ui.p_Center_Freq.metadata  dattorro.dsp.ui.p_Center_Freq.zone\n\n    In [12]: dattorro.dsp.ui.p_Center_Freq.label\n    Out[12]: 'Center Freq.'\n\n    In [13]: dattorro.dsp.ui.p_Center_Freq.metadata\n    Out[13]: {'unit': 'Hz'}\n\n    In [14]: dattorro.dsp.ui.p_Center_Freq.type\n    Out[14]: 'HorizontalSlider'\n\n    In [15]: audio = np.zeros((dattorro.dsp.num_in,fs), dtype=dattorro.dsp.dtype)\n\n    In [16]: audio[:,0] = 1\n\n    In [17]: audio\n    Out[17]:\n    array([[ 1.,  0.,  0., ...,  0.,  0.,  0.],\n           [ 1.,  0.,  0., ...,  0.,  0.,  0.]])\n\n    In [18]: dattorro.compute(audio)\n    Out[18]:\n    array([[ 0.74657288, -0.30020767,  0.0227801 , ...,  0.        ,\n             0.        ,  0.        ],\n           [ 0.74657288, -0.30020767,  0.0227801 , ...,  0.        ,\n             0.        ,  0.        ]])\n\nFor more details, see the built-in documentation (aka `pydoc FAUSTPy`) and - if\nyou are so inclined - the source code.\n\n## Demo script\n\nThe `__main__.py` of the FAUST package contains a small demo application which\nplots some magnitude frequency responses of the example FAUST DSP.  You can\nexecute it by executing\n\n    PYTHONPATH=. python FAUSTPy\n\nin the source directory.  This will display four plots:\n\n- the magnitude frequency response of the FAUST DSP at default settings,\n- the magnitude frequency response with varying Q,\n- the magnitude frequency response with varying gain, and\n- the magnitude frequency response with varying center frequency.\n\n## TODO\n\n- finish the UIGlue wrapper\n- finish the test suite\n  - finish the unit tests\n  - add functional tests so that you can test how everything works together\n    (perhaps use \"UITester.dsp\" and maybe one other DSP from the examples)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcecj%2Ffaust_python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcecj%2Ffaust_python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcecj%2Ffaust_python/lists"}