wav

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wav writes interleaved float32 PCM to classic RIFF/WAVE files.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRIFFSizeLimit indicates that the requested samples exceed the size
	// representable by a classic RIFF/WAVE header.
	ErrRIFFSizeLimit = errors.New("WAV data exceeds the classic RIFF size limit")
	// ErrPCMFrameAlignment indicates that the interleaved samples do not contain
	// complete channel frames.
	ErrPCMFrameAlignment = errors.New("WAV samples do not contain complete channel frames")
)

Functions

This section is empty.

Types

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer writes signed 16-bit PCM samples to a classic RIFF/WAVE file.

func NewWriter

func NewWriter(path string, sampleRate, channels int) (*Writer, error)

NewWriter creates a classic RIFF/WAVE writer. It rejects format fields that do not fit the WAV header before creating or truncating path.

func (*Writer) Close

func (w *Writer) Close() error

Close patches the RIFF and data sizes from the bytes written and closes the file. Repeated calls return nil.

func (*Writer) WriteSamples

func (w *Writer) WriteSamples(samples []float32) error

WriteSamples writes complete interleaved channel frames. The sample conversion clamps to signed 16-bit range and rounds ties to even.

Jump to

Keyboard shortcuts

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