pcm

package
v1.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 2 Imported by: 2

Documentation

Overview

Package pcm converts between different representations of PCM audio data. Ideally the only representations we would need would be []float32 for F32LE and []int16 for S16LE. Sadly, many modules require us to provide raw byte arrays, so we also need conversion functions for []byte.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func F32AdjustVolume added in v1.7.0

func F32AdjustVolume(samples []float32, volume float64) []float32

F32AdjustVolume multiplies each sample in the F32LE PCM data by the given volume factor. A volume of 1.0 leaves the audio unchanged, and values below 1.0 reduce volume.

func F32LEBytesToS16LEBytes

func F32LEBytesToS16LEBytes(in []byte) []byte

F32LEBytesToS16LEBytes converts a slice of int16 bytes to a slice of float32 bytes. This is useful for converting from S16LE to F32LE.

func F32ToS16

func F32ToS16(f float32) int16

F32ToS16 converts a float32 in range -1, 1 to an int16 in range -32768, 32767.

func F32toS16LE

func F32toS16LE(in []float32) []int16

F32toS16LE converts a slice of float32 to a slice of int16. This is useful for converting from F32LE to S16LE.

func F32toS16LEBytes

func F32toS16LEBytes(in []float32) []byte

F32toS16LEBytes converts a slice of float32 to a slice of bytes. This is useful for converting from F32LE to S16LE.

func S16LEBytesToF32LE

func S16LEBytesToF32LE(in []byte) []float32

S16LEBytesToF32LE converts a slice of bytes to a slice of float32. This is useful for converting from S16LE to F32LE.

func S16LEToF32LE

func S16LEToF32LE(in []int16) []float32

S16LEToF32LE converts a slice of int16 to a slice of float32. This is useful for converting from S16LE to F32LE.

func S16ToF32

func S16ToF32(s int16) float32

S16ToF32 converts an int16 in range -32768, 32767 to a float32 in range -1, 1.

Types

This section is empty.

Directories

Path Synopsis
Package rate defines audio sample rates used throughout the application.
Package rate defines audio sample rates used throughout the application.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL