Friday, April 27, 2012

Bandit Died

Last night Bandit, one of BB's pugs, died.  He'd had a surgery earlier in the day to remove bladder stones.  The procedure went well and we brought him home.  He was resting quietly and at some point passed.

As dogs go, pugs are particularly affectionate and companionable.  Bandit was no exception.  Indeed, of the many dogs I've known he was one of the most engaging.  Bandit was likely the runt of the litter.  His tong habitually hung out the right side of his mouth and he was unable to move it to the left.  When our house burned down, Bandit was seared and lost the fur on several spots.  Still he was always a happy camper, full of himself, and glad of everything.  He will be missed.



Anyone who has dogs knows, of course, that they will almost certainly outlive their pets.  Still when you loose a pet it is a great sadness.

Wednesday, April 25, 2012

Laptop v. wireless mouse


Technology is determinant but often still rather unexpected and just plain strange.  Case in point my Sony Vaio VGN-FW370J laptop and Logitech 305 wireless mouse.  I rather like the laptop and the mouse.  When I bought the mouse I plugged in the USB xmit/rcv and presto all was well.  Indeed, things worked so well that I bought a second Logitech mouse for the TV computer!  Many months later the laptop mouse quit working!  Bummer!  Other USB devices worked OK, but not the mouse.

What to do?  A bit of investigation, not enough as it turned out, suggested it was the USB xmit/rcv so I bought a replacement.  No joy!  Still surprisingly other USB devices seemed to work.  Tried the Logitech USB mouse from the TV computer that I knew worked fine.  No joy.  So I did a bit of web searching and found this post.

So I unplugged the laptop and removed the battery, waited a bit, replaced the battery, rebooted, reconnected the Logitech 305 wireless mouse and presto, all is now well.

Clearly technology can be unexpected and just plain strange.

Friday, April 6, 2012

WAV to MP3 for Sandisk Clip+

BB was able to listen to the audio CD riped from WAV to MP3 successfully.  However, the process of ripping is a bit involved

  • copy the WAV to disk & rename with author, title, disk, and track
  • convert to MP3 with lame
  • set MP3 tags with easytag
So I've improved the python script to do all these things.  Here's the current version:
# audiobookcopy.py
# copy multiple CDs in an audio book
# cd appears to automount at ls .gvfs/cdda\ mount\ on\ sr0/
#
# Output file name format that should work well with various players
# Author/Title/CD??-Track??
#
# for info on ripping see http://www.chuckegg.com/quickly-convert-audiobook-cds-to-mp3-files-audio-book-mp3/
# for info on easytag see http://easytag.sourceforge.net/EasyTAG_Documentation.html#ch_1_2_4
import sys
import os
import shutil
from subprocess import call
dir = "/home/rbell01824/.gvfs/cdda mount on sr0"
def ensure_dir(f):
    if not os.path.exists(f):
        os.makedirs(f)
def cacd( author, title, fnbase, cd ):
    print "Processing CD ", cd
    files = os.listdir( dir )
    ifn = 1
    for fn in files:
        src = dir+"/"+fn
        dstdir = author+'/'+title
        fn, fx = os.path.splitext( src )
        #print "Source:", src
        #print "Dest Dir:", dstdir
        #print "FN:", fn
        #print "FX:", fx
        if fx == '.wav' or fx == '.mp3':
            # lame -h -b 192 --tt title --ta artist --tl album --tn track --tg genre source destination.mp3
            idtitle = fnbase+'-%02d'%cd+'-%02d'%ifn
            dst = author+'/'+title+'/'+fnbase+'-%02d'%cd+'-%02d.mp3'%ifn
            #print "Dest:", dst
            cmd = 'lame -h -b 192 --tg Audiobook --tt "%s"' % idtitle
            cmd = cmd + ' --ta "%s"' % author
            cmd = cmd + ' --tl "%s"' % title
            cmd = cmd + ' --tn "%d%02d"' % (cd, ifn)
            cmd = cmd + ' "%s" "%s"' % (src, dst)
            print "lame: %s"%cmd
            return_code = call( cmd, shell=True)
        else:
            dst = author+'/'+title+'/'+fnbase+'-%02d'%cd+'-%02d'%ifn+'.%s'%fx
            print "Dest:", dst
            shutil.copy2( src, dst )
        ifn += 1
    return
def abc():
    if (len(sys.argv) < 3 ):
        print "audiobookcopy author title base_file_name start_CD"
        exit(1)
    print sys.argv[1:]
    author = sys.argv[1]
    title = sys.argv[2]
    fnbase = sys.argv[3]
    ensure_dir( author )
    ensure_dir( author+'/'+title )
    cd = int(sys.argv[4])
    print "start with disk "+str(cd)
    while cd <= 200:
        kbi = raw_input( "Mount CD "+str(cd)+" Press enter:\a" )
        cacd( author, title, fnbase, cd )
        cd += 1
if __name__ == '__main__':
    try:
        __file__
    except:
        sys.argv = [sys.argv[0], 3]
    abc()
Along the way I reorganized the directory structure to / but left the individual files as < code>.

I also found a utility app with a GUI interface, Audio CD Extractor.  It doesn't do as nice a job of naming but otherwise seems OK.

Tuesday, April 3, 2012

Sandisk Clip+ Fun and Games

BB has been listening to audio books on CD from the library while exercising.  Dealing with the CDs is a bit of a pain while exercising so I've been ripping them to an SD card so she can listen to them using a small player.

She had been using an old Pandigital Android tablet.  It works but is a bit over large.  BB wanted a smaller player that could be clipped to her cloths as she exercises.  After a bit of research she bought a Sandisk Clip+.

I copied a book on CDs to a micro SD card and checked to see that it would play.  Everything looked OK but when BB played it the Clip+ died after a few minutes.  I was a bit surprised since the device was only a day old, but OK, electronics do bread, bit of bad luck, etc.  I exchanged the original device for a new one.  BB tried again with identical results!  A second broken device seemed rather unlikely so I decided to look into the problem.

A bit of google search found that the device can be reset by holding the power button down for 20 seconds.  Doing so restored the Clip.  Unfortunately when I played the book, the Clip+ froze and appeared dead after 5 minutes and 30 seconds.  Another reset, another test play and another freeze!

I loaded a different book, this time a set of MP3 files (the original book was WAV files).  The MP3 book played without issue.  So it looks like WAV support on the Clip+ is a bit dodgy.

It's not much of a chore to convert WAV files to MP3s.  I used this small script that I got from the net.

#!/bin/sh
# name of this script: wav2mp3.sh
# wav to mp3
for i in *.wav; do
 if [ -e "$i" ]; then
   file=`basename "$i" .wav`
   lame -h -b 192 "$i" "$file.mp3"
 fi
done

It took a bit to convert all the files in the book.  I reloaded the book now as a set of MP3s on the Clip+ and it now plays OK.

There was a bit more cleanup to do since the Clip+ uses MP3 tags to organize the files it plays.  Enter easytag.  I used it to set the MP3 tags based on the file name (fortunately it contained the autor, title, CD, and track as part of the name).  Easytag has a facility to batch set the MP3 tags.  I set tags as follows:

  • Album to book title
  • Artist to book author
  • Title to CD##Track##
  • CD to CD
  • Track to track

With that done the book is nicely compatible with the Clip+.

To make things a bit easier going forward I modified the python ap I used to rip the CDs to use a better name convention.

# audiobookcopy.py
# copy multiple CDs in an audio book
# cd appears to automount at ls .gvfs/cdda\ mount\ on\ sr0/
#
# Output file name format that should work well with various players
# Author/Title/CD??-Track??
#
# for info on ripping see http://www.chuckegg.com/quickly-convert-audiobook-cds-to-mp3-files-audio-book-mp3/
# for info on easytag see http://easytag.sourceforge.net/EasyTAG_Documentation.html#ch_1_2_4
import sys
import os
import shutil
dir = "/home/rbell01824/.gvfs/cdda mount on sr0"
def ensure_dir(f):
    if not os.path.exists(f):
        os.makedirs(f)
def cacd( author, title, cd ):
    print "Processing CD ", cd
    files = os.listdir( dir )
    ifn = 1
    for fn in files:
        src = dir+"/"+fn
        dst = author+'/'+title+'/'+'%02d'%cd+'-%02d.wav'%ifn
        print "Copy ", fn, " to ", dst
        shutil.copy2( src, dst )
        ifn += 1
    return
def abc():
    if (len(sys.argv) < 3 ):
        print "audiobookcopy author title start_CD"
        print 'audiobookcopy RJB "life Notes" 1'
        exit(1)
    print sys.argv[1:]
    author = sys.argv[1]
    title = sys.argv[2]
    ensure_dir( author )
    ensure_dir( author+'/'+title )
    cd = int(sys.argv[3])
    print "start with disk "+str(cd)
    while cd <= 200:
        kbi = raw_input( "Mount CD "+str(cd)+" Press enter:\a" )
        cacd( author, title, cd )
        cd += 1
if __name__ == '__main__':
    try:
        __file__
    except:
        sys.argv = [sys.argv[0], 3]
    abc()

With those changes made it should be easy to load books on the Clip+.  After a bit more use I'll probably update the python ap to convert to MP3 if necessary and to set tags as part of the process so it's not necessary to use multiple tools.