├── .gitignore ├── Makefile ├── README.md ├── LICENSE.md └── Robotonic.c /.gitignore: -------------------------------------------------------------------------------- 1 | robotonic 2 | *.swp 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(CC) $(CFLAGS) $(LDFLAGS) Robotonic.c -o robotonic -lm 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Robotonic 2 | pipeline music generator 3 | 4 | Installation 5 | ==== 6 | Clone this and just run `make`. 7 | 8 | How it works 9 | ==== 10 | Robotonic takes 4 bytes from stdin on each iteration and generates sound pattern using them as parameters: frequency, wave type (triangle, square, sin or saw), LFO wave type (no LFO, normal fade-in, parabolic fade-in or parabolic fade-out), interval and offset from the beginning of the pattern. Each new pattern overlaps the previous which makes illusion of continuity. 11 | 12 | Usage 13 | ==== 14 | `cat $file|./robotonic|$player` 15 | 16 | , where `$file` is, f. e., `/dev/urandom` or anything else you want to playback, `$player` is any program able to read raw sound data from the stdin and direct them to speakers or maybe even to sound file (f. e., `aplay`). 17 | 18 | Configuration 19 | ==== 20 | Change constants near the top of source file and then recompile the program 21 | 22 | * BUF_SIZE — number of samples generated for each pattern 23 | * SAMP_LENGTH — length of samples (shorter is glitchier because this does not affect the frequency) 24 | * RATE — output sampling rate 25 | * NOISE_LEVEL — from 0 to 255, sets the volume of the noise mixed up with the generated sound 26 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Bohdan Horbyeshko 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /Robotonic.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define BUF_SIZE 8 9 | #define SAMP_LENGTH 1024 10 | #define RATE 8000.0 11 | #define NOISE_LEVEL 0 12 | 13 | int8_t buf[BUF_SIZE*SAMP_LENGTH]; 14 | int8_t mbuf[SAMP_LENGTH]; 15 | uint32_t wvtp; 16 | uint16_t freq; 17 | int i; 18 | int8_t intrvl; 19 | int8_t offset; 20 | 21 | void gen_wave(int8_t*,uint8_t,uint16_t,uint8_t,uint8_t); 22 | void cp_array(int8_t*,int8_t*,int); 23 | void clear_mbuf(int8_t*); 24 | void clear_buf(int8_t*); 25 | 26 | int main(int argc,char** argv){ 27 | wvtp=0; 28 | clear_buf(buf); 29 | while(1){ 30 | switch (read(STDIN_FILENO,&wvtp,4)) { 31 | case 0: 32 | exit(0); 33 | break; 34 | case -1: 35 | write(STDERR_FILENO,"Read error\n",12); 36 | break; 37 | } 38 | freq=((wvtp >> 16) % 0x4000)+0x80; 39 | intrvl=(wvtp >> 5) % 0x08; 40 | intrvl=intrvl?intrvl:4; 41 | offset=wvtp % intrvl; 42 | clear_mbuf(mbuf); 43 | gen_wave(mbuf,(wvtp >> 30) % 0x04,freq,(wvtp >> 27) % 0x08,(wvtp >> 24) % 0x08); 44 | for (i=offset;i