Documentation
¶
Index ¶
- Variables
- func Append(dest Sound, sounds ...Sound)
- func AppendSilence(s Sound, t time.Duration)
- func Crop(s Sound, start, end time.Duration)
- func Gradient(s Sound, start, end time.Duration)
- func Overlay(s, o Sound, delay time.Duration)
- func Volume(s Sound, scale float64)
- func WriteFile(s Sound, path string) error
- type ChunkHeader
- type FileHeader
- type FormatHeader
- type Header
- type Reader
- type Sample
- type Sound
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Append ¶
Append appends sounds to a sound. This method adds and removes channels and modifies sample rates as needed.
func AppendSilence ¶
AppendSilence appends a certain amount of silence to a Sound.
func Crop ¶
Crop isolates a time segment in a sound. If the end time is past the sound's duration, it will be clamped to the end of the sound.
func Gradient ¶
Gradient creates a linear fade-in gradient for an audio file. The voume is 0% at start and 100% at end.
Types ¶
type ChunkHeader ¶
ChunkHeader is the generic 64-bit header in WAV files.
type FileHeader ¶
type FileHeader struct { ChunkHeader Format uint32 }
FileHeader is the "RIFF" chunk
func (FileHeader) Valid ¶
func (h FileHeader) Valid() bool
Valid returns true only if the ID and format match the expected values for WAVE files.
type FormatHeader ¶
type FormatHeader struct { ChunkHeader AudioFormat uint16 NumChannels uint16 SampleRate uint32 ByteRate uint32 BlockAlign uint16 BitsPerSample uint16 }
FormatHeader is the "fmt" sub-chunk
func (FormatHeader) BlockSize ¶
func (f FormatHeader) BlockSize() uint16
BlockSize returns the number of bytes per sample-channel.
func (FormatHeader) Valid ¶
func (f FormatHeader) Valid() bool
Returns true only if the ID, size, and audio format match those of a PCM WAV audio file.
type Header ¶
type Header struct { File FileHeader Format FormatHeader Data ChunkHeader }
Header is the canonical header for all WAV files
func ReadHeader ¶
ReadHeader reads a header from a reader. This does basic verification to make sure the header is valid.
type Reader ¶
type Reader interface { // Header returns the reader's WAV header. Header() *Header // Read reads as many as len(out) samples. // The samples are signed values ranging between -1.0 and 1.0. // Channels are packed side-by-side, so for a stereo track it'd be LRLRLR... // If the end of stream is reached, ErrDone will be returned. Read(out []Sample) (int, error) // Remaining returns the number of samples left to read. Remaining() int }
type Sound ¶
type Sound interface { Channels() int Clone() Sound Duration() time.Duration SampleRate() int Samples() []Sample SetSamples([]Sample) Write(io.Writer) error }
Sound represents and abstract list of samples which can be encoded to a file.
func NewPCM16Sound ¶
NewPCM16Sound creates a new empty Sound with given parameters.
func NewPCM8Sound ¶
NewPCM8Sound creates a new empty Sound with given parameters.