{"id":16654761,"url":"https://github.com/zuzu-typ/pywave","last_synced_at":"2025-04-09T18:13:00.132Z","repository":{"id":53784495,"uuid":"204933098","full_name":"Zuzu-Typ/PyWave","owner":"Zuzu-Typ","description":"Open and read Wave files","archived":false,"fork":false,"pushed_at":"2021-03-14T11:08:25.000Z","size":696,"stargazers_count":5,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T18:12:53.613Z","etag":null,"topics":["create","easy","extension","interface","load","python","python3","read","riff","riff-wave","simple","wave","write"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zuzu-Typ.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":"2019-08-28T13:02:02.000Z","updated_at":"2023-03-06T07:23:46.000Z","dependencies_parsed_at":"2022-09-02T08:44:24.560Z","dependency_job_id":null,"html_url":"https://github.com/Zuzu-Typ/PyWave","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zuzu-Typ%2FPyWave","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zuzu-Typ%2FPyWave/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zuzu-Typ%2FPyWave/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zuzu-Typ%2FPyWave/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zuzu-Typ","download_url":"https://codeload.github.com/Zuzu-Typ/PyWave/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085327,"owners_count":21045139,"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":["create","easy","extension","interface","load","python","python3","read","riff","riff-wave","simple","wave","write"],"created_at":"2024-10-12T09:50:57.676Z","updated_at":"2025-04-09T18:13:00.104Z","avatar_url":"https://github.com/Zuzu-Typ.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyWave  \n## Open, read and write Wave files  \n**PyWave** is a small **extension** that enables you to **open** and **read** the data of any **WAVE\\-RIFF** file\\.  \nIt supports PCM, IEEE\\-FLOAT, EXTENSIBLE and a few other wave formats \\(including 32 and 64 bit waves\\)\\.  \nIt can also create and write wave files, but it's currently limited to PCM\\-Waves and pure data \\(no metadata\\)\\.  \n  \n## Tiny documentation  \n### About PyWave  \n**PyWave** is supposed to **replace** the builtin Python extension `wave`, which doesn't support \\\u003e16\\-bit wave files\\.  \n  \n### Using PyWave  \nTo install PyWave you can use the [PyPI](https://packaging.python.org/tutorials/installing-packages/):  \n\n    pip install PyWave\n  \nTo use PyWave in a script, you have to import the package `PyWave` using  \n\n    import PyWave\n  \nor a wildcard import:  \n\n    from PyWave import *\n  \n  \n  \n#### The Wave class\nYou can use `open(path)` to open and read a wave file\\.  \n  \nOr you can use  \n\n    \n    open(path[, mode = 'r', channels = 2, frequency = 48000, bits_per_sample = 16, format = WAVE_FORMAT_PCM])\n   \nwith \\\u003cmode\\\u003e set to `'w'` to open and create a writable wave file\\.  \n  \nBoth will return an instance of the `Wave` class\\.  \n  \nThe following methods are provided by the `Wave` class:  \n\n    \n    Wave.read([max_bytes = None]) -\u003e \u003cbytes\u003e data\n        Reads and returns at most \u003cmax_bytes\u003e bytes of data.\n        If \u003cmax_bytes\u003e is None, reads until the end.\n    \n    Wave.read_samples(number_of_samples) -\u003e \u003cbytes\u003e data\n        Reads and returns at most \u003cnumber_of_samples\u003e samples of data.\n        \n    Wave.write(data) -\u003e None\n        Writes \u003cdata\u003e to the data chunk of the wave file.\n        Before write can be called, the following members have to be set:\n        - Wave.channels\n        - Wave.frequency\n        - Wave.bits_per_sample\n        \n        This function can only append to the end of the data chunk,\n        thus it is not effected by 'seek()'.\n    \n    Wave.seek(offset[, whence = 0]) -\u003e None\n        Sets the current position in the data stream.\n        If \u003cwhence\u003e is 0, \u003coffset\u003e is the absolute position of the\n        data stream in bytes.\n        If \u003cwhence\u003e is 1, \u003coffset\u003e is added to the current position\n        in the data stream in bytes.\n        If \u003cwhence\u003e is 2, the position will be set to the end of\n        the file plus \u003coffset\u003e.\n        \n    Wave.tell() -\u003e \u003cint\u003e position\n        Returns the current position in the data stream.\n        \n    Wave.close() -\u003e None\n        Closes the file handle.\n  \n      \nAnd it has the following members:  \n\n    \n    Wave.format \u003cint\u003e\n        Format of the audio data. Can be any of:\n        - WAVE_FORMAT_PCM\n        - WAVE_FORMAT_IEEE_FLOAT\n        - WAVE_FORMAT_ALAW\n        - WAVE_FORMAT_MULAW\n        - WAVE_FORMAT_EXTENSIBLE\n        Otherwise the format is unknown\n        \n    Wave.channels \u003cint\u003e\n        The number of audio channels present in the audio stream\n        \n    Wave.frequency \u003cint\u003e\n        Sample rate of the audio stream\n        \n    Wave.bitrate \u003cint\u003e\n        Number of bits per second\n        \n    Wave.bits_per_sample \u003cint\u003e\n        Number of bits per sample (usually 8, 16 or 32)\n        \n    Wave.samples \u003cint\u003e\n        Total number of samples in the audio data\n        \n    Wave.data \u003cbytes\u003e\n        [Deprecated]\n        (only exists if \u003cauto_read\u003e was set to True)\n        Audio data as bytes\n        \n    Wave.metadata \u003cdict\u003e\n        A dictionary containing metadata specified in the wave file\n  \n  \n  \n  \n### Example  \n\n    \n    import PyWave\n    \n    PATH = \"path/to/a/wave/file.wav\"\n    \n    wf = PyWave.open(PATH)\n    \n    print(\"This WAVE file has the following properties:\")\n    print(wf.channels, \"channels\")\n    print(wf.frequency, \"Hz sample rate\")\n    print(wf.bitrate, \"bits per second\")\n    print(wf.samples, \"total samples\")\n    \n    wf_copy = PyWave.open(\"path/to/a/wave/file_copy.wav\", \n                          mode = \"w\",\n                          channels = wf.channels,\n                          frequency = wf.frequency,\n                          bits_per_sample = wf.bits_per_sample,\n                          format = wf.format)\n    wf_copy.write(wf.read())\n    wf.close()\n    wf_copy.close()\n\n\n#### PyTest\n\nPyTest support has been added in the form of a test_pywave.py module, in order to facilitate extensions to the module. In order to use it, one should install PyTest first by running:\n\n```\npip install -r pytest_requirements.txt\n```\n\nOnce installed, you should be able to simply run\n\n```\npytest\n```\n\nIn the repo folder, and see 2 items being collected, and 2 tests passing. \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuzu-typ%2Fpywave","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzuzu-typ%2Fpywave","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuzu-typ%2Fpywave/lists"}