bbox

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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIN_MAX_VOL = 0.1

	SMOOTHING_FAST = 0.9
	SMOOTHING_SLOW = 0.99
)
View Source
const (
	TEMPO_TICK = 15

	// prod
	DECAY      = 3 * time.Minute
	KEEP_ALIVE = 14 * time.Minute
)
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 (
	WAVS    = "./wavs"
	BUF     = 128
	MAX_BUF = 524288 // TODO: make dynamic based on file size
)
View Source
const (
	DEBOUNCE_TIME = 500 * time.Millisecond
)
View Source
const (
	TICK_DELAY = 2
)

Variables

View Source
var KeyMapsPC = map[Key]*Coord{
	{'1', 0}: &Coord{0, 0},
	{'2', 0}: &Coord{0, 1},
	{'3', 0}: &Coord{0, 2},
	{'4', 0}: &Coord{0, 3},
	{'5', 0}: &Coord{0, 4},
	{'6', 0}: &Coord{0, 5},
	{'7', 0}: &Coord{0, 6},
	{'8', 0}: &Coord{0, 7},
	{'!', 0}: &Coord{0, 8},
	{'@', 0}: &Coord{0, 9},
	{'#', 0}: &Coord{0, 10},
	{'$', 0}: &Coord{0, 11},
	{'%', 0}: &Coord{0, 12},
	{'^', 0}: &Coord{0, 13},
	{'&', 0}: &Coord{0, 14},
	{'*', 0}: &Coord{0, 15},

	{'q', 0}: &Coord{1, 0},
	{'w', 0}: &Coord{1, 1},
	{'e', 0}: &Coord{1, 2},
	{'r', 0}: &Coord{1, 3},
	{'t', 0}: &Coord{1, 4},
	{'y', 0}: &Coord{1, 5},
	{'u', 0}: &Coord{1, 6},
	{'i', 0}: &Coord{1, 7},
	{'Q', 0}: &Coord{1, 8},
	{'W', 0}: &Coord{1, 9},
	{'E', 0}: &Coord{1, 10},
	{'R', 0}: &Coord{1, 11},
	{'T', 0}: &Coord{1, 12},
	{'Y', 0}: &Coord{1, 13},
	{'U', 0}: &Coord{1, 14},
	{'I', 0}: &Coord{1, 15},

	{'a', 0}: &Coord{2, 0},
	{'s', 0}: &Coord{2, 1},
	{'d', 0}: &Coord{2, 2},
	{'f', 0}: &Coord{2, 3},
	{'g', 0}: &Coord{2, 4},
	{'h', 0}: &Coord{2, 5},
	{'j', 0}: &Coord{2, 6},
	{'k', 0}: &Coord{2, 7},
	{'A', 0}: &Coord{2, 8},
	{'S', 0}: &Coord{2, 9},
	{'D', 0}: &Coord{2, 10},
	{'F', 0}: &Coord{2, 11},
	{'G', 0}: &Coord{2, 12},
	{'H', 0}: &Coord{2, 13},
	{'J', 0}: &Coord{2, 14},
	{'K', 0}: &Coord{2, 15},

	{'z', 0}: &Coord{3, 0},
	{'x', 0}: &Coord{3, 1},
	{'c', 0}: &Coord{3, 2},
	{'v', 0}: &Coord{3, 3},
	{'b', 0}: &Coord{3, 4},
	{'n', 0}: &Coord{3, 5},
	{'m', 0}: &Coord{3, 6},
	{',', 0}: &Coord{3, 7},
	{'Z', 0}: &Coord{3, 8},
	{'X', 0}: &Coord{3, 9},
	{'C', 0}: &Coord{3, 10},
	{'V', 0}: &Coord{3, 11},
	{'B', 0}: &Coord{3, 12},
	{'N', 0}: &Coord{3, 13},
	{'M', 0}: &Coord{3, 14},
	{'<', 0}: &Coord{3, 15},
}
View Source
var KeyMapsRPI = map[Key]*Coord{

	{'1', 0}:            &Coord{0, 0},
	{'q', 0}:            &Coord{0, 1},
	{0, termbox.KeyTab}: &Coord{0, 2},
	{'a', 0}:            &Coord{0, 3},
	{'z', 0}:            &Coord{0, 4},
	{0, termbox.KeyF1}:  &Coord{0, 5},
	{'2', 0}:            &Coord{0, 6},
	{'w', 0}:            &Coord{0, 7},

	{'s', 0}: &Coord{0, 8},

	{'x', 0}:           &Coord{0, 9},
	{0, termbox.KeyF2}: &Coord{0, 10},
	{'3', 0}:           &Coord{0, 11},
	{'e', 0}:           &Coord{0, 12},
	{0, termbox.KeyF3}: &Coord{0, 13},
	{'d', 0}:           &Coord{0, 14},
	{0, termbox.KeyF4}: &Coord{0, 15},

	{'5', 0}: &Coord{1, 0},
	{'4', 0}: &Coord{1, 1},
	{'r', 0}: &Coord{1, 2},
	{'t', 0}: &Coord{1, 3},
	{'f', 0}: &Coord{1, 4},
	{'g', 0}: &Coord{1, 5},
	{'v', 0}: &Coord{1, 6},
	{'b', 0}: &Coord{1, 7},
	{'6', 0}: &Coord{1, 8},
	{'7', 0}: &Coord{1, 9},
	{'u', 0}: &Coord{1, 10},
	{'y', 0}: &Coord{1, 11},
	{'j', 0}: &Coord{1, 12},
	{'h', 0}: &Coord{1, 13},
	{'m', 0}: &Coord{1, 14},
	{'n', 0}: &Coord{1, 15},

	{'=', 0}:           &Coord{2, 0},
	{'8', 0}:           &Coord{2, 1},
	{'i', 0}:           &Coord{2, 2},
	{']', 0}:           &Coord{2, 3},
	{'k', 0}:           &Coord{2, 4},
	{0, termbox.KeyF6}: &Coord{2, 5},
	{',', 0}:           &Coord{2, 6},
	{0, termbox.KeyF8}: &Coord{2, 7},
	{'9', 0}:           &Coord{2, 8},
	{'o', 0}:           &Coord{2, 9},
	{0, termbox.KeyF7}: &Coord{2, 10},
	{'l', 0}:           &Coord{2, 11},
	{'.', 0}:           &Coord{2, 12},
	{'-', 0}:           &Coord{2, 13},
	{'0', 0}:           &Coord{2, 14},
	{'p', 0}:           &Coord{2, 15},

	{'[', 0}:                   &Coord{3, 0},
	{';', 0}:                   &Coord{3, 1},
	{'\'', 0}:                  &Coord{3, 2},
	{'\\', 0}:                  &Coord{3, 3},
	{'/', 0}:                   &Coord{3, 4},
	{0, termbox.KeyF9}:         &Coord{3, 5},
	{0, termbox.KeyF10}:        &Coord{3, 6},
	{0, termbox.KeyBackspace2}: &Coord{3, 7},

	{0, termbox.KeyF5}:    &Coord{3, 8},
	{0, termbox.KeyEnter}: &Coord{3, 9},
	{0, termbox.KeySpace}: &Coord{3, 10},
	{0, termbox.KeyF12}:   &Coord{3, 11},

	{0, termbox.KeyArrowRight}: &Coord{3, 12},
	{0, termbox.KeyDelete}:     &Coord{3, 13},

	{0, termbox.KeyArrowDown}: &Coord{3, 14},

	{0, termbox.KeyHome}: &Coord{3, 15},
}

mapping from keyboard box

View Source
var (
	MAX_SMOOTHING = math.Pow(0.999, 1.0/100)
)

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 Amplitude

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

func InitAmplitude

func InitAmplitude(level chan<- float64) *Amplitude

func (*Amplitude) Close

func (a *Amplitude) Close()

func (*Amplitude) Run

func (a *Amplitude) Run()

type Beats

type Beats [SOUNDS][BEATS]bool

type Button

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

type Coord

type Coord [2]int

type Gpio

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

func InitGpio

func InitGpio(press chan<- struct{}) *Gpio

func (*Gpio) Close

func (g *Gpio) Close()

func (*Gpio) Run

func (g *Gpio) Run()

type Interval

type Interval struct {
	TicksPerBeat int
	Ticks        int
}

type Key

type Key struct {
	Ch  rune        // a unicode character
	Key termbox.Key // one of Key* constants, invalid if 'Ch' is not 0
}

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(
	msgs []chan<- Beats,
	tempo chan<- int,
	keyMap map[Key]*Coord,
	debug bool,
) *Keyboard

func (*Keyboard) Close

func (kb *Keyboard) Close()

func (*Keyboard) Run

func (kb *Keyboard) Run()

type Loop

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

func InitLoop

func InitLoop(
	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

func (*Render) Close

func (r *Render) Close()

func (*Render) Draw

func (r *Render) Draw()

func (*Render) Run

func (r *Render) Run()

type Wavs

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

func InitWavs

func InitWavs() *Wavs

func (*Wavs) Close

func (w *Wavs) Close()

func (*Wavs) Play

func (wavs *Wavs) Play(i int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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