#ifndef sampler_HEADER_ #define sampler_HEADER_ #include #include #include "jl_ringbuf.h" #include "sound.h" // MidiEvt: A MIDI event. The event has a `type`, which is one of the constants // MIDI_EVT_*. Depending on the event type, it will contain a (control, value) // or a (node, velocity) pair. typedef struct { int type; // One of the MIDI_EVT_* constants. union { int control; int note; }; union { double value; double velocity; }; } MidiEvt; typedef struct { // Global sound config. char section[MAX_NAME]; SoundConfig global_conf; // When loading the configuration file, this is used to map names to // sound indices. int32_t num_sounds; char index[MAX_SOUNDS][MAX_NAME]; char base_dir[PATH_MAX]; // Min/max values output by controller. int midi_min_vel; int midi_max_vel; // Ring buffers for midi events. RingBuffer *midi_free; // Consumed by the midi thread. RingBuffer *midi_new; // Consumed by the jack thread. // Midi map. int num_triggers[MAX_SOUNDS]; int trigger_map[MAX_SOUNDS][MAX_SOUNDS]; // Cut map. int num_cuts[MAX_SOUNDS]; int cut_map[MAX_SOUNDS][MAX_SOUNDS]; // Jack client and ports. jack_client_t *jack_client; jack_port_t *jack_port_L, *jack_port_R; // The sounds. int buf_size; Sound sounds[MAX_SOUNDS]; // Sustain pedal value. int sustainControl; // Output amplitudes. float L_max; float R_max; } Sampler; void sampler_main(Sampler *sampler); void sampler_free(Sampler *sampler); #endif