Membrane Multimedia Framework: PortAudio Element
This package provides Membrane Multimedia Framework elements that can be used to capture and play sound using multiplatform PortAudio library.
Documentation is available at HexDocs.
Installation
Add the following line to your deps
in mix.exs
. Run mix deps.get
.
{:membrane_element_portaudio, "~> 0.2.6"}
You also need to have PortAudio installed.
Sample usage
Playing below pipeline should play a raw file to default output device.
defmodule Membrane.ReleaseTest.Pipeline do
use Membrane.Pipeline
alias Pipeline.Spec
alias Membrane.Element.{PortAudio, File}
@impl true
def handle_init(_) do
children = [
file_src: %File.Source{location: "file.raw"},
pa_sink: PortAudio.Sink
]
links = %{
{:file_src, :output} => {:pa_sink, :input}
}
{{:ok, %Spec{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 Pipeline.Spec
alias Membrane.Element.PortAudio
@impl true
def handle_init(_) do
children = [
pa_src: PortAudio.Source,
pa_sink: PortAudio.Sink
]
links = %{
{:pa_src, :output} => {:pa_sink, :input}
}
{{:ok, %Spec{children: children, links: links}}, %{}}
end
end
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 2018, Software Mansion
Licensed under the Apache License, Version 2.0