├── LICENSE ├── README.md ├── base36.c ├── examples └── bytebeat.orca └── makefile /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Bequa La Froth 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ORCΛ BYTEBEAT 2 | 3 | proof of concept that [orca-c](https://github.com/hundredrabbits/Orca-c) can be used as a synthesizer 4 | 5 | ## demo 6 | 7 | [https://youtu.be/RCjxaDfU2bo](https://youtu.be/RCjxaDfU2bo) 8 | 9 | ## requirements 10 | 11 | - Orca-c 12 | - netcat 13 | - aplay 14 | - the base36 converter from this repo 15 | 16 | ## method 17 | 18 | - compile the base36 converter 19 | ``` 20 | make 21 | ``` 22 | - start Orca-c, specifying a UDP port and some very high bpm: 23 | ``` 24 | orca --osc-port 49160 --strict-timing --bpm 30200 25 | ``` 26 | - then, in another terminal, run this: 27 | ``` 28 | netcat -lu localhost 49160 | base36 | aplay -f u8 -r 2000 29 | ``` 30 | 31 | now you can send UDP packets from orca with the `;` operator. `netcat` receives these packages which are then converted from orca's base36 encoding and normalised to the range 0-255. the resulting values are redirected to `aplay` so they get pushed to the sound card. 32 | 33 | ## caveats 34 | 35 | this method currently does not ensure that orca outputs a steady sample-rate of 2000 Hz. when it goes too slow, it causes a buffer underrun in aplay which is audible as a stutter. when it goes to fast, it introduces latency. the chosen bpm value of 30200 seems to work okay on my computer, with not too much latency and only the occasional stutter. 36 | -------------------------------------------------------------------------------- /base36.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define NS_PER_S 1000000000L 5 | 6 | struct timespec ts_subtract(struct timespec time1, struct timespec time2); 7 | 8 | int main() 9 | { 10 | int c; 11 | 12 | long dt; 13 | struct timespec ts_now, ts_last; 14 | clock_gettime(CLOCK_REALTIME, &ts_last); 15 | 16 | for (;;) { 17 | clock_gettime(CLOCK_REALTIME, &ts_now); 18 | dt = ts_subtract(ts_now, ts_last).tv_nsec; 19 | ts_last = ts_now; 20 | 21 | c = getc(stdin); 22 | 23 | if (c == EOF) break; 24 | else if (c >= '0' && c <= '9') c -= '0'; 25 | else if (c >= 'a' && c <= 'z') c -= 'a' - 10; 26 | else if (c >= 'A' && c <= 'Z') c -= 'A' - 10; 27 | else continue; 28 | 29 | c = c * 255 / 35; 30 | 31 | putc((unsigned char) c, stdout); 32 | fflush(stdout); 33 | 34 | fprintf(stderr, "\r%f Hz \t", (float)NS_PER_S/dt); 35 | } 36 | return 0; 37 | } 38 | 39 | struct timespec ts_subtract(struct timespec time1, struct timespec time2) 40 | { 41 | struct timespec result; 42 | result.tv_sec = time1.tv_sec - time2.tv_sec; 43 | if (time1.tv_nsec < time2.tv_nsec) { 44 | result.tv_nsec = time1.tv_nsec + NS_PER_S - time2.tv_nsec; 45 | result.tv_sec--; 46 | } else { 47 | result.tv_nsec = time1.tv_nsec - time2.tv_nsec; 48 | } 49 | 50 | return (result); 51 | } 52 | -------------------------------------------------------------------------------- /examples/bytebeat.orca: -------------------------------------------------------------------------------- 1 | ......................................................... 2 | ......................................................... 3 | ......................................................... 4 | ......................................................... 5 | ......................................................... 6 | .Cz...................................................... 7 | F.0...................................................... 8 | .i0g..................................................... 9 | F00...................................................... 10 | .i08..................................................... 11 | .08Tzx7xkaqz............................................. 12 | .0C1..................................................... 13 | .00XE.................................................... 14 | .......................................................;0 15 | .......................................................;1 16 | .......................................................;2 17 | .......................................................;3 18 | .......................................................;4 19 | .......................................................;5 20 | .......................................................;6 21 | .......................................................;7 22 | .......................................................;8 23 | .......................................................;9 24 | .......................................................;a 25 | .......................................................;b 26 | .......................................................;c 27 | .......................................................;d 28 | .......................................................;e 29 | .......................................................;f 30 | .......................................................;g 31 | .......................................................;h 32 | .......................................................;i 33 | .......................................................;j 34 | .......................................................;k 35 | .......................................................;l 36 | .......................................................;m 37 | .......................................................;n 38 | .......................................................;o 39 | .......................................................;p 40 | .......................................................;q 41 | .......................................................;r 42 | .......................................................;s 43 | .......................................................;t 44 | .......................................................;u 45 | .......................................................;v 46 | .......................................................;w 47 | .......................................................;x 48 | .......................................................;y 49 | .......................................................;z 50 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | all: base36 2 | 3 | .PHONY: base36 4 | base36: 5 | gcc base36.c -o base36 6 | --------------------------------------------------------------------------------