Example #1
0
func (t *Track) Init() (sampleRate, channels int, err error) {
	b, err := t.r.get()
	if err != nil {
		return 0, 0, err
	}
	g, err := gme.New(b, defaultSampleRate)
	if err != nil {
		return 0, 0, err
	}
	if err := g.Start(t.track); err != nil {
		return 0, 0, nil
	}
	t.g = g
	return defaultSampleRate, defaultChannels, nil
}
Example #2
0
func (t *Track) Info() (codec.SongInfo, error) {
	var si codec.SongInfo
	b, err := t.r.get()
	if err != nil {
		return si, err
	}
	g, err := gme.New(b, gme.InfoOnly)
	if err != nil {
		return si, err
	}
	info, err := g.Track(t.track)
	g.Close()
	return codec.SongInfo{
		Time:   info.PlayLength + gme.FadeLength,
		Artist: info.Author,
		Title:  info.Song,
		Album:  info.Game,
		Track:  float64(t.track),
	}, err
}
Example #3
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
}