alsa

How to use alsa to play sounds simultaneously in c?

旧时模样 提交于 2019-12-06 07:50:58
I'm using alsa lib in c under linux. I'd like to load several wav files and play them depending on some test conditions. I'm using the following code, but it needs to be improved: // A simple C example to play a mono or stereo, 16-bit 44KHz // WAVE file using ALSA. This goes directly to the first // audio card (ie, its first set of audio out jacks). It // uses the snd_pcm_writei() mode of outputting waveform data, // blocking. // // Compile as so to create "alsawave": // gcc -o alsawave alsawave.c -lasound // // Run it from a terminal, specifying the name of a WAVE file to play: // ./alsawave

alsa-util 1.1.0 arm cross compile issue

心不动则不痛 提交于 2019-12-06 05:55:12
I am trying to build alsa-util-1.1.0 for an arm-linux platform, through trial and error I managed to compile alsa-lib and alsa-util ok using these commands: alsa-lib: CC=arm-linux-gnueabihf-gcc ./configure --host=arm-linux -prefix=/home/username/20160311_alsa_work/alsa/install --disable-python alsa-util: CC=arm-linux-gnueabihf-gcc ./configure --prefix=/home/username/20160311_alsa_work/alsa/install --host=arm-linux --with-alsa-inc-prefix=/home/username/20160311_alsa_work/alsa/install/include --with-alsa-prefix=/home/username/20160311_alsa_work/alsa/install/lib --disable-alsamixer --disable

ALSA: buffer underrun on snd_pcm_writei call

不想你离开。 提交于 2019-12-06 05:42:12
问题 I'm getting buffer underruns when running an old program I recently brought back from the ashes. The program loads up a raw sound file fully into memory (2100 bytes long, 525 frames) and prepares ALSA for output (44.1khz, 2 channels, signed 16 bit): if ((err = snd_pcm_set_params(audio_handle, SND_PCM_FORMAT_S16_LE, SND_PCM_ACCESS_RW_INTERLEAVED, 2, 44100, 1, sound.playback_us)) < 0) { printf("E: Failed to prepare PCM: %s\n", snd_strerror(err)); return -1; } PCM state is PREPARED prior to

Is it possible to arecord output from dummy card?

混江龙づ霸主 提交于 2019-12-06 05:30:49
I'm trying to mix audio files via dummy card by using dmix and dsnoop: aplay s1.wav & aplay s2.wav & arecord -f dat -t wav -d 3 result.wav But is it possible? I have only dummy card by: modprobe snd-dummy My ~/.asoundrc file is: defaults.pcm.card 1 #dummy card pcm.duplex { type asym playback.pcm "dmix" capture.pcm "dsnoop" } pcm.!default { type plug slave.pcm "duplex" } Running on: CentOS6.5(x86_64) The snd-dummy driver throws away playback data, and records silence. For a loopback device, use the snd-aloop driver instead. 来源: https://stackoverflow.com/questions/24350367/is-it-possible-to

Running python script as root

旧巷老猫 提交于 2019-12-06 03:47:15
问题 I have the following script: #!/usr/bin/env python import sys import pyttsx def main(): print 'running speech-text.py...' engine = pyttsx.init() str = "Hi..." if len(sys.argv) > 1: str = sys.argv[1] engine.say(str) engine.runAndWait() if __name__ == '__main__': main() and I have placed it in /usr/bin/speech-test.py I have also given it executable permissions and ownership to root: sudo chown root:root /usr/bin/speech-test.py sudo chmod 4755 /usr/bin/speech-test.py However, this script will

Prevent ALSA underruns with PyAudio

风流意气都作罢 提交于 2019-12-05 21:47:42
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? It feels like I'm doing an simple error and I miss it. My system: python: python3.3, OS: Linux Mint

ubuntu12.04安装PPS

半城伤御伤魂 提交于 2019-12-05 04:58:11
PPS是优秀的在线影视软件,它也针对ubuntu开发了相应的客户端,本文简要介绍它的下载安装及一些小问题的解决。 1、下载安装 官方下载地址如下: http://dl.pps.tv/pps_linux_download.html 下载后是*.deb文件,双击调用软件中心安装,遇到提示一律确认。 2、启动软件 打开主页菜单,搜索pps,即可看到应用程序快捷方式 3、视频缓冲完直接跳到下一视频,不能正常播放的问题 该问题12.04出现概率几乎是100%,解决方法是安装以下软件包 sudo apt-get install libjpeg62 4、播放视频没有声音的问题 点击工具菜单=>选项=>选择音频设置... 默认选择是alsa,以alsa开头的还有两个设置,我们选择以alsa开头比较长的第一个,确定并半闭程序,再打开,即可解决。 来源: oschina 链接: https://my.oschina.net/u/552563/blog/69654

ubuntu12.04安装PPS

丶灬走出姿态 提交于 2019-12-05 04:58:02
PPS是优秀的在线影视软件,它也针对ubuntu开发了相应的客户端,本文简要介绍它的下载安装及一些小问题的解决。 1、下载安装 官方下载地址如下: http://dl.pps.tv/pps_linux_download.html 下载后是*.deb文件,双击调用软件中心安装,遇到提示一律确认。 2、启动软件 打开主页菜单,搜索pps,即可看到应用程序快捷方式 3、视频缓冲完直接跳到下一视频,不能正常播放的问题 该问题12.04出现概率几乎是100%,解决方法是安装以下软件包 sudo apt-get install libjpeg62 4、播放视频没有声音的问题 点击工具菜单=>选项=>选择音频设置... 默认选择是alsa,以alsa开头的还有两个设置,我们选择以alsa开头比较长的第一个,确定并半闭程序,再打开,即可解决。 来源: oschina 链接: https://my.oschina.net/u/735674/blog/81642

Simulate Microphone (virtual mic)

好久不见. 提交于 2019-12-05 00:41:46
I've got a problem where I need to "simulate" microphone output. Data will be coming over the network, decoded into PCM and basically needs to be written into the mic - which then other programs can read/record/whatever. I've been reading up on alsa but information is pretty sparse. The file plugin seemes promising - I was thinking of having a named pipe as "infile" which I could then deliver data to from my application. I can't get it to work however (vlc/audacity just segfault). pcm.testing { type file slave { pcm { type hw card 0 device 0 } } infile "/dev/urandom" format "raw" } Are there

Makefile conditional include

蹲街弑〆低调 提交于 2019-12-04 23:42:41
I'm trying to write an application that needs either ALSA or OSS headers. Basically, I want to pass a define to the compiler if /etc/oss.conf does not exist, since that probably means the soundcard.h header doesn't exist (feel free to correct me on that one, I'm still new to working with OSS). Per the OSS documentation, you would use the include directive like so: include /etc/oss.conf CFLAGS := -I$(OSSLIBDIR)/include/sys One problem. OSS support is optional, so I'd want to check if the header exists, and if does, pass a define to the compiler. The problem is, AFAIK there is no way to check if