View Source Membrane PortAudio plugin
Plugin that can be used to capture and play sound using multiplatform PortAudio library.
installation
Installation
Add the following line to your deps
in mix.exs
. Run mix deps.get
.
{:membrane_portaudio_plugin, "~> 0.12.0"}
You also need to have PortAudio installed.
sample-usage
Sample usage
Playing below pipeline should play a raw file to default output device.
defmodule Membrane.ReleaseTest.Pipeline do
use Membrane.Pipeline
alias Membrane.PortAudio
@impl true
def handle_init(_) do
children = [
file_src: %Membrane.Element.File.Source{location: "file.raw"},
pa_sink: PortAudio.Sink
]
links = [
link(:file_src)
|> to(:pa_sink)
]
{{:ok, %ParentSpec{children: children, links: links}}, %{}}
end
end
And this one should forward sound from default input to default output. DO NOT USE WITHOUT HEADPHONES to avoid audio feedback.
defmodule Membrane.ReleaseTest.Pipeline do
use Membrane.Pipeline
alias Membrane.PortAudio
@impl true
def handle_init(_) do
children = [
pa_src: PortAudio.Source,
pa_sink: PortAudio.Sink
]
links = [
link(:pa_src)
|> to(:pa_sink)
]
{{:ok, spec: %ParentSpec{children: children, links: links}}, %{}}
end
end
testing
Testing
Tests contain some cases that use portaudio stuff instead of mocking. Such cases require presence of at least one input and output soundcard, thus they are disabled by default. To enable them, run
mix test --include soundcard
copyright-and-license
Copyright and License
Copyright 2018, Software Mansion
Licensed under the Apache License, Version 2.0