3,12 → 3,13 |
#include <alsa/asoundlib.h> |
|
int exact_rate = 44100; |
|
#define BUFFER_SIZE 1024 |
|
main (int argc, char *argv[]) |
{ |
int i; |
int i,j; |
int err; |
short buf[128]; |
short buf[BUFFER_SIZE]; |
snd_pcm_t *capture_handle; |
snd_pcm_hw_params_t *hw_params; |
|
19,7 → 20,7 |
exit (1); |
} |
|
fprintf (stdout,"nastaveni formatu"); |
fprintf (stdout,"nastaveni formatu\n"); |
|
if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) { |
fprintf (stderr, "cannot allocate hardware parameter structure (%s)\n", |
44,7 → 45,7 |
snd_strerror (err)); |
exit (1); |
} |
fprintf (stdout,"nastaveni formatu"); |
fprintf (stdout,"nastaveni formatu\n"); |
|
if ((err = snd_pcm_hw_params_set_rate_near (capture_handle, hw_params, &exact_rate, 0)) < 0) { |
fprintf (stderr, "cannot set sample rate (%s)\n", |
51,7 → 52,7 |
snd_strerror (err)); |
exit (1); |
} |
fprintf (stdout,"nastaveni vzorkovani"); |
fprintf (stdout,"nastaveni vzorkovani\n"); |
|
if ((err = snd_pcm_hw_params_set_channels (capture_handle, hw_params, 2)) < 0) { |
fprintf (stderr, "cannot set channel count (%s)\n", |
59,7 → 60,7 |
exit (1); |
} |
|
fprintf (stdout,"nastaveni poctu kanalu"); |
fprintf (stdout,"nastaveni poctu kanalu\n"); |
|
if ((err = snd_pcm_hw_params (capture_handle, hw_params)) < 0) { |
fprintf (stderr, "cannot set parameters (%s)\n", |
67,7 → 68,7 |
exit (1); |
} |
|
fprintf (stdout,"nastaveni parametru"); |
fprintf (stdout,"nastaveni parametru\n"); |
|
snd_pcm_hw_params_free (hw_params); |
|
76,17 → 77,18 |
snd_strerror (err)); |
exit (1); |
} |
fprintf (stdout,"povoleni audia"); |
fprintf (stdout,"povoleni audia\n"); |
|
for (i = 0; i < 10; ++i) { |
if ((err = snd_pcm_readi (capture_handle, buf, 128)) != 128) { |
|
if ((err = snd_pcm_readi (capture_handle, buf, BUFFER_SIZE)) != BUFFER_SIZE) { |
fprintf (stderr, "read from audio interface failed (%s)\n", |
snd_strerror (err)); |
exit (1); |
|
} |
} |
|
} |
for (j=0; j < 500; j=j+2) fprintf (stdout,"%u:%d %d\n ",j,buf[j], buf[j+1]); |
|
snd_pcm_close (capture_handle); |
exit (0); |
} |
|