nsf

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2015 License: ISC, ISC Imports: 9 Imported by: 0

README

nsf

Nintendo Sound Format for Go

docs

http://godoc.org/github.com/mjibson/nsf

Documentation

Overview

Package nsf provides reading and emulating of Nintendo NSF sound files.

Testing

PortAudio is the current default for audio output.

To install PortAudio on Mac OSX:

brew install portaudio

To install PortAudio on Ubuntu:

sudo apt-get install portaudio19-dev

Then play with go test. The track can be changed by incrementing the parameter in the n.Init() call in nsf_test.go.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultSampleRate is the default sample rate of a track after calling
	// Init().
	DefaultSampleRate int64 = 44100

	DefaultDuration = time.Minute * 2
	DefaultFade     = time.Second * 2
	DefaultSilence  = time.Second * 2
)
View Source
var ErrUnrecognized = errors.New("nsf: unrecognized format")

Functions

This section is empty.

Types

type NSF

type NSF struct {
	*cpu6502.Cpu

	// Silence is the duration for which if the result of Play is silence,
	// Play will halt. Set to 0 to disable silence check.
	Silence time.Duration
	// SampleRate is the sample rate at which samples will be generated. If not
	// set before Init(), it is set to DefaultSampleRate.
	SampleRate int64

	// Start is the 0-based index of the starting song
	Start     byte
	Songs     []Song
	Copyright string
	Artist    string
	Game      string

	LoadAddr uint16
	InitAddr uint16
	PlayAddr uint16

	SpeedNTSC  uint16
	Bankswitch [8]byte
	Data       []byte
	// contains filtered or unexported fields
}

func New

func New(r io.Reader) (*NSF, error)

func ReadNSF

func ReadNSF(b []byte) (*NSF, error)

ReadNSF reads a NSF file from b.

func ReadNSFE added in v0.0.3

func ReadNSFE(b []byte) (*NSF, error)

ReadNSFE reads a NSFE file from b.

func (*NSF) Init

func (n *NSF) Init(song int)

Init initializes the 1-based song for playing. Only one song my play at once. An invalid song index will play the first song.

func (*NSF) Play

func (n *NSF) Play(samples int) []float32

Play returns the requested number of samples. If less are returned, the silence check or time limit have been reached.

func (*NSF) Tick

func (n *NSF) Tick()

type Song added in v0.0.3

type Song struct {
	Name string
	// Duration is the duration after which Play will halt. Set to < 0 to play
	// indefinitely.
	Duration time.Duration
	// After Duration, fade out. Set to 0 to end immediately.
	Fade time.Duration
}

Directories

Path Synopsis
Package cpu6502 implements a 6502 emulator.
Package cpu6502 implements a 6502 emulator.

Jump to

Keyboard shortcuts

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