Documentation
¶
Index ¶
- Constants
- Variables
- func SpeedToMipMapDepth(speed float64) int
- type Info
- type LookupParam
- type MipMap
- type MipMapSoundFile
- func (sf *MipMapSoundFile[T]) Buffer(channel int, depth int) []T
- func (sf *MipMapSoundFile[T]) Depth() int
- func (sf *MipMapSoundFile[T]) Duration() float64
- func (sf *MipMapSoundFile[T]) Lookup(pos float64, channel int, depth int, wrap bool) T
- func (sf *MipMapSoundFile[T]) LookupAll(pos float64, depth int, wrap bool) []T
- func (sf *MipMapSoundFile[T]) LookupAllWithSpeed(pos float64, speed float64, wrap bool) []T
- func (sf *MipMapSoundFile[T]) LookupWithSpeed(pos float64, channel int, speed float64, wrap bool) T
- func (sf *MipMapSoundFile[T]) NumChannels() int
- func (sf *MipMapSoundFile[T]) NumFrames() int64
- func (sf *MipMapSoundFile[T]) SampleRate() float64
- func (sf *MipMapSoundFile[T]) ZeroCrossings(channel int) ZeroCrossings
- type Reader
- type SoundBank
- type SoundFile
- func (sf *SoundFile[T]) Buffer(channel int, _ int) []T
- func (sf *SoundFile[T]) Depth() int
- func (sf *SoundFile[T]) Duration() float64
- func (sf *SoundFile[T]) Lookup(pos float64, channel int, _ int, wrap bool) T
- func (sf *SoundFile[T]) LookupAll(pos float64, _ int, wrap bool) []T
- func (sf *SoundFile[T]) NumChannels() int
- func (sf *SoundFile[T]) NumFrames() int64
- func (sf *SoundFile[T]) SampleRate() float64
- func (sf *SoundFile[T]) ZeroCrossings(channel int) ZeroCrossings
- type SoundFiler
- type ZeroCrossing
- type ZeroCrossings
Constants ¶
const ( DirectionAny = 0 DirectionUp = 1 DirectionDown = -1 )
Variables ¶
var MipMapCache string
MipMapCache is a folder where the mipmaps of the files are kept, so that a file is filtered once and read back after that: building the lower resolutions of a big instrument takes seconds to a minute, reading them takes a moment. "" is no cache. A file is kept by its path, size and time, and the settings of the filters: a file that changes is made again
Functions ¶
func SpeedToMipMapDepth ¶
Types ¶
type Info ¶
type Info struct {
Channels int
SampleRate float64
// Frames is the length of the file in frames (a frame has a sample of every channel)
Frames int64
}
Info describes a sound file that is open for reading
type LookupParam ¶
func NewLookupParam ¶
func (*LookupParam[T]) Lookup ¶
func (lp *LookupParam[T]) Lookup(b []T) T
type MipMapSoundFile ¶
func MustMipMapSoundFile ¶
func MustMipMapSoundFile[T float.Float](filePath string, depth int) *MipMapSoundFile[T]
func NewMipMapSoundFile ¶
func (*MipMapSoundFile[T]) Buffer ¶
func (sf *MipMapSoundFile[T]) Buffer(channel int, depth int) []T
func (*MipMapSoundFile[T]) Depth ¶
func (sf *MipMapSoundFile[T]) Depth() int
func (*MipMapSoundFile[T]) Duration ¶
func (sf *MipMapSoundFile[T]) Duration() float64
func (*MipMapSoundFile[T]) Lookup ¶
func (sf *MipMapSoundFile[T]) Lookup(pos float64, channel int, depth int, wrap bool) T
func (*MipMapSoundFile[T]) LookupAll ¶
func (sf *MipMapSoundFile[T]) LookupAll(pos float64, depth int, wrap bool) []T
func (*MipMapSoundFile[T]) LookupAllWithSpeed ¶
func (sf *MipMapSoundFile[T]) LookupAllWithSpeed(pos float64, speed float64, wrap bool) []T
func (*MipMapSoundFile[T]) LookupWithSpeed ¶
func (sf *MipMapSoundFile[T]) LookupWithSpeed(pos float64, channel int, speed float64, wrap bool) T
func (*MipMapSoundFile[T]) NumChannels ¶
func (sf *MipMapSoundFile[T]) NumChannels() int
func (*MipMapSoundFile[T]) NumFrames ¶
func (sf *MipMapSoundFile[T]) NumFrames() int64
func (*MipMapSoundFile[T]) SampleRate ¶
func (sf *MipMapSoundFile[T]) SampleRate() float64
func (*MipMapSoundFile[T]) ZeroCrossings ¶
func (sf *MipMapSoundFile[T]) ZeroCrossings(channel int) ZeroCrossings
type Reader ¶
type Reader[T float.Float] interface { // Info is the number of channels, the sample rate and the length of the file Info() Info // SeekFrame moves to a frame, counted from the start of the file. frame may be Info().Frames (the end), but not further. Seeking lossy files // (mp3, ogg) is exact to the frame SeekFrame(frame int64) error // ReadFrames fills buf with interleaved samples, as many whole frames as fit in it and the file has left, and gives the number of frames. At the // end of the file it gives 0 and no error, like libsndfile does ReadFrames(buf []T) (int64, error) // Close closes the file Close() error }
Reader streams the frames of a sound file from disk, for files that are too big to load, or that are read from the middle on (an instrument that plays from disk, a loop). A Reader is not safe for use from more than one goroutine.
It is the small part of libsndfile that a streamer needs, so that a streamer does not need libsndfile itself: Open reads wav, aiff, mp3, flac and ogg vorbis in pure Go, and all the other formats with the libsndfile build tag.
type SoundFile ¶
SoundFile contains sound file deinterleaved samples and implements SoundFiler interface
func MustSoundFile ¶
MustSoundFile must load a sound file
func (*SoundFile[T]) NumChannels ¶
func (*SoundFile[T]) SampleRate ¶
func (*SoundFile[T]) ZeroCrossings ¶
func (sf *SoundFile[T]) ZeroCrossings(channel int) ZeroCrossings
type SoundFiler ¶
type SoundFiler[T float.Float] interface { NumChannels() int SampleRate() float64 NumFrames() int64 Duration() float64 Depth() int Buffer(channel int, depth int) []T Lookup(pos float64, channel int, depth int, wrap bool) T LookupAll(pos float64, depth int, wrap bool) []T ZeroCrossings(channel int) ZeroCrossings }
type ZeroCrossing ¶
type ZeroCrossings ¶
type ZeroCrossings []ZeroCrossing
func (ZeroCrossings) NearestPos ¶
func (z ZeroCrossings) NearestPos(pos float64, direction int) (ZeroCrossing, bool)
NearestPos returns the zero crossing closest to pos (0-1), optionally only crossings in the given direction. Zero crossings are sorted by position, so it uses a binary search: fast also for long files with many crossings (granular sources call it for every grain)
func (ZeroCrossings) NearestPosFrames ¶
func (z ZeroCrossings) NearestPosFrames(pos int64, direction int) (ZeroCrossing, bool)
NearestPosFrames returns the zero crossing closest to the frame position, optionally only crossings in the given direction
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
dsp
|
|
|
resample
Package resample is a pure-Go streaming sample rate converter.
|
Package resample is a pure-Go streaming sample rate converter. |
|
backend/aifc/float80
Package float80 implements the 80-bit IEEE 754 extended precision floating- point format.
|
Package float80 implements the 80-bit IEEE 754 extended precision floating- point format. |