|
|
slmingol posted this in tutorials on August 24th, 2009, @ 3:39 am
Background
I listen to a lot of tech podcasts, and a while back I started not being able to keep up with all of them on a weekly basis. The thought of dropping some of them to make room wasn’t really an option. So I started fast forwarding through some of the “dead air” in an attempt to speed up their playback. This got old pretty quickly. Being a pretty tech. savvy person, I thought there had to be a programmatic way to solve my dilema. I initially latched on to the idea that a program could remove/compress this “dead air” automatically so that its effect would be minimized. This would in theory condense a 1 hour podcast to something less than an hour. Although my final solution didn’t exactly go this route, there was enough of a kernel of an idea that ultimately led me to a workable solution.
Initial Concept
The biggest irony in my solution? it came while I was listening to a podcast, The Linux Outlaws. I think it was this episode. One of the listeners had either emailed or called in with the crux of the solution that I ultimately utilized to get exactly what I wanted. The key concept that this listener had mentioned was changing the tempo of an audio file. Now I’m no audiophile but I had heard the term tempo before, I just never really put much thought into exactly what it was. This listener claimed that you could increase/decrease the tempo of an audio file but still maintain its listenability. My previous experience with speeding up audio, was taking 45 and 78 RPM records and cranking up the speed dial on my turntable so that they sounded like Alvin and the Chimpmunks, an effect called resampling.
Subsequent googling turned up this Wikipedia article. In a nutshell, tempo is similar to the beats per minute (bpm) in music. So what we’re doing when we manipulate the tempo, is we’re increasing/decreasing the beats per minute, but we’re maintaining the pitch of those beats. The key component in maintaining the original quality of an audio file, is to maintain its pitch. Increasing the pitch is the effect you are hearing when you simply turn up the playback speed, as in the turntable example.
mp3faster
So how do you affect the tempo without messing with the pitch? Several tools can do this. Audacity is one of them. However I wanted to develop a script that would do this, because I ultimately wanted to have my podcatching software, bashpodder, automatically speed up all the MP3 files that it downloads. Some more googling turned up exactly what I was looking for, a page on the gPodder wiki” about time stretching . This wiki page had a script on it called mp3faster that did exactly what I wanted. The centerpiece to this script is a command-line tool called soundstretch, which is part of a suite of tools called SoundTouch. The mp3faster script was originally developed to run on Ubuntu, I’ve since modified it with the following enhancements:
- runs on Redhat Distros (RHEL, Fedora, & CentOS)
- improved method for converting the initial MP3 file to WAV
- improved the copying of the original MP3′s id3 tags over to the new MP3 file
- variablized the tempo so that it can be passed in as a command line arguement
- force the replacement of the original MP3 file with the newly modified version
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| % more mp3faster.bash
#!/bin/bash
# mp3faster - script for making mp3 playback faster with soundstretch
#
# debian/ubuntu package requirements
# apt-get install mpg321 soundstretch lame libid3-3.8.3-dev
#
# rhel/centos/fedora package requirements
# yum install mpg321 soundtouch lame id3lib
#
# sample usage for converting all mp3 files in a directory structure:
# find -name "*.mp3" -print0 | xargs -0 -i mp3faster {}
#
# decode mp3 to wav file
#mpg321 --wav "$1.wav" "$1"
# the above decoding technique doesn't always work, and can sometimes
# create a wav file that plays back too fast. Seems to happen with mp3 files that
# have a low bitrate (< 80kbps). Using the lame alternative below get's around this.
# alternative #1 to decoding an mp3 to wav
lame --decode "$1" "$1.wav"
# alternative #2 to decoding an mp3 to wav
# mpg321 -b 10000 -s -r 44100 $1 | sox -t raw -r 44100 -s -w -c2 - "$1.wav"
# process file with soundstretch
#soundstretch "$1.wav" "$1.fast.wav" -tempo=+65
soundstretch "$1.wav" "$1.fast.wav" -tempo=+$2
# encode mp3 file
lame --preset fast medium "$1.fast.wav" "$1.2.mp3"
# copy id3 tags from old file
id3cp -1 "$1" "$1.2.mp3"
# remove temp files
rm "$1.wav" "$1.fast.wav"
# rename original mp3 file to .bak extension
# mv "$1" "$1.bak"
# rename processed mp3 file to original name
mv -f "$1.2.mp3" "$1" |
Prerequisites
To install the prerequisite software on my CentOS 5 system, I used the following command:
…. Continue reading → Speeding up the Playback of Audio Podcasts »»
slmingol posted this in tutorials on August 20th, 2009, @ 2:31 am
If you’ve followed my blog for a while you’ve probably noticed that I like to automate just about everything. I can’t stand doing anything manual, at least more than once. So of course when I setup a network printer, I like to have the Windows drivers that go along with each printer available automagically over the network. This technique isn’t glaringly obvious so I thought I’d quickly document how I accomplished it.
Background
This technique requires that you already have both Samba & CUPS servers setup and configured. You should also already have the printer whose drivers we’re going to install configured and working through CUPS. You can read how I did this for the MFC-8480DN printer in this previous post.
Getting Started
First things first, you typically want to grab a copy of the Windows drivers for your particular printer. Remember, in this example I’m using the network capable, Brother MFC-8480DN, that I discussed in this previous post. I downloaded the Windows drivers from the Brother’s website here. Here’s a link the specific driver bundle that I used. Brother calls this bundle the “Add Printer Wizard Driver”. I then set them aside, so I could focus on getting the special Samba share, print$, configured. This is a special share where print drivers for all versions of Windows can be staged, for later consumption by Windows client systems that add this printer.
Samba
adding the print$ share
For my setup, which is a CentOS 5 system, I added the following stanza to my /etc/samba/smb.conf file.
1
2
3
4
5
6
7
8
9
| # /etc/samba/smb.conf
[print$]
comment = Printer Driver Download Area
path = /etc/samba/drivers
browseable = yes
guest ok = yes
read only = yes
write list = @samba-printers, root |
NOTE: The unpacked driver files that get added to the print$ share will be stored under /etc/samba/drivers on the Samba server. You can put them really anywhere, but I chose to keep them with the Samba config. files.
samba-printers Linux Group
Next, I created a special Linux group that I arbitrarily called samba-printers. Users in this group, in addition to root, will be the only users that have permission to add Windows drivers to the print$ Samba share. I accomplished this by adding the line below to the /etc/group file on the Samba server.
1
2
3
| # /etc/group file on Samba server
samba-printers:x:1020:root,user1,user2 |
The 2 user accounts, user1 & user2, are both Linux accounts as well as Windows accounts. In my home network I typically create them this way to make things like this simpler. If you happen to user different user accounts on Windows vs. Linux you can map the Windows accounts to Linux accounts through the Samba config. file /etc/samba/smbusers.
creating /etc/samba/drivers
Next, I created the directory /etc/samba/drivers and permissioned it with our newly created Linux group using these commands:
1
2
| mkdir -m ug+rwx,o-w,g+s /etc/samba/drivers
chgrp samba-printers /etc/samba/drivers |
…. Continue reading → Howto Install Windows Print Drivers onto a Central Samba Share »»
slmingol posted this in tutorials on July 26th, 2009, @ 11:31 pm
I recently discovered that you can assign descriptions to your OpenVZ instances. This isn’t really that surprising but I never really took the the time until now to scan through the vzctl and vzlist man pages. Prior to discovering these more esoteric features of vzctl and vzlist, I’d normally just run this command to see what’s what with my OpenVZ instances:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| # list of all VE instances
% vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
101 32 running 10.1.1.101 flanders.mydom.net
102 49 running 10.1.1.102 lisa.mydom.net
103 36 running - bart.mydom.net
104 38 running 10.1.1.104 marge.mydom.net
105 34 running 10.1.1.105 homer.mydom.net
106 31 running 10.1.1.106 kang.mydom.net
107 27 running 10.1.1.107 kodos.mydom.net
108 32 running 10.1.1.108 maude.mydom.net
109 30 running 10.1.1.109 nelson.mydom.net
110 32 running 10.1.1.110 ralphie.mydom.net
111 30 running 10.1.1.111 martin.mydom.net |
This had worked fine, but sometimes I’d draw a blank about what’s running in each instance, hence my need for the description column. You can use the following command to see the description of each instance.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| # initial description columns for VEs
% vzlist -o ctid,numproc,status,ip,hostname,description
CTID NPROC STATUS IP_ADDR HOSTNAME DESCRIPTION
101 34 running 10.1.1.101 flanders.mydom.net -
102 49 running 10.1.1.102 lisa.mydom.net -
103 35 running - bart.mydom.net -
104 38 running 10.1.1.104 marge.mydom.net -
105 34 running 10.1.1.105 homer.mydom.net -
106 31 running 10.1.1.106 kang.mydom.net -
107 27 running 10.1.1.107 kodos.mydom.net -
108 32 running 10.1.1.108 maude.mydom.net -
109 30 running 10.1.1.109 nelson.mydom.net -
110 32 running 10.1.1.110 ralphie.mydom.net -
111 30 running 10.1.1.111 martin.mydom.net - |
I used the following commands to set the description for each VE.
1
2
3
4
5
6
7
8
9
10
11
| vzctl set 101 --description "nis server" --save
vzctl set 102 --description "mail,imap,smtp server" --save
vzctl set 103 --description "samba server" --save
vzctl set 104 --description "mysql server" --save
vzctl set 105 --description "www,blog,webmail server" --save
vzctl set 106 --description "trac,git,svn server" --save
vzctl set 107 --description "trac,git,svn server (dev)" --save
vzctl set 108 --description "ldap server (dev)" --save
vzctl set 109 --description "cacti server" --save
vzctl set 110 --description "tracks server" --save
vzctl set 111 --description "wiki server" --save |
Re-running the vzlist command from before now shows the newly added descriptions.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| # filled out description columns for VEs
% vzlist -o ctid,numproc,status,ip,hostname,description
CTID NPROC STATUS IP_ADDR HOSTNAME DESCRIPTION
101 32 running 10.1.1.101 flanders.mydom.net nis server
102 49 running 10.1.1.102 lisa.mydom.net mail,imap,smtp server
103 36 running - bart.mydom.net samba server
104 38 running 10.1.1.104 marge.mydom.net mysql server
105 34 running 10.1.1.105 homer.mydom.net www,blog,webmail server
106 31 running 10.1.1.106 kang.mydom.net trac,git,svn server
107 27 running 10.1.1.107 kodos.mydom.net trac,git,svn server (dev)
108 32 running 10.1.1.108 maude.mydom.net ldap server (dev)
109 30 running 10.1.1.109 nelson.mydom.net cacti server
110 32 running 10.1.1.110 ralphie.mydom.net tracks server
111 30 running 10.1.1.111 martin.mydom.net wiki server |
slmingol posted this in tutorials on July 24th, 2009, @ 3:23 am
At my day job I’m pretty much trapped all day in front of either a Windows PC Desktop or a Windows PC Laptop shelled into lots and lots of UNIX systems. So I’m forced to use PuTTY for all my shelling and terminal needs. We have roughly 60+ systems that we have to login to on a day to day basis, so maintaining all of this within PuTTY’s little dialog box can be a bit trying. Not to mention having to scroll through the PuTTY window every time I want to login to yet another UNIX system. So here are some tips on how I manage to do all this.
Getting Started
The first thing I usually do, after installing PuTTY, is install an addon to PuTTY called, PuTTY Session Manager
PuTTY Session Manager (PSM) is a tool that allows system administrators to organize their PuTTY sessions into folders and assign hot keys to their favorite sessions. This is designed for MS Windows and requires the .NET 2.0 Run time.
 Session Management Window
Generate a Public/Private Key Pair in PuTTY
Now we’re going to set PSM aside for a minute and we’re going to setup a public/private SSH key pair. This key pair will give PuTTY the ability to login to hosts without having to provide your UNIX password every time, but do it in a manner that doesn’t force you to expose passwords in an unsafe way.
PuTTY’s key management is handled by 2 tools, PuTTYgen & Pageant. PuTTYgen manages the creation and overall management of keys, while Pageant is an SSH authentication agent, that holds your private keys in memory, already decoded, so that you can use them without having to re-type passphrases over and over.
Here is a full list of all of PuTTY’s tools:
 PuTTY Utilities
To start PuTTYgen, launch the executable puttygen.exe, and do the following:
- set the type of key to generate to SSH-2 RSA
- set the number of bits in a generated key to 2048
- click the Generate button
Now you need to move your mouse around within the PuTTYgen dialog box to create a stream of random data that PuTTYgen will use to create a random set of keys. After doing this monkey dance for a bit your dialog should look like this:
…. Continue reading → Power Using PuTTY »»
slmingol posted this in tutorials on July 22nd, 2009, @ 11:24 pm
Description
I recently came across this handy ncurses-based tool called wavemon for monitoring the status of both the wireless networks around my laptop as well as my wireless card. It offers most of the features that you’d find in any equivalent GUI. The impressive thing here is that all these features are made available in a terminal window.
Here’s a quick run down of features:
- overview screen, displaying all important information like device configuration, encryption and power management parameters and network information at once
- adaptive level bargraphs for link quality, signal/noise strength and signal-to-noise ratio
- customizeable “level alarm” feature that notices the user of changes in signal level strength audibly and/or visually
- full-screen level histogram displaying signal/noise levels and SNR
- list of access points in range
- menu-based configuration from within the program
Installation
On my Fedora 10 box wavemon was available from the standard repository. So installation was a snap.
Usage
To run wavemon, simply type wavemon in your terminal.
Screenshots
 wavemon Info Tab
 wavemon Level Histogram
I tend to spend a lot of time in terminal windows so I’m always glad when I find yet another ncurses-based app that gives me the same feature offerings as a heavier GUI.
slmingol posted this in tutorials on June 25th, 2009, @ 10:00 am
Background
About a month ago I purchased a MFC aka. an AIO printer/scanner/copier/fax device which was networkable via ethernet. I chose the Brother MFC-8480DN and I’ve been very pleased with it. It replaced another Brother laser printer, a HL-1440 which I never had a single problem with; but our aging SCSI (yes a SCSI) HP scanner had recently given up the ghost. Rather than buy another single purpose scanner, I thought I could consolidate some space in our home office by buying an All-in-One device.
I’ve been extremely satisfied with our choice, except for the lack of drivers available for scanning under Linux. I wasn’t really overly concerned given this particular device was just released as a new product in Q1/2009. My previous Brother printer, which I had since 2002, was supported under Linux from day 1 and looking at the Brother website, pretty much all of their products are too.
Just to be on the safe side I decided to contact customer support just to see if one of the existing devices could be substituted in for my model number. I quickly received an email in which the customer rep. said it wasn’t currently available, but to check back at their website in about 1-2 months and it would be. So I did tonight (June/2009) and was pleasantly surprised to find that indeed, new drivers were available for my device. So I downloaded the new drivers and installed them into one of my OpenVZ VEs as follows.
Before I get started I just wanted to mention that I’ve really grown to liking OpenVZ and have pretty much converted most of my SOHO infrastructure to using it. It really gives me tremendous flexibility in quickly creating containered instances of OSes so that I can play around with things without trashing any of my existing systems.
Getting Started
For this particular setup I already had a devoted instance of OpenVZ just for CUPS, so I opted to use this VE to setup both the printing and scanning capabilities. NOTE: In this howto, I’m only going to focus on what Brother calls Scanning to a file.
1
2
3
4
5
6
7
8
9
10
11
| # requires sane backend
yum install sane-backends
# install the brother drivers
rpm -ivh --nodeps brscan3-0.2.6-1.i386.rpm
# configure the scanner
brsaneconfig3 -a name=mfc8480dn model=MFC-8480DN ip=192.168.1.14
# setup the server daemon (scans to a file)
brscan-skey-0.2.1-3.i386.rpm |
Scanning to a File
This is where there is a small server daemon (brscan-skey), which is able to talk to the scanner, and receive scanned files as either JPG or PNG files (I think it supports other formats too). You can launch it like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| # brscan-skey's usage
#
% brscan-skey -h
USAGE: brscan-skey [option]
This tool enables you to scan a document by using the
Scan key on the Brother MFC through the network.
no option :register all network MFCs
-t :terminate this tool
-p PASSWD :set the password
-u USERNAME :set the user name
--diagnosis :print diagnosis data
-h :help
# Here I am starting up the server daemon!
#
% brscan-skey |
NOTE: Eventually I’ll want to throw together a start/stop script for brscan-skey and incorporate it into this VE as a full fledged service. For now, every time this system reboots I’ll have to manually start it!
Walkthrough
These files are then stored on the system that is running brscan-skey. When this is working I can basically walk up to the MFC-8480DN, stick a piece of paper on the glass, press the scan button, and have the JPG/PNG file get automatically dumped to my server.
- Initial screen on MFC-8480DN LCD after pressing the Scan button
initial LCD
…. Continue reading → Getting a Brother MFC-8480DN Printer/Scanner/Fax and OpenVZ to Play Nice on CentOS 5 »»
|