opl2

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package opl2 renders the melodic mode of the Yamaha YM3812. The oscillator and envelope logic are adapted from st3play's Opal derivative. See LICENSE.st3play.

Index

Constants

View Source
const Rate = 157500000.0 / (11 * 288)

Rate is the native OPL2 sample rate with the ISA oscillator.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chip

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

Chip is an independent nine-channel melodic OPL2 instance.

func New

func New() Chip

New initializes the chip with all notes off.

func (*Chip) Active

func (c *Chip) Active() bool

Active reports whether any operator is sounding or releasing.

func (*Chip) Sample

func (c *Chip) Sample() float32

Sample advances the chip by one native frame.

func (*Chip) Write

func (c *Chip) Write(address, value uint8)

Write updates a melodic OPL2 register. Unused register addresses are ignored.

type Output

type Output struct {
	Chip
	// contains filtered or unexported fields
}

Output resamples the chip's native output with the st3play interpolation kernel. The phase remains continuous across register writes and reads.

func NewOutput

func NewOutput(rate int) Output

NewOutput sets up native OPL2 output at the requested positive sample rate.

func (*Output) RenderSample

func (o *Output) RenderSample() float32

RenderSample produces one output frame.

Jump to

Keyboard shortcuts

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