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
1821 Ged_input_cmd_escape,1821 Ged_input_cmd_escape,
1822} Ged_input_cmd;1822} Ged_input_cmd;
1823 1823
1824staticni 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
1824staticni void ged_input_cmd(Ged *a, Ged_input_cmd ev) {1850staticni void ged_input_cmd(Ged *a, Ged_input_cmd ev) {
1825 switch (ev) {1851 switch (ev) {
1826 case Ged_input_cmd_undo:1852 case Ged_input_cmd_undo:
@@ -1870,27 +1896,7 @@ staticni void ged_input_cmd(Ged *a, Ged_input_cmd ev) { · 43 unmodified lines
1870 a->is_draw_dirty = true;1896 a->is_draw_dirty = true;
1871 break;1897 break;
1872 case Ged_input_cmd_toggle_play_pause:1898 case Ged_input_cmd_toggle_play_pause:
1873 if (a->is_playing) {1899 ged_set_playing(a, !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;
1894 break;1900 break;
1895 case Ged_input_cmd_toggle_show_event_list:1901 case Ged_input_cmd_toggle_show_event_list:
1896 a->draw_event_list = !a->draw_event_list;1902 a->draw_event_list = !a->draw_event_list;
@@ -3553,8 +3559,7 @@ int main(int argc, char **argv) { · 1656 unmodified lines
3553 ged_make_cursor_visible(&t.ged);3559 ged_make_cursor_visible(&t.ged);
3554 // Send initial BPM3560 // Send initial BPM
3555 send_num_message(t.ged.oosc_dev, "/orca/bpm", (I32)t.ged.bpm);3561 send_num_message(t.ged.oosc_dev, "/orca/bpm", (I32)t.ged.bpm);
3556 // Auto-play3562 ged_set_playing(&t.ged, true); // Auto-play
3557 ged_input_cmd(&t.ged, Ged_input_cmd_toggle_play_pause);
3558 // Enter main loop. Process events as they arrive.3563 // Enter main loop. Process events as they arrive.
3559event_loop:;3564event_loop:;
3560 int key = wgetch(stdscr);3565 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