Crate jack [] [src]

extern crate jack;
use std::io;

fn main() {
    // Create client
    let (mut client, _status) =
        jack::Client::open("rust_jack_simple",
                           jack::client_options::NO_START_SERVER)
            .unwrap();

    // Register ports, that will be used in a callback when new data is available.
    let in_a = client.register_port("rust_in_l", jack::AudioInSpec).unwrap();
    let in_b = client.register_port("rust_in_r", jack::AudioInSpec).unwrap();
    let mut out_a = client.register_port("rust_out_l", jack::AudioOutSpec).unwrap();
    let mut out_b = client.register_port("rust_out_r", jack::AudioOutSpec).unwrap();
    let process_callback = move |ps: &jack::ProcessScope| -> jack::JackControl {
        let mut out_a_p = jack::AudioOutPort::new(&mut out_a, ps);
        let mut out_b_p = jack::AudioOutPort::new(&mut out_b, ps);
        let in_a_p = jack::AudioInPort::new(&in_a, ps);
        let in_b_p = jack::AudioInPort::new(&in_b, ps);
        out_a_p.clone_from_slice(&in_a_p);
        out_b_p.clone_from_slice(&in_b_p);
        jack::JackControl::Continue
    };

    // Activate the client, which starts the processing.
    let active_client = client.activate(process_callback).unwrap();

    // Wait for user input
    println!("Press enter/return to quit...");
    let mut user_input = String::new();
    io::stdin().read_line(&mut user_input).ok();

    active_client.deactivate().unwrap();
}

Modules

client_options

Contains ClientOptions flags used when opening a client.

client_status

Contains ClientStatus flags which describe the status of a Client.

port_flags

Contains PortFlags flags which can be used when implementing the PortSpec trait.

Structs

ActiveClient

A JackClient that is currently active. Active clients may contain JackHandlers that are processing data in real-time.

AudioInPort

Safetly wrap a Port<AudioInPort>. Derefs into a &[f32].

AudioInSpec

AudioInSpec implements the PortSpec trait which, defines an endpoint for JACK. In this case, it is a readable 32 bit floating point buffer for audio.

AudioOutPort

Safetly wrap a Port<AudioOutPort>. Can deref into a &mut[f32].

AudioOutSpec

AudioOutSpec implements the PortSpec trait, which defines an endpoint for JACK. In this case, it is a mutable 32 bit floating point buffer for audio.

CLIENT_NAME_SIZE

The maximum string length for port names.

Client

A client to interact with a JACK server.

ClientOptions

Option flags for opening a JACK client.

ClientStatus

Status flags for JACK clients. File an issue if you can get it to appear.

CycleTimes

Internal cycle timing information.

PORT_NAME_SIZE

The maximum string length for port names.

PORT_TYPE_SIZE

The maximum string length for jack type names.

Port

An endpoint to interact with JACK data streams, for audio, midi, etc...

PortFlags

Flags for specifying port options.

ProcessScope

ProcessScope provides information on the client and frame timings within a process callback.

Unowned

Port that holds no data from JACK, though it can be used for obtaining information about external ports.

Enums

JackControl

Specify an option.

JackErr

The Error type that can occur within JACK.

Traits

JackClient

Common JACK client functionality that can be accessed for both inactive and active clients.

JackHandler

Specifies callbacks for JACK.

PortSpec

Represents the data of a Port within a JackHandler::process callback.

Functions

get_time

Return JACK's current system time in microseconds, using the JACK clock source.

set_error_callback

Set the global JACK error callback.

set_info_callback

Set the global JACK info callback.

Type Definitions

UnownedPort

Port that holds no data from Jack, though it can be used to query information.