vox

package module
v0.0.0-...-2ccc308 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2013 License: BSD-2-Clause Imports: 5 Imported by: 1

README

vox Play and manipulate SunVox songs in go

Notes

  • WINDOWS: There isn't a 64bit library for libsunvox yet, so you must use mingw32 and GOARCH=386.
  • You'll have to copy the correct dynamic library for your platform from data into the folder with your program.

Install

go get github.com/ajhager/vox

Try it!

package main

import (
    "github.com/ajhager/vox"
)

func main() {
    vox.Init("", 44100, 2, 0)
    defer vox.Quit()
    song, _ := vox.Open("test.sunvox")
    defer song.Close()
    song.Play()
    for {}
}

Documentation

Index

Constants

View Source
const (
	// Init flags
	NO_DEBUG_OUTPUT     = C.SV_INIT_FLAG_NO_DEBUG_OUTPUT
	USER_AUDIO_CALLBACK = C.SV_INIT_FLAG_USER_AUDIO_CALLBACK
	AUDIO_INT16         = C.SV_INIT_FLAG_AUDIO_INT16
	AUDIO_FLOAT32       = C.SV_INIT_FLAG_AUDIO_FLOAT32
	ONE_THREAD          = C.SV_INIT_FLAG_ONE_THREAD

	// Note constants
	NOTE_OFF      = C.NOTECMD_NOTE_OFF
	ALL_NOTES_OFF = C.NOTECMD_ALL_NOTES_OFF
	CLEAN_SYNTHS  = C.NOTECMD_CLEAN_SYNTHS
	STOP          = C.NOTECMD_STOP
	PLAY          = C.NOTECMD_PLAY

	// Module flags
	FLAG_EXISTS  = C.SV_MODULE_FLAG_EXISTS
	FLAG_EFFECT  = C.SV_MODULE_FLAG_EFFECT
	INPUTS_OFF   = C.SV_MODULE_INPUTS_OFF
	INPUTS_MASK  = C.SV_MODULE_INPUTS_MASK
	OUTPUTS_OFF  = C.SV_MODULE_OUTPUTS_OFF
	OUTPUTS_MASK = C.SV_MODULE_OUTPUTS_MASK

	// Type flags
	INT16   = C.SV_STYPE_INT16
	INT32   = C.SV_STYPE_INT32
	FLOAT32 = C.SV_STYPE_FLOAT32
	FLOAT64 = C.SV_STYPE_FLOAT64
)

Variables

View Source
var (
	Version string
)

Functions

func Init

func Init(dev string, freq, channels, flags int) error

Init loads the sunvox dll and initializes the library.

func Quit

func Quit()

Quit deinitializes the library and unloads the sunvox dll.

func SampleType

func SampleType() int

SampleType returns the internal sample type of the sunvox engine.

func Ticks

func Ticks() uint

Ticks returns the current tick counter (from 0 to 0xFFFFFFFF).

func TicksPerSecond

func TicksPerSecond() uint

TicksPerSecond returns the number of sunvox ticks per second.

Types

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module synths

func (*Module) Color

func (m *Module) Color() (byte, byte, byte)

func (*Module) Name

func (m *Module) Name() string

func (*Module) Position

func (m *Module) Position() (int, int)

func (*Module) Trigger

func (m *Module) Trigger(channel, note, vel, ctl, val int)

Trigger plays a note on a channel in a module. channel: 0..7 note: 0..127 - note; 128 - note off; 129, 130.. - note command vel: 1..129 ctl: CCXX; CC - controller number; X - std effect val: controller value

type Song

type Song struct {
	Mod []*Module
	// contains filtered or unexported fields
}

Song is used to load and play sunvox songs.

func Open

func Open(path string) (*Song, error)

Open creates a new slot and laods a sunvox song into it.

func (*Song) BeatsPerMinute

func (s *Song) BeatsPerMinute() int

BeatsPerMinute returns the songs beats per minute.

func (*Song) Close

func (s *Song) Close()

Close the song. The song should not be used after calling this.

func (*Song) Finished

func (s *Song) Finished() bool

Finished indicates if the song has gotten to the end.

func (*Song) Frames

func (s *Song) Frames() int

Frames gives the length of the song in frames.

func (*Song) Level

func (s *Song) Level(channel int) int

Level returns the current signal level of a channel.

func (*Song) Line

func (s *Song) Line() int

Line returns the current line in the song.

func (*Song) Lines

func (s *Song) Lines() int

Lines gives the length of the song in lines.

func (*Song) Name

func (s *Song) Name() string

Name returns the name of the song.

func (*Song) Pause

func (s *Song) Pause()

Pause stops the song's playback at its current position.

func (*Song) Play

func (s *Song) Play() error

Play starts playback from where ever the song was stopped.

func (*Song) Replay

func (s *Song) Replay()

Replay starts playback from the beginning.

func (*Song) Seek

func (s *Song) Seek(offset, whence int)

Seek sets the offset of the song in lines, interpreted according to whence: // 0 means relative to the start of the song, 1 means relative to the current // line, and 2 means relative to the end.

func (*Song) SetLooping

func (s *Song) SetLooping(loop bool)

SetLooping enables or disables looping.

func (*Song) SetVolume

func (s *Song) SetVolume(vol int)

SetVolume sets the volume of the song.

func (*Song) TicksPerLine

func (s *Song) TicksPerLine() int

TicksPerLine returns the number of ticks per line.

func (*Song) Volume

func (s *Song) Volume() int

Volume returns the volume of the song.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL