Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Instrument ¶
type Instrument int
Instrument is one of the instruments supported through the NBS format.
const ( InstrumentHarp Instrument = iota InstrumentBass InstrumentBassDrum InstrumentSnare InstrumentHat InstrumentGuitar InstrumentFlute InstrumentBell InstrumentChime InstrumentXylophone InstrumentIronXylophone InstrumentCowBell InstrumentDidgeridoo InstrumentBit InstrumentBanjo InstrumentPling )
The following are all supported NBS instruments.
type Layer ¶
type Layer struct { // Volume is the volume of the layer. Volume uint8 // Name is the name of the layer. Name string // contains filtered or unexported fields }
Layer is a layer in the NBS data.
type Note ¶
type Note struct { // Instrument is the instrument intended to be used. Instrument Instrument // Key is the key the note should be played on. Key int }
Note is a note in a note block song.
type Player ¶
type Player struct { // C receives a Note everytime the Song being played by the Player reaches a point where a note should be played. // C is closed as soon as the song ends or when Player.Stop() is called. It is therefore possible to iterate over // this channel. C <-chan Note // contains filtered or unexported fields }
Player plays a Song. Its field C may be iterated over to obtain Notes from the song whenever a new Note should be played like so:
for note := range Player.C { fmt.Println(note) }
The channel C will be closed when the song ends or after Player.Stop is called, meaning the loop will end.
type Song ¶
type Song struct { // Title is the title of the NBS song. Title string // Description is the description of the NBS song. Description string // Author is the creator of the song. Author string // Layers contains each layer. Layers map[int16]*Layer // Length is the length of the song in ticks. Length int64 // SongHeight is the amount of different layers. SongHeight int16 // Speed is the speed of the song. Speed float32 }
Song is a decoded NBS song. A Song may be re-used safely by calling Play for every individual instance of a song being played.
func MustReadFile ¶
MustReadFile reads and parses an NBS file and returns a Song that may be played using Song.Play. It panics if an error occurred during reading.
func Read ¶
Read reads NBS data from a buffer and returns a Song that may be played using Song.Play.