Set ALSA master volume from C code

The following works for me. The parameter volume is to be given in the range [0, 100]. Beware, there is no error handling! void SetAlsaMasterVolume(long volume) { long min, max; snd_mixer_t *handle; snd_mixer_selem_id_t *sid; const char *card = “default”; const char *selem_name = “Master”; snd_mixer_open(&handle, 0); snd_mixer_attach(handle, card); snd_mixer_selem_register(handle, NULL, NULL); snd_mixer_load(handle); snd_mixer_selem_id_alloca(&sid); snd_mixer_selem_id_set_index(sid, 0); … Read more

Call recording – make it work on Nexus 5X (rooting or custom ROM possible)

Not sure if it is a Nexus 5 specific issue but usually the class used to record calls is MediaRecorder. Have you tried to replace AudioRecorder by a MediaRecorder? Based on this stack-overflow question, I think you could try the following code based on Ben blog post: import android.media.MediaRecorder; import android.os.Environment; import java.io.File; import java.io.IOException; … Read more

How to play sound in a Docker container on Mac OS Yosemite

It is definitely possible, you need to mount /dev/snd, see how Jess Frazelle launches a Spotify container, from https://blog.jessfraz.com/post/docker-containers-on-the-desktop/ you will notice docker run -it \ -v /tmp/.X11-unix:/tmp/.X11-unix \ # mount the X11 socket -e DISPLAY=unix$DISPLAY \ # pass the display –device /dev/snd \ # sound –name spotify \ jess/spotify or for Chrome, at the … Read more

Android > 4.0 : Ideas how to record/capture internal audio (e.g. STREAM_MUSIC)?

You must pass audio traffic through your local socket server: Create local socket server Modify audio http stream address to path is thru your local socket server, for example for address http://example.com/stream.mp3 -> http://127.0.0.1:8888/http://example.com/stream.mp3 where 8888 is your socket port. Play http://127.0.0.1:8888/http://example.com/stream.mp3 with default media player Read all incoming requests to port 8888 in your … Read more

PyAudio working, but spits out error messages each time

You can try to clean up your ALSA configuration, for example, ALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2212:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side are caused by /usr/share/alsa/alsa.conf: pcm.rear cards.pcm.rear pcm.center_lfe cards.pcm.center_lfe pcm.side cards.pcm.side Once you comment out these lines, those error message will be gone. You may also want … Read more

Capturing sound from Wine with TargetDataLine

Make use of AudioSystem.write() method. It is much easier targetDataLine.open(format); targetDataLine.start(); AudioInputStream ais=new AudioInputStream(targetDataLine); AudioFileFormat.Type fileformat=AudioFileFormat.Type.WAVE; /* Other Audio file formats supported: AudioFileFormat.Type.AU AudioFileFormat.Type.AIFF AudioFileFormat.Type.AIFC AudioFileFormat.Type.SND */ File audoutputfile=new File(‘myfile’); //adjust extension according to AudioFileFormat AudioSystem.write(ais,fileformat, audoutputfile);

Modifying in-call voice playback in Android custom ROM

There are several possible issues that come to my mind. The blank buffer might indicate that you have the wrong source selected. Also since according to https://developer.android.com/reference/android/media/AudioRecord.html#AudioRecord(int,%20int,%20int,%20int,%20int) you might not always get an exception even if something’s wrong with the configuration, you might want to confirm whether your object has been initialized properly. If all … Read more