View Source Membrane.RawAudio (Membrane: raw audio format v0.10.0)

This module contains a definition and related functions for struct Membrane.RawAudio.t/0, describing a format of raw audio stream with interleaved channels.

Link to this section Summary

Functions

Determines if the sample values are represented by a number in big endian byte ordering.

Converts bytes to frames in given format.

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

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

Converts frames to bytes in given format.

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

Determines if the sample values are represented by a number in little endian byte ordering.

Returns maximum sample value for given sample format.

Returns minimum sample value for given sample format.

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

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

Determines if the sample values are represented by an integer.

Determines if the sample values are represented by a floating point number.

Determines if the sample values are represented by a signed number.

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

Returns a binary which corresponds to the silence during the given interval of time in given format' sample format

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

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

Determines if the sample values are represented by an unsigned number.

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

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

Link to this section Types

@type channels_t() :: pos_integer()
@type sample_rate_t() :: pos_integer()
@type t() :: %Membrane.RawAudio{
  channels: channels_t(),
  sample_format: Membrane.RawAudio.SampleFormat.t(),
  sample_rate: sample_rate_t()
}

Link to this section Functions

@spec big_endian?(t()) :: boolean()

Determines if the sample values are represented by a number in big endian byte ordering.

Inlined by the compiler.

Link to this function

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

View Source
@spec bytes_to_frames(non_neg_integer(), t(), (float() -> integer())) ::
  non_neg_integer()

Converts bytes to frames in given format.

Inlined by the compiler.

Link to this function

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

View Source
@spec bytes_to_time(non_neg_integer(), t(), (float() -> integer())) ::
  Membrane.Time.non_neg_t()

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

Inlined by the compiler.

@spec 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, format)

View Source
@spec frames_to_bytes(non_neg_integer(), t()) :: non_neg_integer()

Converts frames to bytes in given format.

Inlined by the compiler.

Link to this function

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

View Source
@spec frames_to_time(non_neg_integer(), t(), (float() -> integer())) ::
  Membrane.Time.non_neg_t()

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

Inlined by the compiler.

Link to this function

little_endian?(raw_audio)

View Source
@spec little_endian?(t()) :: boolean()

Determines if the sample values are represented by a number in little endian byte ordering.

Inlined by the compiler.

@spec sample_max(t()) :: number()

Returns maximum sample value for given sample format.

Inlined by the compiler.

@spec sample_min(t()) :: number()

Returns minimum sample value for given sample format.

Inlined by the compiler.

@spec 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_audio)

View Source
@spec sample_to_value(bitstring(), t()) :: number()

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

Inlined by the compiler.

Link to this function

sample_type_fixed?(raw_audio)

View Source
@spec sample_type_fixed?(t()) :: boolean()

Determines if the sample values are represented by an integer.

Inlined by the compiler.

Link to this function

sample_type_float?(raw_audio)

View Source
@spec sample_type_float?(t()) :: boolean()

Determines if the sample values are represented by a floating point number.

Inlined by the compiler.

@spec signed?(t()) :: boolean()

Determines if the sample values are represented by a signed number.

Inlined by the compiler.

@spec silence(t()) :: binary()

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

Inlined by the compiler.

Link to this function

silence(format, time, round_f \\ &(&1 |> :math.ceil() |> trunc))

View Source
@spec 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 format' sample format

examples

Examples:

The following code generates the silence for the given format

iex> alias Membrane.RawAudio
iex> format = %RawAudio{sample_rate: 48_000, sample_format: :s16le, channels: 2}
iex> silence = RawAudio.silence(format, 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, format, round_f \\ &(&1 |> :math.ceil() |> trunc))

View Source
@spec time_to_bytes(Membrane.Time.non_neg_t(), t(), (float() -> integer())) ::
  non_neg_integer()

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

Inlined by the compiler.

Link to this function

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

View Source
@spec time_to_frames(Membrane.Time.non_neg_t(), t(), (float() -> integer())) ::
  non_neg_integer()

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

Inlined by the compiler.

@spec unsigned?(t()) :: boolean()

Determines if the sample values are represented by an unsigned number.

Inlined by the compiler.

Link to this function

value_to_sample(value, raw_audio)

View Source
@spec value_to_sample(number(), t()) :: binary()

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

Inlined by the compiler.

Link to this function

value_to_sample_check_overflow(value, format)

View Source
@spec 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.