Membrane.Caps.Audio.Raw (Membrane Caps: Audio.Raw v0.5.0) View Source

This module implements struct for caps representing raw audio stream with interleaved channels.

Link to this section Summary

Functions

Determines if format is big endian.

Converts bytes to frames in given caps.

Converts bytes to time in Membrane.Time units in given caps.

Returns how many bytes are needed to store a single frame.

Converts frames to bytes in given caps.

Converts frames to time in Membrane.Time units in given caps.

Determines if format is little endian.

Returns maximum sample value for given format.

Returns minimum sample value for given format.

Returns how many bytes are needed to store a single sample.

Converts one raw sample into its numeric value, interpreting it for given format.

Determines if format is floating point.

Determines if format is integer.

Determines if format is signed.

Returns one 'silent' sample, that is value of zero in given caps' format.

Returns a binary which corresponds to the silence during the given interval of time in given caps' fromat

Converts time in Membrane.Time units to bytes in given caps.

Converts time in Membrane.Time units to frames in given caps.

Determines if format is unsigned.

Converts value into one raw sample, encoding it in given format.

Same as value_to_sample/2, but also checks for overflow. Returns {:error, :overflow} if overflow happens.

Link to this section Types

Specs

channels_t() :: pos_integer()

Specs

sample_rate_t() :: pos_integer()

Specs

t() :: %Membrane.Caps.Audio.Raw{
  channels: channels_t(),
  format: Membrane.Caps.Audio.Raw.Format.t(),
  sample_rate: sample_rate_t()
}

Link to this section Functions

Specs

big_endian?(t()) :: boolean()

Determines if format is big endian.

Inlined by the compiler.

Link to this function

bytes_to_frames(bytes, caps, round_f \\ &trunc/1)

View Source

Converts bytes to frames in given caps.

Inlined by the compiler.

Link to this function

bytes_to_time(bytes, caps, round_f \\ &trunc/1)

View Source

Specs

bytes_to_time(non_neg_integer(), t(), (float() -> integer())) ::
  Membrane.Time.non_neg_t()

Converts bytes to time in Membrane.Time units in given caps.

Inlined by the compiler.

Specs

frame_size(t()) :: integer()

Returns how many bytes are needed to store a single frame.

Inlined by the compiler

Link to this function

frames_to_bytes(frames, caps)

View Source

Specs

frames_to_bytes(non_neg_integer(), t()) :: non_neg_integer()

Converts frames to bytes in given caps.

Inlined by the compiler.

Link to this function

frames_to_time(frames, caps, round_f \\ &trunc/1)

View Source

Specs

frames_to_time(non_neg_integer(), t(), (float() -> integer())) ::
  Membrane.Time.non_neg_t()

Converts frames to time in Membrane.Time units in given caps.

Inlined by the compiler.

Specs

little_endian?(t()) :: boolean()

Determines if format is little endian.

Inlined by the compiler.

Specs

sample_max(t()) :: number()

Returns maximum sample value for given format.

Inlined by the compiler.

Specs

sample_min(t()) :: number()

Returns minimum sample value for given format.

Inlined by the compiler.

Specs

sample_size(t()) :: integer()

Returns how many bytes are needed to store a single sample.

Inlined by the compiler

Link to this function

sample_to_value(sample, raw)

View Source

Specs

sample_to_value(bitstring(), t()) :: number()

Converts one raw sample into its numeric value, interpreting it for given format.

Inlined by the compiler.

Specs

sample_type_float?(t()) :: boolean()

Determines if format is floating point.

Inlined by the compiler.

Specs

sample_type_int?(t()) :: boolean()

Determines if format is integer.

Inlined by the compiler.

Specs

signed?(t()) :: boolean()

Determines if format is signed.

Inlined by the compiler.

Specs

sound_of_silence(t()) :: binary()

Returns one 'silent' sample, that is value of zero in given caps' format.

Inlined by the compiler.

Link to this function

sound_of_silence(caps, time, round_f \\ &(&1 |> :math.ceil() |> trunc))

View Source

Specs

sound_of_silence(t(), Membrane.Time.non_neg_t(), (float() -> integer())) ::
  binary()

Returns a binary which corresponds to the silence during the given interval of time in given caps' fromat

Examples:

The following code generates the silence for the given caps

iex> alias Membrane.Caps.Audio.Raw, as: Caps
iex> caps = %Caps{sample_rate: 48_000, format: :s16le, channels: 2}
iex> silence = Caps.sound_of_silence(caps, 100 |> Membrane.Time.microseconds)
<<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>
Link to this function

time_to_bytes(time, caps, round_f \\ &(&1 |> :math.ceil() |> trunc))

View Source

Specs

time_to_bytes(Membrane.Time.non_neg_t(), t(), (float() -> integer())) ::
  non_neg_integer()

Converts time in Membrane.Time units to bytes in given caps.

Inlined by the compiler.

Link to this function

time_to_frames(time, caps, round_f \\ &(&1 |> :math.ceil() |> trunc))

View Source

Specs

time_to_frames(Membrane.Time.non_neg_t(), t(), (float() -> integer())) ::
  non_neg_integer()

Converts time in Membrane.Time units to frames in given caps.

Inlined by the compiler.

Specs

unsigned?(t()) :: boolean()

Determines if format is unsigned.

Inlined by the compiler.

Link to this function

value_to_sample(value, raw)

View Source

Specs

value_to_sample(number(), t()) :: binary()

Converts value into one raw sample, encoding it in given format.

Inlined by the compiler.

Link to this function

value_to_sample_check_overflow(value, caps)

View Source

Specs

value_to_sample_check_overflow(number(), t()) ::
  {:ok, binary()} | {:error, :overflow}

Same as value_to_sample/2, but also checks for overflow. Returns {:error, :overflow} if overflow happens.

Inlined by the compiler.