Digitális hangminták
Gaga
cut.c
1 #include <stdio.h>
2 
3 #ifdef _WIN32
4 #include <io.h>
5 #include <fcntl.h>
6 #endif
7 
8 typedef float sample_t;
9 
10 int const sample_rate = 44100;
11 
12 int main(int argc, char *argv[])
13 {
14  double dstart, dstop;
15  long long int start, stop, k;
16  sample_t samples[2];
17 
18  if (argc < 3) {
19  fprintf(stderr, "Usage: %s start stop\n", argv[0]);
20  return 1;
21  }
22 
23  sscanf(argv[1], "%lf", &dstart);
24  sscanf(argv[2], "%lf", &dstop);
25  start = dstart * sample_rate;
26  stop = dstop * sample_rate;
27 
28 #ifdef _WIN32
29  setmode(fileno(stdin), O_BINARY);
30  setmode(fileno(stdout), O_BINARY);
31 #else
32  freopen(NULL, "rb", stdin);
33  freopen(NULL, "wb", stdout);
34 #endif
35 
36  k = 0;
37  while (fread(samples, sizeof(sample_t), 2, stdin) == 2) {
38  if (k >= start && k <= stop)
39  fwrite(samples, sizeof(sample_t), 2, stdout);
40  ++k;
41  }
42 
43  return 0;
44 }
45 
main
int main(int argc, char **argv)
the plugin main function
Definition: amplify.c:19
sample_t
float sample_t
type of a single sample
Definition: amplify.c:11