voicetest

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package voicetest has test helpers for code that uses the voice library.

Index

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 CallKind

type CallKind uint8

CallKind is the Sink method of a recorded Call.

const (
	NoteOn CallKind = iota
	NoteOff
	Release
)

func (CallKind) String

func (k CallKind) String() string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL