-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsine.c
55 lines (51 loc) · 965 Bytes
/
sine.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include <unistd.h>
#include <term.h>
#include <termios.h>
#define drt(ch,nm)\
case ch: \
fprintf(stdout,"i %d 0 5 8000 %d\n",p,nm); break
#define prt(ch,nm)\
case ch: \
p = nm; break
int main(void){
int p;
int c;
static struct termios oldt, newt;
p = 1;
tcgetattr( STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr( STDIN_FILENO, TCSANOW, &newt);
while((c=getchar())!= 27) {
switch(c) {
prt('1',1);
prt('2',2);
prt('3',3);
prt('4',4);
prt('5',5);
drt('z',0);
drt('w',1);
drt('s',2);
drt('x',3);
drt('e',4);
drt('d',5);
drt('c',6);
drt('v',6+1);
drt('t',8);
drt('g',8+1);
drt('b',10);
drt('y',11);
drt('h',12);
drt('n',13);
drt('u',14);
drt('j',15);
drt('m',16);
drt(',',16+1);
}
// fflush( csound_pointer );
fflush(stdout);
}
tcsetattr( STDIN_FILENO, TCSANOW, &oldt);
return 0;
}