{ "info": { "author": "Justin Engel", "author_email": "jtengel08@gmail.com", "bugtrack_url": null, "classifiers": [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3" ], "description": "# Numpy Read Write Buffer\n\nThis library was created to help store audio data in a numpy array. It allows for writing lists and numpy arrays into a circular buffer. You can read the data from the buffer with overlap to perform smooth FFTs.\nThe buffer is a wrapper around a numpy ndarray. It contains a start and end position to keep track of where to read and write the data.\n\nMain Functions:\n * clear() - Clear the length, start, and end indexes\n * get_data() - Return a copy of the data without moving indexes\n * set_data(data) - Set the data and change the shape of the buffer to this data shape\n * write(data, error) - Write data into the buffer and move the end index\n * read(amount) - Read data from the buffer and move the start index. If the amount is greater that what is in the buffer return a 0 length buffer\n\nExtra Functions to help with the start and end pointers:\n * expanding_write(data, error) - Write data into the buffer. If the data is larger than the buffer expand the buffer\n * growing_write(data) - Write data into the buffer if there is not enough space make the buffer larger\n * read_remaining(amount) - Read the amount or read all of the data available to read\n * read_overlap(amount, increment) - Read the amount of data given, but only increment the start index by the increment amount. This makes the next read, read some duplicate data (hence overlap)\n\nBuffer Control Functions:\n * maxsize - (property) change the amount of samples that can be held\n * columns - (property) Number of columns that the array contains (shape[1])\n * shape - (property) Change the shape of the buffer\n * dtype - (property) Change the data type for the numpy buffer\n * get_indexes(start, length) - Return a list of indexes for reading and writing (this makes the buffer circular)\n * move_start(amount, error) - Move the start index (read)\n * move_end(amount, error) - Move the end index (write)\n * get_available_space() - return the amount of data that the buffer can still hold\n\n\n## Example - simple example\nSimple reading and writing. See test_buffer for tests and usage.\n\n```python\nimport numpy as np\nimport np_rw_buffer\n\nbuffer = np_rw_buffer.RingBuffer(10)\n\nbuffer.write(np.arange(5))\nr = buffer.read(4)\nassert np.all(r == np.arange(4).reshape((-1, 1)))\n\n# Not enough data, don't read anything (use read_remaining or get_data)\nd = np.arange(5).reshape((-1, 1))\nbuffer.write(d)\nr = buffer.read(10)\nassert len(r) == 0\nassert len(buffer) == 6\n\nr = buffer.read()\nassert len(r) == 6\nassert np.all(r == np.vstack((d[-1:], d)))\n\nbuffer.write(np.arange(6))\n# buffer.write(np.arange(5)) # Raises an OverflowError\nbuffer.write(np.arange(5), False)\n```\n\n\n## Example - AudioFramingBuffer\nThe AudioFramingBuffer is slightly different from the RingBuffer. It has a sample_rate, seconds, and buffer_delay.\n\nIt's main differences are how it reads and writes. The start and end pointers are completely different and decoupled. \nThe start pointer can underrun the end pointer and back fills with 0's. The end pointer can overrun the start pointer.\n\n```python\nimport numpy as np\nfrom np_rw_buffer import AudioFramingBuffer\n\nbuffer = AudioFramingBuffer(2000, 1)\nbuffer.write(np.array([(i,) for i in range(10)]))\n# Buffer: [(read ptr)0, 1, 2, 3, 4, 5, 6, 7, 8, 9, (write ptr) 0, 0, 0, 0, 0]\nassert buffer._end == 10\nassert buffer._start == 0\n\n# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, (write ptr) 0, 0, 0, 0, 0] (read ptr at end)\nassert np.all(buffer.read(15) == np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0]).reshape((-1, 1)))\nassert buffer._start == 15\nassert buffer._end == 10\n\nbuffer.write(np.array([(i,) for i in range(10)])) # This will write in the position after 19\n# Buffer: [0, 0, 0, 0, 0, 0, 0, 0, 0, (was 9) 0, 0, 1, 2, 3, 4, (read ptr) 5, 6, 7, 8, 9] (write ptr at end)\nassert buffer._end == 20\nassert buffer._start == 15\n\n# [5, 6, 7, 8, 9, (write ptr) 0, 0, 0, 0, 0] (read ptr at end)\nassert np.all(buffer.read(10) == np.array([5, 6, 7, 8, 9, 0, 0, 0, 0, 0]).reshape((-1, 1)))\n```", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/justengel/np_rw_buffer/archive/v1.1.7.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/justengel/np_rw_buffer", "keywords": "buffer,read write buffer,ring buffer,ring,circular buffer,circular", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "np-rw-buffer", "package_url": "https://pypi.org/project/np-rw-buffer/", "platform": "any", "project_url": "https://pypi.org/project/np-rw-buffer/", "project_urls": { "Download": "https://github.com/justengel/np_rw_buffer/archive/v1.1.7.tar.gz", "Homepage": "https://github.com/justengel/np_rw_buffer" }, "release_url": "https://pypi.org/project/np-rw-buffer/1.1.7/", "requires_dist": null, "requires_python": "", "summary": "Library to help store audio data in a circular buffer.", "version": "1.1.7" }, "last_serial": 4482592, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "21d532d6f4f864437721c926420a369a", "sha256": "117676b32d0a54ca0f5e714cac3b9f67d85387f094cf52c813a2fb7446c7cbf9" }, "downloads": -1, "filename": "np_rw_buffer-1.0.0.tar.gz", "has_sig": false, "md5_digest": "21d532d6f4f864437721c926420a369a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7755, "upload_time": "2018-05-03T12:25:56", "url": "https://files.pythonhosted.org/packages/61/dd/ee4d95a9929e621398bd7077dd65cdeb6e3aec79250ad880f516882b94a9/np_rw_buffer-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "4e4006e7fe962ddcb17d7ba75cb808b3", "sha256": "ccc4b69d592e418d60fe89dfd720f8c8f7c01b92189e8cee160302a25c9e426c" }, "downloads": -1, "filename": "np_rw_buffer-1.0.1.tar.gz", "has_sig": false, "md5_digest": "4e4006e7fe962ddcb17d7ba75cb808b3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7856, "upload_time": "2018-05-04T21:39:57", "url": "https://files.pythonhosted.org/packages/ec/81/fc80d8be07149efec24789b1be1b7862392dbf08245196cded95b9aae1f5/np_rw_buffer-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "a159bbb10249782a570e87d36c19eab3", "sha256": "d5fe1e8d58cd49d6a4365e1f853927c880b523dfa20be377880c3c007079a5fc" }, "downloads": -1, "filename": "np_rw_buffer-1.0.2.tar.gz", "has_sig": false, "md5_digest": "a159bbb10249782a570e87d36c19eab3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7761, "upload_time": "2018-05-04T22:37:22", "url": "https://files.pythonhosted.org/packages/43/c2/13d47953b4d2d57c6a0b16b40bc77dc68289dfb344e9228c92e5a2eb503c/np_rw_buffer-1.0.2.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "a191914190673510d91b45600b7cc591", "sha256": "50cd3c24b5576218193d7662cf54574ce5cddb558e8523ad5ec91922488bf653" }, "downloads": -1, "filename": "np_rw_buffer-1.1.0.tar.gz", "has_sig": false, "md5_digest": "a191914190673510d91b45600b7cc591", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10430, "upload_time": "2018-05-11T00:56:11", "url": "https://files.pythonhosted.org/packages/2b/62/2d39dfeb755dfea3133754b07139383ba772c82bf4a45d494a39cf54ac18/np_rw_buffer-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "9f347fa438ecc00f3452791ab03b9db2", "sha256": "5d44e9996abc5a6752736fb48b2f7330e4505feb3912d1a2ce18916f9e258dfb" }, "downloads": -1, "filename": "np_rw_buffer-1.1.1.tar.gz", "has_sig": false, "md5_digest": "9f347fa438ecc00f3452791ab03b9db2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10420, "upload_time": "2018-05-12T12:23:51", "url": "https://files.pythonhosted.org/packages/29/db/25a1e553c30982da584e1574b1b75a22f8c9991abf3b784878a6d5851723/np_rw_buffer-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "c6a2e6ece6797b5a3bef24c3b317e40f", "sha256": "ef3f6ecee5e1178256b431b14a8267504678c4778ca038ee987b2e36be2b1e04" }, "downloads": -1, "filename": "np_rw_buffer-1.1.2.tar.gz", "has_sig": false, "md5_digest": "c6a2e6ece6797b5a3bef24c3b317e40f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10437, "upload_time": "2018-06-18T20:44:36", "url": "https://files.pythonhosted.org/packages/4e/e9/07b7142466532f80d6d448debf99d52988e2047b49a1cb9b5f821186c558/np_rw_buffer-1.1.2.tar.gz" } ], "1.1.3": [ { "comment_text": "", "digests": { "md5": "bd6126f4cafd419d73fd1a9eb255e6c0", "sha256": "c28053989a373357192017b3b2b33b531527658d171a4ff04d94ee945598ae13" }, "downloads": -1, "filename": "np_rw_buffer-1.1.3.tar.gz", "has_sig": false, "md5_digest": "bd6126f4cafd419d73fd1a9eb255e6c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10919, "upload_time": "2018-08-28T15:44:25", "url": "https://files.pythonhosted.org/packages/24/c2/25bfa85554442367943edc89b12151e930e0d51cfd2ad0b38fb6c4609279/np_rw_buffer-1.1.3.tar.gz" } ], "1.1.4": [ { "comment_text": "", "digests": { "md5": "283b9b11bf72cec5fb74eff44edb9413", "sha256": "8573783e50c2cb24146ece0449659c492a5c8cad723bcaccfb4f7993d63bfdf8" }, "downloads": -1, "filename": "np_rw_buffer-1.1.4.tar.gz", "has_sig": false, "md5_digest": "283b9b11bf72cec5fb74eff44edb9413", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11017, "upload_time": "2018-08-28T16:48:09", "url": "https://files.pythonhosted.org/packages/f7/e6/5e42f2ab96d5490e3c2039721899cc77ab2f3f22c81142fbf3136b228976/np_rw_buffer-1.1.4.tar.gz" } ], "1.1.5": [ { "comment_text": "", "digests": { "md5": "57886a767b6228884fe33bf46114e202", "sha256": "c51bc608da80453ae5d660fdcf4725c46f5fbbcef285b317f6188b86252be4c1" }, "downloads": -1, "filename": "np_rw_buffer-1.1.5.tar.gz", "has_sig": false, "md5_digest": "57886a767b6228884fe33bf46114e202", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11100, "upload_time": "2018-10-01T22:42:43", "url": "https://files.pythonhosted.org/packages/7c/89/8b0e478a026bf5886f0acaeda13a5e5c252b1079657d2c72f76f85f73890/np_rw_buffer-1.1.5.tar.gz" } ], "1.1.6": [ { "comment_text": "", "digests": { "md5": "b5f45739331e3c45d0f80b816e0e9ca6", "sha256": "c550036cc4fd0099c75f0c131a0a217b60def6a751c79cb05a01e4e0c8e1c506" }, "downloads": -1, "filename": "np_rw_buffer-1.1.6.tar.gz", "has_sig": false, "md5_digest": "b5f45739331e3c45d0f80b816e0e9ca6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11205, "upload_time": "2018-10-08T20:18:13", "url": "https://files.pythonhosted.org/packages/de/2d/a92be741869d3d925a59243d68e25763013bf155aa6c40fe599c71958956/np_rw_buffer-1.1.6.tar.gz" } ], "1.1.7": [ { "comment_text": "", "digests": { "md5": "e01a975d51338c7732c3a2528055e4b7", "sha256": "053c828d7c0993a4a2eea0f9773140c4c3bc7dd5a1bc4d519fe494abd2840b5d" }, "downloads": -1, "filename": "np_rw_buffer-1.1.7.tar.gz", "has_sig": false, "md5_digest": "e01a975d51338c7732c3a2528055e4b7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11224, "upload_time": "2018-11-13T17:43:00", "url": "https://files.pythonhosted.org/packages/1b/b3/0e7885a12e28b4a3a5afaf86f0599863b28662ec55b0293a3e4d0893ac61/np_rw_buffer-1.1.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e01a975d51338c7732c3a2528055e4b7", "sha256": "053c828d7c0993a4a2eea0f9773140c4c3bc7dd5a1bc4d519fe494abd2840b5d" }, "downloads": -1, "filename": "np_rw_buffer-1.1.7.tar.gz", "has_sig": false, "md5_digest": "e01a975d51338c7732c3a2528055e4b7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11224, "upload_time": "2018-11-13T17:43:00", "url": "https://files.pythonhosted.org/packages/1b/b3/0e7885a12e28b4a3a5afaf86f0599863b28662ec55b0293a3e4d0893ac61/np_rw_buffer-1.1.7.tar.gz" } ] }