apu

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APU

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

APU is the GameBoy's audio processing unit. Audio is comprised of four channels, each one controlled by a set of registers.

Channels 1 and 2 are both Square channels, channel 3 is a arbitrary waveform channel which can be set in RAM, and channel 4 outputs noise.

func (*APU) Init

func (a *APU) Init(sound bool)

Init the sound emulation for a Gameboy.

func (*APU) Read

func (a *APU) Read(address uint16) byte

Read returns a value from the APU.

func (*APU) ToggleSoundChannel

func (a *APU) ToggleSoundChannel(channel int)

ToggleSoundChannel toggles a sound channel for debugging.

func (*APU) Write

func (a *APU) Write(address uint16, value byte)

Write a value to the APU registers.

func (*APU) WriteWaveform

func (a *APU) WriteWaveform(address uint16, value byte)

WriteWaveform writes a value to the waveform ram.

type Channel

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

Channel represents one of four Gameboy sound channels.

func NewChannel

func NewChannel() *Channel

NewChannel returns a new sound channel using a sampling function.

func (*Channel) Reset

func (chn *Channel) Reset(duration int)

Reset the channel to some default variables for the sweep, amplitude, envelope and duration.

func (*Channel) Sample

func (chn *Channel) Sample() (output uint16)

Sample returns a single sample for streaming the sound output. Each sample will increase the internal timer based on the global sample rate.

type WaveGenerator

type WaveGenerator func(t float64) byte

WaveGenerator is a function which can be used for generating waveform samples for different channels.

func Noise

func Noise() WaveGenerator

Noise returns a wave generator for a noise channel. This is used by channel 4.

func Square

func Square(mod float64) WaveGenerator

Square returns a square wave generator with a given mod. This is used for channels 1 and 2.

func Waveform

func Waveform(ram []byte) WaveGenerator

Waveform returns a wave generator for some waveform ram. This is used by channel 3.

Jump to

Keyboard shortcuts

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