drums

package
v0.0.0-...-c6c79d5 Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TEMPO_TICK = 15

	// prod
	DECAY      = 3 * time.Minute
	KEEP_ALIVE = 14 * time.Minute

	// if 50% of beats are active, yield to the next program
	YIELD_LIMIT = SOUNDS * BEATS / 3
)
View Source
const (
	DEFAULT_BPM            = 120
	MIN_BPM                = 30
	MAX_BPM                = 480
	SOUNDS                 = 4
	BEATS                  = 16
	DEFAULT_TICKS_PER_BEAT = 10
	DEFAULT_TICKS          = BEATS * DEFAULT_TICKS_PER_BEAT

	TEMPO_DECAY = 3 * time.Minute
)
View Source
const (
	TICK_DELAY = -6
)

Variables

View Source
var (
	WAVS = [SOUNDS]string{
		"hihat-808.wav",
		"kick-classic.wav",
		"perc-808.wav",
		"tom-808.wav",
	}
)

Functions

func WriteonlyBeats

func WriteonlyBeats(channels []chan Beats) []chan<- Beats

can't pass a slice of non-direction channels as a slice of directional channels, so we have to convert the whole slice to directional first.

func WriteonlyInt

func WriteonlyInt(channels []chan int) []chan<- int

func WriteonlyInterval

func WriteonlyInterval(channels []chan Interval) []chan<- Interval

Types

type Beats

type Beats [SOUNDS][BEATS]bool

type Button

type Button struct {
	// contains filtered or unexported fields
}

type DrumMachine

type DrumMachine struct {
	// contains filtered or unexported fields
}

func (*DrumMachine) Amplitude

func (dm *DrumMachine) Amplitude() chan<- float64

input

func (*DrumMachine) Close

func (dm *DrumMachine) Close() chan<- struct{}

func (*DrumMachine) Keyboard

func (dm *DrumMachine) Keyboard() chan<- bbox.Coord

func (*DrumMachine) New

func (dm *DrumMachine) New(wavDurs map[string]time.Duration) beatboxer.Program

func (*DrumMachine) Play

func (dm *DrumMachine) Play() <-chan string

output

func (*DrumMachine) Render

func (dm *DrumMachine) Render() <-chan render.State

func (*DrumMachine) Yield

func (dm *DrumMachine) Yield() <-chan struct{}

type Interval

type Interval struct {
	TicksPerBeat int
	Ticks        int
}

type Keyboard

type Keyboard struct {
	// contains filtered or unexported fields
}

normal operation:

beats -> emit -> msgs

shtudown operation:

'`' -> closing<- {timers.Stop(), close(msgs), close(emit)} -> termbox.Close()

func InitKeyboard

func InitKeyboard(
	presses <-chan bbox.Coord,
	yield chan<- struct{},
	msgs []chan<- Beats,
	tempo chan<- int,
	debug bool,
) *Keyboard

func (*Keyboard) Close

func (kb *Keyboard) Close()

func (*Keyboard) Flip

func (kb *Keyboard) Flip(beat int, tick int)

type Loop

type Loop struct {
	// contains filtered or unexported fields
}

func InitLoop

func InitLoop(
	play chan<- string,
	msgs <-chan Beats,
	tempo <-chan int,
	ticks []chan<- int,
	intervalCh []chan<- Interval,
) *Loop

func (*Loop) Close

func (l *Loop) Close()

func (*Loop) Run

func (l *Loop) Run()

type Render

type Render struct {
	// contains filtered or unexported fields
}

func InitRender

func InitRender(
	msgs <-chan Beats,
	ticks <-chan int,
	intervalCh <-chan Interval,
	render chan<- render.State,
) *Render

func (*Render) Close

func (r *Render) Close()

func (*Render) Draw

func (r *Render) Draw()

func (*Render) Run

func (r *Render) Run()

Jump to

Keyboard shortcuts

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