xWMA audio — WMA v2 packets with a table of how much each decodes to, as XACT wave
banks and .xwma files hold it — wrapped as a file and decoded to PCM.
riff = TuningFork.Xwma.riff(packets, %{channels: 2, rate: 44_100, bytes_per_second: 12_000, block_align: 4459, seek: table})
{:ok, pcm, %{rate: 44_100, channels: 2}} = TuningFork.Xwma.decode(riff)A file is RIFF/XWMA with a fmt chunk (format tag 0x0161, the channels, rate,
average bytes per second, packet size and 16 bits per sample), a dpds chunk (the
seek table: the decoded byte count at the end of each packet, little-endian 32-bit)
and a data chunk of the packets.
Decoders
Decoding goes to the first available TuningFork.Xwma.Decoder of
config :tuning_fork, :xwma_decoders. Without that setting the list is
TuningFork.Wma — present when a package that decodes WMA itself is a dependency —
then TuningFork.Xwma.Ffmpeg, the machine's ffmpeg. With none available,
decode/1 returns {:error, :no_decoder}.
Each file is decoded once; the PCM is kept in TuningFork.Sample.Fetch.dir/0.
Summary
Functions
Whether this machine can decode xWMA.
The audio of an .xwma file as signed 16-bit little-endian interleaved PCM, with its
rate and channel count, from the first decoder that can run. Fails with
{:error, :no_decoder} or the decoder's own error.
The decoders that can run here, in the order they are tried.
An .xwma file of packets in format.
Types
@type format() :: %{ channels: pos_integer(), rate: pos_integer(), bytes_per_second: pos_integer(), block_align: pos_integer(), seek: [non_neg_integer()] }
Functions
@spec available?() :: boolean()
Whether this machine can decode xWMA.
@spec decode(binary()) :: {:ok, binary(), %{rate: pos_integer(), channels: pos_integer()}} | {:error, term()}
The audio of an .xwma file as signed 16-bit little-endian interleaved PCM, with its
rate and channel count, from the first decoder that can run. Fails with
{:error, :no_decoder} or the decoder's own error.
@spec decoders() :: [module()]
The decoders that can run here, in the order they are tried.
An .xwma file of packets in format.