README
¶
go-jack 
Go bindings for Jack Audio Connection Kit
Usage
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.")
return
}
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.")
return
}
Activate the client:
if code := client.Activate(); code != 0 {
fmt.Println("Failed to activate client.")
return
}
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.
Documentation
¶
Index ¶
- Constants
- func ClientNameSize() int
- func SetErrorFunction(callback ErrorFunction)
- func SetInfoFunction(callback InfoFunction)
- func StrError(status int) error
- type AudioSample
- type BufferSizeCallback
- type Client
- func (client *Client) Activate() int
- func (client *Client) CPULoad() float32
- func (client *Client) Close() int
- func (client *Client) Connect(srcPort, dstPort string) int
- func (client *Client) ConnectPorts(srcPort, dstPort *Port) int
- func (client *Client) Disconnect(srcPort, dstPort string) int
- func (client *Client) DisconnectPorts(srcPort, dstPort *Port) int
- func (client *Client) GetBufferSize() uint32
- func (client *Client) GetFrameTime() uint32
- func (client *Client) GetFramesSinceCycleStart() uint32
- func (client *Client) GetLastFrameTime() uint32
- func (client *Client) GetName() string
- func (client *Client) GetPortById(id PortId) *Port
- func (client *Client) GetPortByName(name string) *Port
- func (client *Client) GetPorts(portName, portType string, flags uint64) []string
- func (client *Client) GetSampleRate() uint32
- func (client *Client) IsPortMine(port *Port) bool
- func (client *Client) IsRealtime() bool
- func (client *Client) OnShutdown(callback ShutdownCallback)
- func (client *Client) PortRegister(portName, portType string, flags, bufferSize uint64) *Port
- func (client *Client) PortUnregister(port *Port) int
- func (client *Client) SetBufferSize(size uint32) int
- func (client *Client) SetBufferSizeCallback(callback BufferSizeCallback) int
- func (client *Client) SetPortConnectCallback(callback PortConnectCallback) int
- func (client *Client) SetPortRegistrationCallback(callback PortRegistrationCallback) int
- func (client *Client) SetPortRenameCallback(callback PortRenameCallback) int
- func (client *Client) SetProcessCallback(callback ProcessCallback) int
- func (client *Client) SetSampleRateCallback(callback SampleRateCallback) int
- func (client *Client) SetXRunCallback(callback XRunCallback) int
- type ErrorFunction
- type InfoFunction
- type MidiBuffer
- type MidiData
- type Port
- func (port *Port) GetBuffer(nframes uint32) []AudioSample
- func (port *Port) GetClientName() string
- func (port *Port) GetConnections() []string
- func (port *Port) GetMidiEvents(nframes uint32) []*MidiData
- func (port *Port) GetName() string
- func (port *Port) GetShortName() string
- func (port *Port) GetType() string
- func (port *Port) MidiClearBuffer(nframes uint32) MidiBuffer
- func (port *Port) MidiEventWrite(event *MidiData, buffer MidiBuffer) int
- func (port *Port) String() string
- type PortConnectCallback
- type PortId
- type PortRegistrationCallback
- type PortRenameCallback
- type ProcessCallback
- type SampleRateCallback
- type ShutdownCallback
- type XRunCallback
Constants ¶
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" )
Variables ¶
This section is empty.
Functions ¶
func ClientNameSize ¶
func ClientNameSize() int
func SetErrorFunction ¶
func SetErrorFunction(callback ErrorFunction)
func SetInfoFunction ¶
func SetInfoFunction(callback InfoFunction)
Types ¶
type AudioSample ¶
type AudioSample float32
type BufferSizeCallback ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ConnectPorts ¶
func (*Client) Disconnect ¶
func (*Client) DisconnectPorts ¶
func (*Client) GetBufferSize ¶
func (*Client) GetFrameTime ¶
func (*Client) GetFramesSinceCycleStart ¶
func (*Client) GetLastFrameTime ¶
func (*Client) GetPortById ¶
func (*Client) GetPortByName ¶
func (*Client) GetSampleRate ¶
func (*Client) IsPortMine ¶
func (*Client) IsRealtime ¶
func (*Client) OnShutdown ¶
func (client *Client) OnShutdown(callback ShutdownCallback)
func (*Client) PortRegister ¶
func (*Client) PortUnregister ¶
func (*Client) SetBufferSize ¶
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 Port ¶
type Port struct {
// contains filtered or unexported fields
}
func (*Port) GetBuffer ¶
func (port *Port) GetBuffer(nframes uint32) []AudioSample
func (*Port) GetClientName ¶
func (*Port) GetConnections ¶
func (*Port) GetMidiEvents ¶
func (*Port) GetShortName ¶
func (*Port) MidiClearBuffer ¶
func (port *Port) MidiClearBuffer(nframes uint32) MidiBuffer
func (*Port) MidiEventWrite ¶
func (port *Port) MidiEventWrite(event *MidiData, buffer MidiBuffer) int
type PortConnectCallback ¶
type PortRenameCallback ¶
type ProcessCallback ¶
type SampleRateCallback ¶
type ShutdownCallback ¶
type ShutdownCallback func()
type XRunCallback ¶
type XRunCallback func() int
Click to show internal directories.
Click to hide internal directories.