Example #1
0
File: nsf.go Project: shazow/mog
func (n *NSFSong) Info() (si codec.SongInfo, err error) {
	ns := n.NSF
	if ns == nil {
		r, _, err := n.Reader()
		if err != nil {
			return si, err
		}
		defer r.Close()
		ns, err = nsf.New(r)
		if err != nil {
			return si, err
		}
	}
	s := n.NSF.Songs[n.Index-1]
	title := s.Name
	if title == "" {
		title = fmt.Sprintf("%s:%02d", n.NSF.Game, n.Index)
	}
	si = codec.SongInfo{
		Time:   s.Duration,
		Artist: n.NSF.Artist,
		Album:  n.NSF.Game,
		Track:  float64(n.Index),
		Title:  title,
	}
	return
}
Example #2
0
File: nsf.go Project: shazow/mog
func (n *NSFSong) Init() (sampleRate, channels int, err error) {
	if n.NSF == nil {
		r, _, err := n.Reader()
		if err != nil {
			return 0, 0, err
		}
		defer r.Close()
		n.NSF, err = nsf.New(r)
		if err != nil {
			return 0, 0, err
		}
	}
	n.NSF.Init(n.Index)
	n.Playing = true
	return int(n.NSF.SampleRate), 1, nil
}
Example #3
0
File: nsf.go Project: shazow/mog
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
}