Rev 32 |
|
Rev 33 |
Line 14... |
|
Line 14... |
14 |
#include <math.h> |
|
14 |
#include <math.h> |
15 |
#include <fftw3.h> |
|
15 |
#include <fftw3.h> |
16 |
|
|
16 |
|
17 |
static char *device = "plughw:1,0"; /* playback device */ |
|
17 |
static char *device = "plughw:1,0"; /* playback device */ |
18 |
static snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format */ |
|
18 |
static snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format */ |
19 |
static unsigned int rate = 24000; /* stream rate */ |
|
19 |
static unsigned int rate = 48000; /* stream rate */ |
20 |
static int resample = 1; /* enable alsa-lib resampling */ |
|
20 |
static int resample = 1; /* enable alsa-lib resampling */ |
21 |
static int period_event = 0; /* produce poll event after each period */ |
|
21 |
static int period_event = 0; /* produce poll event after each period */ |
22 |
|
|
22 |
|
23 |
static snd_pcm_sframes_t buffer_size=7007; // size of buffer at sound card |
|
23 |
static snd_pcm_sframes_t buffer_size=7008; // size of buffer at sound card |
24 |
static snd_pcm_sframes_t period_size=2331; //samples per frame |
|
24 |
static snd_pcm_sframes_t period_size=2328; //samples per frame |
25 |
static snd_output_t *output = NULL; |
|
25 |
static snd_output_t *output = NULL; |
26 |
|
|
26 |
|
27 |
FILE *out; |
|
27 |
FILE *out; |
28 |
|
|
28 |
|
29 |
double df; //frequency resolution |
|
29 |
double df; //frequency resolution |
Line 252... |
|
Line 252... |
252 |
//open and set capture device |
|
252 |
//open and set capture device |
253 |
if ((err = snd_pcm_open(&capture_handle, device, SND_PCM_STREAM_CAPTURE, 0)) < 0) { |
|
253 |
if ((err = snd_pcm_open(&capture_handle, device, SND_PCM_STREAM_CAPTURE, 0)) < 0) { |
254 |
printf("Playback open error: %s\n", snd_strerror(err)); |
|
254 |
printf("Playback open error: %s\n", snd_strerror(err)); |
255 |
return 0; |
|
255 |
return 0; |
256 |
} |
|
256 |
} |
- |
|
|
257 |
else printf("Using audio device: %s\n", device); |
257 |
|
|
258 |
|
258 |
if ((err = set_hwparams(capture_handle, hwparams, 2)) < 0) { |
|
259 |
if ((err = set_hwparams(capture_handle, hwparams, 2)) < 0) { |
259 |
printf("Setting of hwparams failed: %s\n", snd_strerror(err)); |
|
260 |
printf("Setting of hwparams failed: %s\n", snd_strerror(err)); |
260 |
exit(EXIT_FAILURE); |
|
261 |
exit(EXIT_FAILURE); |
261 |
} |
|
262 |
} |