util

package
v0.0.0-...-0ccfc62 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2018 License: GPL-3.0 Imports: 9 Imported by: 7

Documentation

Overview

Renders various data from a channel of [-1, 1] onto screen.

Package util provides a collection of utilities for dealing with Sounds, generating them, displaying them, calculating their samples etc...

Renders various data from a channel of [-1, 1] onto screen.

Index

Constants

View Source
const (
	LOAD_LIMIT = int(s.CyclesPerSecond * 10 * 60) /* 10 minutes */
)

Variables

This section is empty.

Functions

func CacheSamples

func CacheSamples(sound s.Sound) []float64

func GuitarChord

func GuitarChord(chord string) s.Sound

GuitarChord converts a standard guitar representation (e.g. "2x0232") into the sound of those notes being played, assuming standard tuning.

func MidiToHz

func MidiToHz(midiNote int) float64

midiToHz returns the Hz of a given midi note.

func MidiToSound

func MidiToSound(midiNote int) s.Sound

MidiToSound converts a midi note into a sound that plays its pitch.

func ParseChord

func ParseChord(chord string, base uint) s.Sound

ParseChord converts a chord string (e.g. "G#sus4") and base octave into a Sound that contains the notes in the chord.

func ParseNotesToChord

func ParseNotesToChord(notes string, base uint) s.Sound

ParseNotesToChord takes a collection of notes (e.g. "CEG") plus the base octave and returns a sound of them all being played together.

Types

type ComplexLine

type ComplexLine struct {
	Values <-chan []complex128
	R      float32
	G      float32
	B      float32
	// contains filtered or unexported fields
}

Line is the samples channel for the line, plus their color.

type Event

type Event struct {
	// (r, g, b) colours for the event.
	R float32
	G float32
	B float32
}

Event is something that occurred at a single sample of the values.

type Line

type Line struct {
	Values <-chan float64
	R      float32
	G      float32
	B      float32
	// contains filtered or unexported fields
}

Line is the samples channel for the line, plus their color.

func NewLine

func NewLine(v <-chan float64, r float32, g float32, b float32) Line

NewLine creates a line from the exported fields.

type Screen

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

Screen is an on-screen opengl window that renders the channel.

func NewScreen

func NewScreen(width int, height int, samplesPerPixel int) *Screen

NewScreen creates a new output screen of a given size and sample density.

func (*Screen) Render

func (s *Screen) Render(values <-chan float64, sampleRate int)

Render starts rendering a channel of waves samples to screen.

func (*Screen) RenderLinesWithEvents

func (s *Screen) RenderLinesWithEvents(lines []Line, events <-chan interface{}, sampleRate int)

RenderLinesWithEvents renders multiple channels of samples to screen, and draws events.

type SpectrogramScreen

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

Screen is an on-screen opengl window that renders the channel.

func NewSpectrogramScreen

func NewSpectrogramScreen(width int, height int, bpo int) *SpectrogramScreen

NewScreen creates a new output screen of a given size and sample density.

func (*SpectrogramScreen) Render

func (s *SpectrogramScreen) Render(values <-chan []complex128, sampleRate int)

Render starts rendering a channel of waves samples to screen.

func (*SpectrogramScreen) RenderLineWithEvents

func (s *SpectrogramScreen) RenderLineWithEvents(line *ComplexLine, events <-chan interface{}, sampleRate int)

RenderLinesWithEvents renders multiple channels of samples to screen, and draws events.

Jump to

Keyboard shortcuts

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