Found 12 entries, viewing 1 through 5.
Album Sound Check - The GUI
A while ago you'll recall that I wrote a little Python script that would average out the sound check gain adjustment created by iTunes for a given set of songs.
I've gone a step farther and created a simple GUI tool for doing the same.
Album Sound Check (download link) provides a basic interface to editing this field based on the values in a given set of files.
After running the program go ahead and open a directory containing songs from your iTunes library. They will be scanned in and the gain dB adjustment values stored. ASC will then determine an average from this.
You can choose to not have certain songs affect the resulting average by unchecking the "Use" column. You can choose to not have the computed average applied to a given file by unchecking the "Apply" column.
Once you're ready just click "Apply" and ...
Album Based Soundcheck
iTunes supports a feature called Sound Check. Similar to ReplyGain in other players, the goal is make songs playback at a similar volume. This is particularly useful with mixes, songs from various albums do not have jarring transitions. Since this computed on a song-by-song basis, different songs on a single album get different values. In some cases this creates a jarring experience while listening*.
For example: Muse's Absolution has an introduction track that never gets terribly loud, but leads in directly to a normal song. Sound Check did the following:
- "Intro" adjusted +19.5 dB
- "Apocalypse Please" adjusted -8.5 dB
The ending of the first track is meant to be the same volume as the beginning of the second, but because of Sound Check, this doesn't happen.
I have written album_soundcheck.py which computes the average volume of m4a or mp3 files and replaces the iTunes information ...
Building Cocoa GUIs in Python with PyObjC, Part Six
Handling Images
Cocoa provides an easy interface for dealing with images, NSImage. It can be a bit tricky in Python, but once you get it right the first time, it is fairly easy. For our application we have the images stored inside the audio tags and need to populate an NSImage object from binary data stored as a Python byte-string.
There are a number of methods for initializing an NSImage object from various sources. A few of note:
initWithContentsofFile:
initWithData:
initWithPasteboard:
All of these are worth reading about in the developer documentation. We will be using initWithData:
. This accepts a NSData object to make the NSImage. This is a multiple step process, so we'll create a method to make things easier:
def buildNSImage(bytes):
data = NSData.dataWithBytes_length_(bytes, len(bytes))
return NSImage.alloc().initWithData_(data)
bytes
is a Python byte-string containing the image. NSImage will automatically handle the formatting ...
Building Cocoa GUIs in Python with PyObjC, Part Five
Adding Python Modules to the Bundle
If you try to use Python modules on the standard OS X Python path import
statements will work fine. However, if you have non-standard modules that might be in a different location, or ones that you want to ship with, you will notice you can't just import
them.
To bring them into the application bundle you'll have to go through a couple steps, but when it is all done the application will be able to use the modules, and you don't have to require the end user to install anything extra.
Add the files to the Xcode project.
- Select 'Project -> Add to Project' (option-command-a)
- Select the Python module (directory) that you want to add.
-
On the next screen select "Copy items into destination group's folder (if needed)
- Select the correct targets in 'Add to Targets'
- Select "Create Folder References for ...
Building Cocoa GUIs in Python with PyObjC, Part Four
Creating an Open Dialog
Our controller doesn't really do anything at this point. We'll begin by adding an open dialog for the user. This will require us to really delve into the Objective C bridge provided by PyObjC. We'll start by reading some documentation that ships with Xcode.
Let's launch the local documentation browser in Xcode. Under "Help" click "Documentation". In the newly opened documentation browser select the "Mac OS X 10.5" documentation set and search for NSOpenPanel. This is the class we'll be working with to create our open dialog. Have a look through the documentation, then let's code.
First we do some basic stuff, creating the object and setting some permissions. A modified open method on our controller.py
looks like this:
filetypes = ('mp3', 'ogg', 'mp4', 'flac', 'm4a', 'm4p')
@IBAction
def open_(self, sender):
panel = NSOpenPanel.openPanel()
panel.setCanChooseDirectories_(NO)
panel ...