buffer

package
v0.0.0-...-4859f2f Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BufferPool

func BufferPool(ctx context.Context) *pool.Pool[Buffer]

BufferPool returns the buffer pool for this context, or nil if no pool is set.

Example
package main

import (
	"fmt"

	"github.com/green-aloe/enobox/buffer"
	"github.com/green-aloe/enobox/context"
	"github.com/green-aloe/enobox/tone"
)

func main() {
	defer tone.SetNumHarmGains(tone.DefaultNumHarmGains)

	for _, config := range []struct {
		sampleRate   int
		numHarmGains int
	}{
		{context.DefaultSampleRate, tone.DefaultNumHarmGains},
		{48_000, 10},
		{96_000, 100},
	} {
		tone.SetNumHarmGains(config.numHarmGains)
		ctx := context.NewContextWith(context.ContextOptions{
			SampleRate: config.sampleRate,
		})

		pool := buffer.BufferPool(ctx)
		buffer := pool.Get()

		fmt.Println(len(buffer.Tones), len(buffer.Tones[0].HarmonicGains))
	}

}
Output:

44100 20
48000 10
96000 100

Types

type Buffer

type Buffer struct {
	Tones []tone.Tone
}

func NewBuffer

func NewBuffer(ctx context.Context) Buffer

func (*Buffer) Release

func (buffer *Buffer) Release()

Release releases the buffer back to the system. After this, the buffer should not be used again.

func (*Buffer) Reset

func (buffer *Buffer) Reset()

Reset resets a buffer to its zero values.

Jump to

Keyboard shortcuts

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