Documentation
¶
Index ¶
- Constants
- func DisableLogging()
- func DisableVisualization()
- func EnableLogging()
- func EnableVisualization(octave int)
- func Run(callback UserCallback) error
- func RunWithRawSound(callback UserCallbackRaw) error
- func RunWithThreshold(callback UserCallback, signalThreshold float32) error
- type Heard
- type HeardRaw
- type Note
- type Notes
- func (a Notes) Intersection(b Notes) Notes
- func (a Notes) IsEqual(b Notes) bool
- func (a Notes) IsEqualWithoutTones(b Notes) bool
- func (notes Notes) Set(note Note, playing bool) Notes
- func (a Notes) Union(b Notes) Notes
- func (notes Notes) With(note Note) Notes
- func (notes Notes) Without(note Note) Notes
- type RawSound
- type SynthHandle
- type Synthesizer
- func (synth *Synthesizer) CancelAllPlans()
- func (synth *Synthesizer) IsAllDone() bool
- func (synth *Synthesizer) OnAllDone(callback func())
- func (synth *Synthesizer) PlanDelay(duration time.Duration) (handle SynthHandle)
- func (synth *Synthesizer) PlanNotes(notes Notes, duration time.Duration) (handle SynthHandle)
- func (synth *Synthesizer) PlanTimeRemaining() time.Duration
- func (synth *Synthesizer) PlayNoteImmediately(note Note)
- func (synth *Synthesizer) SetNoteImmediately(note Note, playing bool)
- func (synth *Synthesizer) SetNotesImmediately(notes Notes)
- func (synth *Synthesizer) Silence()
- func (synth *Synthesizer) StopNoteImmediately(note Note)
- type UserCallback
- type UserCallbackRaw
Constants ¶
const OctaveCount = 6
Variables ¶
This section is empty.
Functions ¶
func DisableLogging ¶ added in v1.1.2
func DisableLogging()
Disables logging from miniaudio and eridol-core.
func DisableVisualization ¶ added in v1.1.2
func DisableVisualization()
Disables the visualization of FFT data.
func EnableLogging ¶ added in v1.1.2
func EnableLogging()
Enables logging from miniaudio and eridol-core.
func EnableVisualization ¶ added in v1.1.2
func EnableVisualization(octave int)
Shows the visualization of FFT data for an octave. Only one octave can be visable at a time.
func Run ¶ added in v1.1.0
func Run(callback UserCallback) error
Runs the callback every time new note data is avalable for at least one octave. Will not return until the callback returns true to stop. If you want raw sound data use RunWithRawSound(). If you want to set the threshold for note detection, use RunWithThreshold().
func RunWithRawSound ¶ added in v1.1.0
func RunWithRawSound(callback UserCallbackRaw) error
Runs the callback every time new sound data is avalable fo r at least one octave. Sound data is just raw numbers for the loudness of each note, as well as background noise. Will not return until the callback returns true to stop. If you want analyzed note data use Run().
func RunWithThreshold ¶ added in v1.1.7
func RunWithThreshold(callback UserCallback, signalThreshold float32) error
Runs the callback every time new note data is avalable for at least one octave. The sensativity to detecting notes can be set with signalThreshold. If the sensativity is too low it may detect false positives, if it's too high it won't be able to hear quite notes. Will not return until the callback returns true to stop. The default threshould used by Run() is 4, use that if you want a safe value.
Types ¶
type Heard ¶ added in v1.1.0
type Heard struct {
Octaves [OctaveCount]Notes
IsOctaveChanged [OctaveCount]bool
TimeRunning time.Duration
}
The results of eridol analyzing sound from the microphone. Contains boolean values for if each note is declared as playing or not playing
type HeardRaw ¶ added in v1.1.0
type HeardRaw struct {
Octaves [OctaveCount]RawSound
IsOctaveChanged [OctaveCount]bool
TimeRunning time.Duration
}
The results of eridol analyzing sound from the microphone. Contains raw numbers for the loudness of each note, as well as background noise.
type Note ¶
type Note int
An enum for each single note, including the claim and counter-claim tones.
type Notes ¶
A set of notes, including the claim and counter-claim tones. Each is set as on (true) or off (false).
func (Notes) Intersection ¶ added in v1.1.4
Returns the intersection of both sets of notes. An output note will be playing if it is playing in both input sets.
func (Notes) IsEqualWithoutTones ¶ added in v1.1.9
Returns true if note sets are equal, ignoring the claim and counter-claim tones which may be different.
func (Notes) Union ¶ added in v1.1.0
Returns the union of both sets of notes. An output note will be playing if it is playing in either input set.
type RawSound ¶ added in v1.1.0
type RawSound struct {
B float32
Ds float32
Fs float32
A float32
Claim float32
CounterClaim float32
BNoise float32
DsNoise float32
FsNoise float32
ANoise float32
ClaimNoise float32
CounterClaimNoise float32
BackgroundNoise float32
}
The raw sound data heard as float point loudnesses. Background noise around each note, and on average in the whole octave is also included.
type SynthHandle ¶ added in v1.1.10
type SynthHandle struct {
// contains filtered or unexported fields
}
A handle to planned Synth notes, allows them to be cancled later with CancelPlansFrom().
func (SynthHandle) CancelPlansFrom ¶ added in v1.1.10
func (handle SynthHandle) CancelPlansFrom()
Cancels any planned notes from the handle onwards. Notes started with synth.PlayNoteImmediately() will continue regardless until stopped with synthStopNoteImmediately().
func (SynthHandle) IsDone ¶ added in v1.1.10
func (handle SynthHandle) IsDone() bool
Returns true if all the handle's sound is done playing.
func (SynthHandle) OnDone ¶ added in v1.1.11
func (handle SynthHandle) OnDone(callback func()) bool
type Synthesizer ¶ added in v1.1.0
type Synthesizer struct {
// contains filtered or unexported fields
}
Creates sound output for one octave by playing the necessary notes.
func Synth ¶ added in v1.1.0
func Synth(n int) *Synthesizer
Returns the synthesizer for the octave Nth octave. This synth is the same for the entire life of the program.
func (*Synthesizer) CancelAllPlans ¶ added in v1.1.0
func (synth *Synthesizer) CancelAllPlans()
Cancels all planned notes and delays. Notes started with PlayNoteImmediately() will continue regardless until stopped with StopNoteImmediately().
func (*Synthesizer) IsAllDone ¶ added in v1.1.9
func (synth *Synthesizer) IsAllDone() bool
Returns true if all planned sounds are done playing.
func (*Synthesizer) OnAllDone ¶ added in v1.1.12
func (synth *Synthesizer) OnAllDone(callback func())
func (*Synthesizer) PlanDelay ¶ added in v1.1.0
func (synth *Synthesizer) PlanDelay(duration time.Duration) (handle SynthHandle)
Plans a silent delay after any existing planned notes. This is the same as running PlanNotes() with an empty set of notes. Notes started with PlayNoteImmediately() will continue regardless until stopped with StopNoteImmediately(). Returns a handle to cancel this later.
func (*Synthesizer) PlanNotes ¶ added in v1.1.0
func (synth *Synthesizer) PlanNotes(notes Notes, duration time.Duration) (handle SynthHandle)
Plans to play notes for a set duration Will run after any already planned notes, or otherwise as soon as possible. Notes started with PlayNoteImmediately() will continue regardless until stopped with StopNoteImmediately(). Returns a handle to cancel this later.
func (*Synthesizer) PlanTimeRemaining ¶ added in v1.1.0
func (synth *Synthesizer) PlanTimeRemaining() time.Duration
Returns the amount of time remaining in the current series of planned notes. Includes any trailing silences that have been planned.
func (*Synthesizer) PlayNoteImmediately ¶ added in v1.1.0
func (synth *Synthesizer) PlayNoteImmediately(note Note)
Starts playing a single note as soon as possible. The note will continue to play regardless of planned notes until stopped.
func (*Synthesizer) SetNoteImmediately ¶ added in v1.1.0
func (synth *Synthesizer) SetNoteImmediately(note Note, playing bool)
Sets if an immediate note should be playing or note. If a note is set to playing it will continue to play regardless of planned notes until stopped.
func (*Synthesizer) SetNotesImmediately ¶ added in v1.1.0
func (synth *Synthesizer) SetNotesImmediately(notes Notes)
Sets if every note should immediately be playing or not For each note set to playing, it will continue to play regardless of planned notes until stopped.
func (*Synthesizer) Silence ¶ added in v1.1.0
func (synth *Synthesizer) Silence()
Silences everything, stopping immediate notes and canceling all planned notes.
func (*Synthesizer) StopNoteImmediately ¶ added in v1.1.0
func (synth *Synthesizer) StopNoteImmediately(note Note)
Stops a note already set to be playing immediately. Does not affect planned notes in any way.
type UserCallback ¶ added in v1.1.0
The callback type implemented by the user if they want processed notes.
type UserCallbackRaw ¶ added in v1.1.0
The callback type implemented by the user if they want raw sound data.