Browse Source

Remove trigger/'piano' mode.

Old orca-c feature that is not present in orca JS. This was using up the
'!' glyph, which we'll need back for MIDI CC. It was also using up the
'/' input key in the TUI, and added a bunch of stuff to the code that
probably nobody was using.
master
cancel 5 years ago
parent
commit
f8d8e7d589
  1. 2
      cli_main.c
  2. 24
      sim.c
  3. 14
      sim.h
  4. 41
      tui_main.c

2
cli_main.c

@ -103,7 +103,7 @@ int main(int argc, char** argv) {
Usz max_ticks = (Usz)ticks; Usz max_ticks = (Usz)ticks;
for (Usz i = 0; i < max_ticks; ++i) { for (Usz i = 0; i < max_ticks; ++i) {
orca_run(field.buffer, mbuf_r.buffer, field.height, field.width, i, orca_run(field.buffer, mbuf_r.buffer, field.height, field.width, i,
&oevent_list, ORCA_PIANO_BITS_NONE, 0); &oevent_list, 0);
} }
mbuf_reusable_deinit(&mbuf_r); mbuf_reusable_deinit(&mbuf_r);
oevent_list_deinit(&oevent_list); oevent_list_deinit(&oevent_list);

24
sim.c

@ -147,7 +147,6 @@ static ORCA_FORCE_NO_INLINE U8 midi_velocity_of(Glyph g) {
typedef struct { typedef struct {
Glyph* vars_slots; Glyph* vars_slots;
Piano_bits piano_bits;
Oevent_list* oevent_list; Oevent_list* oevent_list;
Usz random_seed; Usz random_seed;
} Oper_extra_params; } Oper_extra_params;
@ -220,7 +219,7 @@ static void oper_poke_and_stun(Glyph* restrict gbuffer, Mark* restrict mbuffer,
//////// Operators //////// Operators
#define UNIQUE_OPERATORS(_) \ #define UNIQUE_OPERATORS(_) \
_('!', keys) \ _('!', midicc) \
_('#', comment) \ _('#', comment) \
_('*', bang) \ _('*', bang) \
_(':', midi) \ _(':', midi) \
@ -303,21 +302,8 @@ BEGIN_OPERATOR(movement)
} }
END_OPERATOR END_OPERATOR
BEGIN_OPERATOR(keys) BEGIN_OPERATOR(midicc)
PORT(0, 1, IN); // TODO unimplemented
PORT(1, 0, OUT);
Glyph g = PEEK(0, 1);
Piano_bits pb = piano_bits_of(g);
// instead of this extra branch, could maybe just leave output port unlocked
// so the '*' goes away on its own?
if (pb == ORCA_PIANO_BITS_NONE)
return;
Glyph o;
if (ORCA_LIKELY((pb & extra_params->piano_bits) == ORCA_PIANO_BITS_NONE))
o = '.';
else
o = '*';
POKE(1, 0, o);
END_OPERATOR END_OPERATOR
BEGIN_OPERATOR(comment) BEGIN_OPERATOR(comment)
@ -758,15 +744,13 @@ END_OPERATOR
//////// Run simulation //////// Run simulation
void orca_run(Glyph* restrict gbuf, Mark* restrict mbuf, Usz height, Usz width, void orca_run(Glyph* restrict gbuf, Mark* restrict mbuf, Usz height, Usz width,
Usz tick_number, Oevent_list* oevent_list, Piano_bits piano_bits, Usz tick_number, Oevent_list* oevent_list, Usz random_seed) {
Usz random_seed) {
Glyph vars_slots[Glyphs_index_count]; Glyph vars_slots[Glyphs_index_count];
memset(vars_slots, '.', sizeof(vars_slots)); memset(vars_slots, '.', sizeof(vars_slots));
mbuffer_clear(mbuf, height, width); mbuffer_clear(mbuf, height, width);
oevent_list_clear(oevent_list); oevent_list_clear(oevent_list);
Oper_extra_params extras; Oper_extra_params extras;
extras.vars_slots = &vars_slots[0]; extras.vars_slots = &vars_slots[0];
extras.piano_bits = piano_bits;
extras.oevent_list = oevent_list; extras.oevent_list = oevent_list;
extras.random_seed = random_seed; extras.random_seed = random_seed;

14
sim.h

@ -2,18 +2,6 @@
#include "bank.h" #include "bank.h"
#include "base.h" #include "base.h"
#define ORCA_PIANO_KEYS_COUNT ((size_t)(('9' - '0') + 1 + ('z' - 'a') + 1))
#define ORCA_PIANO_BITS_NONE UINT64_C(0)
typedef U64 Piano_bits;
static inline Piano_bits piano_bits_of(Glyph g) {
if (g >= '0' && g <= '9')
return UINT64_C(1) << (U64)((Usz)('9' - g));
if (g >= 'a' && g <= 'z')
return UINT64_C(1) << (U64)(((Usz)('z' - g)) + ((Usz)('9' - '0')) + 1);
return UINT64_C(0);
}
void orca_run(Glyph* restrict gbuffer, Mark* restrict mbuffer, Usz height, void orca_run(Glyph* restrict gbuffer, Mark* restrict mbuffer, Usz height,
Usz width, Usz tick_number, Oevent_list* oevent_list, Usz width, Usz tick_number, Oevent_list* oevent_list,
Piano_bits piano_bits, Usz random_seed); Usz random_seed);

41
tui_main.c

@ -189,9 +189,8 @@ static attr_t term_attrs_of_cell(Glyph g, Mark m) {
typedef enum { typedef enum {
Ged_input_mode_normal = 0, Ged_input_mode_normal = 0,
Ged_input_mode_append = 1, Ged_input_mode_append,
Ged_input_mode_piano = 2, Ged_input_mode_selresize,
Ged_input_mode_selresize = 3,
} Ged_input_mode; } Ged_input_mode;
typedef struct { typedef struct {
@ -452,7 +451,7 @@ void print_activity_indicator(WINDOW* win, Usz activity_counter) {
lamps[1] = ACS_HLINE | A_normal; lamps[1] = ACS_HLINE | A_normal;
lamps[2] = ACS_HLINE | A_bold; lamps[2] = ACS_HLINE | A_bold;
lamps[3] = lamps[1]; lamps[3] = lamps[1];
#else // Appearance where segments can turn off completely #else // Appearance where segments can turn off completely
lamps[0] = ' '; lamps[0] = ' ';
lamps[1] = ACS_HLINE | fg_bg(C_black, C_natural) | A_bold; lamps[1] = ACS_HLINE | fg_bg(C_black, C_natural) | A_bold;
lamps[2] = ACS_HLINE | A_normal; lamps[2] = ACS_HLINE | A_normal;
@ -505,10 +504,6 @@ void draw_hud(WINDOW* win, int win_y, int win_x, int height, int width,
wattrset(win, A_bold); wattrset(win, A_bold);
waddstr(win, "append"); waddstr(win, "append");
break; break;
case Ged_input_mode_piano:
wattrset(win, A_reverse);
waddstr(win, "trigger");
break;
case Ged_input_mode_selresize: case Ged_input_mode_selresize:
wattrset(win, A_bold); wattrset(win, A_bold);
waddstr(win, "select"); waddstr(win, "select");
@ -799,7 +794,6 @@ typedef struct {
Oevent_list scratch_oevent_list; Oevent_list scratch_oevent_list;
Susnote_list susnote_list; Susnote_list susnote_list;
Ged_cursor ged_cursor; Ged_cursor ged_cursor;
Piano_bits piano_bits;
Usz tick_num; Usz tick_num;
Usz ruler_spacing_y, ruler_spacing_x; Usz ruler_spacing_y, ruler_spacing_x;
Ged_input_mode input_mode; Ged_input_mode input_mode;
@ -838,7 +832,6 @@ void ged_init(Ged* a, Usz undo_limit, Usz init_bpm, Usz init_seed) {
oevent_list_init(&a->scratch_oevent_list); oevent_list_init(&a->scratch_oevent_list);
susnote_list_init(&a->susnote_list); susnote_list_init(&a->susnote_list);
ged_cursor_init(&a->ged_cursor); ged_cursor_init(&a->ged_cursor);
a->piano_bits = ORCA_PIANO_BITS_NONE;
a->tick_num = 0; a->tick_num = 0;
a->ruler_spacing_y = 8; a->ruler_spacing_y = 8;
a->ruler_spacing_x = 8; a->ruler_spacing_x = 8;
@ -1154,9 +1147,8 @@ void ged_do_stuff(Ged* a) {
apply_time_to_sustained_notes(oosc_dev, midi_mode, secs_span, apply_time_to_sustained_notes(oosc_dev, midi_mode, secs_span,
&a->susnote_list, &a->time_to_next_note_off); &a->susnote_list, &a->time_to_next_note_off);
orca_run(a->field.buffer, a->mbuf_r.buffer, a->field.height, a->field.width, orca_run(a->field.buffer, a->mbuf_r.buffer, a->field.height, a->field.width,
a->tick_num, &a->oevent_list, a->piano_bits, a->random_seed); a->tick_num, &a->oevent_list, a->random_seed);
++a->tick_num; ++a->tick_num;
a->piano_bits = ORCA_PIANO_BITS_NONE;
a->needs_remarking = true; a->needs_remarking = true;
a->is_draw_dirty = true; a->is_draw_dirty = true;
@ -1247,7 +1239,7 @@ void ged_draw(Ged* a, WINDOW* win) {
mbuf_reusable_ensure_size(&a->mbuf_r, a->field.height, a->field.width); mbuf_reusable_ensure_size(&a->mbuf_r, a->field.height, a->field.width);
orca_run(a->scratch_field.buffer, a->mbuf_r.buffer, a->field.height, orca_run(a->scratch_field.buffer, a->mbuf_r.buffer, a->field.height,
a->field.width, a->tick_num, &a->scratch_oevent_list, a->field.width, a->tick_num, &a->scratch_oevent_list,
a->piano_bits, a->random_seed); a->random_seed);
a->needs_remarking = false; a->needs_remarking = false;
} }
int win_h = a->win_h; int win_h = a->win_h;
@ -1330,7 +1322,6 @@ void ged_dir_input(Ged* a, Ged_dir dir, int step_length) {
switch (a->input_mode) { switch (a->input_mode) {
case Ged_input_mode_normal: case Ged_input_mode_normal:
case Ged_input_mode_append: case Ged_input_mode_append:
case Ged_input_mode_piano:
switch (dir) { switch (dir) {
case Ged_dir_up: case Ged_dir_up:
ged_move_cursor_relative(a, -step_length, 0); ged_move_cursor_relative(a, -step_length, 0);
@ -1494,11 +1485,6 @@ void ged_write_character(Ged* a, char c) {
a->is_draw_dirty = true; a->is_draw_dirty = true;
} }
void ged_add_piano_bits_for_character(Ged* a, char c) {
Piano_bits added_bits = piano_bits_of((Glyph)c);
a->piano_bits |= added_bits;
}
bool ged_try_selection_clipped_to_field(Ged const* a, Usz* out_y, Usz* out_x, bool ged_try_selection_clipped_to_field(Ged const* a, Usz* out_y, Usz* out_x,
Usz* out_h, Usz* out_w) { Usz* out_h, Usz* out_w) {
Usz curs_y = a->ged_cursor.y; Usz curs_y = a->ged_cursor.y;
@ -1609,16 +1595,12 @@ void ged_input_character(Ged* a, char c) {
a->is_draw_dirty = true; a->is_draw_dirty = true;
} }
break; break;
case Ged_input_mode_piano:
ged_add_piano_bits_for_character(a, c);
break;
} }
} }
typedef enum { typedef enum {
Ged_input_cmd_undo, Ged_input_cmd_undo,
Ged_input_cmd_toggle_append_mode, Ged_input_cmd_toggle_append_mode,
Ged_input_cmd_toggle_piano_mode,
Ged_input_cmd_toggle_selresize_mode, Ged_input_cmd_toggle_selresize_mode,
Ged_input_cmd_step_forward, Ged_input_cmd_step_forward,
Ged_input_cmd_toggle_show_event_list, Ged_input_cmd_toggle_show_event_list,
@ -1652,14 +1634,6 @@ void ged_input_cmd(Ged* a, Ged_input_cmd ev) {
} }
a->is_draw_dirty = true; a->is_draw_dirty = true;
break; break;
case Ged_input_cmd_toggle_piano_mode:
if (a->input_mode == Ged_input_mode_piano) {
a->input_mode = Ged_input_mode_normal;
} else {
a->input_mode = Ged_input_mode_piano;
}
a->is_draw_dirty = true;
break;
case Ged_input_cmd_toggle_selresize_mode: case Ged_input_cmd_toggle_selresize_mode:
if (a->input_mode == Ged_input_mode_selresize) { if (a->input_mode == Ged_input_mode_selresize) {
a->input_mode = Ged_input_mode_normal; a->input_mode = Ged_input_mode_normal;
@ -1671,10 +1645,9 @@ void ged_input_cmd(Ged* a, Ged_input_cmd ev) {
case Ged_input_cmd_step_forward: case Ged_input_cmd_step_forward:
undo_history_push(&a->undo_hist, &a->field, a->tick_num); undo_history_push(&a->undo_hist, &a->field, a->tick_num);
orca_run(a->field.buffer, a->mbuf_r.buffer, a->field.height, a->field.width, orca_run(a->field.buffer, a->mbuf_r.buffer, a->field.height, a->field.width,
a->tick_num, &a->oevent_list, a->piano_bits, a->random_seed); a->tick_num, &a->oevent_list, a->random_seed);
++a->tick_num; ++a->tick_num;
a->activity_counter += a->oevent_list.count; a->activity_counter += a->oevent_list.count;
a->piano_bits = ORCA_PIANO_BITS_NONE;
a->needs_remarking = true; a->needs_remarking = true;
a->is_draw_dirty = true; a->is_draw_dirty = true;
break; break;
@ -2582,7 +2555,7 @@ int main(int argc, char** argv) {
ged_input_cmd(&ged_state, Ged_input_cmd_toggle_append_mode); ged_input_cmd(&ged_state, Ged_input_cmd_toggle_append_mode);
break; break;
case '/': case '/':
ged_input_cmd(&ged_state, Ged_input_cmd_toggle_piano_mode); // Currently unused. Formerly 'piano'/trigger mode toggle.
break; break;
case '<': case '<':
ged_adjust_bpm(&ged_state, -1); ged_adjust_bpm(&ged_state, -1);

Loading…
Cancel
Save