# `Membrane.RawAudio`
[🔗](https://github.com/membraneframework/membrane_raw_audio_format/blob/v0.12.3/lib/membrane_raw_audio.ex#L1)

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

# `channels_t`

```elixir
@type channels_t() :: pos_integer()
```

# `sample_rate_t`

```elixir
@type sample_rate_t() :: pos_integer()
```

# `t`

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

# `big_endian?`

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

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

Inlined by the compiler.

# `bytes_to_frames`

```elixir
@spec bytes_to_frames(non_neg_integer(), t(), (float() -&gt; integer())) ::
  non_neg_integer()
```

Converts bytes to frames in given format.

Inlined by the compiler.

# `bytes_to_time`

```elixir
@spec bytes_to_time(non_neg_integer(), t(), (float() -&gt; integer())) ::
  Membrane.Time.non_neg()
```

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

Inlined by the compiler.

# `frame_size`

```elixir
@spec frame_size(t()) :: integer()
```

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

Inlined by the compiler

# `frames_to_bytes`

```elixir
@spec frames_to_bytes(non_neg_integer(), t()) :: non_neg_integer()
```

Converts frames to bytes in given format.

Inlined by the compiler.

# `frames_to_time`

```elixir
@spec frames_to_time(non_neg_integer(), t(), (float() -&gt; integer())) ::
  Membrane.Time.non_neg()
```

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

Inlined by the compiler.

# `little_endian?`

```elixir
@spec little_endian?(t()) :: boolean()
```

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

Inlined by the compiler.

# `sample_max`

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

Returns maximum sample value for given sample format.

Inlined by the compiler.

# `sample_min`

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

Returns minimum sample value for given sample format.

Inlined by the compiler.

# `sample_size`

```elixir
@spec sample_size(t()) :: integer()
```

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

Inlined by the compiler

# `sample_to_value`

```elixir
@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.

# `sample_type_fixed?`

```elixir
@spec sample_type_fixed?(t()) :: boolean()
```

Determines if the sample values are represented by an integer.

Inlined by the compiler.

# `sample_type_float?`

```elixir
@spec sample_type_float?(t()) :: boolean()
```

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

Inlined by the compiler.

# `signed?`

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

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

Inlined by the compiler.

# `silence`

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

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

Inlined by the compiler.

# `silence`

```elixir
@spec silence(t(), Membrane.Time.non_neg(), (float() -&gt; integer())) :: binary()
```

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

## 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>>

# `time_to_bytes`

```elixir
@spec time_to_bytes(Membrane.Time.non_neg(), t(), (float() -&gt; integer())) ::
  non_neg_integer()
```

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

Inlined by the compiler.

# `time_to_frames`

```elixir
@spec time_to_frames(Membrane.Time.non_neg(), t(), (float() -&gt; integer())) ::
  non_neg_integer()
```

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

Inlined by the compiler.

# `unsigned?`

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

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

Inlined by the compiler.

# `value_to_sample`

```elixir
@spec value_to_sample(number(), t()) :: binary()
```

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

Inlined by the compiler.

# `value_to_sample_check_overflow`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
