Showing posts with label audio. Show all posts
Showing posts with label audio. Show all posts

Nov 1, 2013

Debian: Sound issue

I had a bit of an issue with ALSA and Debian in regards to my sound device not being detected properly. This meant I had to dig around a bit to get it up and running.

Note that with this method may not work nicely with multiple sound cards. Your mileage may vary....

Problem:

Running the command alsamixer in a terminal returned this error message:
cannot load mixer controls: Invalid argument
Trying to restart the ALSA server got me this:
root@localhost:~# /etc/init.d/alsa-utils stop
[....] Shutting down ALSA...warning: 'alsactl store' failed with error message 'alsactl: get_control:250: Cannot read control info '2,0,0,Front Playback Volume,0': In[FAIL argument'...failed.
So there was something wrong with the system configuration or the control.

For reference, this is what my system has configured:

root@localhost:~# head -n 1 /proc/asound/card0/codec*
==> /proc/asound/card0/codec#2 <==
Codec: Realtek ALC887-VD

==> /proc/asound/card0/codec#3 <==
Codec: Intel PantherPoint HDMI
 root@caesar:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC887-VD Analog [ALC887-VD Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC887-VD Digital [ALC887-VD Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Explanation of these commands (skip if you want to get to the solution)

The first command reads out the first line (head -n1) of each of the files that match the search pattern (/proc/asound/card0/codec*). This matches two files (codec#2 and codec#3). The /proc/ filesystem is where Linux stores all the files necessary for running the operating system, including detected hardware devices. The first file tells us that the system recognizes the motherboard sound card, and the second files recognizes the HDMI output.

The second command confirms our suspicions, and also let's us know that ALSA detects these devices too (the Realtek and the HDMI devices are found and configured).

Now we know that the problem lies in the ALSA configuration, because everything is detected at this stage.

Solution:
  1.  Run the following command and look for your audio device:

    lspci -v
  2. The above step is important because you need to find the line 'Kernel driver in use' associated with your Audio controller (which is outputted by the above line). In my case the kernel was using snd_hda_intel.
  3. Now we need to check to ensure the driver is installed. A simple way is to start off writing (DO NOT PRESS ENTER YET!) modprobe snd and then tab complete it (press the <TAB> key twice). This should bring up a list of sound drivers your system knows about. If your driver is not listed you should try to find and install it.
  4. Edit /etc/modprobe.d/alsa_base.conf and add the following line (you may need to adjust this to suit your system):
    options snd-hda-intel model=generic
  5. Now we need to force ALSA to load the new configuration:
    alsa force-reload
  6. If you can hear sound after running the following command, congratulations!
    aplay /usr/share/sounds/alsa/Front_Center.wav

References: 

Jul 7, 2012

Make your own TRS (headphone) to RCA audio cable

I like to re-use old equipment whenever possible. Mostly because it gives me the opportunity to hack away at it until it suits my needs. This is one such case....

Most portable media players come with a 3.5mm TRS audio jack socket that is intended to play stereo sound on a sound system or headphones. Which is great, except I had an old surround sound system that only used RCA connections...

The TSR socket is the image on the left. The RSA sockets are on the right.
Let's get into the technical differences between each of these connection types:

  • The TSR cable can carry both channels of a stereo signal (the left and right channels). It can also be 'balanced', which is just a fancy way of saying that it is protected from external noise. All of these properties are possible because of the unique configuration of the plug, which is segmented into a Tip, Ring and a Sleeve (if you have been paying attention, that's where the TRS acronym originated).
    Cut away view of a TSR jack plug showing the Tip, Ring and Sleeve.
    For portable media players the TSR connection is unbalanced, with the Left channel transmitted through the Tip and the Right channel transmitted through the Ring. The Sleeve is used as a common ground for both channels.
  • RCA connections can only carry one signal and are always unbalanced.
Now we know the rough anatomy of the connectors we can now hack our own cable! For this guide, we will need one (1) TSR plug and two (2) RCA plugs. This is because the TSR will carry two channels, which we will distribute over the two RCA connectors (each RCA plug can only carry one channel).

  1. Chop off one end of the TSR cable. You can discard the other end (or keep it for later...). Strip and and solder the end.
    I just opened up my extra plug so I could see inside it (as well as know which channel is which)
  2. Chop off two RCA plugs, leaving just enough wire so that we can strip it for our connection. Strip and and solder the end.
  3. You should now have the following:
    From Left-to-Right: The stripped end of the TSR plug (you should see three wires); The TSR plug; The stripped end of the RCA plug; The RCA plug
  4. Connect the signal wire of each RCA plug to a TSR signal channel. For instance, one RCA signal wire will be connected to the TSR Tip wire for the left channel. The other RCA signal wire will be connected to the TSR Ring wire for the right channel.

    Both RCA ground wires are to be connected to the TSR sleeve wire. YOU SHOULD TEST BEFORE SOLDERING!
    Testing the set-up...
  5. Once you have tested it all out, solder the connections and viola! You now have a TSR-to-RCA cable!

Hope this helps someone out there!!!

References: