Showing posts with label sound driver. Show all posts
Showing posts with label sound driver. Show all posts

Monday, September 2, 2013

Editing ID3 tags from command line using Python.

You can build a Python module from scratch just to edit ID3 tags, but there is no need to reinvent the wheel since there are many modules ready for this job.I have been using http://id3-py.sourceforge.net which is very straightforward , anyway, here is a little How-to
* Download the module and extract it to any directory you like
* Navigate to the directory where you extracted the module to
cd /ID3/id3-py-1.2
*Install the module
sudo python setup.py install
* If there is no errors , you are ready to go.
download this python script created by the same author ,
http://id3-py.sourceforge.net/ID3/id3-tagger.py
make it executable
chmod  a+x id3-tagger.py
 , you can copy the file to the home directory for an easier access
we are almost done,
here is an example on how to use the file
find ./ -d 1 -name '*.mp3' -exec ~/id3-tagger.py -A 'soundcloud' {} \;

this command will search for any mp3 file in the directory [not recursively] , then will modify the Album tag to soundcloud , you can modify/add different tags to the command as you wish.

Thursday, April 11, 2013

How make usb-headset as default sound card in Arch Linux

last week I installed ArchBang as replacement to ubuntu ,the installation process went smoothly since all partitions were already set-up, I like it so far , it's more challenging and the learning-curve for me has been great, it requires much more tweaking but in the end , you are in control of every bit of your system. I had few problems though, one of them was cofiguring ALSA sound drivers to take USB-Headset as default card for sound playback, it's possible to choose the audio driver in Smplayer and VLC but not all apps offer this feature and best solution is to edit system-wide setting to take the usb-headset as default.
this is the source I used (if you are into reading  +1000 word guide =) ).
here what i did:
I created a sh script  to generate .asoundrc file with usb-headset as default device
 nano asoundrc.sh  
 paste the following code
 % cat /usr/bin/asoundrc  
 #!/bin/bash  
 # asoundrc v0.1.0 20090101 markc@renta.net GPLv3  
 # asoundrc v0.2.0 20090320 quatro_por_quatro@yahoo.es GPLv3  
 #  
 # A simple script to create a particular default audio device regardless  
 # of what cards are loaded or in what order. It could be used anytime or  
 # placed in a ~/.bashrc script for a persistent setup every login.  
 #  
 # Usage: asoundrc [DEFAULT_CARD] > ~/.asoundrc  
 # use the first parameter as the card name, or else  
 # look for the sound card, discarding those that are only microphones  
 # when there are multiple cards, use the first one  
 if default_card="${1:-$(cat "$(for f in $(ls -1 /proc/asound/card[0-9]*/{midi,codec}* 2>/dev/null); do echo "${f%/*}"; done \  
 | sed -e '\|^[\[:blank:]\]$|d' -e 'q')/id" 2>/dev/null)}"; then  
   echo "Using sound card: ${default_card}" >&2   
   cat /proc/asound/card[0-9]*/id | \  
   gawk --assign default_card="${default_card}" \  
 '{print "pcm."$1" { type hw; card "$1"; }\nctl."$1" { type hw; card "$1"; }" }  
 END {print "pcm.!default pcm."default_card"\nctl.!default ctl."default_card}'  
 else  
   echo "Warning: No sound cards found." >&2  
 fi 
 
 chmod a+x asounrc.sh  
execute the script

here is the output in my case


Using sound card: Intel
pcm.Intel { type hw; card Intel; }
ctl.Intel { type hw; card Intel; }
pcm.CinemaTM { type hw; card CinemaTM; }
ctl.CinemaTM { type hw; card CinemaTM; }
pcm.Headset { type hw; card Headset; }
ctl.Headset { type hw; card Headset; }
pcm.!default pcm.Intel
ctl.!default ctl.Intel
as you can tell, the default card  is Intel (last two lines) , all we need to replace intel with Headset ,copy the text
now create .asoundrc file in your home folder , paste the code , log out then log-in , to see the changes

 #create .asoundrc file in your home folder  
 sudo nano ~/.asoundrc  
 #paste the code and save your work  
 pcm.Intel { type hw; card Intel; }  
 ctl.Intel { type hw; card Intel; }  
 pcm.CinemaTM { type hw; card CinemaTM; }  
 ctl.CinemaTM { type hw; card CinemaTM; }  
 pcm.Headset { type hw; card Headset; }  
 ctl.Headset { type hw; card Headset; }  
 pcm.!default pcm.Headset  
 ctl.!default ctl.Headset  

there are may be other ways to do the same thing but this one sounds simple and did the job for me.