alsa

Prevent ALSA underruns with PyAudio

孤街浪徒 提交于 2019-12-12 09:54:33
问题 I wrote a little program which records voice from the microphone and sends it over network and plays it there. I'm using PyAudio for this task. It works almost fine but on both computers i get errors from ALSA that an underrun occurred. I googled a lot about it and now I know what an underrun even is. But I still don't know how to fix the problem. Most of the time the sound is just fine. But it sounds a little bit strange if underruns occur. Is there anything I should take care of in my code?

Audio Recording in Python

走远了吗. 提交于 2019-12-12 07:32:51
问题 I want to record short audio clips from a USB microphone in Python. I have tried pyaudio, which seemed to fail communicating with ALSA, and alsaaudio, the code example of which produces an unreadable files. So my question: What is the easiest way to record clips from a USB mic in Python? 回答1: This script records to test.wav while printing the current amplitute: import alsaaudio, wave, numpy inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE) inp.setchannels(1) inp.setrate(44100) inp.setformat

Unable to apply configured parameters for a sound device

ぐ巨炮叔叔 提交于 2019-12-11 13:01:17
问题 I wrote the following simple example with asoundlib.h : #include <alsa/asoundlib.h> #include <sys/fcntl.h> #include <unistd.h> typedef struct sound_device_config_t sound_device_config_t; struct sound_device_config_t{ unsigned int rate; unsigned int periods; snd_pcm_uframes_t period_size; unsigned int channels; snd_pcm_format_t sample_format; }; static void _configure_device(snd_pcm_t **pcm_handle_ptr, const char *sd); int main(int argc, char * argv[]){ sound_device_config_t *cfg_ptr = malloc

alsa-utils + ndk-build not working

孤人 提交于 2019-12-11 12:23:38
问题 I have source code alsa-utils-1.0.27.2 from http://www.alsa-project.org/main/index.php/Main_Page I need for build it to my android: user@vbUbuntu1204:~/Android-alsa/alsa-utils$ cat jni/Android.mk ifeq ($(strip $(BOARD_USES_ALSA_AUDIO)),true) ifeq ($(strip $(BUILD_WITH_ALSA_UTILS)),true) LOCAL_PATH:= $(call my-dir) # # Build aplay command # include $(CLEAR_VARS) LOCAL_CFLAGS := \ -fPIC -D_POSIX_SOURCE \ -DALSA_CONFIG_DIR=\"/system/usr/share/alsa\" \ -DALSA_PLUGIN_DIR=\"/system/usr/lib/alsa-lib

How to connect to ALSA server (in this case, Timidity) in Ubuntu using C++?

给你一囗甜甜゛ 提交于 2019-12-11 07:34:20
问题 I am trying to use MIDI under Linux Ubuntu with C++. After a day of using several tools (e.g., JACK) with no success (JACK lags like mad on my machine), I am now trying to use Timidity as the MIDI server. However, I am not able to find any references on the web about how to programmatically connect to Timidity using C++. Is there anyway to do this? Thanks for any suggestions! Notes: I've tried search google with the following: alsa server connect timidity connect program But no answer. 回答1:

Alsa Asynchronous Playback

血红的双手。 提交于 2019-12-11 05:15:29
问题 I want to play a file using asynchronous playback method. I wrote the below code but it is not working., it is showing nothing. Any help thanks in advance. #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <poll.h> #include <alsa/asoundlib.h> snd_pcm_t *playback_handle; short buf[1024]; snd_pcm_uframes_t period_size = 64; void playback_callback (snd_async_handler_t *pcm_callback) { int err; // snd_pcm_t *playback_handle = snd_async_handler_get_pcm(pcm_callback); void *private

Can i set timestamp in ALSA?

删除回忆录丶 提交于 2019-12-11 03:22:16
问题 I am developing one application in which i need to play audio packets as per timestamp. For this i need to tell alsa driver at what timestamp my audio packet should get played. For this i need to set the timestamp of ALSA. I could find the alsa api to get the timestamp (snd_pcm_status_get_tstamp()) at which the audio packet are getting played. void gettimestamp(snd_pcm_t *handle, snd_timestamp_t *timestamp) { int err; snd_pcm_status_t *status; snd_pcm_status_alloca(&status); if ((err = snd

How to play sounds on android faster?

断了今生、忘了曾经 提交于 2019-12-11 02:20:46
问题 I'm working on adding a feature to the Android platform to play a sound from the speaker with the absolute lowest latency possible. I found tinyplay.c in the tinyalsa external project and I am using that as a model. I want to open the pcm device and play a sound and close it within 10 ms if possible. Right now when I call pcm_params_get or pcm_open it will sometimes take only a few millis, but sometimes it takes up to 4 seconds! I believe that if an android sound has played recently it takes

List devices with PyAudio on Linux

孤街醉人 提交于 2019-12-10 20:06:45
问题 When listing audio devices on Linux (I tried with Raspbian / RaspberryPi) with: import pyaudio p = pyaudio.PyAudio() for i in range(p.get_device_count()): print p.get_device_info_by_index(i) I get these errors. How to have a clean PyAudio running on Raspberry? ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.front.0:CARD=0' ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:4720:

Alsa with PCM interface from modem

走远了吗. 提交于 2019-12-10 17:56:54
问题 I have a custom board based on the imx28 CPU. The Serial port of the CPU is connected to the PCM output of a modem. I have to develop a driver for the modem's PCM interface to be a part of ALSA SoC. Can you point out some drivers in the kernel tree that reasembles with my setup? 回答1: See the Documentation/sound/alsa/soc directory in the Linux source. It explains how ASoC drivers are divided into three categories: Codec driver: These define the audio controls, interface capabilities, DAPM