docs
[mirrors/Programs.git] / c / condrum / condrum.c
CommitLineData
21c4e167
H
1#include "bass.h"\r
2#include <conio.h>\r
3#include <stdlib.h>\r
4#include <stdio.h>\r
5\r
6//#define DEBUG //Uncomment for debuging\r
7#define MAX_CHANS 128 //Maximum lenght of line in loopfile (recomended 128 or 64)\r
8\r
9\r
10// display error messages\r
11void Error(const char *text) \r
12{\r
13 printf("Error(%d): %s\n",BASS_ErrorGetCode(),text);\r
14 BASS_Free();\r
15 exit(0);\r
16}\r
17\r
18int main(int argc, char *argv)\r
19{\r
20 if (!BASS_Init(-1,44100,0,0,NULL)) {\r
21 // couldn't initialize device\r
22 printf("Error -1- Init");\r
23 return(0);\r
24 }\r
25 \r
26 char loopf[] = "loop.txt";\r
27 int i = 0, t = 0, sch=sizeof(char), sleep = 500; //t = total chanells\r
28 HSAMPLE sample[MAX_CHANS];\r
29 HCHANNEL channel[MAX_CHANS];\r
30 char *line, bar[MAX_CHANS] = {'1', '0'};\r
31 line = malloc(MAX_CHANS*sch);\r
32 FILE *loop;\r
33 \r
34 loop = fopen(loopf, "r");\r
35 \r
36 printf("ConDrummer\nSimple Console Drumstation for Windows\nHarvie 2oo7\nFile: %s\n\n", loopf);\r
37 \r
38 while(1) {\r
39 fgets(line, MAX_CHANS, loop);\r
40 if(strstr(line, ";")) { \r
41 //printf("%s", line+sch);\r
42 continue;\r
43 }\r
44 if(strstr(line, "!")) { \r
45 printf("%s", line+sch);\r
46 continue;\r
47 }\r
48 if(strstr(line, ":")) {\r
49 line++;\r
50 memset( line+strlen(line)-1, 0, 1);\r
51 printf("Sample: %i = %s\n", i, line);\r
52 sprintf(line, "%s", line);\r
53 sample[i] = BASS_SampleLoad(FALSE, line, 0, 0, 100, BASS_SAMPLE_MONO);\r
54 channel[i] = BASS_SampleGetChannel(sample[i], FALSE); // get a sample channel\r
55 i++;\r
56 t++;\r
57 line--;\r
58 continue;\r
59 }\r
60 \r
61 if(strstr(line, "?")) {\r
62 sleep = atoi(line+sch);\r
63 #ifdef DEBUG\r
64 printf("Delay: %i\n", sleep);\r
65 #endif\r
66 continue;\r
67 }\r
68 if(strstr(line, "@")) {\r
69 sleep = atoi(line+sch);\r
70 sleep = (60*1000)/(sleep*4);\r
71 #ifdef DEBUG\r
72 printf("Delay: %i\n", sleep);\r
73 #endif\r
74 continue;\r
75 }\r
76 \r
77 if(strstr(line, "#")) {\r
78 break;\r
79 }\r
80 }\r
81 \r
82 printf("Channels total: %i\nPlaying...\n\n", t);\r
83 \r
84 //DrumLOOP\r
85 i = 0;\r
86 while(1) {\r
87 i = 0;\r
88 while(1) {\r
89 fgets(line, MAX_CHANS, loop);\r
90 if(strstr(line, "-")) {\r
91 sprintf(bar, "%s\x0", (line+sch));\r
92 break;\r
93 }\r
94 if(feof(loop)) {\r
95 #ifdef DEBUG\r
96 printf("rewind\n"); //Debug\r
97 #endif\r
98 rewind(loop);\r
99 while(1) {\r
100 fgets(line, MAX_CHANS, loop);\r
101 if(strstr(line, "#")) { break; }\r
102 }\r
103 }\r
104 }\r
105 \r
106 for(i = 0;i<t;i++) {\r
107 if (bar[i] == '1') {\r
108 BASS_ChannelPlay(channel[i], FALSE);\r
109 }\r
110 }\r
111 \r
112 Sleep(sleep);\r
113 \r
114 }\r
115 \r
116 BASS_Free();\r
117 return(0);\r
118}\r
119\r
120/*\r
121\r
122TODO (unsorted):\r
123 - better samples (Audacity or ER-0)\r
124 - better (user friendly) loopfile syntax\r
125 - BPM 2 sleep delay calculator\r
126 - better icon\r
127 - manual\r
128 - sample patterns\r
129 - Linux port (SDL???)\r
130 - volume for each beat\r
131 - recording to wav\r
132\r
133*/\r
134\r
135\r
136\r
This page took 0.637293 seconds and 5 git commands to generate.