mlsic

package module
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

README

Go Reference Build

Mlsic

IN DEVELOPMENT

How to get started

First take a look in the /example/ directory for a quick high use example of the module.

Go

You need Go 1.19 installed on your system.

PortAudio

You also need PortAudio installed.

On Debian based linux distors you can do apt install portaudio19-dev.

On MacOS you can use Hoembrew brew install portaudio.

Alternatively under /render you will find a wav and aiff renderer for 100% offline audio generation.

Dot cli

If you wish to render SVG files out of your generated graphs (see /generator) you will need Graphviz Dot cli installed.

Documentation

Overview

Package mlsic provides compositional algorithms and abstractions for producing audio.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Algo1

type Algo1 struct {
	// Model is used as Model.Dump() to retrieve to total of graphs Algo1 should process.
	Graphs Graph
	// Outputs holds output renders.
	Outputs []Renderer
	// Panning is used as Panning.Apply(sine, value) to pan the sine waves generated.
	Panning Pan
	// Format (audio.Format) holds number of channels and sample-rate in Hz.
	Format *audio.Format
	// Logging enables logging during Algo1.Run().
	Logging bool
	// contains filtered or unexported fields
}

Algo1 holds all necessary dependencies for the algorithm to run.

func NewAlgo1

func NewAlgo1(g Graph, r Renderer, opts ...Algo1Option) (a1 *Algo1)

NewAlgo1 creates an Algo1 with the default values. It accepts options for custom setup, ie different audio format or multiple renderers (ie, save as WAV and play via PortAudio.)

func (*Algo1) Run

func (a *Algo1) Run() error

Run executes the Algo1.

type Algo1Option

type Algo1Option func(*Algo1)

Algo1Option if a custom type function that accepts *Algo1 and is used WithXXX options functions.

func Algo1WithAdditionalRenderer

func Algo1WithAdditionalRenderer(r Renderer) Algo1Option

Algo1WithAdditionalRenderer can be used to have Algo1 render with more renderers than the one provided.

func Algo1WithAudioFormat

func Algo1WithAudioFormat(format *audio.Format) Algo1Option

Algo1WithAudioFormat can set custom format for Algo1.

func Algo1WithLogging

func Algo1WithLogging() Algo1Option

Algo1WithLogging enables logging for Algo1.

func Algo1WithPan

func Algo1WithPan(pan Pan) Algo1Option

Algo1WithPan can set custom pan for Algo1.

type Graph

type Graph interface {
	// Dump must return a slice of simple.WeightedUndirectedGraph.
	// The order of the graphs are sorted in the slice is the order
	// they will be executed by the compositional algo.
	Dump() ([]*simple.WeightedUndirectedGraph, error)
}

Graph is intended as decoupling the graph generation implementation from the compositional algorithms.

type Pan

type Pan interface {
	// Apply must accept the audio signal and the relevant position between total of channels Channels().
	// Buffer must always be of MONO format (ie. audio.FormatMono96000 or audio.FormatMono44100).
	// Position must be always between 0.0 and 1.0. In the case of two channels values from 0. to 0.5
	// will represent the left speaker and values from 0.5 to 1. the right one.
	// In the case of four speakers setup values from 0. to 0.25 will represent speakers no.1 etc..
	Apply(signal audio.PCMBuffer, position float32) []*audio.PCMBuffer
	// Channels must return the total number of channels the Apply() method should use.
	Channels() int
}

Pan declares a generic interface intended to be used for panning operations. Pan is not designed for equal power multi-speaker panning. It will always pan the signal from a single source point.

type Renderer

type Renderer interface {
	// Render accepts a slice of audio.PCMBuffer that must always be of MONO format (ie. audio.FormatMono96000 or audio.FormatMono44100).
	// The number of buffers in the slice represent the numbers of audio channels the renderer must handle.
	Render(b []*audio.PCMBuffer) error
}

Renderer Pan declares a generic interface intended to be used for sound rendering operations.

Directories

Path Synopsis
Package calculate provides convenient functions to help perform various repetitive calculations.
Package calculate provides convenient functions to help perform various repetitive calculations.
example
hello
This is simple example demonstrating the use of mlsic packages with a CLI.
This is simple example demonstrating the use of mlsic packages with a CLI.
Package generator implements mlsic.Graph but instead of using GNNs for graph generation, it uses deterministic algos.
Package generator implements mlsic.Graph but instead of using GNNs for graph generation, it uses deterministic algos.
Package pan holds various mlsic.Pan implementations.
Package pan holds various mlsic.Pan implementations.
Package render holds various mlsic.Renderer implementations.
Package render holds various mlsic.Renderer implementations.

Jump to

Keyboard shortcuts

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