render

package
v0.0.0-...-67c439a Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: Unlicense Imports: 10 Imported by: 0

Documentation

Overview

Package render holds various mlsic.Renderer implementations. It should be used along top package compositional algos.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aiff

type Aiff struct {
	// Filepath `/path/to/directory` where the file should be saved.
	Filepath string
}

Aiff holds relevant information for encoding and saving .aiff files out of audio.PCMBuffer.

func (*Aiff) Render

func (a *Aiff) Render(pcmBuffer []*audio.PCMBuffer) error

Render accepts a slice of audio.PCMBuffer and creates out of each one of them a mono .aiff file named /path/to/file/0.aiff for the first channel, /path/to/file/1.aiff for the second etc.

type PortAudio

type PortAudio struct {
	// Latency is part of the portaudio.StreamDeviceParameters.
	Latency time.Duration
	// OutputDevice is the device to be used.
	OutputDevice *portaudio.DeviceInfo
	// BufferSize is part of the portaudio.StreamDeviceParameters.
	BufferSize int
}

PortAudio implements mlsic.Renderer and holds all necessary dependencies for setting up PortAudio.

func NewPortAudio

func NewPortAudio(opts ...PortAudioOption) (pa *PortAudio, err error)

NewPortAudio will try to initialize with a portaudio.DefaultOutputDevice() with the default buffer size set at 512 abd latency 10.

func (*PortAudio) Render

func (p *PortAudio) Render(pcmBuffer []*audio.PCMBuffer) error

Render will render for as many channels as len(pcmBuffer). Samplerate is set by the first channel's (pcmBuffer[0]) format.

type PortAudioOption

type PortAudioOption func(*PortAudio)

PortAudioOption if a custom type function that accepts *PortAudio and is used WithXXX PortAudio options functions.

func WithBufferSize

func WithBufferSize(customSize int) PortAudioOption

WithBufferSize sets PortAudio's buffer size.

func WithLatency

func WithLatency(latency time.Duration) PortAudioOption

WithLatency sets PortAudio's latency.

func WithOutputDevice

func WithOutputDevice(device *portaudio.DeviceInfo) PortAudioOption

WithOutputDevice set custom output device.

type Wav

type Wav struct {
	// Filepath `/path/to/directory` where the file should be saved.
	Filepath string
	// Meta holds .wav file metadata.
	Meta *wav.Metadata
}

Wav holds relevant information for encoding and saving .wav files out of audio.PCMBuffer.

func (*Wav) Render

func (w *Wav) Render(pcmBuffer []*audio.PCMBuffer) error

Render accepts a slice of audio.PCMBuffer and creates out of each one of them a mono .wav file named /path/to/file/0.wav for the first channel, /path/to/file/1.wav for the second etc.

Jump to

Keyboard shortcuts

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