Documentation
¶
Overview ¶
Package aac provides AAC encoding functionality for beep audio streams.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
Encode writes a beep.Streamer to an io.Writer in AAC format. Returns an error if encoding fails, if the format has an unsupported precision, or if the format has more than 2 channels.
Example ¶
Example demonstrates encoding generated audio (sine wave).
format := beep.Format{
SampleRate: 44100,
NumChannels: 2,
Precision: 2,
}
// Generate a 440 Hz sine wave (A4 note) for 3 seconds
sine, err := generators.SineTone(format.SampleRate, 440)
if err != nil {
log.Fatal(err)
}
limited := beep.Take(format.SampleRate.N(3*time.Second), sine)
// Create output file
out, err := os.Create("sine.aac")
if err != nil {
log.Fatal(err)
}
defer out.Close()
// Encode to AAC
if err = aac.Encode(out, limited, aac.EncodeOptions{
Format: format,
BitRate: 128000,
}); err != nil {
log.Fatal(err)
}
Types ¶
type EncodeOptions ¶
type EncodeOptions struct {
// Embed the source audio format. Precision must be 2 (16-bit PCM) to match the AAC encoder requirements.
beep.Format
// BitRate in bits/sec.
// If 0, defaults to 64000 bits/sec.
BitRate int
}
EncodeOptions defines the options for AAC encoding.
Click to show internal directories.
Click to hide internal directories.