Giter Site home page Giter Site logo

orca-c's Introduction

ORCΛ

Orca is an esoteric programming language and live editor designed to quickly create procedural sequencers. Every letter of the alphabet is an operation, lowercase letters execute on *bang*, and uppercase letters execute each frame.

This is the C implementation of the ORCΛ language and terminal livecoding environment. It's designed to be power efficient. It can handle large files, even if your terminal is small.

Orca is not a synthesizer, but a flexible livecoding environment capable of sending MIDI, OSC, and UDP to your audio/visual interfaces like Ableton, Renoise, VCV Rack, or SuperCollider.

Main git repo GitHub mirror
git.sr.ht/~rabbits/orca github.com/hundredrabbits/Orca-c

Quick Start for Debian/Raspbian (Raspberry Pi)

sudo apt-get install git libncurses5-dev libncursesw5-dev libportmidi-dev
git clone https://github.com/hundredrabbits/Orca-c.git
cd Orca-c
make          # Compile orca
build/orca    # Run orca

To choose your MIDI output device, press F1 (or Ctrl+D) to open the main menu, and then select MIDI Output...

┌ ORCA ───────────────┐┌ PortMidi Device Selection ─────┐
│   New               ││ > (*) #0 - Midi Through Port-0 │
│   Open...           ││   ( ) #2 - ES1371              │
│   Save              │└────────────────────────────────┘
│   Save As...        │
│                     │
│   Set BPM...        │
│   Set Grid Size...  │
│   Auto-fit Grid     │
│                     │
│   OSC Output...     │
│ > MIDI Output...    │
│                     │
│   Clock & Timing... │
│.....................│

Prerequisites

Core library: A C99 compiler (no VLAs required), plus enough libc for malloc, realloc, free, memcpy, memset, and memmove. (Also, #pragma once must be supported.)

Command-line interpreter: The above, plus POSIX, and enough libc for the common string operations (strlen, strcmp, etc.)

Livecoding terminal UI: The above, plus ncurses (or compatible curses library), and floating point support (for timing.) Optionally, PortMidi can be used to enable direct MIDI output.

Build

The build script, called simply tool, is written in POSIX sh. It should work with gcc (including the musl-gcc wrapper), tcc, and clang, and will automatically detect your compiler. You can manually specify a compiler with the -c option.

Currently known to build on macOS (gcc, clang, tcc) and Linux (gcc, musl-gcc, tcc, and clang, optionally with LLD), and Windows via cygwin or WSL (gcc or clang, tcc untested).

There is a fire-and-forget make wrapper around the build script.

PortMidi is an optional dependency. It can be enabled by adding the option --portmidi when running the tool build script.

Mouse awareness can be disabled by adding the --no-mouse option.

Build using the tool build script

Run ./tool help to see usage info. Examples:

./tool build -c clang-7 --portmidi orca
    # Build the livecoding environment with a compiler
    # named clang-7, with optimizations enabled, and
    # with PortMidi enabled for MIDI output.
    # Binary placed at build/orca

./tool build -d orca
    # Debug build of the livecoding environment.
    # Binary placed at build/debug/orca

./tool build -d cli
    # Debug build of the headless CLI interpreter.
    # Binary placed at build/debug/cli

./tool clean
    # Same as make clean. Removes build/

Build using the make wrapper

make release    # optimized build, binary placed at build/orca
make debug      # debugging build, binary placed at build/debug/orca
make clean      # removes build/

The make wrapper will enable --portmidi by default. If you run the tool build script on its own, --portmidi is not enabled by default.

orca Livecoding Environment Usage

Usage: orca [options] [file]

General options:
    --undo-limit <number>  Set the maximum number of undo steps.
                           If you plan to work with large files,
                           set this to a low number.
                           Default: 100
    --initial-size <nxn>   When creating a new grid file, use these
                           starting dimensions.
    --bpm <number>         Set the tempo (beats per minute).
                           Default: 120
    --seed <number>        Set the seed for the random function.
                           Default: 1
    -h or --help           Print this message and exit.

OSC/MIDI options:
    --strict-timing
        Reduce the timing jitter of outgoing MIDI and OSC messages.
        Uses more CPU time.

    --osc-midi-bidule <path>
        Set MIDI to be sent via OSC formatted for Plogue Bidule.
        The path argument is the path of the Plogue OSC MIDI device.
        Example: /OSC_MIDI_0/MIDI

Example: build and run orca livecoding environment with MIDI output

$ ./tool build --portmidi orca           # compile orca using build script
$ build/orca                             # run orca

orca Livecoding Environment Controls

┌ Controls ───────────────────────────────────────────┐
│           Ctrl+Q  Quit                              │
│       Arrow Keys  Move Cursor                       │
│     Ctrl+D or F1  Open Main Menu                    │
│   0-9, A-Z, a-z,  Insert Character                  │
│    ! : % / = # *                                    │
│         Spacebar  Play/Pause                        │
│ Ctrl+Z or Ctrl+U  Undo                              │
│           Ctrl+X  Cut                               │
│           Ctrl+C  Copy                              │
│           Ctrl+V  Paste                             │
│           Ctrl+S  Save                              │
│           Ctrl+F  Frame Step Forward                │
│           Ctrl+R  Reset Frame Number                │
│ Ctrl+I or Insert  Append/Overwrite Mode             │
│        ' (quote)  Rectangle Selection Mode          │
│ Shift+Arrow Keys  Adjust Rectangle Selection        │
│   Alt+Arrow Keys  Slide Selection                   │
│   ` (grave) or ~  Slide Selection Mode              │
│           Escape  Return to Normal Mode or Deselect │
│  ( ) _ + [ ] { }  Adjust Grid Size and Rulers       │
│          < and >  Adjust BPM                        │
│                ?  Controls (this message)           │
└─────────────────────────────────────────────────────┘

cli command-line interface interpreter

The CLI (cli binary) reads from a file and runs the orca simulation for 1 timestep (default) or a specified number (-t option) and writes the resulting state of the grid to stdout.

cli [-t timesteps] infile

You can also make cli read from stdin:

echo -e "...\na34\n..." | cli /dev/stdin

Extras

  • Discuss and get help in the forum thread.
  • Support this project through Patreon.
  • See the License (MIT) file for license rights and limitations.

orca-c's People

Contributors

a773music avatar cancel avatar cmaughan avatar eelfroth avatar ftrvxmtrx avatar juniorctl avatar linearsunrise avatar milligramme avatar neauoire avatar npisanti avatar pangrus avatar russtopia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

orca-c's Issues

Pitch bend versus Commands list

ORCA-C makes use of ? to bring up a commands list. This is extremely helpful, to the point that I was astonished to find it missing from the original Over there, a ? sends a pitch bend. We should have parity. ? is a smart key to press for help. Pitch bend should likely be something else that's not in use yet like ^ or ~. Whatever we land on, let's make sure it matches in the C port so everything works together.

Paste from external source

With the JS version, I like the ability to have some blocks of code on a separate txt file and just copy/paste some of them in orca, however, it seems that this doesn't work with this version?
I tried on windows with the cygwin version, using a debian in WSL and remotely from a RPI with Putty.

Implement Midi Mono operator

Just like Midi, except that it automatically triggers a noteOff for all active notes on that channel, making it easier to use with mono synths.

interactive help

The interactive help (displayed when cursor over operator like in electron orca) would be great to have...

Homebrew thingy for Mac

It seems like the only reasonable way to get a command-line/terminal program in a usable state onto people's Macs is with Homebrew. I don't really know how Homebrew works internally, though the tool build script I made for orca will check to see if ncurses and portmidi have been installed via Homebrew.

It would be nice if someone could help create a Homebrew thingy (formula? cask? uhh) so that people only have to run 1 command to orca and its dependencies installed and working on a Mac.

When using a small display, the list of operators is truncated

When using a small display, such as the Raspberry Pi touch screen, the list of operators is truncated.

Steps to reproduce:

  1. Open orca-c
  2. Open the Main Menu, then select the option to display the list of operators
  3. The list of operator appears

Current result:
The list displays operator A to M, but not N and after.

Expected result:
The list of operator continues on the other side like the Windows version:

Alternative: Maybe allow to navigate/scroll the list using arrow keys?

./tool not working with clang on debian 9

./tool -c clang build release orca 

returns

clang: error: unknown argument: '-no-pie'

also if you install the clang-6.0 package and do

./tool -c clang-6.0 build release orca 

it works as intended, so it is just matter of minimum clang version (default debian is 3.8 )

make release doesn't detect the gcc version but works as intended, so this bug isn't really a priority, but it's still good to know this behavior.

Thanks for the great work on the orca porting!

K operator working differently than nodejs version

I just found that the K operator is working differently than in the NodeJs version. To reproduce it just create anything that is reading the Chords from somewhere else like in this example:

martinberlin/Remora@903e371

When reading this:
#C..D....#

The K operator will be stuck in the Chord until the new one comes. The behaviour in the other version is that when there is a silence dot, this will also read, which permits playing no note. If I'm correct this is the right way it should be.

Noob Q: Bangs doesn't seams to trigger UDP events to Pilot

Hi, I'm very new to ORCA and Pilot, seams I'm failing to send simple UDP messages from orca-c to Pilot.
There ; doesn't light up when is next to *.

image

I compile orca in a Ubuntu 20.04 laptop.

But the same configuration works perfectly if I tried it on the electron app

Undo not working while playing

I was not able to undo. I looked at the code and changed this:

diff --git a/tui_main.c b/tui_main.c
index d525d05..e671915 100644
--- a/tui_main.c
+++ b/tui_main.c
@@ -1854,10 +1854,7 @@ staticni void ged_input_cmd(Ged *a, Ged_input_cmd ev) {
   case Ged_input_cmd_undo:
     if (undo_history_count(&a->undo_hist) == 0)
       break;
-    if (a->is_playing)
-      undo_history_apply(&a->undo_hist, &a->field, &a->tick_num);
-    else
-      undo_history_pop(&a->undo_hist, &a->field, &a->tick_num);
+    undo_history_pop(&a->undo_hist, &a->field, &a->tick_num);
     ged_cursor_confine(&a->ged_cursor, a->field.height, a->field.width);
     ged_update_internal_geometry(a);
     ged_make_cursor_visible(a);

I am very confused why does undo restore the tick? And why is it disabled while playing?

Bang operator behavior

From Orca's README:

  • bang: Bangs neighboring operands

In both Orca and Orca-c the bang operator * actually only bangs the western and northern neighbors. Other bang sources such as D and F, even when wired with J or Y, as well as a Held * seem to behave in ways similar to the documented in the Orca README.

Input:

11111
1.n.1
1w*e1
1.s.1
11111

Expected output after one tick/frame:

11111
1.*.1
1*.*1
1.*.1
11111

Actual output after one tick/frame:

11111
1.*.1
1*.e1
1.s.1
11111

Disclaimer: I'm writing a clean room (no code from the original) minimal Orca clone with no support for integration with other programs.

Request to build with Visual Studio

Interested in if its possible to somehow PORT a version of this to be able to be built with visual studio ?
i cant seem to get this to build on pc ..
any assiatance would be cool :)

cheers

undefined behaviour with more than 16 simultaneous messages

I started having some crashes in my orca patches so i found that orca-c cannot output more than 16 messages simultaneously before having undefinded behavior.

for example this test orca code:

...............D1.....R....D1.....R......................
...............*=14012h....*=a4012s......................
...............D1.....R....D1.....R......................
...............*=24012k....*=b4012v......................
...............D1.....R....D1.....R......................
...............*=34012g....*=c4012h......................
...............D1.....R....D1.....R......................
...............*=44012k....*=d4012z......................
...............D1.....R....D1.....R......................
...............*=54012b....*=e4012x......................
...............D1.....R....D1.....R......................
...............*=64012z....*=f4012o......................
...............D1.....R....D1.....R......................
...............*=740121....*=g4012v......................
...............D1.....R..................................
...............*=84012m..................................
...............D1.....R..................................
...............*=94012c..................................
.........................................................
...........................d1............................
............................=h4012x......................
.........................................................
.........................................................
.........................................................
.........................................................

as soon as the last d is made uppercase will give undefined behavior in release build and it will crash the debug build with some memory dump.

I solved it on my machine by changing the value here from 16 to 32:
https://github.com/hundredrabbits/Orca-c/blob/master/bank.c#L23

@cancel is it safe to do this? as there are 36 possible osc outputs, mixed also with possible midi notes to various channels, i thing we should increase the maximum simultaneous messages to 64 or 128 (maybe someone will want to do some orca black midi someday)

Let me know.

Wrong midi octaves

Hi,
It seems that the midi messages are offsets by -2 octaves. When I send a :13C it triggers the C1 note.

Tested with a raspberry Pi

Midi CC operator

The up caret '^' in Orca JS sends Midi continuous control messages & would be super handy to have in Orca-c

Warning under raspbian 10

Hi,

pi@raspberrypi:~/audio $ git clone https://github.com/hundredrabbits/Orca-c.git
Clonage dans 'Orca-c'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 3373 (delta 2), reused 6 (delta 2), pack-reused 3367
Réception d'objets: 100% (3373/3373), 889.09 KiB | 1.31 MiB/s, fait.
Résolution des deltas: 100% (2282/2282), fait.
pi@raspberrypi:~/audio $ cd Orca-c
pi@raspberrypi:~/audio/Orca-c $ make
sim.c: In function ‘midi_note_number_of’:
sim.c:65:8: warning: conversion from ‘int’ to ‘Glyph’ {aka ‘char’} may change value [-Wconversion]
   g &= ~(1 << 5);                // make uppercase
        ^
Executable program saved as: build/orca
To run it, simply execute it:
$ build/orca

Just to warn you. Orca is working but this little error...

GCC 4.9.2 flags errors on Debian Jessie/Oldstable (PocketCHIP)

JIC:
I compiled Orca-c on my PocketCHIP yesterday out of curiosity, ARMv7l, Debian Jessie/oldstable,
GCC 4.9.2
i had to remove the latest two cc_flags "-Werror=incompatible-pointer-types` -Werror=int-conversion" to be able to build orca & cli (not exactly sure of the consequences yet of course)

The GCC errors were:

cc1: error: -Werror=incompatible-pointer-types: no option -Wincompatible-pointer-types
cc1: error: -Werror=int-conversion: no option -Wint-conversion"

// Also echoing #1 with the same two harmless GCC Warnings

Warning: Failed to detect compiler type
Warning: Failed to detect compiler version

(clang-3.8 on Jessie failed with some errors but i'm skipping clang for now as it's OldStable - the CHIPs/PocketCHIP are stuck on it for now...)

I also built Orca-c on macOS with no problem and tested it with Sonic-Pi as an OSC server (using the Plogue MIDI format) on the same machine but i haven't tested sending OSC from the PocketCHIP yet.

input of B operator not visualized

Hi!
the input for the B operator that should be on the right, is not marked with a different color and uses the same color of the grid. Functionally, it still works, it is just confusing.

Jack midi support

I'd like to be able to use Orca-c in my studio environment so being able to expose a jack midi port would be quite essential.

Request: Control Orca via UDP

The Javascript version of Orca now can now be controlled via UDP as shown in the following snippet from the README:

Control Orca via UDP

You can send UDP to Orca on port 49161.

p, will start playing.
s, will stop playing.
r, will run the current frame.
g, will return the current frame.
b123, will set the bpm to 123.
f456, will set the frame to 456.
w*12:34, will write *, at 12,

This is a killer feature which would be nice to have in the C version.

V operators read output only updated after assignment

I found a peculiarity in orca-c. Variable ('V') operator read outputs are only updated when they occur lexicographically after the first V write operation.

orca-variable-assignment

I would expect for V read operations to work regardless of where they are placed.

MIDI Velocity Differences between Orca-JS and Orca-C

Orca-JS and Orca-C send different velocity values when provided with the same arguments. This is most noticable when providing no velocity argument as Orca-JS sends a note-on with full velocity while Orca-C uses a velocity of 1 which is not audible. Below is a table of the velocity values generated from example commands:

Command     Orca-JS    Orca-C

:03C..      127        1 #
:03C0.      No event   1
:03C1.      8          15
:03C2.      16         29
:03C3.      25         43
:03C4.      33         57
:03C5.      42         71
:03C6.      50         85
:03C7.      59         99
:03C8.      67         113
:03C9.      76         127
:03Ca.      84         0
:03Cb.      93         2
:03Cc.      101        7
:03Cd.      110        12
:03Ce.      118        17
:03Cf.      127        22
:03C[g-z].  127        increases by 5 for each letter until z which is 122

won't run on cpu that lacks SSSE3 (?)

note the triple S, it's different then SSE3
(https://en.wikipedia.org/wiki/SSSE3)

I assume it is again that my pc (Athlon64X2) is segfaulting on freshly compiled code like this because it misses this particular instruction set.

Is Orca-C really using this instruction set? Or is it just a feature that could be turned off?

Linking error on linux

I get the following linking error when trying to build ORCA-C:

/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/orca.77MRyA.ltrans0.ltrans.o: undefined reference to symbol 'keypad'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /lib64/libtinfow.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

This can be solved by linking against tinfow:
0001-fix-linking-error.txt

"live help" missing

The very useful "live help" display found in electron orca is solely missed :-)

Example: the midi operator (:)
Hovering over the ":" in electron orca displays "Midi" in lower part of the screen
Hovering over the first input (one east) displays "-chann", etc

./tools not working on ubuntu 14.04 Chromebook

Multiple errors of this form:
tui_main.c:1:0: error: bad value (nehalem) for -march= switch

Removed the following from ./tool and was able to compile with out errors:
case $arch in
x86_64) add cc_flags -march=nehalem;;
esac

gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.4)
Ubuntu 14.04.5 LTS
Intel(R) Core(TM) i3-5015U CPU @ 2.10GHz

Random operator ('R') doesn't respect capitalization

The Random operator seems to work differently in Orca-c than regular Orca. In regular Orca the Random ('R') operator's output will have the case (upper or lower) that matches that of the right operand:

 aRD 
  C
-or-
aRd
 c

In Orca-c, however, the output of R seems to be always lowercase, regardless of the case of the input.

ctrl-arrow eight-jump

The ctrl-arrow "jump eight locations" would be very helpful when navigating larger canvases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.