Version 3, last updated by tjac0 at Jun 02 15:42 2009 UTC
Adding Instrument
Adding an Instrument to Robot Rock
What you need:
- soundfont for the instrument (fontName.sf2, ex: Maestro.sf2)
- an icon for the instrument (icon.png)
- text file of tags (info.txt)
- python file of the instrument itself (instrumentName.py, ex: snaredrum.py)
- python file to test the instrument (test instrumentName.py, ex: testsnaredrum.py)
- folder to contain most of these files (instrumentName musician/, ex: snaredrummusician/)
What goes where:
- The soundfont file goes in the folder /robotrock/soundfonts/ (this may also be /Python26/robotrockresources/sounds/)
- All of the other files go into the instrument folder.
Formatting:
info.txt
- info.txt has the following format:
tags: tag1,tag2,_tag3
- tag1, tag2, and tag3 are tags supplied by you, the developer (ex: drum, guitar, percussion)
- Here is a sample line for info,txt:
tags: percussion,drumkit,snare
- The important parts to note:
- Starts with "tags: " - always needs to start with this string
- Comma separated listing of tags. Also, there should be no spaces after the commas, this is optional but highly recommended.
- You can add as many tags as you desire, but you should only put on descriptive tags, the tags tell the UI how to sort this instrument.
instrumentName.py:
- Needs to inherit from Musician (in musician.py) at some point. Can inherit from something like MusicianStructured and get this as well.
- Needs a special Musician() method.
- Same indentation as the class declaration
- Returns newly created instance of this musician
- ex: in snaredrume.py:
class SnareDrum(MusicianStructured)
...
def Musician()
return SnareDrum()
- in __init__:
- Needs a self.instrument field containing a string of the name of the instrument (ex: 'snare drum')
- Non-tonal instruments need a self._my_tone which indexes to it's sound in the soundfont (ex: Drumkit["Snare Drum 1"]; referenced through a dictionary)
- Fields for energy, complexity, key signature, and time signature (it is recommended that these get accessed by properties)
- A compose method: compose(self, measure, window_start, window_duration, current_score_slice)
- This method is called by the conductor (access to this musician from the rest of the program)
- See musician.py, sample musicians, and the rest of the documentation for further details
- To hear music, the musician needs to be properly adding notes onto the given measure (see sample musicians for how to do this)
Additional steps
- The folder for the musician (ex: snaredrummusician/) needs to go in /robotrock/robotrock/musicians/
- Need to edit the file /robotrock/soundfonts/basic_set.txt (could also be in /Python26/robotrockresourses/sounds)
- Add a line for the new musician, format is below:
- instumentname : soundfont
- The instrumentname is the same one written into the self.instrument field
- The soundfont is a soundfont (of type .sf2) placed in the same folder as basic_set.txt
- ex: snare drum : HS_R8_Drums.sf2