22 November, 2005

 

More music, more guitar, less giggles

After having so much fun creating Howler, I decided to have a bash at writing something a little more serious with my guitar.

My playing hasn't improved at all since last time, so it's still a matter of sampling individual notes and chords and then putting them back together in Cheesetracker . And when I say I'm a bad guitarist, I'm giving myself more credit than I deserve. I couldn't tell you what notes or chords I'm playing - it's all done with trial and error, sticking my fingers in places a contortionist might wince at and strumming wildly. It certainly looks like I'm a guitarist, and that's good enough for now.

Anyway, the final result is available as coastal.ogg or coastal.mp3.

I get asked quite a lot about the names I give to my tracks. There really isn't much of a relationship between name and content. The names are really just there to differentiate one track from another.

I think I'm going to write a little app to generate track names by randomly picking words from a dictionary. I don't have much free time, so if anyone feels like doing this for me (nudge nudge - 110/159/171?) I'd be very happy. Let's see, we'll need to open text files, read strings, maybe take a number as a command-line argument for the length of the name, use regular expressions to pick words that make up this length...

In case I'm being too subtle: for Coventry's first-year programmers, this could be an alternative way to meet the learning outcomes for some of the IO chapter.


Comments:
Any comments on this short script?
Cheers, the mysterious coder...


#!/usr/bin/python

class TrackNamer:
def __init__(self, fileObject):
import random
self.wordList = [x.strip() for x in fileObject.readlines()]

def generateName(self, length):
#construct temp list with words of desired length
self.transientList = [x for x in self.wordList if len(x)==length]
#if list is empty
if len(self.transientList) == 0:
return 'No words of that length'
#Otherwise, return a random element of the list
return random.choice(self.transientList)


def main():
print '***Welcome to the track namer***\n'

filePath = raw_input('Please provide a valid path to a text file:\n')

try:
myWordDict = open(filePath, 'r')
except:
print 'Could not open file, please try again'

myNamer = TrackNamer(myWordDict)

#accept an integer
userinput=1
while userinput != 0:
userinput = int(raw_input('How long should the word be? (0 to exit)\n'))
print myNamer.generateName(userinput)
else:
sys.exit(0)



if __name__ == '__main__':

import sys, random

main()
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?

Social bookmarks

Delicious

Bookmark this on Delicious

Links

Support The Commons









This site:

Free your code:

archives