Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Commander ($) operator and utils. #77

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

royeden
Copy link

@royeden royeden commented Aug 18, 2021

Preface:

The other day I was watching this tutorial featured in the OrcaJS repo, and I found out that adjusting the BPM programmatically (as seen here) wasn't an option, so I decided to try and implement that, along with some of the other features from the commander interface.

I haven't programmed anything in C beyond some "hello world" stuff (I come from a JS background) and this PR is the result of reverse engineering the really comprehensible code written in this repo + some web search 😄 .


Changes:

Menu

  • Added menu option under help for the Crtl + G command to show operators.

Implemented Orca commander interface:

State (state.h):

  • Abstracted values that could be altered via commands to a new struct called State*, it saves bpm, tick_num, is_playing and *oosc_dev (that one is still a TODO).
  • Implemented this struct through the whole app.

* This abstraction was necessary to change is_playing via reference pointer (without abstracting the whole Ged struct). It could still be implemented without struct nesting, changing the type of is_playing to int and leaving everything inside of the Ged struct intact (this could maybe favor performance, but I don't know how much the performance is affected currently by passing a struct vs passing each value individually by reference).

Commander (commander.h, commander.c, sim.h, sim.c, cli_main.c, symisc.c):

  • Implemented parse_command(Glyph command, State state) method. This implementation adds the following commands: play,run, stop, bpm:num, frame:num, rewind:num and skip:num. It uses strtok to obtain tokens, strcmp to compare strings and strtoul to parse number values.
  • Added commander operation, it copies the current buffer with the same values as the UDP parser (this should also be revised) and passes the copy as a command to the parse_command method.
  • orca_run now takes state as the only param related to bpm, tick_num, is_playing and oosc_dev.

tool:

  • Prioritize compilation of commander.c to avoid linking errors.

Caveats and considerations:

  • Perhaps nesting structs isn't the best option for performance in devices that have smaller computing power, but I currently have no means to test this (also addressed in State abstraction). This can be mitigated easily removing said abstraction and passing every single value by reference,
  • Some stuff is dependent and copied directly from the udp operator code, perhaps it needs some considerations in regards to how commands are parsed (as it copies 16 chars from the buffer in the copy method).
  • Maybe some stuff could be abstracted into macros and I'm not considering it.
  • There's some issues regarding advancing single frames: sometimes this triggers a double BANG (don't know if it relates to these changes or is a separate issue, but it's simple to view when using the skip command).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant