fix: update transport access and function calls across engine, tui, and tests
Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
35
makefile
35
makefile
@@ -4,55 +4,58 @@ LDFLAGS = -ljack -lm -lncurses
|
||||
|
||||
all: jack-looper test_engine test_tui test_gui test_cli
|
||||
|
||||
jack-looper: main.o engine.o tui.o gui.o cli.o lib/microui.o
|
||||
jack-looper: main.o engine.o tui.o gui.o cli.o transport.o lib/microui.o
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test_engine: test_engine.o engine.o
|
||||
test_engine: test_engine.o engine.o transport.o
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test_tui: test_tui.o engine.o
|
||||
test_tui: test_tui.o engine.o transport.o
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test_gui: test_gui.o gui.o engine.o lib/microui.o
|
||||
test_gui: test_gui.o gui.o engine.o transport.o lib/microui.o
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test_cli: test_cli.o engine.o cli.o
|
||||
test_cli: test_cli.o engine.o cli.o transport.o
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
test_double_process: test_double_process.o engine.o
|
||||
test_double_process: test_double_process.o engine.o transport.o
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
main.o: main.c engine.h tui.h
|
||||
main.o: main.c engine.h tui.h transport.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
engine.o: engine.c engine.h
|
||||
engine.o: engine.c engine.h transport.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
tui.o: tui.c tui.h engine.h
|
||||
tui.o: tui.c tui.h engine.h transport.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
gui.o: gui.c gui.h engine.h lib/microui.h
|
||||
gui.o: gui.c gui.h engine.h transport.h lib/microui.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
lib/microui.o: lib/microui.c lib/microui.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
test_engine.o: test_engine.c engine.h
|
||||
transport.o: transport.c transport.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
test_tui.o: test_tui.c engine.h tui.h
|
||||
test_engine.o: test_engine.c engine.h transport.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
test_gui.o: test_gui.c gui.h engine.h
|
||||
test_tui.o: test_tui.c engine.h tui.h transport.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
test_cli.o: test_cli.c engine.h
|
||||
test_gui.o: test_gui.c gui.h engine.h transport.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
test_double_process.o: test_double_process.c engine.h
|
||||
test_cli.o: test_cli.c engine.h transport.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
cli.o: cli.c cli.h engine.h
|
||||
test_double_process.o: test_double_process.c engine.h transport.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
cli.o: cli.c cli.h engine.h transport.h
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
.PHONY: all clean test
|
||||
|
||||
@@ -307,10 +307,10 @@ void test_transport_initial_state(void) {
|
||||
Engine *engine = create_test_engine();
|
||||
|
||||
assert(engine->transport->state == TRANSPORT_STOPPED);
|
||||
assert(engine->transport.clock_count == 0);
|
||||
assert(engine->transport.beat_position == 0);
|
||||
assert(engine->transport.bar_position == 0);
|
||||
assert(engine->transport.sample_position == 0);
|
||||
assert(engine->transport->clock_count == 0);
|
||||
assert(engine->transport->beat_position == 0);
|
||||
assert(engine->transport->bar_position == 0);
|
||||
assert(engine->transport->sample_position == 0);
|
||||
|
||||
destroy_test_engine(engine);
|
||||
printf("PASSED\n");
|
||||
@@ -328,14 +328,14 @@ void test_transport_reset(void) {
|
||||
engine->transport->bar_position = 5;
|
||||
engine->transport->sample_position = 10000;
|
||||
|
||||
engine_reset_transport(engine);
|
||||
engine_transport_stop(engine);
|
||||
engine_process_commands(engine);
|
||||
|
||||
assert(engine->transport->state == TRANSPORT_STOPPED);
|
||||
assert(engine->transport.clock_count == 0);
|
||||
assert(engine->transport.beat_position == 0);
|
||||
assert(engine->transport.bar_position == 0);
|
||||
assert(engine->transport.sample_position == 0);
|
||||
assert(engine->transport->clock_count == 0);
|
||||
assert(engine->transport->beat_position == 0);
|
||||
assert(engine->transport->bar_position == 0);
|
||||
assert(engine->transport->sample_position == 0);
|
||||
|
||||
destroy_test_engine(engine);
|
||||
printf("PASSED\n");
|
||||
@@ -435,10 +435,10 @@ void test_midi_clock_start(void) {
|
||||
Engine *engine = create_test_engine();
|
||||
|
||||
// Simulate receiving MIDI Start (0xFA)
|
||||
engine->transport.clock_count = 50;
|
||||
engine->transport.beat_position = 2;
|
||||
engine->transport.bar_position = 3;
|
||||
engine->transport.sample_position = 5000;
|
||||
engine->transport->clock_count = 50;
|
||||
engine->transport->beat_position = 2;
|
||||
engine->transport->bar_position = 3;
|
||||
engine->transport->sample_position = 5000;
|
||||
|
||||
// Process start message (simplified - just call the logic directly)
|
||||
engine->transport->state = TRANSPORT_PLAYING;
|
||||
@@ -447,11 +447,11 @@ void test_midi_clock_start(void) {
|
||||
engine->transport->bar_position = 0;
|
||||
engine->transport.sample_position = 0;
|
||||
|
||||
assert(engine->transport.rolling == true);
|
||||
assert(engine->transport.clock_count == 0);
|
||||
assert(engine->transport.beat_position == 0);
|
||||
assert(engine->transport.bar_position == 0);
|
||||
assert(engine->transport.sample_position == 0);
|
||||
assert(engine->transport->state == TRANSPORT_PLAYING);
|
||||
assert(engine->transport->clock_count == 0);
|
||||
assert(engine->transport->beat_position == 0);
|
||||
assert(engine->transport->bar_position == 0);
|
||||
assert(engine->transport->sample_position == 0);
|
||||
|
||||
destroy_test_engine(engine);
|
||||
printf("PASSED\n");
|
||||
@@ -469,7 +469,7 @@ void test_midi_clock_stop(void) {
|
||||
engine->transport->state = TRANSPORT_STOPPED;
|
||||
|
||||
assert(engine->transport->state == TRANSPORT_STOPPED);
|
||||
assert(engine->transport->clock_count == 100); // Keep position
|
||||
assert(engine->transport->clock_count == 100);
|
||||
|
||||
destroy_test_engine(engine);
|
||||
printf("PASSED\n");
|
||||
@@ -487,7 +487,7 @@ void test_midi_clock_continue(void) {
|
||||
engine->transport->state = TRANSPORT_PLAYING;
|
||||
|
||||
assert(engine->transport->state == TRANSPORT_PLAYING);
|
||||
assert(engine->transport->clock_count == 100); // Keep position
|
||||
assert(engine->transport->clock_count == 100);
|
||||
|
||||
destroy_test_engine(engine);
|
||||
printf("PASSED\n");
|
||||
@@ -498,26 +498,26 @@ void test_beat_tracking(void) {
|
||||
printf("Test 22: Beat tracking from clock ticks... ");
|
||||
Engine *engine = create_test_engine();
|
||||
|
||||
engine->transport.rolling = true;
|
||||
engine->transport.clock_count = 0;
|
||||
engine->transport.beat_position = 0;
|
||||
engine->transport.bar_position = 0;
|
||||
engine->transport->state = TRANSPORT_PLAYING;
|
||||
engine->transport->clock_count = 0;
|
||||
engine->transport->beat_position = 0;
|
||||
engine->transport->bar_position = 0;
|
||||
|
||||
// Simulate 24 clock ticks (one beat)
|
||||
for (int i = 0; i < MIDI_CLOCKS_PER_BEAT; i++) {
|
||||
engine->transport.clock_count++;
|
||||
engine->transport->clock_count++;
|
||||
if (engine->transport.clock_count % MIDI_CLOCKS_PER_BEAT == 0) {
|
||||
engine->transport.beat_position =
|
||||
(engine->transport.beat_position + 1) % BEATS_PER_BAR;
|
||||
engine->transport->beat_position =
|
||||
(engine->transport->beat_position + 1) % BEATS_PER_BAR;
|
||||
if (engine->transport.beat_position == 0) {
|
||||
engine->transport.bar_position++;
|
||||
engine->transport->bar_position++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert(engine->transport.beat_position == 1);
|
||||
assert(engine->transport.bar_position == 0);
|
||||
assert(engine->transport.clock_count == MIDI_CLOCKS_PER_BEAT);
|
||||
assert(engine->transport->beat_position == 1);
|
||||
assert(engine->transport->bar_position == 0);
|
||||
assert(engine->transport->clock_count == MIDI_CLOCKS_PER_BEAT);
|
||||
|
||||
// Simulate 3 more beats (total 4 beats = 1 bar)
|
||||
for (int i = 0; i < MIDI_CLOCKS_PER_BEAT * 3; i++) {
|
||||
@@ -531,9 +531,9 @@ void test_beat_tracking(void) {
|
||||
}
|
||||
}
|
||||
|
||||
assert(engine->transport.beat_position == 0); // Wrapped around
|
||||
assert(engine->transport.bar_position == 1); // One full bar
|
||||
assert(engine->transport.clock_count == MIDI_CLOCKS_PER_BEAT * 4);
|
||||
assert(engine->transport->beat_position == 0);
|
||||
assert(engine->transport->bar_position == 1);
|
||||
assert(engine->transport->clock_count == MIDI_CLOCKS_PER_BEAT * 4);
|
||||
|
||||
destroy_test_engine(engine);
|
||||
printf("PASSED\n");
|
||||
@@ -547,17 +547,17 @@ void test_sample_position_calculation(void) {
|
||||
|
||||
// After 24 clocks (1 beat at 120 BPM), sample position should be:
|
||||
// (24 * 48000 * 4) / (24 * 4) = 48000 samples (1 beat)
|
||||
engine->transport.clock_count = MIDI_CLOCKS_PER_BEAT;
|
||||
engine->transport.sample_position =
|
||||
(engine->transport.clock_count * engine->sample_rate * 4) /
|
||||
engine->transport->clock_count = MIDI_CLOCKS_PER_BEAT;
|
||||
engine->transport->sample_position =
|
||||
(engine->transport->clock_count * engine->sample_rate * 4) /
|
||||
(MIDI_CLOCKS_PER_BEAT * BEATS_PER_BAR);
|
||||
|
||||
assert(engine->transport.sample_position == engine->sample_rate); // 1 beat = 48000 samples
|
||||
|
||||
// After 96 clocks (4 beats = 1 bar)
|
||||
engine->transport.clock_count = MIDI_CLOCKS_PER_BEAT * 4;
|
||||
engine->transport.sample_position =
|
||||
(engine->transport.clock_count * engine->sample_rate * 4) /
|
||||
engine->transport->clock_count = MIDI_CLOCKS_PER_BEAT * 4;
|
||||
engine->transport->sample_position =
|
||||
(engine->transport->clock_count * engine->sample_rate * 4) /
|
||||
(MIDI_CLOCKS_PER_BEAT * BEATS_PER_BAR);
|
||||
|
||||
assert(engine->transport.sample_position == engine->sample_rate * 4); // 1 bar = 192000 samples
|
||||
@@ -580,9 +580,9 @@ void test_quantization_with_transport(void) {
|
||||
|
||||
// Calculate next beat boundary
|
||||
jack_nframes_t frames_per_beat = engine->sample_rate; // 48000 at 120 BPM
|
||||
jack_nframes_t current_pos = engine->transport.sample_position;
|
||||
jack_nframes_t current_pos = engine->transport->sample_position;
|
||||
jack_nframes_t next_beat = ((current_pos / frames_per_beat) + 1) * frames_per_beat;
|
||||
jack_nframes_t quantize_frame = next_beat - engine->transport.sample_position;
|
||||
jack_nframes_t quantize_frame = next_beat - engine->transport->sample_position;
|
||||
|
||||
// Should be 48000 samples to next beat
|
||||
assert(quantize_frame == frames_per_beat);
|
||||
@@ -591,7 +591,7 @@ void test_quantization_with_transport(void) {
|
||||
engine_set_quantize_mode(engine, QUANTIZE_BAR);
|
||||
jack_nframes_t frames_per_bar = frames_per_beat * BEATS_PER_BAR;
|
||||
jack_nframes_t next_bar = ((current_pos / frames_per_bar) + 1) * frames_per_bar;
|
||||
quantize_frame = next_bar - engine->transport.sample_position;
|
||||
quantize_frame = next_bar - engine->transport->sample_position;
|
||||
|
||||
// Should be 96000 samples to next bar (2 beats into 4-beat bar)
|
||||
assert(quantize_frame == frames_per_beat * 2);
|
||||
|
||||
22
test_tui.c
22
test_tui.c
@@ -200,14 +200,14 @@ void test_transport_reset_via_tui(void) {
|
||||
engine->transport->sample_position = 10000;
|
||||
|
||||
// Simulate pressing 'x'
|
||||
engine_reset_transport(engine);
|
||||
engine_transport_stop(engine);
|
||||
engine_process_commands(engine);
|
||||
|
||||
assert(engine->transport->state == TRANSPORT_STOPPED);
|
||||
assert(engine->transport.clock_count == 0);
|
||||
assert(engine->transport.beat_position == 0);
|
||||
assert(engine->transport.bar_position == 0);
|
||||
assert(engine->transport.sample_position == 0);
|
||||
assert(engine->transport->clock_count == 0);
|
||||
assert(engine->transport->beat_position == 0);
|
||||
assert(engine->transport->bar_position == 0);
|
||||
assert(engine->transport->sample_position == 0);
|
||||
|
||||
destroy_test_engine(engine);
|
||||
printf("PASSED\n");
|
||||
@@ -440,14 +440,14 @@ void test_multiple_transport_resets(void) {
|
||||
engine->transport->bar_position = i;
|
||||
engine->transport->sample_position = 10000 * i;
|
||||
|
||||
engine_reset_transport(engine);
|
||||
engine_transport_stop(engine);
|
||||
engine_process_commands(engine);
|
||||
|
||||
assert(engine->transport->state == TRANSPORT_STOPPED);
|
||||
assert(engine->transport.clock_count == 0);
|
||||
assert(engine->transport.beat_position == 0);
|
||||
assert(engine->transport.bar_position == 0);
|
||||
assert(engine->transport.sample_position == 0);
|
||||
assert(engine->transport->clock_count == 0);
|
||||
assert(engine->transport->beat_position == 0);
|
||||
assert(engine->transport->bar_position == 0);
|
||||
assert(engine->transport->sample_position == 0);
|
||||
}
|
||||
|
||||
destroy_test_engine(engine);
|
||||
@@ -1535,7 +1535,7 @@ void test_undo_transport_reset(void) {
|
||||
engine->transport->sample_position = 10000;
|
||||
|
||||
// Reset transport
|
||||
engine_reset_transport(engine);
|
||||
engine_transport_stop(engine);
|
||||
engine_process_commands(engine);
|
||||
assert(engine->transport->state == TRANSPORT_STOPPED);
|
||||
assert(engine->transport->clock_count == 0);
|
||||
|
||||
Reference in New Issue
Block a user