alsa

Get master sound volume in C in Linux

拈花ヽ惹草 提交于 2019-11-29 22:40:43
问题 I'm trying to retrieve (and probably later set) the master sound volume in Linux. I'm using PulseAudio, but ideally it should work for ALSA too. I found this very helpful post on how to set the volume, and from that I was able to deduce the existence of snd_mixer_selem_get_playback_volume() to retrieve the current setting. However on my system, this seems to be giving me wrong readings - where mixer programs show 100%, this tops out at about 66%. If I open pavucontrol I can see the volume for

ALSA tutorial required

痞子三分冷 提交于 2019-11-29 21:56:43
I am New to audio programming.I want to create small application which is capable of playing and gives volume control . I am using alsa-lib. I want to know what is the purpose of switch (ex.Master Playback switch), enum in mixer elements and what value should i set to those switchs . Please suggest me some tutorial for mixer settings as well as alsa programming . Just collecting some here, that have example code: ALSA Programming HOWTO v.1.0.0 [alsamodular.sourceforge.net] A tutorial on using the ALSA Audio API [equalarea.com] 2002 A close look at ALSA [volkerschatz.com] ALSA API - Sample

Tutorials for OpenSL ES for Android

六月ゝ 毕业季﹏ 提交于 2019-11-29 19:12:58
I've been trying to look into using the OpenSL ES library that is available for doing native audio with android 2.3, but it appears that the header files and the 600 page pdf of the spec are the only available documentation. Where should I be looking for examples, tutorials, or a brief overview of the capabilities? Phonon There's an example app that comes with the NDK called NativeAudio . It has examples of nearly anything you would ever want to implement: effects, streaming, synthesis, etc. If you look at its code, you'll get a good head start. You could also check victor lazzarini's audio

Linux ALSA/Sound-API Questions - How do you mute?

馋奶兔 提交于 2019-11-29 16:10:15
问题 How do I mute sound using C? Is there an ALSA function call? Are there any other function calls/APIs that can MUTE the microphone? I have written some code to do audio playback using ALSA, and I have noticed a DELAY before the sound starts playing ... how do I reduce DELAY or LATENCY on sound playback? x 回答1: #include <alsa/asoundlib.h> void SetAlsaMasterMute() { long min, max; snd_mixer_t *handle; snd_mixer_selem_id_t *sid; const char *card = "default"; const char *selem_name = "Master"; snd

alsa移植到tiny6410

倖福魔咒の 提交于 2019-11-29 12:19:30
最近学习用到alsa,所以就准备移植alsa到自己的tiny6410上, 首先需要准备些东西,tiny6410的文件系统,如果用NFS就更好; alsa-lib-1.0.24.1.tar.bz2 alsa-utils-1.0.24.2.tar.bz2 好了,下面开始移植 环境:fedora12 交叉工具位置: /opt/FriendlyARM/toolschain/4.5.1/ 开发板根文件系统位置: /opt/filesystem/rootfs-qt4-2/ 在/opt/alsa下解压源码 tar xjf alsa-lib-1.0.24.1.tar.bz2 tar xjf alsa-utils-1.0.24.2.tar.bz2 1.开始移植alsa-lib 进入alsa-lib源码目 录,输入以下命令 ./configure --host=arm-linux --target=arm-linux --prefix=/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/lib/arm-alsa --enable-static --enable-shared --disable-python --with-configdir=/usr/share --with-plugindir=/usr/lib/alsa_lib

Android AudioRecord - Won't Initialize 2nd time

前提是你 提交于 2019-11-29 12:07:34
问题 Hej, im currently trying to get AudioRecord to work. Because I need it in a bigger project. But it seems to mess up a lot. I have been trying alot of things, so I went back to basic when I traced this bug. I am using my Samsung Galaxy S as my debugdevice. My problem is, first time after a reboot of my device I can initialize the AudioRecord object I create without problems. But the second time I run it, it won't initialize the AudioRecord object. I have tried several frequencies, fyi. Here is

ALSA: Relation between period size of speaker and mic

帅比萌擦擦* 提交于 2019-11-29 07:54:10
I have audio conferencing device which has a mic and speaker. Both mic and speaker having same sampling rate set by snd_pcm_hw_params_set_rate_near() say 8000 Hz. Do I need to set period size and number of periods to be same for both (for two such devices communicate each other) ? Or can I choose a different period/period size for speaker than the one configured for mic ? How do I decide on which period and period size to use ? I am using snd_pcm_hw_params_set_period_size_near() and snd_pcm_hw_params_set_periods_near() APIs to set period size and period for both speaker and mic. (I am new to

Linux pipe audio file to microphone input

半腔热情 提交于 2019-11-28 22:00:47
I'm looking for a way to feed audio data from a file into the microphone so when 3rd party applications (such as arecord or Chromium's "search by voice" feature) use the microphone for audio input, they receive the audio data from the file instead. Here's my scenario : An application I wrote records audio data from the microphone (using ALSA) and saves it to a file (audioFile0.raw). At some unknown point in time in the future, some unknown 3rd party application (as in, something I did not develop so I have no development control over, such as the Chromium web browser's "search by voice"

The meaning of period in ALSA

耗尽温柔 提交于 2019-11-28 17:38:22
I'm using ALSA for and audio application on Linux, I found great docs explain how to use it : 1 and this one . although I have some issues to understand this part of the setup : /* Set number of periods. Periods used to be called fragments. */ if (snd_pcm_hw_params_set_periods(pcm_handle, hwparams, periods, 0) < 0) { fprintf(stderr, "Error setting periods.\n"); return(-1); } what does mean set a number of period when I'm using the PLAYBACK mode and : /* Set buffer size (in frames). The resulting latency is given by */ /* latency = periodsize * periods / (rate * bytes_per_frame) */ if (snd_pcm

run apps using audio in a docker container

放肆的年华 提交于 2019-11-28 15:59:41
This question is inspired by Can you run GUI apps in a docker container? . The basic idea is to run apps with audio and ui (vlc, firefox, skype, ...) I was searching for docker containers using pulseaudio but all containers I found where using pulseaudio streaming over tcp. (security sandboxing of the applications) https://gist.github.com/hybris42/ce429de428e5af3a344a https://github.com/jlund/docker-chrome-pulseaudio https://github.com/tomparys/docker-skype-pulseaudio In my case I would prefere playing audio from an app inside the container directly to my host pulseaudio. (without ssh