synth

package
v0.0.0-...-441bbdd Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Combine

func Combine(readers ...io.Reader) io.Reader

Combine takes an arbitrary number of Readers that return int16 samples, and returns a Reader that combines those samples into one single sample value

func NewSineWave

func NewSineWave(sampleRate int, freq float64, duration time.Duration) io.Reader

NewSineWave returns a SineWave io.Reader. The Reader returns int16 samples of a sine wave with maximum amplitude. Byte ordering is little endian. The format is:

[sample 0 byte 0] [sample 0 byte 1] [sample 1 byte 0] [sample 1 byte 1]...

func NewSquareWave

func NewSquareWave(sampleRate int, freq float64, duration time.Duration) io.Reader

NewSquareWave returns a SquareWave io.Reader. The Reader returns int16 samples of a square wave with maximum amplitude. Byte ordering is little endian. The format is:

[sample 0 byte 0] [sample 0 byte 1] [sample 1 byte 0] [sample 1 byte 1]...

func Plot

func Plot(r io.Reader, caption string, scale float64) string

Plot reads the int16 samples from the io.Reader and returns a XY plot. The number of points in the X axis is fixed, use scale to control zooming out, e.g. for a scale of 0.25 each data point represents 4 samples

func Sustain

func Sustain(r io.Reader, percentage float64) io.Reader

Sustain takes a Reader that returns int16 samples, and returns a Reader that multiplies each value by the given percentage. The percentage must be a value between 0 and 1

Types

type CombinedReader

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

CombinedReader takes an arbitrary number of Readers that return int16 samples, and combines those samples into one single sample value

func (*CombinedReader) Read

func (m *CombinedReader) Read(p []byte) (int, error)

type SineWave

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

SineWave is an io.Reader that returns int16 samples. The Reader returns int16 samples of a sine wave with maximum amplitude. Byte ordering is little endian. The format is:

[sample 0 byte 0] [sample 0 byte 1] [sample 1 byte 0] [sample 1 byte 1]...

func (*SineWave) Read

func (s *SineWave) Read(buf []byte) (int, error)

type SquareWave

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

SquareWave is an io.Reader that returns int16 samples. The Reader returns int16 samples of a square wave with maximum amplitude. Byte ordering is little endian. The format is:

[sample 0 byte 0] [sample 0 byte 1] [sample 1 byte 0] [sample 1 byte 1]...

func (*SquareWave) Read

func (s *SquareWave) Read(buf []byte) (int, error)

type SustainedReader

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

SustainedReader takes a Reader that returns int16 samples, and multiplies each value by the given percentage. The percentage must be a value between 0 and 1

func (*SustainedReader) Read

func (s *SustainedReader) Read(p []byte) (n int, err error)

type WaveGenerator

type WaveGenerator = func(sampleRate int, freq float64, duration time.Duration) io.Reader

A WaveGenerator returns an io.Reader. The Reader returns int16 samples of a wave with maximum amplitude. Byte ordering is little endian. The format is:

[sample 0 byte 0] [sample 0 byte 1] [sample 1 byte 0] [sample 1 byte 1]...

Jump to

Keyboard shortcuts

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