Files
looper/src/channel.h
Loic Coenen 04b59999c8 fix: make loop_count atomic and increase remove channel delay
Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
2026-05-12 18:28:54 +00:00

47 lines
1.0 KiB
C

#ifndef CHANNEL_H
#define CHANNEL_H
// cppcheck-suppress missingIncludeSystem
#include <jack/jack.h>
#include <stdatomic.h>
#define LOOP_BUF_SIZE (5 * 48000)
#define MAX_CHANNELS 16
#include "ringbuffer.h"
typedef enum {
STATE_IDLE,
STATE_RECORD,
STATE_LOOPING,
STATE_PAUSED
} looper_state;
struct channel_t {
atomic_int state;
int prev_state;
float loop_buffer[LOOP_BUF_SIZE];
atomic_int loop_count;
int record_pos;
int playback_pos;
atomic_int active;
jack_port_t *audio_in;
jack_port_t *audio_out;
_Atomic RingBuf *save_ring;
};
/* Globals declared in looper.c */
extern struct channel_t channels[MAX_CHANNELS];
extern atomic_int channel_count;
extern int next_channel_id;
extern atomic_int cmd_add;
extern atomic_int cmd_remove;
extern atomic_int cmd_load;
extern atomic_int cmd_save;
void channel_add(jack_client_t *client, int idx);
void channel_remove(jack_client_t *client, int idx);
#endif