Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorOli <olivier.belanger@umontreal.ca>2007-10-19 08:08:02 (GMT)
committer Oli <olivier.belanger@umontreal.ca>2007-10-19 08:08:02 (GMT)
commit3e9a586f404b70cda362cf888653de9c940fd849 (patch)
tree427a99619ebf947600a3cc2c0ef9437fb2953f09 /common
parent9307df223f0be4193a21fddd48e32ce15b9ed4ef (diff)
switch to instrumentDB
Diffstat (limited to 'common')
-rw-r--r--common/Config.py300
-rw-r--r--common/Generation/GenerationRythm.py12
-rwxr-xr-xcommon/Generation/Generator.py9
-rw-r--r--common/Util/Block.py5
-rw-r--r--common/Util/CSoundClient.py28
-rw-r--r--common/Util/CSoundNote.py5
-rw-r--r--common/Util/InstrumentDB.py59
-rw-r--r--common/Util/InstrumentPanel.py12
-rw-r--r--common/Util/Instruments.py240
-rw-r--r--common/Util/NoteDB.py8
10 files changed, 309 insertions, 369 deletions
diff --git a/common/Config.py b/common/Config.py
index d583f16..2aae053 100644
--- a/common/Config.py
+++ b/common/Config.py
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
import os
-import common.Util.InstrumentDB as InstrumentDB
from sugar.activity.activity import get_bundle_path
from sugar import env
-QUICKLOAD = os.path.isfile("QUICKLOAD") # skip loading inessential comenents to speed things up
+#QUICKLOAD = os.path.isfile("QUICKLOAD") # skip loading inessential comenents to speed things up
SugarMode = True
@@ -52,48 +51,17 @@ PLUGIN_VERBOSE = 0
PLUGIN_UNIVORC = TAM_TAM_ROOT + "/common/Resources/tamtamorc.csd"
PLUGIN_KSMPS = 64
PLUGIN_RATE = 16000
-#PLUGIN_KSMPS = 64
-#PLUGIN_RATE = 22050
## PLUGIN ALSA PARAMETERS:
-
-## for macbook pro
-#PLUGIN_PERIOD = 1024
-#PLUGIN_NPERIODS = 4
-
-## for XO with root
-#PLUGIN_PERIOD = 256
-#PLUGIN_NPERIODS = 2
-
-## for XO as normal user
PLUGIN_PERIOD = 256 #512
PLUGIN_NPERIODS = 2
##############
## SOUNDS
##############
-KIT_ELEMENT = 24 * [0]
-for i in range(0,13):
- KIT_ELEMENT += 2 * [i]
-KIT_ELEMENT = tuple(KIT_ELEMENT)
-
-class Instrument:
- def __init__( self, name, instrumentId, csoundInstrumentId, instrumentRegister, category, loopStart, loopEnd, crossDur, ampScale = 1, kit = None ):
- self.name = name
- self.instrumentId = instrumentId
- self.csoundInstrumentId = csoundInstrumentId
- self.instrumentRegister = instrumentRegister
- self.category = category
- self.loopStart = loopStart
- self.loopEnd = loopEnd
- self.crossDur = crossDur
- self.ampScale = ampScale
- self.kit = kit
LOW, MID, HIGH, PUNCH = range( 4 )
-# Sounds categories: musicInst, animals, drum, people, electronic, concret, mic
-#INSTRUMENTS ( csound table, csound instrument, register, instrumentClass, category )
INSTRUMENT_TABLE_OFFSET = 5000
INST_FREE = 5000
INST_TIED = 5001
@@ -102,279 +70,15 @@ INST_PERC = 5021
CATEGORIES = ['all','animals','concret','keyboard','people','percussions','strings','winds', 'mysounds']
-instrumentDB = InstrumentDB.getRef()
-
-_nextInstrumentId = [0]
-INSTRUMENTS = {}
-def _addInstrument( name, csoundInstrumentId, instrumentRegister, category, loopStart, loopEnd, crossDur, ampScale = 1, kit = None ):
- if not QUICKLOAD or name[0:4] == "drum" or name in ["flute", "kalimba"]: # quick load
- INSTRUMENTS[name] = Instrument( name, _nextInstrumentId[0], csoundInstrumentId, instrumentRegister, category, loopStart, loopEnd, crossDur, ampScale, kit )
- instrumentDB.addInstrumentFromArgs( name, csoundInstrumentId, instrumentRegister, loopStart, loopEnd, crossDur, ampScale, name, LIB_DIR+"/Images/"+name+".png", [ category ] )
- _nextInstrumentId[0] += 1
-
-
-_addInstrument( "mic1", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1 )
-_addInstrument( "mic2", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1 )
-_addInstrument( "mic3", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1 )
-_addInstrument( "mic4", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1 )
-_addInstrument( "lab1", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 )
-_addInstrument( "lab2", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 )
-_addInstrument( "lab3", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 )
-_addInstrument( "lab4", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 )
-_addInstrument( "lab5", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 )
-_addInstrument( "lab6", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 )
-_addInstrument( "ounk", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
-_addInstrument( "gam", INST_TIED, HIGH, 'percussions', .69388, .7536, .02922, 1 )
-_addInstrument( "guit", INST_TIED, MID, 'strings', .08592, .75126, .33571, 1.3 )
-_addInstrument( "koto", INST_TIED, HIGH, 'strings', .56523, .70075, .05954, 1 )
-_addInstrument( "clarinette", INST_TIED, MID, 'winds', 1.635276375, 2.72956523438, .2, 0.6 )
-_addInstrument( "flute", INST_TIED, MID, 'winds', .47169, .53693, .02481, 1 )
-_addInstrument( "drum1hatpedal", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum1hatshoulder", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum1hardride", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum1ridebell", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum1snare", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum1snaresidestick", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum1crash", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum1splash", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum1tom", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum1floortom", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1)
-_addInstrument( "drum1chine", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum1kick", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "piano", INST_TIED, MID, 'keyboard', 0.8883, 1.420524, .13575, 1 )
-_addInstrument( "dog", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
-_addInstrument( "duck", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
-_addInstrument( "drum2darbukadoom", INST_SIMP, LOW, 'percussions', 0, 0 ,0, 1 )
-_addInstrument( "drum2darbukapied", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum2darbukapiedsoft", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum2hatflanger", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum2darbukatak", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum2darbukafinger", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum2darbukaroll", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum2darbukaslap", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum2hatpied", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum2tambourinepied", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum2hatpied2", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum2tambourinepiedsoft", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum3cowbell", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum3cowbelltip", INST_SIMP, MID, 'percussions', 0, 0, 0, 1)
-_addInstrument( "drum3cup", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum3djembelow", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum3djembemid", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum3djembesidestick", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum3djembeslap", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum3djembestickmid", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum3metalstand", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum3pedalperc", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum3rainstick", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum3tambourinehigh", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum3tambourinelow", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "harmonica", INST_TIED, MID, 'winds', .1531, .19188, .01792, 1 )
-_addInstrument( "alarm", INST_TIED, MID, 'concret', 1.37555859375, 2.0286015625, .0675, 0.5 )
-_addInstrument( "bird", INST_TIED, MID, 'animals', .1, 1, .05, 1 )
-_addInstrument( "cat", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
-_addInstrument( "duck2", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
-_addInstrument( "bottle", INST_TIED, MID, 'concret', .20532, .41064, .05292, 1 )
-_addInstrument( "clang", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "ow", INST_SIMP, MID, 'people', 0, 0, 0, 1 )
-_addInstrument( "sheep", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
-_addInstrument( "water", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "zap", INST_TIED, MID, 'keyboard', .299, .7323, .09895, 1 )
-_addInstrument( "trumpet", INST_TIED, MID, 'winds', .91195, 1.652909375, .05375, 0.5)
-_addInstrument( "bubbles", INST_TIED, MID, 'concret', 0.02, 1.177, 0.02, 1)
-_addInstrument( "marimba", INST_TIED, MID, 'percussions', .18883789, .343623047, .07625, 0.5)
-_addInstrument( "triangle", INST_TIED, MID, 'percussions', 2.27261836, 3.2965453, .2, 0.6)
-_addInstrument( "laugh", INST_SIMP, MID, 'people', 0, 0, 0, 1 )
-_addInstrument( "voix", INST_TIED, MID, 'people', .89608, .96092, .02343, 1 )
-_addInstrument( "cling", INST_TIED, MID, 'keyboard', .09096, .7878, .18026, 1 )
-_addInstrument( "byke", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "door", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "basse", INST_TIED, MID, 'strings', 0.50470875, 0.833315, 0.09375, 1 )
-_addInstrument( "acguit", INST_TIED, MID, 'strings', 1.4037, 1.84235625, 0.2, 0.8 )
-_addInstrument( "diceinst", INST_SIMP, MID, 'concret', 0, 0, 0, 1.3 )
-_addInstrument( "didjeridu", INST_TIED, LOW, 'winds', .55669, 1.73704, .09178, 2 )
-_addInstrument( "harmonium", INST_TIED, MID, 'keyboard', .242032, .898165625, .2, 0.5 )
-_addInstrument( "horse", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
-_addInstrument( "kalimba", INST_TIED, MID, 'percussions', .20751, .30161, .04658, 1.3 )
-_addInstrument( "mando", INST_TIED, MID, 'strings', 0.507107031, 0.934144531, 0.2, 0.5 )
-_addInstrument( "ocarina", INST_TIED, MID, 'winds', .06612, .19033, .01776, 1 )
-_addInstrument( "rhodes", INST_TIED, MID, 'keyboard', 0.58100625, 0.821625, 0.067, 1 )
-_addInstrument( "saxo", INST_TIED, MID, 'winds', 1.161051953, 3.001209765, .05, 0.5 )
-_addInstrument( "shenai", INST_TIED, MID, 'winds', .29003, .33072, .00634, 0.7 )
-_addInstrument( "sitar", INST_TIED, MID, 'strings', 1.1361625, 1.575134375, .183, 0.4 )
-_addInstrument( "tuba", INST_TIED, LOW, 'winds', .51063, .58384, .035, 1 )
-_addInstrument( "violin", INST_TIED, MID, 'strings', .105, .30656, .028, 1 )
-_addInstrument( "guidice1", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "guidice2", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "guidice3", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "guidice4", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "guidice5", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "guidice6", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "guidice7", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "guidice8", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "guidice9", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "guidice10", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "drum4afrofeet", INST_SIMP, LOW, 'percussions', 0, 0 ,0, 1 )
-_addInstrument( "drum4fingersn", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum4mutecuic", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum4stompbass", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum4tambouri", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum4tr707clap", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum4tr707open", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum4tr808closed", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum4tr808sn", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum4tr909bass", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum4tr909kick", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum4tr909sn", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum5timablesslap", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum5congagraveouvert", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum5timablesaiguslap", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum5congagraveferme", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum5guiroretour", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum5vibraslap", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum5congaaiguouvert", INST_SIMP, MID, 'percussions', 0, 0 ,0, 1 )
-_addInstrument( "drum5quicamedium", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum5quicaaigu", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum5agogograve", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum5bongoaiguouvert", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum5agogoaigu", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "drum5bongograveouvert", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
-_addInstrument( "camera", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "car", INST_TIED, MID, 'concret', .67, 1.05761, .01, 0.7 )
-_addInstrument( "cello", INST_TIED, MID, 'strings', 0.4761, 0.92244375, 0.19125, .75 )
-_addInstrument( "chimes", INST_TIED, MID, 'percussions', 4.104825, 5.644134375, .02, 1 )
-_addInstrument( "crash", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
-_addInstrument( "guit2", INST_TIED, MID, 'strings', 1.186341406, 1.929568266, .2, 0.5 )
-_addInstrument( "plane", INST_SIMP, MID, 'concret', 0, 0, 0, 0.7 )
-_addInstrument( "slap", INST_SIMP, MID, 'concret', 0, 0, 0, 0.7 )
-
-try:
- ifile = open(PREF_DIR + '/sounds_settings', 'r')
- for line in ifile.readlines():
- list = line.split()
- _addInstrument(list[0], int(list[1]), int(list[2]), list[3], list[4], float(list[5]), float(list[6]), float(list[7]))
-except:
- pass
-
-
-DRUM1KIT = { 24 : INSTRUMENTS["drum1kick"],
- 26 : INSTRUMENTS["drum1floortom"],
- 28 : INSTRUMENTS["drum1tom"],
- 30 : INSTRUMENTS["drum1chine"],
- 32 : INSTRUMENTS["drum1splash"],
- 34 : INSTRUMENTS["drum1crash"],
- 36 : INSTRUMENTS["drum1snaresidestick"],
- 38 : INSTRUMENTS["drum1snaresidestick"],
- 40 : INSTRUMENTS["drum1snare"],
- 42 : INSTRUMENTS["drum1ridebell"],
- 44 : INSTRUMENTS["drum1hardride"],
- 46 : INSTRUMENTS["drum1hatshoulder"],
- 48 : INSTRUMENTS["drum1hatpedal"] }
-
-DRUM2KIT = { 24 : INSTRUMENTS["drum2darbukadoom"],
- 26 : INSTRUMENTS["drum2darbukapied"],
- 28 : INSTRUMENTS["drum2darbukapiedsoft"],
- 30 : INSTRUMENTS["drum2hatflanger"],
- 32 : INSTRUMENTS["drum2darbukatak"],
- 34 : INSTRUMENTS["drum2darbukatak"],
- 36 : INSTRUMENTS["drum2darbukafinger"],
- 38 : INSTRUMENTS["drum2darbukaroll"],
- 40 : INSTRUMENTS["drum2darbukaslap"],
- 42 : INSTRUMENTS["drum2hatpied"],
- 44 : INSTRUMENTS["drum2tambourinepied"],
- 46 : INSTRUMENTS["drum2hatpied2"],
- 48 : INSTRUMENTS["drum2tambourinepiedsoft"] }
-
-DRUM3KIT = { 24 : INSTRUMENTS["drum3djembelow"],
- 26 : INSTRUMENTS["drum3pedalperc"],
- 28 : INSTRUMENTS["drum3djembeslap"],
- 30 : INSTRUMENTS["drum3tambourinehigh"],
- 32 : INSTRUMENTS["drum3tambourinelow"],
- 34 : INSTRUMENTS["drum3rainstick"],
- 36 : INSTRUMENTS["drum3djembemid"],
- 38 : INSTRUMENTS["drum3djembesidestick"],
- 40 : INSTRUMENTS["drum3djembestickmid"],
- 42 : INSTRUMENTS["drum3cowbell"],
- 44 : INSTRUMENTS["drum3cowbelltip"],
- 46 : INSTRUMENTS["drum3cup"],
- 48 : INSTRUMENTS["drum3metalstand"] }
-
-DRUM4KIT = { 24 : INSTRUMENTS["drum4afrofeet"],
- 26 : INSTRUMENTS["drum4tr909kick"],
- 28 : INSTRUMENTS["drum4tr909bass"],
- 30 : INSTRUMENTS["drum4stompbass"],
- 32 : INSTRUMENTS["drum4tr707open"],
- 34 : INSTRUMENTS["drum4mutecuic"],
- 36 : INSTRUMENTS["drum4tr808sn"],
- 38 : INSTRUMENTS["drum4tr707clap"],
- 40 : INSTRUMENTS["drum4tr909sn"],
- 42 : INSTRUMENTS["drum4tambouri"],
- 44 : INSTRUMENTS["drum4fingersn"],
- 46 : INSTRUMENTS["drum4fingersn"],
- 48 : INSTRUMENTS["drum4tr808closed"] }
-
-DRUM5KIT = { 24 : INSTRUMENTS["drum5timablesslap"],
- 26 : INSTRUMENTS["drum5timablesaiguslap"],
- 28 : INSTRUMENTS["drum5congagraveouvert"],
- 30 : INSTRUMENTS["drum5quicamedium"],
- 32 : INSTRUMENTS["drum5guiroretour"],
- 34 : INSTRUMENTS["drum5vibraslap"],
- 36 : INSTRUMENTS["drum5congagraveferme"],
- 38 : INSTRUMENTS["drum5quicaaigu"],
- 40 : INSTRUMENTS["drum5congaaiguouvert"],
- 42 : INSTRUMENTS["drum5agogoaigu"],
- 44 : INSTRUMENTS["drum5bongograveouvert"],
- 46 : INSTRUMENTS["drum5agogograve"],
- 48 : INSTRUMENTS["drum5bongoaiguouvert"] }
-
-_addInstrument( "drum1kit", 0, 0, "percussions", 0, 0, 0, 1, DRUM1KIT )
-_addInstrument( "drum2kit", 0, 0, "percussions", 0, 0, 0, 1, DRUM2KIT )
-_addInstrument( "drum3kit", 0, 0, "percussions", 0, 0, 0, 1, DRUM3KIT )
-_addInstrument( "drum4kit", 0, 0, "percussions", 0, 0, 0, 1, DRUM4KIT )
-_addInstrument( "drum5kit", 0, 0, "percussions", 0, 0, 0, 1, DRUM5KIT )
-
-INSTRUMENTSID = {}
-for i in INSTRUMENTS:
- INSTRUMENTSID[INSTRUMENTS[i].instrumentId] = INSTRUMENTS[i]
-
-
-#DRUMKITS = ['drum1kit', 'drum2kit', 'drum3kit', 'drum4kit']
-#DRUMSINSTRUMENTSDICT = [DRUM1KIT, DRUM2KIT, DRUM3KIT, DRUM4KIT]
-
-RECORDABLE_INSTRUMENTS = set( [ "mic1", "mic2", "mic3", "mic4" ] )
-RECORDABLE_INSTRUMENT_CSOUND_IDS = { "mic1" : 7,
- "mic2" : 8,
- "mic3" : 9,
- "mic4" : 10 }
-
#CSOUND COMMANDS
CSOUND_LOAD_INSTRUMENT = 'f%d 0 0 -1 "%s" 0 0 0'
CSOUND_MIC_RECORD = 'i5201 0 5 %d'
-CSOUND_UNLOAD_TABLES = 'i%d 0 0.1 %d' % (INST_FREE, len(INSTRUMENTS))
+CSOUND_UNLOAD_TABLES = 'i%d 0 0.1 %d' % (INST_FREE, 150) # removed magic number
CSOUND_NOTE_OFF = 'i %s.%s .2 0.01 1. 0. 0. 0.5 %d 0 0 0 0' %('%d','%d',INSTRUMENT_TABLE_OFFSET)
CSOUND_LOAD_LS_INSTRUMENT = 'f4999 0 0 -1 \"%s\" 0 0 0'
CSOUND_PLAY_LS_NOTE = 'i %i 0 -1'
CSOUND_STOP_LS_NOTE = 'i 5022 0 0.5'
-#CSOUND COMMANDS - DEPRECATED
-
-LOAD_INSTRUMENT_COMMAND = \
- "perf.InputMessage('f%d 0 0 -1 \"%s\" 0 0 0')\n"
-PLAY_NOTE_COMMAND = \
- "perf.InputMessage('i %d.%d %f %f %f %f %f %f %d %f %f %d %f %f %f %f')\n"
-#TODO: add the extra three params to COMMAND_MINUS_DELAY, and instrument 5777 in univorc.csd
-PLAY_NOTE_COMMAND_MINUS_DELAY = \
- "perf.InputMessage('i 5777 0.0 0.001 %d.%d %s %f %f %f %f %f %d %f %f %d %f')\n"
-PLAY_NOTE_OFF_COMMAND = \
- "perf.InputMessage('i %s.%s .2 0.01 1. 0. 0. 0.5 %d 0 0 0 0')\n" \
- % ('%d', '%d', INSTRUMENT_TABLE_OFFSET )
-MIC_RECORDING_COMMAND = \
- "perf.InputMessage('i5201 0 5 %d')\n"
-UNLOAD_TABLES_COMMAND = \
- "perf.InputMessage('i%d 0 0.1 %d')\n" % (INST_FREE, len(INSTRUMENTS))
-
-
-
#################
## GUI CONSTANTS
diff --git a/common/Generation/GenerationRythm.py b/common/Generation/GenerationRythm.py
index 5e1b31d..583f642 100644
--- a/common/Generation/GenerationRythm.py
+++ b/common/Generation/GenerationRythm.py
@@ -1,10 +1,13 @@
import Utils
import random
from math import sqrt
+import common.Util.InstrumentDB as InstrumentDB
import common.Config as Config
from common.Generation.GenerationConstants import GenerationConstants
class GenerationRythm:
+ def __init__(self):
+ self.instrumentDB = InstrumentDB.getRef()
def celluleRythmSequence(self, parameters, barLength, trackId, trackInstrument=None ):
rythmSequence = [0, ]
@@ -85,7 +88,6 @@ class GenerationRythm:
rythmSequence = []
onsetTime = None
randomParamScaler = parameters.rythmRegularity[trackId] * 2 + 0.5
-# need radioButton with 0 for random choose and each generator independant
whichRandomGenerator = random.randint(0, 4)
maximumNumberOfNotes = int( (parameters.density[trackId]) * GenerationConstants.MAX_NOTES_PER_BAR)
@@ -133,7 +135,7 @@ class GenerationRythm:
upBeatsAppend = upBeats.append
- if Config.INSTRUMENTS[ trackInstrument ].instrumentRegister == Config.PUNCH:
+ if self.instrumentDB.instNamed[ trackInstrument ].instrumentRegister == Config.PUNCH:
registerDensity = 0.5
downBeatRecurence = 4
upBeatOffset = Config.TICKS_PER_BEAT / 2
@@ -141,7 +143,7 @@ class GenerationRythm:
for downBeat in downBeats:
upBeatsAppend( downBeat + upBeatOffset )
- elif Config.INSTRUMENTS[ trackInstrument ].instrumentRegister == Config.LOW:
+ elif self.instrumentDB.instNamed[ trackInstrument ].instrumentRegister == Config.LOW:
registerDensity = 1.5
downBeatRecurence = 4
upBeatOffset = Config.TICKS_PER_BEAT / 2
@@ -149,7 +151,7 @@ class GenerationRythm:
for downBeat in downBeats:
upBeatsAppend( downBeat + upBeatOffset )
- elif Config.INSTRUMENTS[ trackInstrument ].instrumentRegister == Config.MID:
+ elif self.instrumentDB.instNamed[ trackInstrument ].instrumentRegister == Config.MID:
registerDensity = 1
downBeatRecurence = 1
upBeatOffset = Config.TICKS_PER_BEAT / 4
@@ -157,7 +159,7 @@ class GenerationRythm:
for downBeat in downBeats:
upBeatsAppend( downBeat + upBeatOffset )
- elif Config.INSTRUMENTS[ trackInstrument ].instrumentRegister == Config.HIGH:
+ elif self.instrumentDB.instNamed[ trackInstrument ].instrumentRegister == Config.HIGH:
registerDensity = 1.5
downBeatRecurence = 1
upBeatOffset = Config.TICKS_PER_BEAT / 4
diff --git a/common/Generation/Generator.py b/common/Generation/Generator.py
index 8e92780..ff05462 100755
--- a/common/Generation/Generator.py
+++ b/common/Generation/Generator.py
@@ -4,12 +4,15 @@ import math
import Utils
import Drunk
+import common.Util.InstrumentDB as InstrumentDB
import common.Config as Config
from common.Util.CSoundNote import CSoundNote
from common.Generation.GenerationConstants import GenerationConstants
from common.Generation.GenerationRythm import GenerationRythm
from common.Generation.GenerationPitch import GenerationPitch
+instrumentDB = InstrumentDB.getRef()
+
class GenerationParameters:
def __init__( self,
density = GenerationConstants.DEFAULT_DENSITY,
@@ -67,7 +70,7 @@ def generator1(
def makeDurationSequence( onsetList, parameters, table_duration, barLength, currentInstrument ):
durationSequence = []
- if Config.INSTRUMENTS[currentInstrument].name[0:4] == 'drum':
+ if instrumentDB.instNamed[currentInstrument].name[0:4] == 'drum':
duration = GenerationConstants.DOUBLE_TICK_DUR / 2
durationSequence = [duration] * len(onsetList)
return durationSequence
@@ -87,7 +90,7 @@ def generator1(
trackNotes = trackOfNotes
if drumPitch:
- currentInstrument = Config.INSTRUMENTS[instrument[pageId][trackId]].kit[drumPitch[0]].name
+ currentInstrument = instrumentDB.instNamed[instrument[pageId][trackId]].kit[drumPitch[0]]
rythmSequence = makeRythm.drumRythmSequence(parameters, currentInstrument, barLength)
pitchSequence = makePitch.drumPitchSequence(len(rythmSequence), parameters, drumPitch, table_pitch )
else:
@@ -102,7 +105,7 @@ def generator1(
rand = random.random
append = trackNotes.append
pan = GenerationConstants.DEFAULT_PAN
- instrument_id = Config.INSTRUMENTS[instrument[pageId][trackId]].instrumentId
+ instrument_id = instrumentDB.instNamed[instrument[pageId][trackId]].instrumentId
for i in numOfNotes:
if drumPitch:
if ( rand() * fillDrum ) > ( parameters.silence[0] * .5 ):
diff --git a/common/Util/Block.py b/common/Util/Block.py
index b1395b8..45f942a 100644
--- a/common/Util/Block.py
+++ b/common/Util/Block.py
@@ -5,6 +5,7 @@ import gtk
import random
+import common.Util.InstrumentDB as InstrumentDB
import common.Config as Config
from common.Util.NoteDB import PARAMETER
@@ -368,7 +369,7 @@ class Drum(Block):
#:::
def __init__( self, owner, data ):
Block.__init__( self, owner, data )
-
+ self.instrumentDB = InstrumentDB.getRef()
self.type = Drum
self.canSubstitute = True
@@ -441,7 +442,7 @@ class Drum(Block):
if block.type == Loop:
return False
- if Config.INSTRUMENTSID[block.data["id"]].kit == None:
+ if self.instrumentDB.instId[block.data["id"]].kit == None:
return False
if abs( self.x - block.x ) < Block.SNAP and abs( self.y - block.y ) < Block.SNAP:
diff --git a/common/Util/CSoundClient.py b/common/Util/CSoundClient.py
index e3963cf..c2ca4ff 100644
--- a/common/Util/CSoundClient.py
+++ b/common/Util/CSoundClient.py
@@ -12,6 +12,7 @@ import common.Config as Config
from common.Generation.GenerationConstants import GenerationConstants
from common.Util.Clooper.aclient import *
from common.Util import NoteDB
+import common.Util.InstrumentDB as InstrumentDB
_note_template = array.array('f', [0] * 19 )
@@ -50,6 +51,7 @@ class _CSoundClientPlugin:
self.periods_per_buffer = 2
global _loop_default
_loop_default = self.loopCreate()
+ self.instrumentDB = InstrumentDB.getRef()
def __del__(self):
self.connect(False)
@@ -75,12 +77,12 @@ class _CSoundClientPlugin:
def load_mic_instrument( self, inst ):
fileName = Config.SNDS_DIR + '/' + inst
- instrumentId = Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[inst].instrumentId
+ instrumentId = Config.INSTRUMENT_TABLE_OFFSET + self.instrumentDB.instNamed[inst].instrumentId
sc_inputMessage(Config.CSOUND_LOAD_INSTRUMENT % (instrumentId, fileName))
def load_synth_instrument( self, inst ):
fileName = Config.SNDS_DIR + '/' + inst
- instrumentId = Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[inst].instrumentId
+ instrumentId = Config.INSTRUMENT_TABLE_OFFSET + self.instrumentDB.instNamed[inst].instrumentId
sc_inputMessage(Config.CSOUND_LOAD_INSTRUMENT % (instrumentId, fileName))
def load_ls_instrument( self, inst ):
@@ -88,12 +90,12 @@ class _CSoundClientPlugin:
sc_inputMessage(Config.CSOUND_LOAD_LS_INSTRUMENT % fileName)
def load_instruments( self ):
- for instrumentSoundFile in Config.INSTRUMENTS.keys():
- if instrumentSoundFile[0:3] == 'mic' or instrumentSoundFile[0:3] == 'lab' or Config.INSTRUMENTS[instrumentSoundFile].category == 'mysounds':
+ for instrumentSoundFile in self.instrumentDB.instNamed.keys():
+ if instrumentSoundFile[0:3] == 'mic' or instrumentSoundFile[0:3] == 'lab' or self.instrumentDB.instNamed[instrumentSoundFile].category == 'mysounds':
fileName = Config.SNDS_DIR + '/' + instrumentSoundFile
else:
fileName = Config.SOUNDS_DIR + "/" + instrumentSoundFile
- instrumentId = Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[ instrumentSoundFile ].instrumentId
+ instrumentId = Config.INSTRUMENT_TABLE_OFFSET + self.instrumentDB.instNamed[ instrumentSoundFile ].instrumentId
sc_inputMessage( Config.CSOUND_LOAD_INSTRUMENT % (instrumentId, fileName) )
def connect( self, init = True ):
@@ -181,7 +183,7 @@ class _CSoundClientPlugin:
if note.cs.mode == 'mini':
instrument_id_offset = 0
elif note.cs.mode == 'edit':
- if Config.INSTRUMENTSID[note.cs.instrumentId].kit != None:
+ if self.instrumentDB.instId[note.cs.instrumentId].kit != None:
instrument_id_offset = 0
else:
instrument_id_offset = 100
@@ -191,8 +193,8 @@ class _CSoundClientPlugin:
elif (parameter == NoteDB.PARAMETER.PITCH):
if (Config.DEBUG > 2): print 'INFO: updating pitch', (page<<16)+id, value
pitch = value
- if Config.INSTRUMENTSID[note.cs.instrumentId].kit != None:
- instrument = Config.INSTRUMENTSID[note.cs.instrumentId].kit[pitch]
+ if self.instrumentDB.instId[note.cs.instrumentId].kit != None:
+ instrument = self.instrumentDB.instId[note.cs.instrumentId].kit[pitch]
csoundInstId = instrument.csoundInstrumentId
csoundTable = Config.INSTRUMENT_TABLE_OFFSET + instrument.instrumentId
if (Config.DEBUG > 2): print 'INFO: updating drum instrument (pitch)', (page<<16)+id, instrument.name, csoundInstId
@@ -210,9 +212,9 @@ class _CSoundClientPlugin:
sc_loop_updateEvent( loopId, (page<<16)+id, self.DURATION, value, cmd)
elif (parameter == NoteDB.PARAMETER.INSTRUMENT):
pitch = note.cs.pitch
- instrument = Config.INSTRUMENTSID[value]
+ instrument = self.instrumentDB.instId[value]
if instrument.kit != None:
- instrument = instrument.kit[pitch]
+ instrument = self.instrumentDB.instNamed[instrument.kit[pitch]]
csoundInstId = instrument.csoundInstrumentId
csoundTable = Config.INSTRUMENT_TABLE_OFFSET + instrument.instrumentId
loopStart = instrument.loopStart
@@ -277,9 +279,9 @@ class _CSoundClientPlugin:
tied, instrumentId, mode, instrumentId2 = -1):
rval=storage
- instrument = Config.INSTRUMENTSID[instrumentId]
+ instrument = self.instrumentDB.instId[instrumentId]
if instrument.kit != None:
- instrument = instrument.kit[pitch]
+ instrument = self.instrumentDB.instNamed[instrument.kit[pitch]]
pitch = 1
time_in_ticks = 0
else:
@@ -331,7 +333,7 @@ class _CSoundClientPlugin:
rval[14]= float(instrument.crossDur)
if instrumentId2 != -1:
- instrument2 = Config.INSTRUMENTSID[instrumentId2]
+ instrument2 = self.instrumentDB.instId[instrumentId2]
csInstrumentId2 = (instrument2.csoundInstrumentId + 100) * 0.0001
rval[15] = Config.INSTRUMENT_TABLE_OFFSET + instrumentId2 + csInstrumentId2
rval[16] = instrument2.loopStart
diff --git a/common/Util/CSoundNote.py b/common/Util/CSoundNote.py
index 535084d..a188a62 100644
--- a/common/Util/CSoundNote.py
+++ b/common/Util/CSoundNote.py
@@ -1,4 +1,5 @@
import common.Config as Config
+import common.Util.InstrumentDB as InstrumentDB
class CSoundNote :
def __init__( self,
@@ -8,7 +9,7 @@ class CSoundNote :
pan,
duration,
trackId,
- instrumentId = Config.INSTRUMENTS["flute"].instrumentId,
+ instrumentId = 1, #self.instrumentDB.instNamed["flute"].instrumentId,
attack = 0.005,
decay = 0.098,
reverbSend = 0.1,
@@ -18,6 +19,8 @@ class CSoundNote :
mode = 'edit',
instrumentId2 = -1 ):
+ self.instrumentDB = InstrumentDB.getRef()
+
self.onset = onset
self.pitch = pitch
self.amplitude = amplitude
diff --git a/common/Util/InstrumentDB.py b/common/Util/InstrumentDB.py
index 900dd86..fd276ae 100644
--- a/common/Util/InstrumentDB.py
+++ b/common/Util/InstrumentDB.py
@@ -7,21 +7,22 @@ import os
class Instrument:
def __init__(self, id):
- self.id = id
+ self.instrumentId = id
# build an Instrument instance from argument list
def loadFromArgs( self, name, csoundInstrumentId, register, loopStart,
- loopEnd, crossDur, ampScale, wav, img, labels ):
+ loopEnd, crossDur, ampScale, kit, wav, img, category ):
self.name = name
self.csoundInstrumentId = csoundInstrumentId
- self.register = register
+ self.instrumentRegister = register
self.loopStart = loopStart
self.loopEnd = loopEnd
self.crossDur = crossDur
self.ampScale = ampScale
+ self.kit = kit
self.wav = wav
self.img = img
- self.labels = labels
+ self.category = category
# build an Instrument instance by parsing a file
def loadFromPath(self, path ):
@@ -36,9 +37,10 @@ class Instrument:
self.loopEnd = float( f.readline())
self.crossDur = float( f.readline())
self.ampScale = float( f.readline())
+ self.kit = None
self.wav = f.readline()
self.img = f.readline()
- self.labels = f.readline().split()
+ self.category = f.readline().split()
f.close()
class InstrumentDB:
@@ -48,22 +50,21 @@ class InstrumentDB:
self.labelSet = {'All':set([])} # <key> -> all instruments labelled by <key>
self.inst = [] # all instruments
self.instNamed = {} # <name> -> instrument with that name
- self.kit = [] # all kits. kits are lists of 13 instruments
- self.kitNamed = {} # <name> -> kit with that name
+ self.instId = {} # <instrumentId> -> instrument
# TEMP? add instrument from args
def addInstrumentFromArgs( self, name, csoundInstrumentId, register, loopStart,
- loopEnd, crossDur, ampScale, wav, img, labels ):
+ loopEnd, crossDur, ampScale, kit, wav, img, category ):
i = Instrument(len(self.inst))
self.inst += [ i ]
- i.loadFromArgs( name, csoundInstrumentId, register, loopStart, loopEnd, crossDur, ampScale, wav, img, labels )
- #print 'labelSet... ', self.labelSet
- self.labelSet['All'].add(i)
- for l in i.labels:
- if l not in self.labelSet:
- self.labelSet[l] = set([])
- self.labelSet[l].add( i )
+ i.loadFromArgs( name, csoundInstrumentId, register, loopStart, loopEnd, crossDur, ampScale, kit, wav, img, category )
+ self.instNamed[ i.name ] = i
+ self.instId[i.instrumentId] = i
+ self.labelSet['All'].add(i)
+ if not self.labelSet.has_key(category):
+ self.labelSet[category] = set([])
+ self.labelSet[category].add( i )
# add an instrument to the DB by reading from an instrument definition file
def addInstrument( self, path ):
@@ -71,23 +72,12 @@ class InstrumentDB:
self.inst += [ i ]
i.loadFromPath( path )
self.instNamed[ i.name ] = i
+ self.instId[self.instNamed[i].instrumentId] = i
#print 'labelSet... ', self.labelSet
self.labelSet['All'].add(i)
- for l in i.labels:
- if l not in self.labelSet:
- self.labelSet[l] = set([])
- self.labelSet[l].add( i )
-
- # add a kit by reading from a kit definition file
- def addKit( self, path ):
- strlist = file(path, 'r').readline().split()
- if len(strlist) != 14:
- raise 'kit length != 13'
- for str in strlist[1:]:
- if str not in self.inst_named:
- raise 'invalid instrument'
- kit = [ self.instNamed[name] for name in strlist ]
- self.kit += [ kit ]
+ if not self.labelSet.has_key(category):
+ self.labelSet[category] = set([])
+ self.labelSet[category].add( i )
# try to load each file in a given folder as an instrument def. file
def scanInstrumentDir( self, path ):
@@ -98,15 +88,6 @@ class InstrumentDB:
except :
print 'ERROR: scanning instrument path %s: file %s invalid' % (path, fpath)
- # try to load each file in a given folder as a kit def. file
- def scanKitDir( self, path ):
- dirlist = os.listdir( path )
- for fpath in dirlist:
- try :
- self.addKit( fpath )
- except :
- print 'ERROR: scanning kit path %s: file %s invalid' % (path, fpath)
-
def getLabels( self ):
return self.labelSet.keys()
diff --git a/common/Util/InstrumentPanel.py b/common/Util/InstrumentPanel.py
index 8cac210..fc933b9 100644
--- a/common/Util/InstrumentPanel.py
+++ b/common/Util/InstrumentPanel.py
@@ -6,6 +6,7 @@ import gtk
import time
+import common.Util.InstrumentDB as InstrumentDB
import common.Config as Config
from common.Util.ThemeWidgets import *
Tooltips = Config.Tooltips
@@ -14,6 +15,7 @@ class InstrumentPanel( gtk.EventBox ):
def __init__(self,setInstrument = None, playInstrument = None, enterMode = False, micRec = None, synthRec = None, rowLen = 8, _instDic = None, force_load = True ):
gtk.EventBox.__init__(self)
+ self.instrumentDB = InstrumentDB.getRef()
self.setInstrument = setInstrument
self.playInstrument = playInstrument
self.micRec = micRec
@@ -116,10 +118,10 @@ class InstrumentPanel( gtk.EventBox ):
if timeout >= 0 and time.time() > timeout: return False
if loadStage[1] == 1:
- keys = Config.INSTRUMENTS.keys()
+ keys = self.instrumentDB.instNamed.keys()
for i in range(loadStage[2], len(keys)):
key = keys[i]
- instrument = Config.INSTRUMENTS[key]
+ instrument = self.instrumentDB.instNamed[key]
if key[0:4] != 'drum' and key[0:4] != 'guid' and key[0:3] != 'mic' and key[0:3] != 'lab':
self.instrumentList["all"].append( key )
if key[0:4] != 'drum' and key[0:4] != 'guid' and key[0:3] != 'mic' and key[0:3] != 'lab':
@@ -333,9 +335,9 @@ class DrumPanel( gtk.EventBox ):
self.setDrum = setDrum
self.instrumentList = []
- keys = Config.INSTRUMENTS.keys()
- for key in Config.INSTRUMENTS.keys():
- if Config.INSTRUMENTS[key].category == "kit":
+ keys = self.instrumentDB.instNamed.keys()
+ for key in self.instrumentDB.instNamed.keys():
+ if self.instrumentDB.instNamed[key].category == "kit":
self.instrumentList.append( key )
self.instrumentList.sort()
self.drawDrums()
diff --git a/common/Util/Instruments.py b/common/Util/Instruments.py
new file mode 100644
index 0000000..9382d9e
--- /dev/null
+++ b/common/Util/Instruments.py
@@ -0,0 +1,240 @@
+import common.Config as Config
+import common.Util.InstrumentDB as InstrumentDB
+
+LOW = Config.LOW
+MID = Config.MID
+HIGH = Config.HIGH
+PUNCH = Config.PUNCH
+
+INSTRUMENT_TABLE_OFFSET = Config.INSTRUMENT_TABLE_OFFSET
+INST_FREE = Config.INST_FREE
+INST_TIED = Config.INST_TIED
+INST_SIMP = Config.INST_SIMP
+INST_PERC = Config.INST_PERC
+
+instrumentDB = InstrumentDB.getRef()
+
+
+def _addInstrument( name, csoundInstrumentId, instrumentRegister, category, loopStart, loopEnd, crossDur, ampScale = 1, kit = None ):
+ instrumentDB.addInstrumentFromArgs( name, csoundInstrumentId, instrumentRegister, loopStart, loopEnd, crossDur, ampScale, kit, name, Config.LIB_DIR+"/Images/"+name+".png", category )
+
+
+_addInstrument( "mic1", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1 )
+_addInstrument( "mic2", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1 )
+_addInstrument( "mic3", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1 )
+_addInstrument( "mic4", INST_TIED, MID, 'mysounds', .01, 1.99, .01, 1 )
+_addInstrument( "lab1", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 )
+_addInstrument( "lab2", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 )
+_addInstrument( "lab3", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 )
+_addInstrument( "lab4", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 )
+_addInstrument( "lab5", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 )
+_addInstrument( "lab6", INST_SIMP, MID, 'mysounds', 0, 0, 0, 1 )
+_addInstrument( "ounk", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
+_addInstrument( "gam", INST_TIED, HIGH, 'percussions', .69388, .7536, .02922, 1 )
+_addInstrument( "guit", INST_TIED, MID, 'strings', .08592, .75126, .33571, 1.3 )
+_addInstrument( "koto", INST_TIED, HIGH, 'strings', .56523, .70075, .05954, 1 )
+_addInstrument( "clarinette", INST_TIED, MID, 'winds', 1.635276375, 2.72956523438, .2, 0.6 )
+_addInstrument( "flute", INST_TIED, MID, 'winds', .47169, .53693, .02481, 1 )
+_addInstrument( "drum1hatpedal", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum1hatshoulder", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum1hardride", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum1ridebell", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum1snare", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum1snaresidestick", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum1crash", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum1splash", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum1tom", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum1floortom", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1)
+_addInstrument( "drum1chine", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum1kick", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "piano", INST_TIED, MID, 'keyboard', 0.8883, 1.420524, .13575, 1 )
+_addInstrument( "dog", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
+_addInstrument( "duck", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
+_addInstrument( "drum2darbukadoom", INST_SIMP, LOW, 'percussions', 0, 0 ,0, 1 )
+_addInstrument( "drum2darbukapied", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum2darbukapiedsoft", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum2hatflanger", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum2darbukatak", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum2darbukafinger", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum2darbukaroll", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum2darbukaslap", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum2hatpied", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum2tambourinepied", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum2hatpied2", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum2tambourinepiedsoft", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum3cowbell", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum3cowbelltip", INST_SIMP, MID, 'percussions', 0, 0, 0, 1)
+_addInstrument( "drum3cup", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum3djembelow", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum3djembemid", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum3djembesidestick", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum3djembeslap", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum3djembestickmid", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum3metalstand", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum3pedalperc", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum3rainstick", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum3tambourinehigh", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum3tambourinelow", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "harmonica", INST_TIED, MID, 'winds', .1531, .19188, .01792, 1 )
+_addInstrument( "alarm", INST_TIED, MID, 'concret', 1.37555859375, 2.0286015625, .0675, 0.5 )
+_addInstrument( "bird", INST_TIED, MID, 'animals', .1, 1, .05, 1 )
+_addInstrument( "cat", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
+_addInstrument( "duck2", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
+_addInstrument( "bottle", INST_TIED, MID, 'concret', .20532, .41064, .05292, 1 )
+_addInstrument( "clang", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "ow", INST_SIMP, MID, 'people', 0, 0, 0, 1 )
+_addInstrument( "sheep", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
+_addInstrument( "water", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "zap", INST_TIED, MID, 'keyboard', .299, .7323, .09895, 1 )
+_addInstrument( "trumpet", INST_TIED, MID, 'winds', .91195, 1.652909375, .05375, 0.5)
+_addInstrument( "bubbles", INST_TIED, MID, 'concret', 0.02, 1.177, 0.02, 1)
+_addInstrument( "marimba", INST_TIED, MID, 'percussions', .18883789, .343623047, .07625, 0.5)
+_addInstrument( "triangle", INST_TIED, MID, 'percussions', 2.27261836, 3.2965453, .2, 0.6)
+_addInstrument( "laugh", INST_SIMP, MID, 'people', 0, 0, 0, 1 )
+_addInstrument( "voix", INST_TIED, MID, 'people', .89608, .96092, .02343, 1 )
+_addInstrument( "cling", INST_TIED, MID, 'keyboard', .09096, .7878, .18026, 1 )
+_addInstrument( "byke", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "door", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "basse", INST_TIED, MID, 'strings', 0.50470875, 0.833315, 0.09375, 1 )
+_addInstrument( "acguit", INST_TIED, MID, 'strings', 1.4037, 1.84235625, 0.2, 0.8 )
+_addInstrument( "diceinst", INST_SIMP, MID, 'concret', 0, 0, 0, 1.3 )
+_addInstrument( "didjeridu", INST_TIED, LOW, 'winds', .55669, 1.73704, .09178, 2 )
+_addInstrument( "harmonium", INST_TIED, MID, 'keyboard', .242032, .898165625, .2, 0.5 )
+_addInstrument( "horse", INST_SIMP, MID, 'animals', 0, 0, 0, 1 )
+_addInstrument( "kalimba", INST_TIED, MID, 'percussions', .20751, .30161, .04658, 1.3 )
+_addInstrument( "mando", INST_TIED, MID, 'strings', 0.507107031, 0.934144531, 0.2, 0.5 )
+_addInstrument( "ocarina", INST_TIED, MID, 'winds', .06612, .19033, .01776, 1 )
+_addInstrument( "rhodes", INST_TIED, MID, 'keyboard', 0.58100625, 0.821625, 0.067, 1 )
+_addInstrument( "saxo", INST_TIED, MID, 'winds', 1.161051953, 3.001209765, .05, 0.5 )
+_addInstrument( "shenai", INST_TIED, MID, 'winds', .29003, .33072, .00634, 0.7 )
+_addInstrument( "sitar", INST_TIED, MID, 'strings', 1.1361625, 1.575134375, .183, 0.4 )
+_addInstrument( "tuba", INST_TIED, LOW, 'winds', .51063, .58384, .035, 1 )
+_addInstrument( "violin", INST_TIED, MID, 'strings', .105, .30656, .028, 1 )
+_addInstrument( "guidice1", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "guidice2", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "guidice3", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "guidice4", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "guidice5", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "guidice6", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "guidice7", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "guidice8", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "guidice9", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "guidice10", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "drum4afrofeet", INST_SIMP, LOW, 'percussions', 0, 0 ,0, 1 )
+_addInstrument( "drum4fingersn", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum4mutecuic", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum4stompbass", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum4tambouri", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum4tr707clap", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum4tr707open", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum4tr808closed", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum4tr808sn", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum4tr909bass", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum4tr909kick", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum4tr909sn", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum5timablesslap", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum5congagraveouvert", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum5timablesaiguslap", INST_SIMP, LOW, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum5congagraveferme", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum5guiroretour", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum5vibraslap", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum5congaaiguouvert", INST_SIMP, MID, 'percussions', 0, 0 ,0, 1 )
+_addInstrument( "drum5quicamedium", INST_SIMP, PUNCH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum5quicaaigu", INST_SIMP, MID, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum5agogograve", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum5bongoaiguouvert", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum5agogoaigu", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "drum5bongograveouvert", INST_SIMP, HIGH, 'percussions', 0, 0, 0, 1 )
+_addInstrument( "camera", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "car", INST_TIED, MID, 'concret', .67, 1.05761, .01, 0.7 )
+_addInstrument( "cello", INST_TIED, MID, 'strings', 0.4761, 0.92244375, 0.19125, .75 )
+_addInstrument( "chimes", INST_TIED, MID, 'percussions', 4.104825, 5.644134375, .02, 1 )
+_addInstrument( "crash", INST_SIMP, MID, 'concret', 0, 0, 0, 1 )
+_addInstrument( "guit2", INST_TIED, MID, 'strings', 1.186341406, 1.929568266, .2, 0.5 )
+_addInstrument( "plane", INST_SIMP, MID, 'concret', 0, 0, 0, 0.7 )
+_addInstrument( "slap", INST_SIMP, MID, 'concret', 0, 0, 0, 0.7 )
+
+try:
+ ifile = open(PREF_DIR + '/sounds_settings', 'r')
+ for line in ifile.readlines():
+ list = line.split()
+ _addInstrument(list[0], int(list[1]), int(list[2]), list[3], list[4], float(list[5]), float(list[6]), float(list[7]), float(list[8]))
+except:
+ pass
+
+
+DRUM1KIT = { 24 : "drum1kick",
+ 26 : "drum1floortom",
+ 28 : "drum1tom",
+ 30 : "drum1chine",
+ 32 : "drum1splash",
+ 34 : "drum1crash",
+ 36 : "drum1snaresidestick",
+ 38 : "drum1snaresidestick",
+ 40 : "drum1snare",
+ 42 : "drum1ridebell",
+ 44 : "drum1hardride",
+ 46 : "drum1hatshoulder",
+ 48 : "drum1hatpedal" }
+
+DRUM2KIT = { 24 : "drum2darbukadoom",
+ 26 : "drum2darbukapied",
+ 28 : "drum2darbukapiedsoft",
+ 30 : "drum2hatflanger",
+ 32 : "drum2darbukatak",
+ 34 : "drum2darbukatak",
+ 36 : "drum2darbukafinger",
+ 38 : "drum2darbukaroll",
+ 40 : "drum2darbukaslap",
+ 42 : "drum2hatpied",
+ 44 : "drum2tambourinepied",
+ 46 : "drum2hatpied2",
+ 48 : "drum2tambourinepiedsoft" }
+
+DRUM3KIT = { 24 : "drum3djembelow",
+ 26 : "drum3pedalperc",
+ 28 : "drum3djembeslap",
+ 30 : "drum3tambourinehigh",
+ 32 : "drum3tambourinelow",
+ 34 : "drum3rainstick",
+ 36 : "drum3djembemid",
+ 38 : "drum3djembesidestick",
+ 40 : "drum3djembestickmid",
+ 42 : "drum3cowbell",
+ 44 : "drum3cowbelltip",
+ 46 : "drum3cup",
+ 48 : "drum3metalstand" }
+
+DRUM4KIT = { 24 : "drum4afrofeet",
+ 26 : "drum4tr909kick",
+ 28 : "drum4tr909bass",
+ 30 : "drum4stompbass",
+ 32 : "drum4tr707open",
+ 34 : "drum4mutecuic",
+ 36 : "drum4tr808sn",
+ 38 : "drum4tr707clap",
+ 40 : "drum4tr909sn",
+ 42 : "drum4tambouri",
+ 44 : "drum4fingersn",
+ 46 : "drum4fingersn",
+ 48 : "drum4tr808closed" }
+
+DRUM5KIT = { 24 : "drum5timablesslap",
+ 26 : "drum5timablesaiguslap",
+ 28 : "drum5congagraveouvert",
+ 30 : "drum5quicamedium",
+ 32 : "drum5guiroretour",
+ 34 : "drum5vibraslap",
+ 36 : "drum5congagraveferme",
+ 38 : "drum5quicaaigu",
+ 40 : "drum5congaaiguouvert",
+ 42 : "drum5agogoaigu",
+ 44 : "drum5bongograveouvert",
+ 46 : "drum5agogograve",
+ 48 : "drum5bongoaiguouvert" }
+
+_addInstrument( "drum1kit", 0, 0, "percussions", 0, 0, 0, 1, DRUM1KIT )
+_addInstrument( "drum2kit", 0, 0, "percussions", 0, 0, 0, 1, DRUM2KIT )
+_addInstrument( "drum3kit", 0, 0, "percussions", 0, 0, 0, 1, DRUM3KIT )
+_addInstrument( "drum4kit", 0, 0, "percussions", 0, 0, 0, 1, DRUM4KIT )
+_addInstrument( "drum5kit", 0, 0, "percussions", 0, 0, 0, 1, DRUM5KIT )
diff --git a/common/Util/NoteDB.py b/common/Util/NoteDB.py
index e62ca32..646f8d8 100644
--- a/common/Util/NoteDB.py
+++ b/common/Util/NoteDB.py
@@ -1,4 +1,4 @@
-
+import common.Util.InstrumentDB as InstrumentDB
import common.Config as Config
class PARAMETER:
@@ -35,13 +35,14 @@ class Note:
class Page:
def __init__( self, beats, color = 0, instruments = False, local = True ): # , tempo, insruments, color = 0 ):
+ self.instrumentDB = InstrumentDB.getRef()
self.beats = beats
self.ticks = beats*Config.TICKS_PER_BEAT
self.color = color
if not instruments:
- self.instruments = [ Config.INSTRUMENTS["kalimba"].instrumentId for i in range(Config.NUMBER_OF_TRACKS-1) ] + [ Config.INSTRUMENTS["drum1kit"].instrumentId ]
+ self.instruments = [ self.instrumentDB.instNamed["kalimba"].instrumentId for i in range(Config.NUMBER_OF_TRACKS-1) ] + [ self.instrumentDB.instNamed["drum1kit"].instrumentId ]
else:
self.instruments = instruments[:]
@@ -85,6 +86,7 @@ class NoteListener:
class NoteDB:
def __init__( self ):
+ self.instrumentDB = InstrumentDB.getRef()
self.noteD = {} # bins containing all the notes by page, track, and id
# structure self.noteD[pageId][trackIndex][noteId]
@@ -283,7 +285,7 @@ class NoteDB:
for page in pages:
list = []
for track in range(Config.NUMBER_OF_TRACKS):
- list.append(Config.INSTRUMENTSID[self.pages[page].instruments[track]].name)
+ list.append(self.instrumentDB.instId[self.pages[page].instruments[track]].name)
dict[page] = list[:]
return dict