synth

package
v0.0.0-...-8f00a11 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package synth provides functions for audio synthesis.

Stream

Most functions return a Stream, which is a contained channel that is closable, so consumers may end the signal generation. Typical stream usage may look like:

// Function that returns a stream
stream := synth.Func(...)

// Process frames from the stream
for i := 0; i < 128; i++ {
   processSample(stream.Next())
}

// We're done here
stream.Close()

References

Mostly based in audiolazy © Copyright 2012-2016 Danilo de Jesus da Silva Bellini.

https://github.com/danilobellini/audiolazy

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Frequency

type Frequency float64

Frequency in Hz

func (Frequency) Lag

func (f Frequency) Lag() Lag

Lag (number of samples) for the frequency (rad/sample).

func (Frequency) String

func (f Frequency) String() string

type Lag

type Lag float64

Lag or Number of samples

func (Lag) Frequency

func (l Lag) Frequency() Frequency

Frequency (rad/sample) for the lag (number of samples).

type SampleRate

type SampleRate uint64

SampleRate samples per second

func (SampleRate) SHz

func (r SampleRate) SHz() (float64, Frequency)

SHz returns the second and HZ unit (samples and radians per sample).

type Stream

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

Stream contains a channel of streamed samples.

func FadeIn

func FadeIn(duration int64) *Stream

func FadeOut

func FadeOut(duration int64) *Stream

func Fixed

func Fixed(duration int64, value float64) *Stream

Fixed returns a fixed stream of samples.

func FixedOnes

func FixedOnes(duration int64) *Stream

FixedOnes stream.

func FixedZeros

func FixedZeros(duration int64) *Stream

FixedZeros stream.

func GaussianNoise

func GaussianNoise(duration int64, mu, sigma float64) *Stream

func Impulse

func Impulse(duration int64, dit, dat float64) *Stream

func Line

func Line(duration int64, begin, end float64) *Stream

Line produces a streamar finite stream with a straight stream.

func LinearADSR

func LinearADSR(duration, attack, decay int64, sustain float64, release int64) *Stream

LinearADSR is a streamar ADSR envelope

func LinearAttack

func LinearAttack(attack, decay int64, sustain float64) *Stream

LinearAttack is a streaming ADS fading attack generator.

func NewStream

func NewStream(buffer int) *Stream

NewStream with an optional buffer size. Set to 0 to create an unbuffered stream.

func Sinusoid

func Sinusoid(frequency float64, phase float64) *Stream

func WhiteNoise

func WhiteNoise(duration int64, low, high float64) *Stream

func (*Stream) Close

func (f *Stream) Close()

Close the sending function. Calling Next will yield undefined results and may panic.

func (*Stream) Done

func (f *Stream) Done() bool

Done checks if the stream sender is done.

func (*Stream) Next

func (f *Stream) Next() float64

Next sample in the stream.

Jump to

Keyboard shortcuts

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