Documentation
¶
Overview ¶
Package voicetest has test helpers for code that uses the voice library.
Index ¶
- type Call
- type CallKind
- type RecordingSink
- func (s *RecordingSink) Calls() []Call
- func (s *RecordingSink) NoteOff(owner voice.Owner, inst voice.Instrument, note float32)
- func (s *RecordingSink) NoteOn(owner voice.Owner, inst voice.Instrument, note, velocity, pan float32)
- func (s *RecordingSink) Release(owner voice.Owner)
- func (s *RecordingSink) Reset()
- func (s *RecordingSink) Sounding(owner voice.Owner) []Call
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Call ¶
type Call struct {
Kind CallKind
Owner voice.Owner
Instrument voice.Instrument
Note float32
Velocity float32
Pan float32
}
Call is one recorded Sink call. Fields a method does not have are zero.
type RecordingSink ¶
type RecordingSink struct {
// contains filtered or unexported fields
}
RecordingSink is a voice.Sink that records every call instead of making sound. It is safe for concurrent use. Its methods allocate (it is for tests, not hot paths), so preallocate with NewRecordingSink for alloc tests.
func NewRecordingSink ¶
func NewRecordingSink(capacity int) *RecordingSink
NewRecordingSink returns a sink with room for capacity calls before it allocates.
func (*RecordingSink) Calls ¶
func (s *RecordingSink) Calls() []Call
Calls returns a copy of the calls so far, oldest first.
func (*RecordingSink) NoteOff ¶
func (s *RecordingSink) NoteOff(owner voice.Owner, inst voice.Instrument, note float32)
NoteOff implements voice.Sink.
func (*RecordingSink) NoteOn ¶
func (s *RecordingSink) NoteOn(owner voice.Owner, inst voice.Instrument, note, velocity, pan float32)
NoteOn implements voice.Sink.
func (*RecordingSink) Release ¶
func (s *RecordingSink) Release(owner voice.Owner)
Release implements voice.Sink.
func (*RecordingSink) Reset ¶
func (s *RecordingSink) Reset()
Reset forgets the recorded calls, keeping the capacity.
func (*RecordingSink) Sounding ¶
func (s *RecordingSink) Sounding(owner voice.Owner) []Call
Sounding returns the NoteOn calls of owner that are still sounding: not followed by a NoteOff of the same instrument and pitch (which ends every sounding note of that instrument and pitch, as synth.Stream does) or a Release. A test that ends a line checks that it is empty.