Documentation
¶
Index ¶
- func AmplitudeToDB(a float64) float64
- func AmplitudeToSample(a float64, bitDepth int, signed bool) (s int)
- func AudioLevel(samples []int) float64
- func ConvertBitDepth(srcSample int, srcBitDepth, dstBitDepth int) (dstSample int, err error)
- func DBToAmplitude(db float64) float64
- func DBToSample(db float64, bitDepth int, signed bool) int
- func Normalize(samples []int, bitDepth int) (o []int)
- func SampleToAmplitude(s int, bitDepth int, signed bool) (a float64)
- func SampleToDB(s int, bitDepth int, signed bool) float64
- type ChannelsConverter
- type SampleFunc
- type SampleRateConverter
- type SilenceDetector
- type SilenceDetectorOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AmplitudeToDB ¶ added in v1.2.1
func AmplitudeToSample ¶ added in v1.2.1
func AudioLevel ¶
AudioLevel computes the audio level of samples https://dsp.stackexchange.com/questions/2951/loudness-of-pcm-stream https://dsp.stackexchange.com/questions/290/getting-loudness-of-a-track-with-rms?noredirect=1&lq=1
func ConvertBitDepth ¶
ConvertBitDepth converts the bit depth
func DBToAmplitude ¶ added in v1.2.1
func SampleToAmplitude ¶ added in v1.2.1
func SampleToDB ¶ added in v1.2.1
https://stackoverflow.com/questions/2445756/how-can-i-calculate-audio-db-level
Types ¶
type ChannelsConverter ¶
type ChannelsConverter struct {
// contains filtered or unexported fields
}
func NewChannelsConverter ¶
func NewChannelsConverter(srcNumChannels, dstNumChannels int, fn SampleFunc) *ChannelsConverter
func (*ChannelsConverter) Add ¶
func (c *ChannelsConverter) Add(i int) (err error)
func (*ChannelsConverter) Reset ¶
func (c *ChannelsConverter) Reset()
type SampleFunc ¶
type SampleRateConverter ¶
type SampleRateConverter struct {
// contains filtered or unexported fields
}
func NewSampleRateConverter ¶
func NewSampleRateConverter(srcSampleRate, dstSampleRate, numChannels int, fn SampleFunc) *SampleRateConverter
func (*SampleRateConverter) Add ¶
func (c *SampleRateConverter) Add(i int) (err error)
func (*SampleRateConverter) Reset ¶
func (c *SampleRateConverter) Reset()
type SilenceDetector ¶
type SilenceDetector struct {
// contains filtered or unexported fields
}
SilenceDetector represents a silence detector
func NewSilenceDetector ¶
func NewSilenceDetector(o SilenceDetectorOptions) (d *SilenceDetector)
NewSilenceDetector creates a new silence detector
func (*SilenceDetector) Add ¶
func (d *SilenceDetector) Add(samples []int) (validSamples [][]int)
Add adds samples to the buffer and checks whether there are valid samples between silences
type SilenceDetectorOptions ¶
type SilenceDetectorOptions struct {
MaxSilenceAudioLevel float64 `toml:"max_silence_audio_level"`
MinSilenceDuration time.Duration `toml:"min_silence_duration"`
SampleRate int `toml:"sample_rate"`
StepDuration time.Duration `toml:"step_duration"`
}
SilenceDetectorOptions represents a silence detector options
Click to show internal directories.
Click to hide internal directories.