{"id":18352745,"url":"https://github.com/membraneframework/membrane_portaudio_plugin","last_synced_at":"2025-12-12T00:10:36.632Z","repository":{"id":39995775,"uuid":"80109989","full_name":"membraneframework/membrane_portaudio_plugin","owner":"membraneframework","description":"Raw audio retriever and player based on PortAudio","archived":false,"fork":false,"pushed_at":"2024-07-11T10:14:48.000Z","size":439,"stargazers_count":4,"open_issues_count":1,"forks_count":5,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-04T01:15:59.323Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/membraneframework.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-26T11:45:14.000Z","updated_at":"2024-07-11T10:09:25.000Z","dependencies_parsed_at":"2023-07-16T07:52:10.742Z","dependency_job_id":"9ad5c369-2262-4a02-9886-532311c14bd0","html_url":"https://github.com/membraneframework/membrane_portaudio_plugin","commit_stats":{"total_commits":129,"total_committers":16,"mean_commits":8.0625,"dds":0.5891472868217054,"last_synced_commit":"89bc11569b49804678da4b1c15d9553220686814"},"previous_names":["membraneframework/membrane-element-portaudio"],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membraneframework%2Fmembrane_portaudio_plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membraneframework%2Fmembrane_portaudio_plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membraneframework%2Fmembrane_portaudio_plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membraneframework%2Fmembrane_portaudio_plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/membraneframework","download_url":"https://codeload.github.com/membraneframework/membrane_portaudio_plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247103305,"owners_count":20884023,"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-11-05T21:37:08.181Z","updated_at":"2025-12-12T00:10:36.598Z","avatar_url":"https://github.com/membraneframework.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Membrane PortAudio plugin\n\n[![Hex.pm](https://img.shields.io/hexpm/v/membrane_portaudio_plugin.svg)](https://hex.pm/packages/membrane_portaudio_plugin)\n[![API Docs](https://img.shields.io/badge/api-docs-yellow.svg?style=flat)](https://hexdocs.pm/membrane_portaudio_plugin/)\n[![CircleCI](https://circleci.com/gh/membraneframework/membrane_portaudio_plugin.svg?style=svg)](https://circleci.com/gh/membraneframework/membrane_portaudio_plugin)\n\nThe plugin that captures and plays sound using the multiplatform PortAudio library.\n\n## Installation\n\nAdd the following line to your `deps` in `mix.exs`. Run `mix deps.get`.\n\n```elixir\n{:membrane_portaudio_plugin, \"~\u003e 0.19.3\"}\n```\n\nThis package depends on the [PortAudio](http://portaudio.com/) library. The precompiled build will be pulled and linked automatically. However, should there be any problems, consider installing it manually.\n\nWhen running on linux [ALSA (alsa-lib)](https://github.com/alsa-project/alsa-lib) needs to be present on the system for the precompiled build to work. In most cases it's installed by default, however in case it's not present you can install it manually.\n\n### Manual instalation of dependencies\n#### Ubuntu\n\n```bash\nsudo apt-get install alsa\n```\n```bash\nsudo apt-get install portaudio19-dev\n```\n\n#### Arch/Manjaro\n\n```bash\npacman -S alsa-lib\n```\n```bash\npacman -S portaudio\n```\n\n#### MacOS\n\n```bash\nbrew install portaudio\n```\n\n## Tasks\n\nThe `mix pa_devices` task prints available audio devices and their IDs, which you can pass to the `Membrane.PortAudio.Source` or `Membrane.PortAudio.Sink`.\n\n## Sample usage\n\nThe pipeline below should play a raw file to a default output device.\n\n```elixir\ndefmodule Example.Pipeline do\n  use Membrane.Pipeline\n\n  alias Membrane.PortAudio\n\n  @impl true\n  def handle_init(_ctx, _opts) do\n    structure = \n      child(:file_src, %Membrane.Element.File.Source{location: \"file.raw\"})\n      |\u003e child(:pa_sink, PortAudio.Sink)\n    \n    {[spec: structure], %{}}\n  end\nend\n\nMembrane.Pipeline.start_link(Example.Pipeline)\nProcess.sleep(:infinity)\n```\n\nAnd this one should forward sound from the default input to the default output. DO NOT USE WITHOUT HEADPHONES to avoid audio feedback.\n\n```elixir\ndefmodule Example.Pipeline do\n  use Membrane.Pipeline\n\n  alias Membrane.PortAudio\n\n  @impl true\n  def handle_init(_ctx, _opts) do\n    structure =\n      child(:pa_src, PortAudio.Source)\n      |\u003e child(:pa_sink, PortAudio.Sink)\n\n    {[spec: structure], %{}}\n  end\nend\n\nMembrane.Pipeline.start_link(Example.Pipeline)\nProcess.sleep(:infinity)\n```\n\n### Low latency\n\nTo reduce the latency of the sink and/or source, you can:\n- set the `latency` option to `:low` to configure the sound card in the low latency mode,\n- reduce the `portaudio_buffer_size` to make PortAudio produce/consume smaller audio chunks,\n\nfor example:\n\n```elixir\nchild(:pa_src, %PortAudio.Source{latency: :low, portaudio_buffer_size: 32})\n|\u003e child(:pa_sink, %PortAudio.Sink{latency: :low, portaudio_buffer_size: 32})\n```\n\n## Testing\n\nTests contain some cases that use PortAudio stuff instead of mocking. Such cases require the presence of at least one input and output sound card, thus they are disabled by default. To enable them, run\n```\nmix test --include soundcard\n```\n\n## Copyright and License\n\nCopyright 2018, [Software Mansion](https://swmansion.com/?utm_source=git\u0026utm_medium=readme\u0026utm_campaign=membrane-portaudio-plugin)\n\n[![Software Mansion](https://logo.swmansion.com/logo?color=white\u0026variant=desktop\u0026width=200\u0026tag=membrane-github)](https://swmansion.com/?utm_source=git\u0026utm_medium=readme\u0026utm_campaign=membrane-portaudio-plugin)\n\nLicensed under the [Apache License, Version 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmembraneframework%2Fmembrane_portaudio_plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmembraneframework%2Fmembrane_portaudio_plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmembraneframework%2Fmembrane_portaudio_plugin/lists"}