History

Cleanup

cancel committed 6 years ago

Commit 33ec0051 parent 951ba8c1 file · +28 −23Browse files

Unified · Split

tui_main.c+28−23
@@ -1821,6 +1821,32 @@ typedef enum { · 1820 unmodified lines
18211821 Ged_input_cmd_escape,
18221822 } Ged_input_cmd;
18231823
1824+staticni void ged_set_playing(Ged *a, bool playing) {
1825+ if (playing == a->is_playing)
1826+ return;
1827+ if (playing) {
1828+ undo_history_push(&a->undo_hist, &a->field, a->tick_num);
1829+ a->is_playing = true;
1830+ a->clock = stm_now();
1831+ a->midi_bclock_sixths = 0;
1832+ // dumb'n'dirty, get us close to the next step time, but not quite
1833+ a->accum_secs = 60.0 / (double)a->bpm / 4.0;
1834+ if (a->midi_bclock) {
1835+ send_midi_byte(a->oosc_dev, &a->midi_mode, 0xFA); // "start"
1836+ a->accum_secs /= 6.0;
1837+ }
1838+ a->accum_secs -= 0.0001;
1839+ send_control_message(a->oosc_dev, "/orca/started");
1840+ } else {
1841+ ged_stop_all_sustained_notes(a);
1842+ a->is_playing = false;
1843+ send_control_message(a->oosc_dev, "/orca/stopped");
1844+ if (a->midi_bclock)
1845+ send_midi_byte(a->oosc_dev, &a->midi_mode, 0xFC); // "stop"
1846+ }
1847+ a->is_draw_dirty = true;
1848+}
1849+
18241850 staticni void ged_input_cmd(Ged *a, Ged_input_cmd ev) {
18251851 switch (ev) {
18261852 case Ged_input_cmd_undo:
@@ -1870,27 +1896,7 @@ staticni void ged_input_cmd(Ged *a, Ged_input_cmd ev) { · 43 unmodified lines
18701896 a->is_draw_dirty = true;
18711897 break;
18721898 case Ged_input_cmd_toggle_play_pause:
1873− if (a->is_playing) {
1874− ged_stop_all_sustained_notes(a);
1875− a->is_playing = false;
1876− send_control_message(a->oosc_dev, "/orca/stopped");
1877− if (a->midi_bclock)
1878− send_midi_byte(a->oosc_dev, &a->midi_mode, 0xFC); // "stop"
1879− } else {
1880− undo_history_push(&a->undo_hist, &a->field, a->tick_num);
1881− a->is_playing = true;
1882− a->clock = stm_now();
1883− a->midi_bclock_sixths = 0;
1884− // dumb'n'dirty, get us close to the next step time, but not quite
1885− a->accum_secs = 60.0 / (double)a->bpm / 4.0;
1886− if (a->midi_bclock) {
1887− send_midi_byte(a->oosc_dev, &a->midi_mode, 0xFA); // "start"
1888− a->accum_secs /= 6.0;
1889− }
1890− a->accum_secs -= 0.0001;
1891− send_control_message(a->oosc_dev, "/orca/started");
1892− }
1893− a->is_draw_dirty = true;
1899+ ged_set_playing(a, !a->is_playing);
18941900 break;
18951901 case Ged_input_cmd_toggle_show_event_list:
18961902 a->draw_event_list = !a->draw_event_list;
@@ -3553,8 +3559,7 @@ int main(int argc, char **argv) { · 1656 unmodified lines
35533559 ged_make_cursor_visible(&t.ged);
35543560 // Send initial BPM
35553561 send_num_message(t.ged.oosc_dev, "/orca/bpm", (I32)t.ged.bpm);
3556− // Auto-play
3557− ged_input_cmd(&t.ged, Ged_input_cmd_toggle_play_pause);
3562+ ged_set_playing(&t.ged, true); // Auto-play
35583563 // Enter main loop. Process events as they arrive.
35593564 event_loop:;
35603565 int key = wgetch(stdscr);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t