Git Product home page Git Product logo

go-jack's Introduction

go-jack GoDoc

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.

go-jack's People

Contributors

andrepxx avatar angadn avatar gethiox avatar munshkr avatar padster avatar xthexder avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.