Crate jack [] [src]

extern crate jack;

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

    // Register ports. They will be used in a callback when new data is available.
    let in_a = client.register_port("rust_in_l", jack::AudioInSpec::default()).unwrap();
    let in_b = client.register_port("rust_in_r", jack::AudioInSpec::default()).unwrap();
    let mut out_a = client.register_port("rust_out_l", jack::AudioOutSpec::default()).unwrap();
    let mut out_b = client.register_port("rust_out_r", jack::AudioOutSpec::default()).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 to quit
    use std::io;
    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<AudioInSpec>. 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<AudioOutSpec>. Derefs 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.

MidiInPort

Safetly wrap a Port<MidiInPort>.

MidiInSpec

MidiInSpec implements the PortSpec trait, which defines an endpoint for JACK.

MidiIter

Iterate through Midi Messages within a MidiInPort.

MidiOutPort

Safetly wrap a Port<MidiInPort>.

MidiOutSpec

MidiOutSpec implements the PortSpec trait, which defines an endpoint for JACK.

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.

RawMidi

Contains 8bit raw midi information along with a timestamp relative to the process cycle.

Unowned

PortSpec for a port that holds no readable or write-able stream data from JACK, though it can be used for obtaining information about external ports.

Enums

JackControl

Specify an option, either to continue processing, or to stop.

JackErr

An error that can occur in 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. It is recommended to use the log crate.

set_info_callback

Set the global JACK info callback. It is recommended to use the log crate.

Type Definitions

JackFrames
JackPortId
JackTime
UnownedPort

Port<UnownedSpec> - Port that holds no data from Jack, though it can still be used to query information.