40 lines
1,014 B
Go
40 lines
1,014 B
Go
package format
|
|
|
|
import (
|
|
"git.gammaspectra.live/S.O.N.G/Kirika/audio"
|
|
"io"
|
|
)
|
|
|
|
type Format interface {
|
|
// Identify checks whether a format is of a type. peek includes a few first bytes, extension is the lowercase file extension without a dot.
|
|
Identify(peek []byte, extension string) bool
|
|
|
|
// Open Opens a stream and decodes it into an audio.Stream
|
|
Open(r io.ReadSeekCloser, blockSize int) (*audio.Stream, error)
|
|
}
|
|
|
|
type AnalyzerFormat interface {
|
|
Format
|
|
// OpenAnalyzer Opens a stream and decodes it into an audio.Stream, and additionally copy AnalyzerPacket back
|
|
OpenAnalyzer(r io.ReadSeekCloser, blockSize int) (*audio.Stream, chan *AnalyzerPacket, error)
|
|
}
|
|
|
|
type WriteSeekCloser interface {
|
|
io.Writer
|
|
io.Closer
|
|
io.Seeker
|
|
}
|
|
|
|
type Encoder interface {
|
|
// Encode Receives a stream and encodes it into a writer
|
|
Encode(stream *audio.Stream, writer WriteSeekCloser) error
|
|
}
|
|
|
|
type AnalyzerPacket struct {
|
|
//Samples interleaved samples
|
|
Samples []int32
|
|
Channels int
|
|
SampleRate int
|
|
BitDepth int
|
|
}
|