Audio Channel change/swap automatically - linux

I am working with digital TV in Linux platform. Currently I am facing with one issue in audio. When I give stereo audio to
snd_pcm_write_i
Function and after long time running the audio channels get swapped. That is, right channel audio hearing in Left channel and Left in Right. I dumped the PCM data in to a file before giving to alsa in issue case and played using 'aplay' and audio is good.So I think the PCM data is OK. In my system,'AK4643' audio codec device is used. Does any one faces this issue? If so please help me.

The issue was associated with the I2S driver .
Fixed the issue with updated driver from chip vendor.

Related

How to debug a Linux I2S audio input issue

I am trying, and failing, to connect an I2S microphone (Invensense ICS43432) to my Raspberry Pi (B+) running Arch Linux. I have asked for specific advice in the relevant Arch Linux ARM forum but my question is really more general than that: how does one go about debugging Linux audio input issues?
I have verified with a logic analyser that the I2S microphone is sending sensible data in the correct channel (left) and the correct pin of the Raspberry Pi. The I2S microphone appears under ALSA as a "sound card". arecord is perfectly happy to record from that device and I have boosted the gain of that device using alsamixer by 30 dB. Yet all the data bytes of the recorded file are zero.
How does one go about checking the flow of audio data, the operation of DMA, under Linux?
I had the same problem trying to record in stereo, using 2 Adafruit I2S MEMS breakout mics: arecord worked fine, but zeros when using ALSA to write to a bin file. Choosing a 32 bit word format (Little Endian 32 bits, Signed) made it work. Only I end up with 64 bit stereo Frames.

Is it possible to capture audio from an ASIO device with ffmpeg?

We have a setup with a Windows 7 machine where we installed Dante Virtual Soundcard and start that soundcard with ASIO capabilities. The soundcard will receive audio over the network from a Tesira server. We want to capture the audio to files (highly preferring each channel to a separate file). The files will be played back on a later moment. There will likely be 6 channels or more.
In the same setup we use ffmpeg to capture some video which is working fine, with Direct Show. So for audio we wanted to use the same setup, since ffmpeg is able to record audio as well. However, there seems to be no option to select the ASIO devices which the virtual soundcard probably creates. So the question is what command line to use for ffmpeg, or what to install? Or which other program can record ASIO from command line?
I already tried installing:
Asio4all (actually wrong way around)
sox (don't know why actually)
HiFi Cable Asio Bridge (from VB-audio, not enough channels even with donate version)
Voicemeeter (from VB-Audio, not enough channels and actually mixes down)
O Deus Asio link, this might be an interesting option but it did not let me configure any route, any suggestions?
One thing I noticed is that the virtual soundcard can also be set to use WDM. Then I can see the devices with ffmpeg -list_devices true -f dshow -i duymmy, but recording does not yield any result, I have to ctrl-c to make it stop instead of q, and the file is zero bytes. Supposedly this is because the data over the network is all ASIO formatted and the Tesira Server cannot send "WDM data". FFmpeg stops at selecting the capture pin for audio only
EDIT:
I ran ffmpeg with high verbosity and when selecting the WDM soundcard it stops at Selecting pin Capture on audio only. Also when requesting the options it gives the same line for 22 times: min ch=1 bits=8 rate= 11025 max ch=2 bits=16 rate= 44100
You might use Voicemeeter instead of HIFI-Cable / ASIO-Bridge. Voicemeeter is a virtual audio device mixer able to connect everything together, any audio point, in any interface and any app together (including ASIO DAW)... Download & User Manual on www.voicemeeter.com
To answer my own question: it is not possible to capture sound from an ASIO device with ffmpeg. Maybe I will write the code for it if I need it...
I could however solve my issues by separating the two streams of audio data we have (AVB and Dante). These where on the same switch and maybe it is a bug in the firmware, maybe misconfiguration.
Thanks for your help!
How do I get the output from an ASIO device to IceCast2 or FFMpeg?
Duplicate?
And if not, Place the output for ffmpeg -f dshow -i "audio=your_device_name_in_dshow" -list_options

Setting channel volume in ALSA

My app plays raw PCM audio data through various channels using ALSA. I'm allocating a new audio channel by using snd_pcm_open(), then setting the PCM format via the snd_pcm_hw_params_xxx() calls and finally feeding raw PCM audio data to ALSA by using the snd_pcm_writei() API.
This is all working fine so far but I haven't found any way to tell ALSA to reduce the volume of a sound channel allocated in the way outlined above. Of course, I could just manually apply volume scaling to the PCM data before sending it to ALSA via snd_pcm_writei() but is there really no way to have ALSA do this on its own?
ALSA has no such function.
You have to do the scaling yourself, or use a sound server like PulseAudio.
You can via amixer:
amixer cset name='Headphone Playback Volume' 98%,100%
To get the name value - check alsamixer, appending 'Playback Volume' to each.
And via alsamixer:
Keyboard z is left channel decrease.
q is left increase.
and
c is right decrease.
e is right increase

Regarding audio recording audio using pulseaudio API

I cannot record audio using monitor source of sink devices,from 2 to 3 days.I have reinstalled Pulseaudio, but the problem remains. I am using ubuntu 12.04 with default pulse audio. few day ago, i had same problem but I reinstalled ubuntu so I overcame problem but now same problem...??
from my point of view, Monitor of internal audio does not seem to get any signal.because
i check Pulse Audio Volume Control (pavucontrol), in which volume bar does not shown volume level in playtab and same case in output Devices tab.However, I can hear audio,and the pavucontrol Play tab shows the name of the applications which is running.
suggest any way to overcome this problem, because my application need audio recording from speaker(from context of pulse audio from sink device).
Thanks...
I got the solution, it was a simple case of the monitor being muted. In pavucontrol go to input devices, then in the show button at the bottom switch it to All input devices. I believe it's normally set to all except monitors, so the monitor doesn't show up. In my case it was this monitor that was muted, but I could still hear sound because the internal audio wasn't muted. sorry for pasting here but lets Hope it helps someone....

Can v4l2 be used to read audio and video from the same device?

I have a capture card that captures SDI video with embedded audio. I have source code for a Linux driver, which I am trying to enhance to add video4linux2 support. My changes are based on the vivi example.
The problem I've come up against is that all the example I can find deal with only video or only audio. Even on the client side, everything seems to assume v4l is just video, like ffmpeg's libavdevice.
Do I need to have my driver create two separate devices, a v4l2 device and an alsa device? It seems like this makes the job of keeping audio and video in sync much more difficult.
I would prefer some way for each buffer passed between the driver and the app (through v4l2's mmap interface) contain a frame, plus some audio that matches up (with respect to time) with that frame.
Or perhaps have each buffer contain a flag indicating if it is a video frame, or a chunk of audio. Then the time stamps on the buffers could be used to sync things up.
But I don't see a way to do this with the V4L2 API spec, nor do I see any examples of v4l2-enabled apps (gstreamer, ffmpeg, transcode, etc) reading both audio and video from a single device.
Generally, the audio capture part of a device shows up as a separate device. It's usually a different physical device (posibly sharing a card), which makes sense. I'm not sure how much help that is, but it's how all of the software I'm familiar with works...
There are some spare or reserved fields in the v4l2 buffers that can be used to pass audio or other data from the driver to the calling application via pointers to mmaped buffers.
I modified the BT8x8 driver to use this approach to pass data from an A/D card synchronized to the video on Ubuntu 6.06.
It worked OK, but the effort of maintaining my modified driver caused me to abandon this approach.
If you are still interested I could dig out the details.
IF you want your driver to play with gstreamer etc. a separate audio device generally is what is expected.
Most of the cheap v4l2 capture card's audio is only an analog pass through with a volume control requiring a jumper to capture the audio via the sound card's line input.

Resources