package module
Version: v0.0.0-...-bc86040 Latest Latest

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

Go to latest
Published: Aug 5, 2022 License: MIT Imports: 4 Imported by: 12


go-jack GoDoc

Go bindings for Jack Audio Connection Kit


For a working passthrough example see example/passthrough.go

Import the package:

import "github.com/xthexder/go-jack"

Connect to an existing jack server:

client, _ := jack.ClientOpen("Example Client", jack.NoStartServer)
if client == nil {
	fmt.Println("Could not connect to jack server.")
defer client.Close()

Add a processing callback:

func process(nframes uint32) int {
	// Do processing here
	return 0

/* ... */

if code := client.SetProcessCallback(process); code != 0 {
	fmt.Println("Failed to set process callback.")

Activate the client:

if code := client.Activate(); code != 0 {
	fmt.Println("Failed to activate client.")

Add an output port:

port := client.PortRegister("out_1", jack.DEFAULT_AUDIO_TYPE, jack.PortIsOutput, 0)

Output a sine wave:

var Port *jack.Port

func process(nframes uint32) int {
	samples := Port.GetBuffer(nframes)
	nsamples := float64(len(samples))
	for i := range samples {
		samples[i] = jack.AudioSample(math.Sin(float64(i)*math.Pi*20/nsamples) / 2)
	return 0

Implemented Bindings

  • jack_client_t jack_client_open(client_name, options, *status)
  • int jack_client_close()
  • int jack_client_name_size()
  • char* jack_get_client_name(client)
  • jack_nframes_t jack_get_sample_rate(client)
  • void jack_on_shutdown(client, callback, arg)
  • int jack_set_process_callback(client, callback, arg)
  • jack_port_t jack_port_register(client, name, type, flags, buffer_size)
  • int jack_port_unregister(client, port)
  • void* jack_port_get_buffer(port, nframes)
  • int jack_midi_event_get(event, port_buffer, event_index)
  • void jack_midi_clear_buffer(port_buffer)
  • int jack_midi_event_write(port_buffer, time, data, data_size)
  • void jack_set_error_function(callback)
  • void jack_set_info_function(callback)

See Official Jack API for detailed documentation on each of these functions.




View Source
const (
	// JackOptions
	NullOption    = C.JackNullOption
	NoStartServer = C.JackNoStartServer
	UseExactName  = C.JackUseExactName
	ServerName    = C.JackServerName
	LoadName      = C.JackLoadName
	LoadInit      = C.JackLoadInit
	SessionID     = C.JackSessionID

	// JackPortFlags
	PortIsInput    = C.JackPortIsInput
	PortIsOutput   = C.JackPortIsOutput
	PortIsPhysical = C.JackPortIsPhysical
	PortCanMonitor = C.JackPortCanMonitor
	PortIsTerminal = C.JackPortIsTerminal

	// JackStatus
	Failure       = C.JackFailure
	InvalidOption = C.JackInvalidOption
	NameNotUnique = C.JackNameNotUnique
	ServerStarted = C.JackServerStarted
	ServerFailed  = C.JackServerFailed
	ServerError   = C.JackServerError
	NoSuchClient  = C.JackNoSuchClient
	LoadFailure   = C.JackLoadFailure
	InitFailure   = C.JackInitFailure
	ShmFailure    = C.JackShmFailure
	VersionError  = C.JackVersionError
	BackendError  = C.JackBackendError
	ClientZombie  = C.JackClientZombie

	DEFAULT_AUDIO_TYPE = "32 bit float mono audio"
	DEFAULT_MIDI_TYPE  = "8 bit raw midi"


This section is empty.


func ClientNameSize

func ClientNameSize() int

func SetErrorFunction

func SetErrorFunction(callback ErrorFunction)

func SetInfoFunction

func SetInfoFunction(callback InfoFunction)

func StrError

func StrError(status int) error


type AudioSample

type AudioSample float32

type BufferSizeCallback

type BufferSizeCallback func(uint32) int

type Client

type Client struct {
	// contains filtered or unexported fields

func ClientOpen

func ClientOpen(name string, options int) (*Client, int)

func (*Client) Activate

func (client *Client) Activate() int

func (*Client) CPULoad

func (client *Client) CPULoad() float32

func (*Client) Close

func (client *Client) Close() int

func (*Client) Connect

func (client *Client) Connect(srcPort, dstPort string) int

func (*Client) ConnectPorts

func (client *Client) ConnectPorts(srcPort, dstPort *Port) int

func (*Client) Disconnect

func (client *Client) Disconnect(srcPort, dstPort string) int

func (*Client) DisconnectPorts

func (client *Client) DisconnectPorts(srcPort, dstPort *Port) int

func (*Client) GetBufferSize

func (client *Client) GetBufferSize() uint32

func (*Client) GetFrameTime

func (client *Client) GetFrameTime() uint32

func (*Client) GetFramesSinceCycleStart

func (client *Client) GetFramesSinceCycleStart() uint32

func (*Client) GetLastFrameTime

func (client *Client) GetLastFrameTime() uint32

func (*Client) GetName

func (client *Client) GetName() string

func (*Client) GetPortById

func (client *Client) GetPortById(id PortId) *Port

func (*Client) GetPortByName

func (client *Client) GetPortByName(name string) *Port

func (*Client) GetPorts

func (client *Client) GetPorts(portName, portType string, flags uint64) []string

func (*Client) GetSampleRate

func (client *Client) GetSampleRate() uint32

func (*Client) IsPortMine

func (client *Client) IsPortMine(port *Port) bool

func (*Client) IsRealtime

func (client *Client) IsRealtime() bool

func (*Client) OnShutdown

func (client *Client) OnShutdown(callback ShutdownCallback)

func (*Client) PortRegister

func (client *Client) PortRegister(portName, portType string, flags, bufferSize uint64) *Port

func (*Client) PortUnregister

func (client *Client) PortUnregister(port *Port) int

func (*Client) SetBufferSize

func (client *Client) SetBufferSize(size uint32) int

func (*Client) SetBufferSizeCallback

func (client *Client) SetBufferSizeCallback(callback BufferSizeCallback) int

func (*Client) SetPortConnectCallback

func (client *Client) SetPortConnectCallback(callback PortConnectCallback) int

func (*Client) SetPortRegistrationCallback

func (client *Client) SetPortRegistrationCallback(callback PortRegistrationCallback) int

func (*Client) SetPortRenameCallback

func (client *Client) SetPortRenameCallback(callback PortRenameCallback) int

func (*Client) SetProcessCallback

func (client *Client) SetProcessCallback(callback ProcessCallback) int

func (*Client) SetSampleRateCallback

func (client *Client) SetSampleRateCallback(callback SampleRateCallback) int

func (*Client) SetXRunCallback

func (client *Client) SetXRunCallback(callback XRunCallback) int

type ErrorFunction

type ErrorFunction func(string)

type InfoFunction

type InfoFunction func(string)

type MidiBuffer

type MidiBuffer *[]byte

type MidiData

type MidiData struct {
	Time   uint32
	Buffer []byte

type Port

type Port struct {
	// contains filtered or unexported fields

func (*Port) GetBuffer

func (port *Port) GetBuffer(nframes uint32) []AudioSample

func (*Port) GetClientName

func (port *Port) GetClientName() string

func (*Port) GetConnections

func (port *Port) GetConnections() []string

func (*Port) GetMidiEvents

func (port *Port) GetMidiEvents(nframes uint32) []*MidiData

func (*Port) GetName

func (port *Port) GetName() string

func (*Port) GetShortName

func (port *Port) GetShortName() string

func (*Port) GetType

func (port *Port) GetType() string

func (*Port) MidiClearBuffer

func (port *Port) MidiClearBuffer(nframes uint32) MidiBuffer

func (*Port) MidiEventWrite

func (port *Port) MidiEventWrite(event *MidiData, buffer MidiBuffer) int

func (*Port) String

func (port *Port) String() string

type PortConnectCallback

type PortConnectCallback func(PortId, PortId, bool)

type PortId

type PortId uint32

type PortRegistrationCallback

type PortRegistrationCallback func(PortId, bool)

type PortRenameCallback

type PortRenameCallback func(PortId, string, string)

type ProcessCallback

type ProcessCallback func(uint32) int

type SampleRateCallback

type SampleRateCallback func(uint32) int

type ShutdownCallback

type ShutdownCallback func()

type XRunCallback

type XRunCallback func() int


Path Synopsis

Jump to

Keyboard shortcuts

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