Documentation ¶
Index ¶
- Constants
- Variables
- func CalcGoertzel(freq float64, samplingRate float64, samples MonoSamples) float64
- func CalculateAverage(slice []float64) (float64, error)
- type AudioStream
- type Channel
- type MonoSamples
- type NoiseOut
- type PlayI
- type RecordI
- type Recorder
- type Sample
- type SinusOut
- type SoundbenchError
- type StereoSamples
- type Tone
- type Tones
Constants ¶
const ( INPUT = 1 OUTPUT = 2 )
const ( MONO = 1 STEREO = 2 )
const ( LEFT = 1 RIGHT = 2 )
const ( EDEVICE = 1 ECHANNEL = 2 EFREQ = 3 EMONO = 4 ESTEREO = 5 EAMPLITUDE = 6 EFUNCTION = 7 EINTERNAL = 8 )
Errorcodes
Variables ¶
var ChName = map[int]string{ LEFT: "LEFT", RIGHT: "RIGHT", }
var ChValue = map[string]int{ "LEFT": LEFT, "RIGHT": RIGHT, }
var ErrorDescription = map[int]string{ EDEVICE: "Unknown Device", ECHANNEL: "Channel unknown, not defined or contains invalid data", EFREQ: "Invalid Frequency", EMONO: "A Mono Stream takes exactly one Channel", ESTEREO: "A Stereo Stream takes exactly two Channels", EAMPLITUDE: "Invalid Amplitude", EFUNCTION: "Test Function does not exist", EINTERNAL: "Internal Error", }
map containing the description of the Errorcode
var ErrorName = map[int]string{ EDEVICE: "EDEVICE", ECHANNEL: "ECHANNEL", EFREQ: "EFREQ", EMONO: "EMONO", ESTEREO: "ESTEREO", EAMPLITUDE: "EAMPLITUDE", EFUNCTION: "EFUNCTION", EINTERNAL: "EINTERNAL", }
map containing the string representation of the Errorcode
Functions ¶
func CalcGoertzel ¶
func CalcGoertzel(freq float64, samplingRate float64, samples MonoSamples) float64
CalcGoertzel calculates the power for a given frequency in a MonoSample. The Goertzel Algorithm requires much less CPU cycles than calculating the sprectrum power density through an FFT. For more details on the Goertzel Filter check out: https://courses.cs.washington.edu/courses/cse466/12au/calendar/Goertzel-EETimes.pdf
func CalculateAverage ¶
CalculateAverage calculates the mean value over a slice of float64 values
Types ¶
type AudioStream ¶
type AudioStream struct { DeviceName string Direction int Samplingrate float64 Channels map[int]Channel FramesPerBuffer int Out PlayI In RecordI // contains filtered or unexported fields }
AudioStream contains all data necessary to play/record data from an audio device (sound card)
func (*AudioStream) Initialize ¶
func (as *AudioStream) Initialize() error
Initialize the Audiostream and open it
type MonoSamples ¶
type MonoSamples []Sample
type PlayI ¶
type PlayI interface {
// Process(StereoSamples)
Process(interface{})
}
PlayI is the interface that must be implemented to play audio on a local soundcard
type RecordI ¶
type RecordI interface { Process(interface{}) GetData() []StereoSamples }
RecordI is the interface that must be implemented to record from a local soundcard
type Recorder ¶
type Recorder struct {
Samples []StereoSamples
}
Recorder holds the recorded StereoSamples
func (*Recorder) GetData ¶
func (rec *Recorder) GetData() []StereoSamples
GetData returns the slice of recorded StereoSamples
type SinusOut ¶
type SinusOut struct { TonesL Tones TonesR Tones StepL float64 StepR float64 // contains filtered or unexported fields }
type SoundbenchError ¶
func (*SoundbenchError) Error ¶
func (e *SoundbenchError) Error() string
type StereoSamples ¶
type StereoSamples [][]Sample