{ "info": { "author": "Andrew W. Schmeder, falkTX", "author_email": "andy@a2hd.com", "bugtrack_url": null, "classifiers": [], "description": "Note: This is currently a direct clone of the SourceForge project at http://py-jack.sourceforge.net/\n\nOriginal readme follows.\n------------------------\n\nPyJack version 0.5.2\nOriginal code by Andrew W. Schmeder , in2003\nTransport support by Il'dar Akhmetgaleev , in Jan 14 2008\nRevision and packaging by falkTX , in Feb 2010\nImplemented changes by the Clam Team , in Mar 2010\nMore Jack implementations by falkTX , in Apr 2010\n\nThis is open source software released under the GPL license.\nThe full text of this license is found in the file 'LICENSE',\nincluded with this source code package.\n\nThis software is presently distributed from http://www.a2hd.com.\nPlease check that site for the latest version.\n\n------------------------------------------------------------------------\n------------------------------------------------------------------------\nDescription:\n\n PyJack is a module written in C which exposes the Jack API to Python.\nFor information about Jack see http://jackit.sourceforge.net. This\nenables a Python program to connect to and interact with pro-audio\napplications which use the Jack Audio Server.\n\n------------------------------------------------------------------------\nPurpose:\n\n- To show that it can be done.\n\n- For programmers who want to prototype DSP and sound synthesis\nalgorithms using Numeric Python and similar tools. PyJack provides the\nmeans to capture and playback audio.\n\n- For patchbay applications; A powerful Jack patchbay can be written\nin Python using this module. This is planned for the future.\n\n------------------------------------------------------------------------\nInstallation:\n\n This package uses the excellent and simple Python distutils.\n Installation is very simple. It works something like this;\n \n# tar -xzvf pyjack-0.*.tar.gz (unpack archive)\n# cd pyjack-0.* (cd to source dir)\n# (sudo) python setup.py install (install...)\n\n------------------------------------------------------------------------\nDemos:\n\n Demos can be found in the \"demos\" directory\n \n------------------------------------------------------------------------\nRealtime Issues:\n\n Python is known to be relatively slow (compared to C/C++),\nand non-realtime due to memory management details. Because of this,\nPython is -NOT- a suitable language for realtime audio processing!\nThis means that it is unacceptable to place the Python intepreter \n\"inside\" of a Jack client. \n PyJack therefore uses a \"semi-detached\" method. The PyJack \nclient consists of two threads; a Jack client thread and a Python\nthread. The Jack client thread is run in realtime context; it never\nblocks, it is entirely deterministic, and does not touch any Python\ndata structures nor the interpreter. The Jack client thread merely\ncopies audio data in/out of socket buffers. On the Python side,\ncalls to jack.process() copy audio data in/out of the other end of\nthose sockets providing the connection to Python via Numeric arrays\nof floats. In any case, use of a large buffer size (e.g. 1024 samples)\nis recommended.\n In order to capture or playback audio without missing a block,\nPython must call jack.process() at least once every 500*(N/Sr)\nmilliseconds. (N = jack.get_buffer_size(), Sr = jack.get_sample_rate()).\nIf this rate is not kept up, you may get jack.InputSyncError or \njack.OutputSyncError exceptions thrown by jack.process().\n Typically you will want to use the following design for a DSP\nprototyping program:\n\n 1. Attach to the jack server (jack.attach)\n Create input and output ports (jack.register_port)\n Connect inputs and outputs to jack graph (jack.connect)\n Activate client (jack.activate)\n 2. Preallocate matricies for input and output audio data\n 3. Capture X seconds of audio (jack.process)\n 4. Process audio using your algorithm\n It does not matter how long this takes...\n 5. Playback X seconds of audio (jack.process)\n 6. Detach from jack server (jack.detach)\n\n See the example code to get started; testtone.py and capture.py.\n\n------------------------------------------------------------------------\n------------------------------------------------------------------------\n------------------------------------------------------------------------\nModule Documentation and Usage Examples:\n\nExample: Importing the module:\n>>> import jack\n>>> dir(jack)\n['CanMonitor', ... ]\n>>> print jack.attach.__doc__\nAttach client to the Jack server\n\n------------------------------------------------------------------------\nExceptions Thrown by the Jack module:\n\n These are called jack.Error, jack.InputSyncError, etc.\n \njack.Error:\n A general exception thrown when things go wrong. Usually something \n bad, like \"can't connect to server\", or \"failed to connect ports\"\n\njack.NotConnectedError:\n Thrown when you try to access a jack API function before the client \n has been attached. \n\njack.UsageError:\n Thrown when you are misusing the PyJack API. For example, trying to \n call jack.activate() when the client has already been activated.\n\njack.InputSyncError:\njack.OutputSyncError:\n Often the low level jack client thread is not synchronized with the \n Python side. This exception will be thrown to warn you that there a \n potential synchronization problem. jack.OutputSyncError is extremely \n uncommon, you should not ever see that error. jack.InputSyncError is \n very common, for example if you have activated the client but do not \n start calling jack.process() immediately.\n\n>>> import jack\n>>> import time\n>>> jack.attach(\"test\")\n... etc\n>>> jack.activate()\n>>> time.sleep(1)\n>>> jack.process(output, input)\n\n Here you will get a InputSyncError, because you have been sleeping \n for 1 second, the data in the audio buffer is about 1 second old. \n In other words, the input stream has been stopped for 1 second, \n holding old data. In spite of getting this error, you _will_ get \n the old audio data in your input array.\n\n Say that you want to write a monitoring application in Python; Now, \n having a toolkit running along with audio processing in realtime is \n nearly impossible (I've tried it; there is just not enough time to \n redraw the screen without getting an InputSyncError). Basically what \n you will want to do is only call jack.process() a few times per \n second (say 5 times per second). Each time you call jack.process() \n it will throw an InputSyncError, but you know that the audio data is \n at most 1/5th of a second old; that is probably good enough for a \n very simple metering of the input without making the GUI requirements \n too extreme.\n\n------------------------------------------------------------------------\nJack Port Flags:\n\njack.IsInput\njack.IsOutput\njack.CanMonitor\njack.IsPhysical\njack.IsTerminal\n\n These are bit flags which indicate the properties of Jack ports. Use \n the bitwise operators (| and &) with them; \n \nExample:\n>>> print jack.get_port_flags('alsa_pcm:capture_1')\n22\n>>> print (jack.get_port_flags('alsa_pcm:capture_1') & jack.IsInput) > 0\n0\n>>> print (jack.get_port_flags('alsa_pcm:capture_1') & jack.IsOutput) > 0\n1\n>>> print (jack.get_port_flags('alsa_pcm:capture_1') & jack.IsPhysical) > 0\n1\n>>> print (jack.get_port_flags('alsa_pcm:capture_1') & jack.IsTerminal) > 0\n1\n>>> print (jack.get_port_flags('alsa_pcm:capture_1') & jack.CanMonitor) > 0\n0\n\n When creating ports, you will want to use a bitwise | of the flags;\n \n>>> jack.register_port(\"input_1\", jack.IsInput | jack.CanMonitor)\n>>> jack.register_port(\"input_1\", jack.IsOutput | jack.CanMonitor)\n\n------------------------------------------------------------------------\nFunction calls in the jack module:\n\n---\njack.attach(name)\n Attach to the jack server using the given client name.\n All other function calls in the jack module require that you call\n this function first. (otherwise you will get a NotConnectedError).\n\n>>> jack.attach(\"foo_client\")\n\n---\njack.detach()\n Detach from the jack server\n \n>>> jack.detach()\n>>> jack.get_sample_rate()\nTraceback (most recent call last):\n File \"\", line 1, in ?\njack.NotConnectedError: Jack connection has not yet been established.\n\n---\njack.register_port(name, flags)\n Create a new port for this client with the given flags.\n Once a port is created it cannot be 'unregistered'.\n (The Jack API does permit this, but the PyJack module does not support it.)\n\n---\njack.activate()\n Enables callbacks to the realtime jack thread.\n This must be called before jack.process() is used.\n Enabling the realtime thread has minimal CPU overhead.\n \n---\njack.deactivate()\n Disables Jack callbacks to the realtime thread.\n Opposite of jack.activate()\n jack.process() cannot be used after jack.deactivate() is called,\n until jack.activate() is called again.\n\n---\njack.process()\n This function exchanges audio between Python and the realtime jack thread.\n \n It requires two arguments, which are both 2D Numeric Python arrays.\n The arrays -must- be of type 'Float'. The size in the first dimenision\n must match the number of inputs or outputs, and the size of the second\n dimension must match the buffer size. See capture.py and testtone.py\n for examples of how this works. Following is a part of the code from\n testtone.py. In this example there is only one input port and one output\n port. input.shape = (1, 1024), output.shape = (1, 144000).\n Notice that process will modify entries in the input array.\n\ninput = Numeric.zeros((1,N), 'f') # note the float type here...\noutput = Numeric.reshape(\n Numeric.sin(\n 2*Numeric.pi*440.0 * (Numeric.arange(0, sec, 1.0/(Sr), 'f')[0:int(Sr*sec)])\n ), (1, Sr*sec)).astype('f')\n\ni = 0\nwhile i < output.shape[1] - N:\n try:\n jack.process(output[:,i:i+N], input)\n i += N\n except jack.InputSyncError:\n pass\n except jack.OutputSyncError:\n pass\n\n---\njack.get_ports()\n Returns a list of all registered ports in the Jack graph.\n The name of a port looks like: \"client_name:port_name\"\n\n>>> jack.get_ports()\n['alsa_pcm:capture_1', 'alsa_pcm:capture_2', 'alsa_pcm:capture_3', ... ]\n\n---\njack.get_port_flags()\n Returns an integer which is the bitwise-or of all flags for a given port.\n\n>>> jack.get_port_flags('alsa_pcm:playback_6')\n21\n\n---\njack.get_connections()\n Returns a list of ports connected to the given port.\n If nothing is connected, returns a list of length zero.\n \n>>> jack.get_connections('alsa_pcm:capture_1')\n['foo_client:input_1']\n\n---\njack.connect(source, destination)\n Connect two ports on the Jack graph.\n Note that source must have the IsOutput flag, and\n destination must have the IsInput flag.\n If you want to recieve or send audio, you must\n connect your client's inputs/outputs (those\n ports registered via jack.register_port()) to\n something else which is generating or recieving\n audio, e.g. the alsa_pcm ports.\n You can connect ports which belong to other clients\n as well, e.g. for a patchbay application.\n \n At the time of writing, there is a bug in the Jack\n API which causes audio data to be missing from\n input buffers if ports are connected before \n jack.activate() is called. Until this is fixed,\n please make sure that you call jack.activate() \n prior to using jack.connect().\n \n---\njack.disconnect(source, destination)\n Break a connection established by jack.connect().\n \n---\njack.get_buffer_size()\n Returns the current buffer size used by the Jack server.\n If this number is small you may have a lot of synchronization problems.\n \n---\njack.get_sample_rate()\n Returns the current sample rate used by the Jack server.\n \n---\njack.check_events()\n Check if any asynchronous event callbacks have been raised since\n the last call to jack.check_events().\n Use of this function does -NOT- require that you be presently attached\n to the Jack server; however the values will not change unless you are!\n\n>>> jack.check_events()\n{'graph_ordering': 0, 'shutdown': 0, 'port_registration': 0, 'hangup': 0}\n\nIf graph_ordering == 1:\n Then a pair of ports somewhere in the jack graph has been connected or \ndisconnected.\n\nIf port_registration == 1:\n Then a port has been added or removed from the jack graph.\n \nIf shutdown == 1:\n Then the Jack server has shutdown; your client is no longer attached.\n \nIf hangup == 1:\n Then the Jack server decided to kill the PyJack client for some reason;\n the client is no longer attached.\n \n Any flag which is raised is immediatly reset to zero when this \n function is called.\n \n------------------------------------------------------------------------\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://www.a2hd.com/software", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "py-jack", "package_url": "https://pypi.org/project/py-jack/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/py-jack/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://www.a2hd.com/software" }, "release_url": "https://pypi.org/project/py-jack/0.5.2/", "requires_dist": null, "requires_python": null, "summary": "Python bindings for the Jack Audio Server", "version": "0.5.2" }, "last_serial": 920309, "releases": { "0.5.1": [], "0.5.2": [ { "comment_text": "", "digests": { "md5": "4e239927913f65b4752f2c4ff8aad105", "sha256": "67951f7b78ded52f3191a5267cd917f1270a6abe28341ccb3575bdd482488590" }, "downloads": -1, "filename": "py-jack-0.5.2.tar.gz", "has_sig": false, "md5_digest": "4e239927913f65b4752f2c4ff8aad105", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13490, "upload_time": "2013-11-15T10:21:10", "url": "https://files.pythonhosted.org/packages/55/4e/9898b87140f02f672b23d004c223eeb9c16d79d94b5ae44358bef8140356/py-jack-0.5.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4e239927913f65b4752f2c4ff8aad105", "sha256": "67951f7b78ded52f3191a5267cd917f1270a6abe28341ccb3575bdd482488590" }, "downloads": -1, "filename": "py-jack-0.5.2.tar.gz", "has_sig": false, "md5_digest": "4e239927913f65b4752f2c4ff8aad105", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13490, "upload_time": "2013-11-15T10:21:10", "url": "https://files.pythonhosted.org/packages/55/4e/9898b87140f02f672b23d004c223eeb9c16d79d94b5ae44358bef8140356/py-jack-0.5.2.tar.gz" } ] }