Documentation ¶
Index ¶
- func CurrentContext() *audio.Context
- func GetStereoSampleAsF32s(buffer []byte) (float32, float32)
- func GetStereoSampleAsI16s(buffer []byte) (int16, int16)
- func Initialize(sampleRate int)
- func IsContextReady() bool
- func NaNsToZero[T Float](buffer []T)
- func NormalizeF32(value float32) float32
- func SampleRate() int
- func StoreL16Sample(buffer []byte, left int16, right int16)
- func StoreNormF32StereoSampleAsL16(buffer []byte, left, right float32)
- func TimeDurationToOffset(duration time.Duration) int64
- func TimeDurationToSamples(duration time.Duration) int64
- type Adder
- type AutomationPanel
- type BGM
- func (self *BGM) DeletePlayer() error
- func (self *BGM) FadeIn(startWait, fadeDuration time.Duration)
- func (self *BGM) FadeOut(fadeDuration time.Duration)
- func (self *BGM) FullyFadedOut() bool
- func (self *BGM) Pause()
- func (self *BGM) Play() error
- func (self *BGM) Rewind() error
- func (self *BGM) SetMasterVolume(factor float32)
- func (self *BGM) SetMuted(muted bool)
- func (self *BGM) SetPosition(position time.Duration) error
- func (self *BGM) SetUserVolume(volume float32)
- func (self *BGM) SetVolumeCorrectorFactor(factor float32)
- type BgmKey
- type FadeType
- type Fader
- func (self *Fader) ForceVolume(targetVolume float32)
- func (self *Fader) FullyFadedOut() bool
- func (self *Fader) GetPosition() int64
- func (self *Fader) SeekSample(n int) error
- func (self *Fader) Transition(targetVolume float32, waitSamples, fadeSamples int64)
- func (self *Fader) WriteStereo(buffer []float32) (int, error)
- type Float
- type ProcessorInAdapterL16
- func (self *ProcessorInAdapterL16) GetPosition() int64
- func (self *ProcessorInAdapterL16) Read(buffer []byte) (int, error)
- func (self *ProcessorInAdapterL16) Seek(offset int64, whence int) (int64, error)
- func (self *ProcessorInAdapterL16) SeekSample(sample int) error
- func (self *ProcessorInAdapterL16) WriteStereo(buffer []float32) (int, error)
- type ProcessorOutAdapterL16
- func (self *ProcessorOutAdapterL16[T]) Read(buffer []byte) (int, error)
- func (self *ProcessorOutAdapterL16[T]) Seek(offset int64, whence int) (int64, error)
- func (self *ProcessorOutAdapterL16[T]) SetMasterVolume(volume float32)
- func (self *ProcessorOutAdapterL16[T]) SetMuted(muted bool)
- func (self *ProcessorOutAdapterL16[T]) SetUserVolume(volume float32)
- func (self *ProcessorOutAdapterL16[T]) SetVolumeCorrectorFactor(factor float32)
- type ResourceKey
- type SfxKey
- type SfxPlayer
- type Soundscape
- func (self *Soundscape) AutomationPanel() *AutomationPanel
- func (self *Soundscape) Crossfade(key BgmKey, fadeOut, inWait, fadeIn time.Duration)
- func (self *Soundscape) FadeIn(key BgmKey, fadeOut, wait, fadeIn time.Duration)
- func (self *Soundscape) FadeOut(fadeOut time.Duration)
- func (self *Soundscape) GetBGMMuted() bool
- func (self *Soundscape) GetMasterMuted() bool
- func (self *Soundscape) GetMasterVolume() float32
- func (self *Soundscape) GetSFXMuted() bool
- func (self *Soundscape) GetUserBGMVolume() float32
- func (self *Soundscape) GetUserSFXVolume() float32
- func (self *Soundscape) IsActive(key BgmKey) bool
- func (self *Soundscape) PlaySFX(key SfxKey)
- func (self *Soundscape) RegisterBGM(bgm *BGM) BgmKey
- func (self *Soundscape) RegisterSFX(sfx *SfxPlayer) SfxKey
- func (self *Soundscape) SetBGMMuted(muted bool)
- func (self *Soundscape) SetMasterMuted(muted bool)
- func (self *Soundscape) SetMasterVolume(volume float32)
- func (self *Soundscape) SetSFXMuted(muted bool)
- func (self *Soundscape) SetUserBGMVolume(volume float32)
- func (self *Soundscape) SetUserSFXVolume(volume float32)
- func (self *Soundscape) Update() error
- type StereoProcessor
- type TriggerKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurrentContext ¶
func GetStereoSampleAsF32s ¶
func GetStereoSampleAsI16s ¶
func IsContextReady ¶
func IsContextReady() bool
func NaNsToZero ¶
func NaNsToZero[T Float](buffer []T)
func NormalizeF32 ¶
func SampleRate ¶
func SampleRate() int
func StoreL16Sample ¶
func TimeDurationToOffset ¶
func TimeDurationToSamples ¶
Types ¶
type Adder ¶
type Adder struct {
// contains filtered or unexported fields
}
func NewAdder ¶
func NewAdder(sources ...StereoProcessor) *Adder
func (*Adder) GetPosition ¶
func (*Adder) SeekSample ¶
type AutomationPanel ¶
type AutomationPanel struct {
// contains filtered or unexported fields
}
Most loosely typed mess ever. Very practical.
func NewAutomationPanel ¶
func NewAutomationPanel() *AutomationPanel
func (*AutomationPanel) GetResource ¶
func (self *AutomationPanel) GetResource(key ResourceKey) any
func (*AutomationPanel) RegisterTrigger ¶
func (self *AutomationPanel) RegisterTrigger(trigger func() error) TriggerKey
func (*AutomationPanel) StoreResource ¶
func (self *AutomationPanel) StoreResource(resource any) ResourceKey
func (*AutomationPanel) Trigger ¶
func (self *AutomationPanel) Trigger(key TriggerKey) error
type BGM ¶
type BGM struct {
// contains filtered or unexported fields
}
func NewBgmFromFader ¶
func NewBgmFromLooper ¶
func (*BGM) DeletePlayer ¶
func (*BGM) FullyFadedOut ¶
func (*BGM) SetMasterVolume ¶ added in v0.0.3
func (*BGM) SetUserVolume ¶
func (*BGM) SetVolumeCorrectorFactor ¶
type Fader ¶
type Fader struct {
// contains filtered or unexported fields
}
func NewFader ¶
func NewFader(source StereoProcessor) *Fader
func (*Fader) ForceVolume ¶
Only advisable to use during setup if you want some fader to start at 1 instead of 0. Forcing volume changes while playing or similar is almost always wrong.
func (*Fader) FullyFadedOut ¶
Typically used to know if we can pause the player. If audio.Player provided direct access to the source or had special error return values to pause it, life could be a bit easier.
func (*Fader) GetPosition ¶
func (*Fader) SeekSample ¶
func (*Fader) Transition ¶
Target volume should be in [0, 1]. Values below 0 will panic, but values slightly above 1 may be useful in some scenarios, so they aren't checked. You should be extremely careful with that, though.
type ProcessorInAdapterL16 ¶
type ProcessorInAdapterL16 struct {
// contains filtered or unexported fields
}
func NewProcessorInAdapterL16 ¶
func NewProcessorInAdapterL16(source io.ReadSeeker) *ProcessorInAdapterL16
func (*ProcessorInAdapterL16) GetPosition ¶
func (self *ProcessorInAdapterL16) GetPosition() int64
func (*ProcessorInAdapterL16) Read ¶
func (self *ProcessorInAdapterL16) Read(buffer []byte) (int, error)
func (*ProcessorInAdapterL16) Seek ¶
func (self *ProcessorInAdapterL16) Seek(offset int64, whence int) (int64, error)
func (*ProcessorInAdapterL16) SeekSample ¶
func (self *ProcessorInAdapterL16) SeekSample(sample int) error
func (*ProcessorInAdapterL16) WriteStereo ¶
func (self *ProcessorInAdapterL16) WriteStereo(buffer []float32) (int, error)
type ProcessorOutAdapterL16 ¶
type ProcessorOutAdapterL16[Source StereoProcessor] struct { // contains filtered or unexported fields }
func NewProcessorOutAdapterL16 ¶
func NewProcessorOutAdapterL16[T StereoProcessor](source T) *ProcessorOutAdapterL16[T]
func (*ProcessorOutAdapterL16[T]) Read ¶
func (self *ProcessorOutAdapterL16[T]) Read(buffer []byte) (int, error)
func (*ProcessorOutAdapterL16[T]) Seek ¶
func (self *ProcessorOutAdapterL16[T]) Seek(offset int64, whence int) (int64, error)
func (*ProcessorOutAdapterL16[T]) SetMasterVolume ¶ added in v0.0.3
func (self *ProcessorOutAdapterL16[T]) SetMasterVolume(volume float32)
func (*ProcessorOutAdapterL16[T]) SetMuted ¶ added in v0.0.3
func (self *ProcessorOutAdapterL16[T]) SetMuted(muted bool)
func (*ProcessorOutAdapterL16[T]) SetUserVolume ¶
func (self *ProcessorOutAdapterL16[T]) SetUserVolume(volume float32)
func (*ProcessorOutAdapterL16[T]) SetVolumeCorrectorFactor ¶
func (self *ProcessorOutAdapterL16[T]) SetVolumeCorrectorFactor(factor float32)
type ResourceKey ¶
type ResourceKey uint8
type SfxPlayer ¶
type SfxPlayer struct {
// contains filtered or unexported fields
}
func NewSfxPlayer ¶
func (*SfxPlayer) PlayWithVolume ¶ added in v0.0.3
Typically the volume is masterVolume*sfxVolume.
func (*SfxPlayer) SetBackoff ¶
func (*SfxPlayer) SetVolumeCorrectorFactor ¶
type Soundscape ¶
type Soundscape struct {
// contains filtered or unexported fields
}
func NewSoundscape ¶
func NewSoundscape() *Soundscape
func (*Soundscape) AutomationPanel ¶
func (self *Soundscape) AutomationPanel() *AutomationPanel
func (*Soundscape) Crossfade ¶
func (self *Soundscape) Crossfade(key BgmKey, fadeOut, inWait, fadeIn time.Duration)
func (*Soundscape) FadeIn ¶
func (self *Soundscape) FadeIn(key BgmKey, fadeOut, wait, fadeIn time.Duration)
func (*Soundscape) FadeOut ¶
func (self *Soundscape) FadeOut(fadeOut time.Duration)
func (*Soundscape) GetBGMMuted ¶ added in v0.0.3
func (self *Soundscape) GetBGMMuted() bool
func (*Soundscape) GetMasterMuted ¶ added in v0.0.3
func (self *Soundscape) GetMasterMuted() bool
func (*Soundscape) GetMasterVolume ¶ added in v0.0.3
func (self *Soundscape) GetMasterVolume() float32
func (*Soundscape) GetSFXMuted ¶ added in v0.0.3
func (self *Soundscape) GetSFXMuted() bool
func (*Soundscape) GetUserBGMVolume ¶
func (self *Soundscape) GetUserBGMVolume() float32
func (*Soundscape) GetUserSFXVolume ¶
func (self *Soundscape) GetUserSFXVolume() float32
func (*Soundscape) IsActive ¶
func (self *Soundscape) IsActive(key BgmKey) bool
func (*Soundscape) PlaySFX ¶
func (self *Soundscape) PlaySFX(key SfxKey)
func (*Soundscape) RegisterBGM ¶
func (self *Soundscape) RegisterBGM(bgm *BGM) BgmKey
func (*Soundscape) RegisterSFX ¶
func (self *Soundscape) RegisterSFX(sfx *SfxPlayer) SfxKey
func (*Soundscape) SetBGMMuted ¶ added in v0.0.3
func (self *Soundscape) SetBGMMuted(muted bool)
func (*Soundscape) SetMasterMuted ¶ added in v0.0.3
func (self *Soundscape) SetMasterMuted(muted bool)
func (*Soundscape) SetMasterVolume ¶ added in v0.0.3
func (self *Soundscape) SetMasterVolume(volume float32)
Notice: SFXs volume will not change until next play if already playing.
func (*Soundscape) SetSFXMuted ¶ added in v0.0.3
func (self *Soundscape) SetSFXMuted(muted bool)
func (*Soundscape) SetUserBGMVolume ¶
func (self *Soundscape) SetUserBGMVolume(volume float32)
func (*Soundscape) SetUserSFXVolume ¶
func (self *Soundscape) SetUserSFXVolume(volume float32)
func (*Soundscape) Update ¶
func (self *Soundscape) Update() error
type StereoProcessor ¶
type StereoProcessor interface { // Returns the number of samples written. This can be at most len(buffer)/2, // as the buffer stores interleaved channel values. WriteStereo(buffer []float32) (int, error) // Seek the given sample. SeekSample(n int) error // Get the current position in samples. GetPosition() int64 }
type TriggerKey ¶
type TriggerKey uint8