Friday, October 15, 2010

One Plump Spider

Garden Orb Weaver
A Garden Orb Weaver spider (Araneus diadematus) basking in the fall sun.

Thursday, October 14, 2010

PowerShell GCI (Get-ChildItem) LiteralPath Issue

Test Music Directory for Powershell Scripts
After finishing ripping our CD collection to FLAC format (link) we wrote some PowerShell scripts to analyze the directory hierarchy that the FLAC (*.flac) files reside in. The hierarchy is something like this \\server\music\artist\album\track.flac where “artist”, “album”, and “track” change according the CD and track ripped. Starting at the top of the node \\server\music the scripts generate the following stats:

1. Number of album folders that do not have music (at least one .flac files). This can indicate that something went wrong and needs to be checked.

2. Number of artist folders that have no album folders in them. For housekeeping reasons it’s not necessary to have empty folders hanging around.

3. Number of .flac files that are less than 500 kb. This can indicate a potential problem with the ripping process. Some .flac files can be that small such as hidden files or silent tracks.

In the course of ripping CDs the following situation for 2+ disc collection can occur:

\\server\music\artistBlah\albumBlah [Disc 1]
\\server\music\artistBlah\albumBlah [Disc 2]

where the “[Disc 1]” and “[Disc 2]” are part of the folder name.

So we have our directory structure defined, what are the basics of the PowerShell scripts? They are .ps1 files that run at a PowerShell command prompt. The key command used in the scripts is the Get-ChildItem cmdlet, or commonly typed as just gci. The gci cmdlet operates like a directory listing. The gci cmdlet has several switches that help refine what you want to have returned like only files with certain file extensions (*.flac). The scripts work by first invoking a gci (with appropriate switches) at the root directory (\\server\music), capturing that into an array, and then iterating through that array and checking each array entry for specific criteria. The problem we ran into is that some switches of the gci cmdlet did not work well with the use of brackets “[“ and “]” in the folder name.

To make the problem we encountered more concrete, let’s suppose we have the following directory structure:

..\artist1\album1 [disc 1]
..\artist1\album1 [disc 2]

In a PowerShell command window if you invoke the following command:
gci -path ("\\server\music\artist1\album1 [disc 1]") -recurse -include *.flac

The result is that nothing is found when we are expecting that is should return the file.flac.

Similarly, if you invoke the following command:
gci -path ("\\server\music\artist1\album2") -recurse -include *.flac

The result returns file.flac as expected.

The problem with the first command is the use of brackets in the first path (folder name) which are perfectly legal to use in folder names but PowerShell interprets these as range operators as discussed in this TechNet Tip. To get around the problem of having PowerShell interpret the range character we can use the -literalpath switch of the gci cmdlet.

So invoking this command:
gci -literalpath ("\\server\music\artist1\album 1 [disc 1]")

Returns file.flac as expected. The problem of using –literalpath intead of –path is that the –include switch seems to be ignored so we can’t refine what we are looking for. One workaround for this – and the point of this post – is that you have to then iterate through the items in each album folder. The following code snippet shows a workaround that will work:

$assetList = gci -literalpath ("C:\temp\music\artist1\album 1 [disc 1]")
if ($assetList -ne $null)
foreach ($item in $assetList )
$n = $item.Name.ToLower();
if ($n.EndsWith(".flac"))
#Do something to indicate a match was found.

For more information on this problem see this TechNet Tip and this forum post. Here’s a simple PowerShell script for iterating through a two level directory structure looking for *.flac files.

# usage : .\findDirectoriesWithNoMusic.ps1 "root"
# example: .\findDirectoriesWithNoMusic.ps1 "\\server\music"
# output : report.txt

$arg = $args[0]
if ($arg.Length -lt 1)
write-host "****************************************************
No root directory specified...
usage: $output = .\findDirectoriesWithNoMusic.ps1 root

Write-Progress "Getting directory information" -status "This could take several minutes for a large number of directories."
$list = gci -path ($arg) -recurse -exclude *.* # the first use of GCI

$output = "Report of directories with no music `n"

for ($i=0; $i -le $list.Length - 1; $i++)
if ($list[$i].Parent.FullName -ne $arg)
$albumPath = ($list[$i].Parent.Name + "\" + $list[$i].Name).ToLower()
$assetList = gci -literalpath ($arg + "\" + $albumPath) # the second use of GCI because we can't be sure if brackets [] exist in the $albumPath
$flag = 0;
if ($assetList -ne $null)
foreach ($item in $assetList )
$n = $item.Name.ToLower();
if ($n.EndsWith(".flac") -or $n.EndsWith(".mp3") -or $n.EndsWith(".wma") -or $n.EndsWith(".mp4") -or $n.EndsWith(".wav") -or $n.EndsWith(".m4a"))
$flag = 1;
if ($flag -eq 0) { $output += "rmdir " + "`"" + $albumPath + "`" /s /q" + "`n" }
Write-Progress "Creating report ... " -status "% Complete" -percentcomplete (100*($i/$list.Length))

$output out-file report.txt

Wednesday, October 13, 2010

FLAC Project Finish

FLAC Progress
In a previous post, The Year of the FLAC, we kicked off our home audio CD digitization project. We finished the project on October 1st. First we’ll present some of the parameters of the project, followed by some tactical suggestions if you are considering such a project, and finally some thoughts on the project in general.

Project Parameters

- Number of CDs ripped: 2228. Each CD was read (physically put into a computer disk drive) at least once or more in the case of problem CDs. The 2228 albums were for 1247 artists. The FLACs are stored in the typical folder hierarchy of artists\album.

- Bad CDs: 6 CDs had some bad tracks and 3 CDs were not FLAC’able at all.
- Software: We used dBpoweramp to rip CDs and encode into FLAC.

- OS: Windows 7 on a desktop computer that had two DVD drives which could be operated simultaneously. When using both drives it seemed best to stagger the use of the drives by letting one drive rip while getting the metadata and preparing for the rip on the other drive.

- Size: 643 GB for all the resulting FLAC files (includes imagery which is minor). We calculate roughly a 33% reduction in disk space used compared to the normal audio format (uncompressed PCM raw).

An example of creating a simple PowerShell script for checking for empty music folders after ripping is shown here.

Tactical Suggestions If You Are Thinking About Approaching a Similar Project

- You need a good system of organization when processing this many CDs (or anything for that matter). We used different locations and bins to indicate CDs waiting to be processed and CDs finished. Sticky notes were used freely to leave notes on different CDs because in our effort there were two of us working at any given time.

- You might need to clean a CD in order to get it to read properly. If one drive doesn’t work, try another. We had a couple of cases in which one drive was able to read a CD that another couldn't.

- While Dbpoweramp is pretty good at supplying metadata (it draws from several metadata sources), you should still verify it.

- Spot check rips after completing. There are a couple of cases when a custom post-project PowerShell script that we ran found problems with some tracks. In a nutshell any FLAC file that is less than 500kb is considered suspect as potentially incomplete and we did find some CDs where we thought the CD ripped fine, but didn’t. These infrequent problems are accounted for in the Bad CDs number above.

- If you care about the quality of artwork, the metadata that comes through when using Dbpoweramp may disappoint you, but you can substitute your own. The maximum image size pixel size accepted seems to be about 500 x 500 so anything bigger is scaled to that.

Thoughts on Digitizing a Moderate-Sized Home CD Collection

There is a lot of music we purchased that probably wasn't worth the effort to rip. We will probably never listen to that music and it's perhaps not worth even cluttering, both space-wise and information-wise, our home system. We estimate that about 10-20% of the final music count (2,228) CDs is what we care about. Now with services where you can listen to almost anything you want on demand, we will not being buying CDs in the same way. Yes, we will purchase some, just not as many as we have in the past.

The medium is (part of) the message. A format that you experience music in is important to your connection to it. Part of the angst in the project was letting go of CDs and embracing digital collections like auto-generated playlists (Pandora), music on-demand services (Rhapsody), etc. The Sonos system makes this easy. We get locked into media choices and it becomes hard to change the longer you wait. It seemed inevitable that we took this step. We went through similar pain with a cassette conversion project.

For this project we opened boxes of CDs dated April 2005, when they got packed for our remodel. Wow, not opening a box in 5 years must mean we don’t need or a least we don’t use what’s inside, right? I think the music in those boxes has a greater chance of being used now that it is digitized and easily accessible via Sonos.

Tuesday, October 12, 2010

The Italians: A Full Length Portrait Featuring Their Manners and Morals

The Italians: A Full Length Portrait Featuring Their Manners and Morals (1964) is a book by Luigi Barzini (1908 - 1984). Barzini was an Italian journalist and author who worked in American for several years and also wrote Americans are Alone in the World (1953). There are two notions you may have about this book that will quickly be dispelled once you get a little way into The Italians. The first notion is that The Italians is a flattering portrait of Italians. It isn’t and in fact, at times it is quite cynical. The second notion is that this is just a portrait about manners and morals. Again it isn't because there is a historical component to the book.

There are two underlying questions that Barzini has in mind throughout the book. He mentions them in the Forward and again in the Conclusion. They are this: “Why did Italy, a land notoriously teeming with vigorous, wide-awake and intelligent people, always behave so feebly? Why was she invaded, ravaged, sacked, humiliated in every century, and yet failed to do the simple things necessary to defend herself?” These are bold questions to ask about one’s country. In working his way to an answer, Barzini alternates between chapters about observations and generalizations on different aspects of Italy, such the eternal charm of Italy or the importance of spectacle in Italy, and historical-themed chapters, such as rise and fall of Cola di Rienzo, Mussolini, and the Battle of Fornovo. I found the history chapters the most successful and as they lent the most weight to the book, including Chapter 7: Cola di Rienzo and the Obsession of Atiquity, Chapter 8: Mussolini or the Limitations of Showmanship, Chapter 9: Realism and Guicciardini, Chapter 15: Fornovo and After, and Chapter 16: The Perennial Baroque.

So how does Barzini answer the questions he raises? He bases his answer around unity or lack thereof. Feeble behavior and invasions occurred because Italy wasn't unified. Barzini writes that even during the days of Imperial Rome, Italy remained a mosaic of different administrative entities. Any unification attempts in subsequent centuries from the outside were usually short lived. Barzini writes: “The Italians felt much too old and wise to become imitation northerners.” Italians were already unified by their past greatness. Finally, the church as a possible unifying force was a sometime ally and sometime foe and was kept in check so that it never could be the unifier. In fact, Italy was not unified until 1861, and tenuously at that, as only a small percentage of the population supported it initially. So if Italy unified earlier than she did, she might have behaved less-feebly and defended herself more ably? An intriguing idea, but certainly not a given.

In Chapter 7: Cola di Rienzo or the Obsession of Antiquity, Barzini discusses the rise and fall of Cola di Rienzo (1313 – 1354), an Italian politician and tribune of Rome who broached the question of Italian unification; he tried but did not succeed. A chronicler during his last days said ‘This man has lighted a fire he will not be able to put out.’ Barzini continues: “(The chronicler drove the point home with an earthy proverb, which cannot be printed here in English: ‘Che vale petere e poi culo stringere? Faticasi le natiche.’)” The proverb can be roughly translated as “Why fart and then close your ass? It only tires the cheeks.”

There are many interesting historical characters and events that Barzini weaves into the narrative, and this book is well worth reading if just for that. Chapter 16: The Perennial Baroque, in particular, is a stand out. The Baroque is a historic period from the 16th century to the 18th century which encompasses a characteristic style of art, architecture, and music. Baroque style has tendencies toward being overly ornate, needlessly complicated, and excessively emotive in composition, what you might describe as over-the-top. In that context, Barzini posits that “elements of Baroque life, oppression, tedium, and revolt, were stronger in Italy than anywhere else” and hence Italians took to Baroque quite nicely. In fact, Barzini claims that Italians are still living in a Baroque reality - at least as of the late 1950s and early 1960s when Barzini wrote the book. Of the Baroque period, Benedetto Croce (1866 – 1952) wrote and Barzini re-quotes: “Italy, who had given birth to apostles and martyrs in earlier centuries, and would beget more later, during the Risorgimento, did not produce any in the Baroque age, because such men cannot exist when there is lazy tranquility and resignation in the spirit.” That the idea of a strong creative energy channeled into narrow, acceptable expressions would ultimately lead to a sterile period is interesting.

While I find much of what Barzini writes interesting, I also take it with a grain of salt. To read it as if the author intends to be provocative might help. Whether Barzini intends this, I do not know. In my collective time in Italy and studying Italy and Italian culture, I can see elements of truth in The Italians, but ultimately I believe people, and the Italians included, are more complex and nuanced to accept all of what Barzini says.

The Terra-Cotta Dog (Il Cane di Terracotta)

The Terracotta Dog
The Terra-Cotta Dog (2003) is the second in the Inspector Montalbano Mystery series by Andrea Camilleri (1925 - ). Il Cane di Terracotta (1996) is the Italian title. The events unfold around the fictional town of Vigàta in Sicily in the fictional province of Montelusa. Salvo Montalbano, a police inspector (commissario di polizia), investigates a few contemporary crimes and one fifty-year old crime. It is the latter that occupies Montalbano for the bulk of the book. The inspector is obsessed with reconstructing the last days of two young lovers during 1943, the year of the Allied landing in Sicily. The titular terra-cotta dog guards the couple in their death. As the circumstances of their death are unraveled by Montalbano we learn that the seven sleepers story is involved.

The Terra-Cotta Dog follows the pattern of a quick moving plot line, lucky breaks, and a tough but lovable detective who may stretch the truth from time to time to make sure justice ultimately prevails. Montalbano occupies himself with understanding the truth of an event or action even when his colleagues and friends have moved on. In The Terra-Cotta Dog Montalbano works to put his mind at rest as to what happened to the two young lovers; current investigations almost bore him. In The Shape of Water Montalbano does much the same in that he does not accept what looked like a stock answer to a death.

In the course of Montalbano stewing over the two deaths, he eats his way to temporary relief thanks to his favorite restaurant Trattoria San Calogero, his housekeeper Adelina, and his friends. Here are a few of the food references Camilleri manages to work into the story:

· mostaccioli (mostazzoli) - a cookie based on almonds
· passaluna olives - a type of the Ogliarola
· càlia e simenza - a mix of roasted chickpeas and pumpkin seeds
· tabsica - an oval-shaped pizza
· pasta ‘ncasciata - a baked macaroni dish with beef, cheese and béchamel
· petrafèrnula - a type of cake based on honey, orange, and citron rinds
· mèusa – calf’s spleen (or lamb?) sliced into thin strips and cooked in fat
· pasta con le sarde - classic Sicilian dish served usually with bucatini and a sauce of fresh sardines, tops of wild fennel, pine nuts, raisins, garlic and saffron
· purpi alla carrettera - octopus served in a sauce of olive oil, lemon, and hot pepper

There is a web site, Le ricette di Montalbano, that gives recipes for food items described in the book. Buon appetito!

The image shown below is the Italian version front cover. In copertina: Ammaestractrice di cani di Antonio Donghi. Collezione del Banco di Roma, Roma.
Il cane di terracotta

Monday, October 11, 2010

LA Fitness Spin + Yoga Playlists

My unofficial Ballard spin - yoga playlist that sonically sums up for us one and a half years of a double feature of spin followed by yoga every Monday, Wednesday, and Friday is below (culled to just 20 entries – it was hard). It spans several spin instructors and one yoga instructor. These aren’t necessarily my favorite songs but the most evocative of my LA Fitness experience besides the occasional club announcement: “what gets measured gets improved!”.

- Nickelback, All the Rights Reasons, “Rockstar” (1995)
- Rhianna, Music of the Sun, “Pon de Replay” (2005)
- Gwen Stefani, The Sweet Escape, “Wind It Up” (2006)
- Wolfmother, Wolfmother, "Joker and the Thief" (2006)
- Scissor Sisters, Ta-Dah, “I Don’t Feel Like Dancin’” (2006)
- Usher, Raymond v. Raymond, “OMG” (2010)
- The Black Eyed Peas, The E.N.D., “I Gotta Feeling” (2009)
- Gnarls Barkley, The Odd Couple, “Going On” (2008)
- Madonna, I’m Breathless, “Vogue” (1990)
- Kevin Rudolf, In the City, “Let It Rock” (2008)

- Cake, Comfort Eagle, “Short Skirt, Long Jacket” (2001)
- Who, Who’s Next, “Won’t get Fooled Again” (1971)
- No Doubt, Tragic Kingdom, “Just a Girl” (1995)
- U2, How to Dismantle an Atomic Bomb, “Vertigo” (2004)
- Tina Turner, Private Dancer, “Better Be Good To Me” (1984)
- OneRepublic, Waking Up, "All the Right Moves" (2009)
- Billy Bragg and Wilco, Mermaid Avenue, "California Stars" (1998)
- MC Yogi, Elephant Power, “Ganesh is Fresh (feat. Jai Uttal)” (2008)
- Kelly McGuire, Boat in Belize, "Island State of Mind" (2007)
- Pink, Funhouse,“Glitter in the Air” (2008)

Thursday, October 7, 2010

Spin Etiquette

We have gone to the morning spin class at LA Fitness in Ballard for about a one year and a half now. Here are some rules which would be nice if fellow spinners and those who use the spin room followed:

1. Don’t drag a bike to some corner and then leave it there. It’s interpreted as out of order and generally causes confusion. This most often happens when someone comes in when the class is not in progress (most of the day) and drags a bike to look out a window, for example, out of the normal “formation” and never puts it back.

2. Don’t leave a dirty towel or any towel on the bike unless you intend to indicate you are reserving the bike for an upcoming class. Again, this usually happens when people during non-class hours get lazy and leave a towel on the bike which is later interpreted as “reserved” by people arriving for the next class.

3. Don’t aim the fan toward the two bikes at the side of the room; it's intended to cool the other 25+ riders. (The room is set up so that two bikes are off to the instructor’s left.)

4. If you are leaving early don’t sit in the front row. It’s annoying and disruptive.

5. Don’t be possessive about bikes. People become so fixated on getting their favorite bike or position that behavior begins to get strange. Be adventurous and try different bikes and positions in the room.

6. Don’t talk at length while the spin class is in progress. A couple of words or sentences, fine. Extended conversations, no.

7. Check your biking shorts for holes and rips. It’s not all that interesting to be behind some unintended skin exposure, especially during the hovers.

8. If you ate a whole bunch of garlic the night before, chances are the class hasn’t and will be suffering.

9. Smile more.

Happy spinning ;-)