Files
beatglow/audio/complex128.go
T
2026-10-29 17:28:51 +01:00

45 lines
976 B
Go

package audio
// Complex128 represents a slice of 64-bit floating-point linear PCM encoded
// audio samples, in the range of -1 to +1.
type Complex128 []complex128
// Len implements the Slice interface.
func (p Complex128) Len() int {
return len(p)
}
// Cap implements the Slice interface.
func (p Complex128) Cap() int {
return cap(p)
}
// At implements the Slice interface.
func (p Complex128) At(i int) float64 {
return real(p[i])
}
// Set implements the Slice interface.
func (p Complex128) Set(i int, s float64) {
p[i] = complex(s, 0)
}
// Slice implements the Slice interface.
func (p Complex128) Slice(low, high int) Slice {
return p[low:high]
}
// Make implements the Slice interface.
func (p Complex128) Make(length, capacity int) Slice {
return make(Float64, length, capacity)
}
// CopyTo implements the Slice interface.
func (p Complex128) CopyTo(dst Slice) int {
d, ok := dst.(Complex128)
if ok {
return copy(d, p)
}
return sliceCopy(dst, p)
}