func main() { err := vox.Init("", 44100, 2, 0) if err != nil { panic(err) } defer vox.Quit() println(vox.Version) song, err := vox.Open("../data/songs/test.sunvox") if err != nil { panic(err) } defer song.Close() println(song.Name()) song.SetVolume(256) song.Mod[7].Trigger(0, 64, 128, 0, 0) time.Sleep(1 * time.Second) song.Mod[7].Trigger(0, 64, 128, 0, 0) time.Sleep(1 * time.Second) song.Play() for !song.Finished() { } }
func playInFull(songPath string) { songName := filepath.Base(songPath) errTest(vox.Init("", 44100, 2, 0)) println("Vox!\nv" + vox.Version + "\n") println("Playing song \"" + songName + "\"...") defer vox.Quit() song, err := vox.Open(songPath) errTest(err) song.SetLooping(false) defer song.Close() song.Play() for !song.Finished() { } //TODO: Doesn't ever stop... }
func playSprite(songPath string, piece int) { songName := filepath.Base(songPath) errTest(vox.Init("", 44100, 2, 0)) println("Vox!\nv" + vox.Version + "\n") println("Playing song \"" + songName + "\"...") defer vox.Quit() song, err := vox.Open(songPath) errTest(err) song.SetLooping(false) pieceLength := song.Lines() / 8 // Eight pieces per sprite defer song.Close() song.Seek(piece*pieceLength, 0) song.Play() for song.Line() < ((piece+1)*pieceLength - 1) { } time.Sleep(time.Duration(getSongLength(*song)) * time.Second) song.Pause() }
func studder(songPath string, studderTime int) { songName := filepath.Base(songPath) errTest(vox.Init("", 44100, 2, 0)) println("Vox!\nv" + vox.Version + "\n") println("Playing song \"" + songName + "\"...") defer vox.Quit() song, err := vox.Open(songPath) errTest(err) song.SetLooping(false) defer song.Close() song.Play() for !song.Finished() { println("Line " + strconv.Itoa(song.Line()) + ", Volume " + strconv.Itoa(song.Volume()) + "%") song.Pause() time.Sleep(time.Duration(studderTime) * time.Millisecond) song.Play() time.Sleep(time.Duration(studderTime) * time.Millisecond) } }