Documentation ¶
Index ¶
- Variables
- type AsmOptimizations
- type EncodeOptions
- type Lame
- func (l *Lame) EncodeFlush() (residual []byte, err error)
- func (l *Lame) EncodeInt16(dataLeft, dataRight []int16, mp3Buf []byte) (int, error)
- func (l *Lame) EncodeInt16Interleaved(data []int16, mp3Buf []byte) (int, error)
- func (l *Lame) EncodeInt32(dataLeft, dataRight []int32, mp3Buf []byte) (int, error)
- func (l *Lame) EncodeInt64(dataLeft, dataRight []int32, mp3Buf []byte) (int, error)
- func (l *Lame) GetATHlower() float32
- func (l *Lame) GetATHonly() int
- func (l *Lame) GetATHshort() int
- func (l *Lame) GetATHtype() int
- func (l *Lame) GetAllowDiffShort() int
- func (l *Lame) GetAnalysis() int
- func (l *Lame) GetAthaaSensitivity() float32
- func (l *Lame) GetAthaaType() int
- func (l *Lame) GetAudiophileGain() int
- func (l *Lame) GetBWriteVbrTag() int
- func (l *Lame) GetBrate() int
- func (l *Lame) GetCompressionRatio() float32
- func (l *Lame) GetCopyright() int
- func (l *Lame) GetDecodeOnTheFly() int
- func (l *Lame) GetDecodeOnly() int
- func (l *Lame) GetDisableReservoir() int
- func (l *Lame) GetEmphasis() int
- func (l *Lame) GetEncoderDelay() int
- func (l *Lame) GetEncoderPadding() int
- func (l *Lame) GetErrorProtection() int
- func (l *Lame) GetExpNspsytune() int
- func (l *Lame) GetExperimentalX() int
- func (l *Lame) GetExperimentalY() int
- func (l *Lame) GetExperimentalZ() int
- func (l *Lame) GetExtension() int
- func (l *Lame) GetFindReplayGain() int
- func (l *Lame) GetForceMs() int
- func (l *Lame) GetForceShortBlocks() int
- func (l *Lame) GetFrameNum() int
- func (l *Lame) GetFramesize() int
- func (l *Lame) GetFreeFormat() int
- func (l *Lame) GetHighpassfreq() int
- func (l *Lame) GetHighpasswidth() int
- func (l *Lame) GetInSampleRate() int
- func (l *Lame) GetInterChRatio() float32
- func (l *Lame) GetLowpassfreq() int
- func (l *Lame) GetLowpasswidth() int
- func (l *Lame) GetMfSamplesToEncode() int
- func (l *Lame) GetMode() Mode
- func (l *Lame) GetMsfix() float32
- func (l *Lame) GetNoATH() int
- func (l *Lame) GetNoShortBlocks() int
- func (l *Lame) GetNoclipGainChange() int
- func (l *Lame) GetNoclipScale() float32
- func (l *Lame) GetNogapCurrentindex() int
- func (l *Lame) GetNogapTotal() int
- func (l *Lame) GetNumChannels() int
- func (l *Lame) GetOriginal() int
- func (l *Lame) GetOutSampleRate() int
- func (l *Lame) GetPeakSample() float32
- func (l *Lame) GetQuality() int
- func (l *Lame) GetQuantComp() int
- func (l *Lame) GetQuantCompShort() int
- func (l *Lame) GetRadioGain() int
- func (l *Lame) GetScale() float32
- func (l *Lame) GetScaleRight() float32
- func (l *Lame) GetSizeMp3buffer() int
- func (l *Lame) GetStrictISO() int
- func (l *Lame) GetTotalframes() int
- func (l *Lame) GetUseTemporal() int
- func (l *Lame) GetVBR() VBRMode
- func (l *Lame) GetVBRHardMin() int
- func (l *Lame) GetVBRMaxBitrateKbps() int
- func (l *Lame) GetVBRMeanBitrateKbps() int
- func (l *Lame) GetVBRMinBitrateKbps() int
- func (l *Lame) GetVBRQ() int
- func (l *Lame) GetVBRQuality() float32
- func (l *Lame) GetVersion() int
- func (l *Lame) InitParams() error
- func (l *Lame) SetATHlower(ATHlower float32) error
- func (l *Lame) SetATHonly(ATHonly int) error
- func (l *Lame) SetATHshort(ATHshort int) error
- func (l *Lame) SetATHtype(ATHtype int) error
- func (l *Lame) SetAllowDiffShort(allowDiffShort int) error
- func (l *Lame) SetAnalysis(analysis int) error
- func (l *Lame) SetAsmOptimizations(optim AsmOptimizations, mode int) error
- func (l *Lame) SetAthaaSensitivity(athaaSensitivity float32) error
- func (l *Lame) SetAthaaType(athaaType int) error
- func (l *Lame) SetBWriteVbrTag(bWriteVbrTag int) error
- func (l *Lame) SetBrate(brate int) error
- func (l *Lame) SetCompressionRatio(compressionRatio float32) error
- func (l *Lame) SetCopyright(copyright int) error
- func (l *Lame) SetDecodeOnTheFly(decode_on_the_fly int) error
- func (l *Lame) SetDecodeOnly(decodeOnly int) error
- func (l *Lame) SetDisableReservoir(disable_reservoir int) error
- func (l *Lame) SetEmphasis(emphasis int) error
- func (l *Lame) SetErrorProtection(errorProtection int) error
- func (l *Lame) SetExpNspsytune(expNspsytune int) error
- func (l *Lame) SetExperimentalX(experimentalX int) error
- func (l *Lame) SetExperimentalY(experimentalY int) error
- func (l *Lame) SetExperimentalZ(experimentalZ int) error
- func (l *Lame) SetExtension(extension int) error
- func (l *Lame) SetFindReplayGain(findReplayGain int) error
- func (l *Lame) SetForceMs(forceMs int) error
- func (l *Lame) SetForceShortBlocks(forceShortBlocks int) error
- func (l *Lame) SetFreeFormat(freeFormat int) error
- func (l *Lame) SetHighpassfreq(highpassfreq int) error
- func (l *Lame) SetHighpasswidth(highpasswidth int) error
- func (l *Lame) SetInSampleRate(sampleRate int) error
- func (l *Lame) SetInterChRatio(interChRatio float32) error
- func (l *Lame) SetLowpassfreq(lowpassfreq int) error
- func (l *Lame) SetLowpasswidth(lowpasswidth int) error
- func (l *Lame) SetMode(mode Mode) error
- func (l *Lame) SetMsfix(msfix float32)
- func (l *Lame) SetNoATH(noATH int) error
- func (l *Lame) SetNoShortBlocks(noShortBlocks int) error
- func (l *Lame) SetNogapCurrentindex(nogapCurrentindex int) error
- func (l *Lame) SetNogapTotal(nogapTotal int) error
- func (l *Lame) SetNumChannels(numChannels int) error
- func (l *Lame) SetOriginal(original int) error
- func (l *Lame) SetOutSampleRate(outSampleRate int) error
- func (l *Lame) SetPreset(preset int) error
- func (l *Lame) SetQuality(quality int) error
- func (l *Lame) SetQuantComp(quantComp int) error
- func (l *Lame) SetQuantCompShort(quantCompShort int) error
- func (l *Lame) SetScale(scale float32) error
- func (l *Lame) SetScaleLeft(scale float32) error
- func (l *Lame) SetScaleRight(scaleRight float32) error
- func (l *Lame) SetStrictISO(strictISO int) error
- func (l *Lame) SetUseTemporal(useTemporal int) error
- func (l *Lame) SetVBR(vbr VBRMode) error
- func (l *Lame) SetVBRHardMin(VBRHardMin int) error
- func (l *Lame) SetVBRMaxBitrateKbps(VBRMaxBitrateKbps int) error
- func (l *Lame) SetVBRMeanBitrateKbps(VBRMeanBitrateKbps int) error
- func (l *Lame) SetVBRMinBitrateKbps(VBRMinBitrateKbps int) error
- func (l *Lame) SetVBRQ(VBR_q int) error
- func (l *Lame) SetVBRQuality(VBRQuality float32) error
- type Mode
- type VBRMode
- type WavHeader
- type WavHeaderRemaining
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( ErrInsufficientMemory = errors.New("cannot allocate memory for Lame") ErrCannotInitParams = errors.New("cannot init params, most likely invalid params, especially sample rates") ErrParamsNotInit = errors.New("params not initialized") ErrTooSmallBuffer = errors.New("too small buffer") ErrUnknown = errors.New("unknown") ErrEmptyArguments = errors.New("some arguments are empty") ErrInvalidSampleRate = errors.New("invalid sample rate, supports only 8, 12, 16, 22, 32, 44.1, 48k") )
var ( // ChunkId is invalid ErrInvalidWavChunkId = errors.New("invalid wav chunk id, expected RIFF or RIFX") // Cannot read ChunkId at all ErrCannotReadChunkId = errors.New("cannot read chunkId") // Cannot read header at all ErrCannotReadHeader = errors.New("cannot read headers") )
var ErrUnsupportedChannelNum = errors.New("only 1 and 2 channels are supported")
Functions ¶
This section is empty.
Types ¶
type AsmOptimizations ¶
type AsmOptimizations int
asm_optimizations_e
const ( AO_INVALID AsmOptimizations = iota AO_MMX AO_AMD_3DNOW AO_SSE )
let us define asm optimizations
type EncodeOptions ¶
type EncodeOptions struct { InBigEndian bool // true if it is in big-endian InSampleRate int // Hz, e.g., 8000, 16000, 12800, 44100, etc. InBitsPerSample int // typically 16 should be working fine. the bit count of each sample, e.g., 2Bytes/sample->16bits InNumChannels int // count of channels, for mono ones, please remain 1, and 2 if stereo OutSampleRate int // Hz OutMode Mode // MODE_MONO, MODE_STEREO, etc. OutQuality int // quality: 0-highest, 9-lowest }
options for encoder
type Lame ¶
type Lame struct {
// contains filtered or unexported fields
}
Bridge towards lame_global_struct
func (*Lame) EncodeFlush ¶
* NOTE: MUST BE CALLED AFTER CONVERSION * returns the length of trailing bytes
func (*Lame) EncodeInt16 ¶
- BELOW ARE <CONVERT> FUNCTIONS
encode pcm to mp3, given buffer according to LAME, there is a loose bound for the buf, len=1.25*numSamped + 7200
func (*Lame) EncodeInt16Interleaved ¶
encode pcm to mp3, given buffer. same with encodeInt64, except data for left and right channels being interleaved according to LAME, there is a loose bound for the buf, len=1.25*numSamped + 7200
func (*Lame) EncodeInt32 ¶
func (*Lame) EncodeInt64 ¶
func (*Lame) GetATHlower ¶
func (*Lame) GetATHonly ¶
func (*Lame) GetATHshort ¶
func (*Lame) GetATHtype ¶
func (*Lame) GetAllowDiffShort ¶
func (*Lame) GetAnalysis ¶
func (*Lame) GetAthaaSensitivity ¶
func (*Lame) GetAthaaType ¶
func (*Lame) GetAudiophileGain ¶
AudiophileGain value. Multipled by 10 and rounded to the nearest.
func (*Lame) GetBWriteVbrTag ¶
func (*Lame) GetCompressionRatio ¶
func (*Lame) GetCopyright ¶
func (*Lame) GetDecodeOnTheFly ¶
func (*Lame) GetDecodeOnly ¶
func (*Lame) GetDisableReservoir ¶
func (*Lame) GetEmphasis ¶
func (*Lame) GetEncoderPadding ¶
padding appended to the input to make sure decoder can fully decode all input. Note that this value can only be calculated during the call to lame_encoder_flush(). Before lame_encoder_flush() has been called, the value of encoder_padding = 0.
func (*Lame) GetErrorProtection ¶
func (*Lame) GetExpNspsytune ¶
func (*Lame) GetExperimentalY ¶
func (*Lame) GetExperimentalZ ¶
func (*Lame) GetExtension ¶
func (*Lame) GetFindReplayGain ¶
func (*Lame) GetForceMs ¶
func (*Lame) GetForceShortBlocks ¶
func (*Lame) GetFreeFormat ¶
func (*Lame) GetHighpassfreq ¶
func (*Lame) GetHighpasswidth ¶
func (*Lame) GetInterChRatio ¶
func (*Lame) GetLowpassfreq ¶
func (*Lame) GetLowpasswidth ¶
func (*Lame) GetMfSamplesToEncode ¶
number of PCM samples buffered, but not yet encoded to mp3 data.
func (*Lame) GetNoShortBlocks ¶
func (*Lame) GetNoclipGainChange ¶
Gain change required for preventing clipping.
ref: https://github.com/gypified/libmp3lame/blob/master/include/lame.h#L623
func (*Lame) GetNoclipScale ¶
* ref: https://github.com/gypified/libmp3lame/blob/master/include/lame.h#L623
func (*Lame) GetNogapCurrentindex ¶
func (*Lame) GetNogapTotal ¶
func (*Lame) GetOriginal ¶
func (*Lame) GetOutSampleRate ¶
func (*Lame) GetQuality ¶
func (*Lame) GetQuantComp ¶
func (*Lame) GetQuantCompShort ¶
func (*Lame) GetRadioGain ¶
RadioGain value. Multiplied by 10 and rounded to the nearest.
func (*Lame) GetScaleRight ¶
func (*Lame) GetSizeMp3buffer ¶
size (bytes) of mp3 data buffered, but not yet encoded. ref: https://github.com/gypified/libmp3lame/blob/master/include/lame.h#L594
func (*Lame) GetStrictISO ¶
func (*Lame) GetTotalframes ¶
lame's estimate of the total number of frames to be encoded
only valid if calling program set num_samples
func (*Lame) GetUseTemporal ¶
func (*Lame) GetVBRHardMin ¶
func (*Lame) GetVBRMaxBitrateKbps ¶
func (*Lame) GetVBRMeanBitrateKbps ¶
func (*Lame) GetVBRMinBitrateKbps ¶
func (*Lame) GetVBRQuality ¶
func (*Lame) GetVersion ¶
mp3 version 0=MPEG-2 1=MPEG-1 (2=MPEG-2.5)
func (*Lame) InitParams ¶
* NOTE: MUST BE CALLED BEFORE CONVERSION * sets more internal configuration based on data provided above.
func (*Lame) SetATHlower ¶
lower ATH by this many db
func (*Lame) SetATHshort ¶
only use ATH for short blocks
func (*Lame) SetAllowDiffShort ¶
allow blocktypes to differ between channels? default: 0 for jstereo, 1 for stereo
func (*Lame) SetAnalysis ¶
below are general control parameters default: 0 set to 1 if you need LAME to ollect data for an MP3 frame analyzer
func (*Lame) SetAsmOptimizations ¶
func (l *Lame) SetAsmOptimizations(optim AsmOptimizations, mode int) error
func (*Lame) SetAthaaSensitivity ¶
adjust (in dB) the point below which adaptive ATH level adjustment occurs
func (*Lame) SetAthaaType ¶
select ATH adaptive adjustment type
func (*Lame) SetBWriteVbrTag ¶
1 = write a Xing VBR header frame. default = 1 this variable must have been added by a Hungarian notation Windows programmer :-)
func (*Lame) SetCompressionRatio ¶
func (*Lame) SetCopyright ¶
*******************************************************************
- frame params ********************************************************************** mark as copyright. default=0
func (*Lame) SetDecodeOnTheFly ¶
decode on the fly. Search for the peak sample. If the ReplayGain * analysis is enabled then perform the analysis on the decoded data * stream. default = 0 (disabled) * NOTE: if this option is set the build-in decoder should not be used
func (*Lame) SetDecodeOnly ¶
1=decode only. use lame/mpglib to convert mp3/ogg to wav. default=0
func (*Lame) SetDisableReservoir ¶
disable the bit reservoir. For testing only. default=0
func (*Lame) SetEmphasis ¶
Input PCM is emphased PCM (for instance from one of the rarely
emphased CDs), it is STRONGLY not recommended to use this, because psycho does not take it into account, and last but not least many decoders ignore these bits
func (*Lame) SetErrorProtection ¶
error_protection. Use 2 bytes from each frame for CRC checksum. default=0
func (*Lame) SetExpNspsytune ¶
Naoki's psycho acoustic model. default=0
func (*Lame) SetExperimentalX ¶
func (*Lame) SetExperimentalY ¶
another experimental option. for testing only
func (*Lame) SetExperimentalZ ¶
another experimental option. for testing only
func (*Lame) SetExtension ¶
MP3 'private extension' bit Meaningless. default=0
func (*Lame) SetFindReplayGain ¶
perform ReplayGain analysis? default = 0 (disabled)
func (*Lame) SetForceMs ¶
force_ms. Force M/S for all frames. For testing only. default = 0 (disabled)
func (*Lame) SetForceShortBlocks ¶
force short blocks
func (*Lame) SetFreeFormat ¶
use free_format? default = 0 (disabled)
func (*Lame) SetHighpassfreq ¶
freq in Hz to apply highpass. Default = 0 = lame chooses. -1 = disabled
func (*Lame) SetHighpasswidth ¶
width of transition band, in Hz. Default = one polyphase filter band
func (*Lame) SetInSampleRate ¶
set input sample rate
func (*Lame) SetInterChRatio ¶
use temporal masking effect (default = 1)
func (*Lame) SetLowpassfreq ¶
filtering... freq in Hz to apply lowpass. Default = 0 = lame chooses. -1 = disabled
func (*Lame) SetLowpasswidth ¶
width of transition band, in Hz. Default = one polyphase filter band
func (*Lame) SetMode ¶
mode = 0,1,2,3 = stereo, jstereo, dual channel (not supported), mono default: lame picks based on compression ration and input channels
func (*Lame) SetNoShortBlocks ¶
disable short blocks
func (*Lame) SetNogapCurrentindex ¶
func (*Lame) SetNogapTotal ¶
counters for gapless encoding
func (*Lame) SetOriginal ¶
mark as original. default=1
func (*Lame) SetOutSampleRate ¶
output sample rate in Hz. default = 0, which means LAME picks best value based on the amount of compression. MPEG only allows: MPEG1 32, 44.1, 48khz MPEG2 16, 22.05, 24 MPEG2.5 8, 11.025, 12 (not used by decoding routines)
func (*Lame) SetQuality ¶
internal algorithm selection. True quality is determined by the bitrate but this variable will effect quality by selecting expensive or cheap algorithms. quality=0..9. 0=best (very slow). 9=worst. recommended: 2 near-best quality, not too slow
5 good quality, fast 7 ok quality, really fast
func (*Lame) SetQuantComp ¶
select a different "best quantization" function. default=0
func (*Lame) SetQuantCompShort ¶
func (*Lame) SetScale ¶
scale the input by this amount before encoding. default=1 (not used by decoding routines)
func (*Lame) SetScaleLeft ¶
scale the channel 0 (left) input by this amount before encoding. default=1 (not used by decoding routines) ref: https://github.com/gypified/libmp3lame/blob/master/include/lame.h#L206
func (*Lame) SetScaleRight ¶
scale the channel 1 (right) input by this amount before encoding. default=1 (not used by decoding routines)
func (*Lame) SetStrictISO ¶
enforce strict ISO compliance. default=0
func (*Lame) SetUseTemporal ¶
use temporal masking effect (default = 1)
func (*Lame) SetVBRHardMin ¶
1=strictly enforce VBR_min_bitrate. Normally it will be violated for analog silence
func (*Lame) SetVBRMaxBitrateKbps ¶
func (*Lame) SetVBRMeanBitrateKbps ¶
Ignored except for VBR=vbr_abr (ABR mode)
func (*Lame) SetVBRMinBitrateKbps ¶
func (*Lame) SetVBRQuality ¶
VBR quality level. 0=highest 9=lowest, Range [0,...,10[
type WavHeader ¶
type WavHeader struct { // RIFF Header ChunkId [4]byte // fixed "RIFF" or "RIFX" if the file is big-endian WavHeaderRemaining }
The header of a common wav file, length=44B
func ReadWavHeader ¶
Try to read the wav header from the given reader returns non-nil err if error occurs NOTE: the reader's position would be permanently changed, even if the given data is corrupted
func (*WavHeader) IsBigEndian ¶
func (*WavHeader) ToEncodeOptions ¶
func (hdr *WavHeader) ToEncodeOptions() EncodeOptions
build an encodeOptions object by wavHeader
type WavHeaderRemaining ¶
type WavHeaderRemaining struct { ChunkSize int32 // Size of the overall file - 8 bytes, in bytes (32-bit integer). Typically, you'd fill this in after creation. Format [4]byte // fixed "WAVE" // Format Header SubChunk1Id [4]byte // fixed "fmt\0" SubChunk1Size int32 // Length of format data as listed above AudioFormat int16 // Type of format (1 is PCM) - 2 byte integer NumChannels int16 // Number of Channels - 2 byte integer SampleRate int32 // Sample Rate - 32 byte integer. Common values are 44100 (CD), 48000 (DAT). Sample Rate = Number of Samples per second, or Hertz. ByteRate int32 // *NOT BIT RATE*, but byte rate (Sample Rate * BitsPerSample * Channels) / 8. BlockAlign int16 // BitsPerSample int16 // Bits per sample // Data SubChunk2Id [4]byte // Contains "data" SubChunk2Size int32 // Number of bytes in data. Number of samples * num_channels * sample byte size }
type Writer ¶
type Writer struct { EncodeOptions // contains filtered or unexported fields }
func (*Writer) ForceUpdateParams ¶
forced to init the params inside NOT NECESSARY