Ejemplo n.º 1
0
func ReadNSFSongs(rf codec.Reader) (codec.Songs, error) {
	r, _, err := rf()
	if err != nil {
		return nil, err
	}
	defer r.Close()
	n, err := nsf.New(r)
	if err != nil {
		return nil, err
	}
	songs := make(codec.Songs, len(n.Songs))
	for i := 0; i < len(n.Songs); i++ {
		songs[codec.Int(i)] = &NSFSong{
			NSF:    n,
			Index:  i + 1,
			Reader: rf,
		}
	}
	return songs, nil
}
Ejemplo n.º 2
0
func NewSongs(rf codec.Reader) (codec.Songs, error) {
	d := reader{
		r: rf,
	}
	b, err := d.get()
	if err != nil {
		return nil, err
	}
	gg, err := gme.New(b, defaultSampleRate)
	if err != nil {
		return nil, err
	}
	songs := make(codec.Songs)
	for i, tr := 0, gg.Tracks(); i < tr; i++ {
		songs[codec.Int(i)] = &Track{
			r:     &d,
			track: i,
		}
	}
	return songs, nil
}