audio

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: GPL-3.0, GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package audio implements the audio generation of the TIA. Originally, Gopher2600 used Ron Fries' audio implementation but this has now been completely superceded by the work of Chris Brenner.

Chris's work has been used in both the 6502.ts and Stella projects. Source from both projects was used as reference. Both projects are exactly equivalent.

  6502.ts (published under the MIT licence)
		https://github.com/6502ts/6502.ts/blob/6f923e5fe693b82a2448ffac1f85aea9693cacff/src/machine/stella/tia/PCMAudio.ts
		https://github.com/6502ts/6502.ts/blob/6f923e5fe693b82a2448ffac1f85aea9693cacff/src/machine/stella/tia/PCMChannel.ts

 Stella (published under the GNU GPL v2.0 licence)
		https://github.com/stella-emu/stella/blob/e6af23d6c12893dd17711002971087f28f87c31f/src/emucore/tia/Audio.cxx
		https://github.com/stella-emu/stella/blob/e6af23d6c12893dd17711002971087f28f87c31f/src/emucore/tia/AudioChannel.cxx

Index

Constants

View Source
const SampleFreq = 31400

SampleFreq represents the number of samples generated per second. This is the 30Khz reference frequency desribed in the Stella Programmer's Guide.

Variables

This section is empty.

Functions

func CmpRegisters added in v0.15.0

func CmpRegisters(a Registers, b Registers) bool

CmpRegisters returns true if the two registers contain the same values

Types

type Audio

type Audio struct {

	// the volume output for each channel
	Vol0 uint8
	Vol1 uint8
	// contains filtered or unexported fields
}

Audio is the implementation of the TIA audio sub-system, using Ron Fries' method. Reference source code here:

https://raw.githubusercontent.com/alekmaul/stella/master/emucore/TIASound.c

func NewAudio

func NewAudio() *Audio

NewAudio is the preferred method of initialisation for the Audio sub-system.

func (*Audio) RSYNC added in v0.15.0

func (au *Audio) RSYNC()

RSYNC resets clock228 to zero.

func (*Audio) ReadMemRegisters added in v0.12.1

func (au *Audio) ReadMemRegisters(data chipbus.ChangedRegister) bool

ReadMemRegisters checks the TIA memory for changes to registers that are interesting to the audio sub-system

Returns true if memory.ChipData has not been serviced.

func (*Audio) Reset added in v0.15.0

func (au *Audio) Reset()

func (*Audio) SetTracker added in v0.15.0

func (au *Audio) SetTracker(tracker Tracker)

SetTracker adds a Tracker implementation to the Audio sub-system.

func (*Audio) Snapshot added in v0.7.1

func (au *Audio) Snapshot() *Audio

Snapshot creates a copy of the TIA Audio sub-system in its current state.

func (*Audio) Step added in v0.14.0

func (au *Audio) Step() bool

Step the audio on one TIA clock. The step will be filtered to produce a 30Khz clock.

func (*Audio) String

func (au *Audio) String() string

type Registers added in v0.15.0

type Registers struct {
	Control uint8 // 4 bit
	Freq    uint8 // 5 bit
	Volume  uint8 // 4 bit
}

each channel has three registers that control its output. from the "Stella Programmer's Guide":

"Each audio circuit has three registers that control a noise-tone generator (what kind of sound), a frequency selection (high or low pitch of the sound), and a volume control."

not all the bits are used in each register. the comments below indicate how many of the least-significant bits are used.

func (Registers) String added in v0.15.0

func (reg Registers) String() string

type Tracker added in v0.15.0

type Tracker interface {
	// Tick is called every video cycle
	Tick(channel int, reg Registers)
}

Tracker implementations display or otherwise record the state of the audio registers for each channel.

Directories

Path Synopsis
Package mix is used to combine two distinct sound sources into either a mono or stereo signal.
Package mix is used to combine two distinct sound sources into either a mono or stereo signal.

Jump to

Keyboard shortcuts

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