0
Я читаю звуковые значения с помощью библиотеки alsa и возвращаю некоторое значение, подобное этому 40239717. Но я не понимал средств. Как преобразовать это значение в нормальную форму.Что такое библиотека alsa?
Мой код для чтения, как это:
if ((err = snd_pcm_open (&capture_handle, "default", SND_PCM_STREAM_CAPTURE, 0)) < 0) {
qDebug("cannot open audio device default\n");
exit (1);
}
if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) {
qDebug ("cannot allocate hardware parameter structure\n");
exit (1);
}
if ((err = snd_pcm_hw_params_any (capture_handle, hw_params)) < 0) {
qDebug("cannot initialize hardware parameter structure\n");
exit (1);
}
if ((err = snd_pcm_hw_params_set_access (capture_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
qDebug ("cannot set access type \n");
exit (1);
}
if ((err = snd_pcm_hw_params_set_format (capture_handle, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
qDebug ("cannot set sample format\n");
exit (1);
}
if ((err = snd_pcm_hw_params_set_rate_near (capture_handle, hw_params, &sample_rate, 0)) < 0) {
qDebug ("cannot set sample rate\n");
exit (1);
}
if ((err = snd_pcm_hw_params_set_period_size_near (capture_handle, hw_params, &frame, 0)) < 0) {
qDebug ("cannot set sample rate\n");
exit (1);
}
if ((err = snd_pcm_hw_params_set_channels (capture_handle, hw_params, 2)) < 0) {
qDebug ("cannot set channel count\n");
exit (1);
}
if ((err = snd_pcm_hw_params (capture_handle, hw_params)) < 0) {
qDebug ("cannot set parameters\n");
exit (1);
}
if ((err = snd_pcm_prepare (capture_handle)) < 0) {
qDebug ("cannot prepare audio interface for use\n");
exit (1);
}
if ((err = snd_pcm_readi(capture_handle,buffer,frame)) != frame) {
qDebug("read from audio interface failed\n");
}