Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TamTamMini.activity
diff options
context:
space:
mode:
authorNat <natcl@hotmail.com>2007-10-26 20:46:18 (GMT)
committer Nat <natcl@hotmail.com>2007-10-26 20:46:18 (GMT)
commit1a4a49865ea6543177a9734b80fb3a9227808b45 (patch)
tree384aff89f07f06960977f5a283f1625a72523ff9 /TamTamMini.activity
parent7c0c78e17dccfdd34c78c7a10ceb8b315986d8de (diff)
parent2e1f26239411a0448c31f4911263ada60dbf3514 (diff)
Merge branch 'master' of git+ssh://natcl@dev.laptop.org/git/projects/tamtam
Diffstat (limited to 'TamTamMini.activity')
-rw-r--r--TamTamMini.activity/.DS_Storebin0 -> 6148 bytes
-rw-r--r--TamTamMini.activity/Config.py603
-rw-r--r--TamTamMini.activity/MANIFEST6
-rw-r--r--TamTamMini.activity/Mini/Fillin.py2
-rw-r--r--TamTamMini.activity/Mini/GenRythm.py18
-rw-r--r--TamTamMini.activity/Mini/InstrumentPanel.py22
-rw-r--r--TamTamMini.activity/Mini/KeyboardStandAlone.py14
-rwxr-xr-xTamTamMini.activity/Mini/Loop.py10
-rw-r--r--TamTamMini.activity/Mini/MiniSequencer.py2
-rw-r--r--TamTamMini.activity/Mini/NoteStdAlone.py103
-rw-r--r--TamTamMini.activity/Mini/RythmGenerator.py30
-rw-r--r--TamTamMini.activity/Mini/miniTamTamMain.py132
-rw-r--r--TamTamMini.activity/Mini/miniToolbars.py258
-rw-r--r--TamTamMini.activity/TamTamMini.py14
-rwxr-xr-xTamTamMini.activity/icons/accept.svg18
15 files changed, 370 insertions, 862 deletions
diff --git a/TamTamMini.activity/.DS_Store b/TamTamMini.activity/.DS_Store
new file mode 100644
index 0000000..6926115
--- /dev/null
+++ b/TamTamMini.activity/.DS_Store
Binary files differ
diff --git a/TamTamMini.activity/Config.py b/TamTamMini.activity/Config.py
deleted file mode 100644
index 6d164bb..0000000
--- a/TamTamMini.activity/Config.py
+++ /dev/null
@@ -1,603 +0,0 @@
-# -*- 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
-
-SugarMode = True
-
-if os.path.isfile("DEBUG"):
- f = open("DEBUG")
- l = f.read(10)
- f.close()
- if len(l): DEBUG = int( l )
- else: DEBUG = 99
-else:
- DEBUG = 0
-print "Debug Level %d" % (DEBUG)
-
-
-TAM_TAM_ROOT = get_bundle_path()
-print 'INFO: loaded TAMTAM_ROOT=%s' % TAM_TAM_ROOT
-
-
-#PATHS
-if os.path.isdir("/usr/share/tamtam/Sounds"):
- SOUNDS_DIR = "/usr/share/tamtam/Sounds"
- LIB_DIR = "/usr/share/tamtam"
-else:
- SOUNDS_DIR = "/usr/share/activities/TamTamEdit.activity/common/Resources/Sounds"
- LIB_DIR = "/usr/share/activities/TamTamEdit.activity/common/Resources"
-FILES_DIR = TAM_TAM_ROOT + "/common/Resources"
-TUNE_DIR='/'
-SYNTH_DIR='/'
-if SugarMode == True:
- PREF_DIR = env.get_profile_path() + '/tamtam'
- TUNE_DIR=env.get_profile_path() + '/tamtam/tunes'
- SYNTH_DIR=env.get_profile_path() + '/tamtam/synthlab'
- SNDS_DIR=env.get_profile_path() + '/tamtam/snds'
- SCRATCH_DIR = PREF_DIR + "/.scratch/"
-else:
- PREF_DIR = os.getenv('HOME') + '/.tamtam'
- TUNE_DIR= os.getenv('HOME') + '/.tamtam/tunes'
- SYNTH_DIR= os.getenv('HOME') + '/.tamtam/synthlab'
- SNDS_DIR= os.getenv('HOME') + '/.tamtam/snds'
- SCRATCH_DIR = PREF_DIR + "/.scratch/"
-
-#PLUGIN
-PLUGIN_DEBUG = PREF_DIR + "/clooper.log"
-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, soundClass, category, loopStart, loopEnd, crossDur, ampScale = 1, kit = None ):
- self.name = name
- self.instrumentId = instrumentId
- self.csoundInstrumentId = csoundInstrumentId
- self.instrumentRegister = instrumentRegister
- self.soundClass = soundClass
- self.category = category
- self.loopStart = loopStart
- self.loopEnd = loopEnd
- self.crossDur = crossDur
- self.ampScale = ampScale
- self.kit = kit
- #print (self.name, self.instrumentId, self.csoundInstrumentId, self.instrumentRegister, self.soundClass, self.category, self.loopStart, self.loopEnd, self.crossDur)
-
-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
-INST_SIMP = 5011
-INST_PERC = 5021
-
-CATEGORIES = ['all','animals','concret','keyboard','people','percussions','strings','winds', 'mysounds']
-
-instrumentDB = InstrumentDB.getRef()
-
-_nextInstrumentId = [0]
-INSTRUMENTS = {}
-def _addInstrument( name, csoundInstrumentId, instrumentRegister, soundClass, category, loopStart, loopEnd, crossDur, kit = None ):
- ampScale = 1
- if not QUICKLOAD or name[0:4] == "drum" or name in ["flute", "kalimba"]: # quick load
- INSTRUMENTS[name] = Instrument( name, _nextInstrumentId[0], csoundInstrumentId, instrumentRegister, soundClass, category, loopStart, loopEnd, crossDur, ampScale, kit )
- instrumentDB.addInstrumentFromArgs( name, name, instrumentRegister, loopStart, loopEnd, crossDur, ampScale, name, FILES_DIR+"/Images/"+name+".png", [ category ] )
- _nextInstrumentId[0] += 1
-
-
-_addInstrument( "mic1", INST_TIED, MID, 'melo', 'mic', .01, 1.99, .01 )
-_addInstrument( "mic2", INST_TIED, MID, 'melo', 'mic', .01, 1.99, .01 )
-_addInstrument( "mic3", INST_TIED, MID, 'melo', 'mic', .01, 1.99, .01 )
-_addInstrument( "mic4", INST_TIED, MID, 'melo', 'mic', .01, 1.99, .01 )
-_addInstrument( "lab1", INST_SIMP, MID, 'melo', 'lab', 0, 0, 0 )
-_addInstrument( "lab2", INST_SIMP, MID, 'melo', 'lab', 0, 0, 0 )
-_addInstrument( "lab3", INST_SIMP, MID, 'melo', 'lab', 0, 0, 0 )
-_addInstrument( "lab4", INST_SIMP, MID, 'melo', 'lab', 0, 0, 0 )
-_addInstrument( "lab5", INST_SIMP, MID, 'melo', 'lab', 0, 0, 0 )
-_addInstrument( "lab6", INST_SIMP, MID, 'melo', 'lab', 0, 0, 0 )
-_addInstrument( "ounk", INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 )
-_addInstrument( "gam", INST_TIED, HIGH, 'melo', 'percussions', .69388, .7536, .02922 )
-_addInstrument( "guit", INST_TIED, MID, 'melo', 'strings', .08592, .75126, .33571 )
-_addInstrument( "koto", INST_TIED, HIGH, 'melo', 'strings', .56523, .70075, .05954 )
-_addInstrument( "clarinette", INST_TIED, MID, 'melo', 'winds', .57905, .73319, .04934 )
-_addInstrument( "flute", INST_TIED, MID, 'melo', 'winds', .47169, .53693, .02481 )
-_addInstrument( "drum1hatpedal", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum1hatshoulder", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum1hardride", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum1ridebell", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum1snare", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum1snaresidestick", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum1crash", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum1splash", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum1tom", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum1floortom", INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0)
-_addInstrument( "drum1chine", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum1kick", INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "piano", INST_TIED, MID, 'melo', 'keyboard', 0.8883, 1.420524, .13575 )
-_addInstrument( "dog", INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 )
-_addInstrument( "duck", INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 )
-_addInstrument( "drum2darbukadoom", INST_SIMP, LOW, 'drum', 'drum', 0, 0 ,0 )
-_addInstrument( "drum2darbukapied", INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum2darbukapiedsoft", INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum2hatflanger", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum2darbukatak", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum2darbukafinger", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum2darbukaroll", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum2darbukaslap", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum2hatpied", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum2tambourinepied", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum2hatpied2", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum2tambourinepiedsoft", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum3cowbell", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum3cowbelltip", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0)
-_addInstrument( "drum3cup", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum3djembelow", INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum3djembemid", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum3djembesidestick", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum3djembeslap", INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum3djembestickmid", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum3metalstand", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum3pedalperc", INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum3rainstick", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum3tambourinehigh", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum3tambourinelow", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "harmonica", INST_TIED, MID, 'melo', 'winds', .1531, .19188, .01792 )
-_addInstrument( "alarm", INST_TIED, MID, 'melo', 'concret', 1.37555859375, 2.0286015625, .0675 )
-_addInstrument( "bird", INST_TIED, MID, 'melo', 'animals', .1, 1, .05 )
-_addInstrument( "cat", INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 )
-_addInstrument( "duck2", INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 )
-_addInstrument( "bottle", INST_TIED, MID, 'melo', 'concret', .20532, .41064, .05292 )
-_addInstrument( "clang", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "ow", INST_SIMP, MID, 'melo', 'people', 0, 0, 0 )
-_addInstrument( "sheep", INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 )
-_addInstrument( "water", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "zap", INST_TIED, MID, 'melo', 'keyboard', .299, .7323, .09895 )
-_addInstrument( "trumpet", INST_TIED, MID, 'melo', 'winds', .39934, .45537, .02729)
-_addInstrument( "bubbles", INST_TIED, MID, "melo", 'concret', 0.02, 1.177, 0.02)
-_addInstrument( "marimba", INST_TIED, MID, "melo", 'percussions', .26545, .33098, .03087)
-_addInstrument( "triangle", INST_TIED, MID, "melo", 'percussions', 1.21002, 1.31805, .01268)
-_addInstrument( "laugh", INST_SIMP, MID, 'melo', 'people', 0, 0, 0 )
-_addInstrument( "voix", INST_TIED, MID, 'melo', 'people', .89608, .96092, .02343 )
-_addInstrument( "cling", INST_TIED, MID, 'melo', 'keyboard', .09096, .7878, .18026 )
-_addInstrument( "byke", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "door", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "basse", INST_TIED, MID, 'melo', 'strings', 0.50470875, 0.833315, 0.09375 )
-_addInstrument( "acguit", INST_TIED, MID, 'melo', 'strings', 1.4037, 1.84235625, 0.2 )
-_addInstrument( "diceinst", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "didjeridu", INST_TIED, LOW, 'melo', 'winds', .55669, 1.73704, .09178 )
-_addInstrument( "harmonium", INST_TIED, MID, 'melo', 'keyboard', .04674, .41073, .18384 )
-_addInstrument( "horse", INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 )
-_addInstrument( "kalimba", INST_TIED, MID, 'melo', 'percussions', .20751, .30161, .04658 )
-_addInstrument( "mando", INST_TIED, MID, 'melo', 'strings', 0.316548, 0.532008, 0.02875 )
-_addInstrument( "ocarina", INST_TIED, MID, 'melo', 'winds', .06612, .19033, .01776 )
-_addInstrument( "rhodes", INST_TIED, MID, 'melo', 'keyboard', 0.58100625, 0.821625, 0.067 )
-_addInstrument( "saxo", INST_TIED, MID, 'melo', 'winds', .53722, .6583, .05264 )
-_addInstrument( "shenai", INST_TIED, MID, 'melo', 'winds', .29003, .33072, .00634 )
-_addInstrument( "sitar", INST_TIED, MID, 'melo', 'strings', .63187, .67882, .01654 )
-_addInstrument( "tuba", INST_TIED, LOW, 'melo', 'winds', .51063, .58384, .035 )
-_addInstrument( "violin", INST_TIED, MID, 'melo', 'strings', .105, .30656, .028 )
-_addInstrument( "guidice1", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "guidice2", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "guidice3", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "guidice4", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "guidice5", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "guidice6", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "guidice7", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "guidice8", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "guidice9", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "guidice10", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "drum4afrofeet", INST_SIMP, LOW, 'drum', 'drum', 0, 0 ,0 )
-_addInstrument( "drum4fingersn", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum4mutecuic", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum4stompbass", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum4tambouri", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum4tr707clap", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum4tr707open", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum4tr808closed", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum4tr808sn", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum4tr909bass", INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum4tr909kick", INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum4tr909sn", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum5timablesslap", INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum5congagraveouvert", INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum5timablesaiguslap", INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum5congagraveferme", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum5guiroretour", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum5vibraslap", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum5congaaiguouvert", INST_SIMP, MID, 'drum', 'drum', 0, 0 ,0 )
-_addInstrument( "drum5quicamedium", INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum5quicaaigu", INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum5agogograve", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum5bongoaiguouvert", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum5agogoaigu", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "drum5bongograveouvert", INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 )
-_addInstrument( "camera", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "car", INST_TIED, MID, 'melo', 'concret', .67, 1.05761, .01 )
-_addInstrument( "cello", INST_TIED, MID, 'melo', 'strings', 0.4761, 0.92244375, 0.19125 )
-_addInstrument( "chimes", INST_TIED, MID, 'melo', 'percussions', .09, 2.97633, .01 )
-_addInstrument( "crash", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "guit2", INST_TIED, MID, 'melo', 'strings', .33, 1.1583, .02 )
-_addInstrument( "plane", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-_addInstrument( "slap", INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )
-
-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, 0, "kit", 0, 0, 0, DRUM1KIT )
-_addInstrument( "drum2kit", 0, 0, 0, "kit", 0, 0, 0, DRUM2KIT )
-_addInstrument( "drum3kit", 0, 0, 0, "kit", 0, 0, 0, DRUM3KIT )
-_addInstrument( "drum4kit", 0, 0, 0, "kit", 0, 0, 0, DRUM4KIT )
-_addInstrument( "drum5kit", 0, 0, 0, "kit", 0, 0, 0, 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_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
-#################
-
-LANGUAGE = 'En'
-if os.path.isdir("/usr/share/tamtam/Images"):
- IMAGE_ROOT = '/usr/share/tamtam/Images/'
-else:
- IMAGE_ROOT = "/usr/share/activities/TamTamEdit.activity/common/Resources/Images/"
-MAIN_WINDOW_PADDING = 5
-
-BG_COLOR = '#404040'
-FG_COLOR = '#818286'
-
-NOTE_HEIGHT = 9 # pixels
-NOTE_IMAGE_PADDING = 6
-NOTE_IMAGE_PADDING_MUL2 = NOTE_IMAGE_PADDING*2
-NOTE_IMAGE_TAIL = 1059
-NOTE_IMAGE_ENDLENGTH = 12
-HIT_HEIGHT = 13 # pixels
-HIT_IMAGE_PADDING = 6
-HIT_IMAGE_PADDING_MUL2 = HIT_IMAGE_PADDING*2
-TRACK_SPACING = 4
-TRACK_SPACING_DIV2 = TRACK_SPACING//2
-TRACK_COLORS = [ ( "#00290B", "#00E847" ), \
- ( "#3F0200", "#E72500" ), \
- ( "#002642", "#0090EA" ), \
- ( "#313D00", "#F9EF00" ), \
- ( "#17083B", "#4A00ED" ) ]
-#TRACK_COLORS = [ ( "#00591B", "#00E847" ), \
-# ( "#6F1200", "#E72500" ), \
-# ( "#004682", "#0090EA" ), \
-# ( "#716D00", "#F9EF00" ), \
-# ( "#37187B", "#4A00ED" ) ]
-BEAT_COLOR = "#999999"
-BEAT_LINE_SIZE = 2
-PLAYHEAD_COLOR = "#666666"
-PLAYHEAD_SIZE = 2
-PLAYHEAD_SIZE_DIV2 = PLAYHEAD_SIZE/2.0
-MARQUEE_COLOR = "#FFFFFF"
-MARQUEE_SIZE = 2
-
-PAGE_BORDER_SIZE = 2
-PAGE_SELECTED_BORDER_SIZE = 5
-PAGE_WIDTH = 100
-PAGE_HEIGHT = 25
-
-PAGE_THUMBNAIL_WIDTH = 92
-PAGE_THUMBNAIL_WIDTH_DIV2 = PAGE_THUMBNAIL_WIDTH/2
-PAGE_THUMBNAIL_HEIGHT = 65
-
-THUMBNAIL_TRACK_RECT = [ ( 2, 4, 83, 10 ), \
- ( 2, 14, 83, 10 ), \
- ( 2, 24, 83, 10 ), \
- ( 2, 34, 83, 10 ), \
- ( 2, 44, 83, 13 ) ]
-THUMBNAIL_DRAG_COLOR = "#000000"
-THUMBNAIL_TRACK_COLOR = "#FF0000"
-THUMBNAIL_SELECTED_COLOR = "#2266FF"
-THUMBNAIL_DISPLAYED_COLOR = "#CC1133"
-
-TOOLBAR_BCK_COLOR = '#404040'
-WHITE_COLOR = '#FFFFFF'
-### miniTamTam/SYNTHLAB SPECIFIC ###
-INST_BCK_COLOR = '#999999'
-PANEL_BCK_COLOR = '#CCCCCC'
-PANEL_COLOR = '#CCCCCC'
-SL_LINE_COLOR = "#666666"
-SL_HIGHLIGHT_COLOR = "#FFFFFF"
-SL_OVER_WIRE_COLOR = "#FFFFFF"
-SL_OVER_GATE_COLOR = "#00FF18"
-SL_OVER_GATE_REJECT_COLOR = "#B30000"
-PANEL_RADIUS = 10
-PANEL_SPACING = 2
-
-###Instrument Panel###
-CATEGORY_BCK_COLOR = '#222222'
-INSTRUMENT_GRID_COLOR = '#CCCCCC'
-
-###Welcome Screen Specific###
-WS_PANEL_COLOR = '#404040'
-WS_BCK_COLOR = '#CCCCCC'
-
-# hardware keycodes for mod keys
-MOD_LSHIFT = 50
-MOD_RSHIFT = 62
-MOD_LCTRL = 37
-MOD_RCTRL = 109
-MOD_LALT = 64
-MOD_RALT = 113
-
-
-
-########
-## Things that don't belong!
-#######
-class _ModKeys:
- def __init__( self ):
- self.shiftDown = False
- self.ctrlDown = False
- self.altDown = False
-
- def keyPress( self, code ):
- if code == MOD_LSHIFT or code == MOD_RSHIFT: self.shiftDown = True
- elif code == MOD_LCTRL or code == MOD_RCTRL: self.ctrlDown = True
- elif code == MOD_LALT or code == MOD_RALT: self.altDown = True
-
- def keyRelease( self, code ):
- if code == MOD_LSHIFT or code == MOD_RSHIFT: self.shiftDown = False
- elif code == MOD_LCTRL or code == MOD_RCTRL: self.ctrlDown = False
- elif code == MOD_LALT or code == MOD_RALT: self.altDown = False
-
-ModKeys = _ModKeys()
-
-
-############
-## EDIT DEFAULTS
-############
-
-#DEFAULTS
-PLAYER_TEMPO = 100
-PLAYER_TEMPO_LOWER = 30
-PLAYER_TEMPO_UPPER = 160
-DEFAULT_VOLUME = 50
-
-#NUMERICAL CONSTANTS
-NUMBER_OF_POSSIBLE_PITCHES = 25
-MINIMUM_PITCH = 24
-MAXIMUM_PITCH = MINIMUM_PITCH + NUMBER_OF_POSSIBLE_PITCHES - 1
-NUMBER_OF_POSSIBLE_PITCHES_DRUM = 13
-PITCH_STEP_DRUM = 2
-MINIMUM_PITCH_DRUM = 24
-MAXIMUM_PITCH_DRUM = MINIMUM_PITCH_DRUM + PITCH_STEP_DRUM*(NUMBER_OF_POSSIBLE_PITCHES_DRUM - 1)
-MINIMUM_NOTE_DURATION = 1 # ticks
-MS_PER_MINUTE = 60000.0
-TICKS_PER_BEAT = 12
-TICKS_PER_BEAT_DIV2 = TICKS_PER_BEAT/2
-MAXIMUM_BEATS = 12 # maximum beats per page
-NUMBER_OF_TRACKS = 5
-NUMBER_OF_PAGES = 2
-
-MINIMUM_AMPLITUDE = 0
-MAXIMUM_AMPLITUDE = 1
-
-DEFAULT_GRID = 3
-DEFAULT_GRID_DIV2 = DEFAULT_GRID / 2.0
-
-
-####################
-## ToolTips
-####################
-LANGUAGE = 'en'
-exec 'from common.Resources.tooltips_%s import Tooltips' % LANGUAGE
-
-
-####################
-## KeyMapping
-####################
-
-LOOP_KEYS = [17, 18, 19, 20, 21, 32, 33, 34, 35, 45, 46, 47, 48, 51, 60, 61]
-# Key = Hardware Keycode Value = Note
-
-KEY_MAP_PIANO = {24:36, #Q
- 25:38, #W
- 26:40, #E
- 27:41, #R
- 28:43, #T
- 29:45, #Y
- 30:47, #U
- 31:48, #I
-
- 11:37, #2
- 12:39, #3
- 14:42, #5
- 15:44, #6
- 16:46, #7
-
- 39:25, #S
- 40:27, #D
- 42:30, #G
- 43:32, #H
- 44:34, #J
- 46:37, #L
-
- 52:24, #Z
- 53:26, #X
- 54:28, #C
- 55:29, #V
- 56:31, #B
- 57:33, #N
- 58:35, #M
- 59:36} #,
-
-KEY_MAP_NOTPIANO = {24:24, #Q
- 25:25, #W
- 26:26, #E
- 27:27, #R
- 28:28, #T
- 29:29, #Y
- 30:30, #U
- 31:31, #I
- 32:32, #O
- 33:33, #P
-
- 38:34, #A
- 39:35, #S
- 40:36, #D
- 41:37, #F
- 42:38, #G
- 43:39, #H
- 44:40, #J
- 45:41, #K
- 46:42, #L
-
- 52:43, #Z
- 53:44, #X
- 54:45, #C
- 55:46, #V
- 56:47, #B
- 57:48} #N
-
-KEY_MAP = KEY_MAP_PIANO
diff --git a/TamTamMini.activity/MANIFEST b/TamTamMini.activity/MANIFEST
index 67d6985..03beac4 100644
--- a/TamTamMini.activity/MANIFEST
+++ b/TamTamMini.activity/MANIFEST
@@ -1,10 +1,10 @@
MANIFEST
NEWS
setup.py
-Config.py
TamTamMini.py
activity/activity-tamtammini.svg
activity/activity.info
+icons/accept.svg
icons/keyrec.svg
icons/loop.svg
icons/micrec1.svg
@@ -42,14 +42,12 @@ common/Util/ControlStream.py
common/Util/Credits.py
common/Util/InstrumentDB.py
common/Util/InstrumentPanel.py
-common/Util/Instrument_.py
+common/Util/Instruments.py
common/Util/KeyboardWindow.py
common/Util/LoopSettings.py
common/Util/Network.py
common/Util/NoteDB.py
-common/Util/NoteLooper.py
common/Util/Profiler.py
-common/Util/Sound.py
common/Util/ThemeWidgets.py
common/Util/Trackpad.py
common/Util/__init__.py
diff --git a/TamTamMini.activity/Mini/Fillin.py b/TamTamMini.activity/Mini/Fillin.py
index 8dfc23f..162f8ef 100644
--- a/TamTamMini.activity/Mini/Fillin.py
+++ b/TamTamMini.activity/Mini/Fillin.py
@@ -6,7 +6,7 @@ import gobject
from RythmGenerator import *
from common.Util.CSoundClient import new_csound_client
from common.Util.NoteDB import Note
-import Config
+import common.Config as Config
class Fillin:
def __init__( self, nbeats, tempo, instrument, reverb, volume ):
diff --git a/TamTamMini.activity/Mini/GenRythm.py b/TamTamMini.activity/Mini/GenRythm.py
index 1132991..7d67994 100644
--- a/TamTamMini.activity/Mini/GenRythm.py
+++ b/TamTamMini.activity/Mini/GenRythm.py
@@ -1,11 +1,13 @@
import random
-import Config
+import common.Config as Config
from common.Generation.GenerationConstants import GenerationConstants
from common.Generation.Utils import *
+from common.Util import InstrumentDB
class GenRythm:
def drumRythmSequence(self, instrumentName, nbeats, density, regularity ):
+ instrumentDB = InstrumentDB.getRef()
rythmSequence = []
binSelection = []
downBeats = []
@@ -14,28 +16,28 @@ class GenRythm:
countDown = 0
onsetTime = None
- if Config.INSTRUMENTS[instrumentName].instrumentRegister == Config.PUNCH:
+ if instrumentDB.instNamed[instrumentName].instrumentRegister == Config.PUNCH:
registerDensity = 0.5
downBeatRecurence = 4
downBeats = [x for x in GenerationConstants.DRUM_PUNCH_ACCENTS[ nbeats ]]
for downBeat in downBeats:
upBeats.append( downBeat + Config.TICKS_PER_BEAT / 2 )
- if Config.INSTRUMENTS[instrumentName].instrumentRegister == Config.LOW:
+ if instrumentDB.instNamed[instrumentName].instrumentRegister == Config.LOW:
registerDensity =1
downBeatRecurence = 4
downBeats = [x for x in GenerationConstants.DRUM_LOW_ACCENTS[ nbeats ]]
for downBeat in downBeats:
upBeats.append( downBeat + Config.TICKS_PER_BEAT / 2 )
- if Config.INSTRUMENTS[instrumentName].instrumentRegister == Config.MID:
+ if instrumentDB.instNamed[instrumentName].instrumentRegister == Config.MID:
registerDensity = .75
downBeatRecurence = 1
downBeats = [x for x in GenerationConstants.DRUM_MID_ACCENTS[ nbeats ]]
for downBeat in downBeats:
upBeats.append( downBeat + Config.TICKS_PER_BEAT / 4 )
- if Config.INSTRUMENTS[instrumentName].instrumentRegister == Config.HIGH:
+ if instrumentDB.instNamed[instrumentName].instrumentRegister == Config.HIGH:
registerDensity = 1.5
downBeatRecurence = 1
downBeats = [x for x in GenerationConstants.DRUM_HIGH_ACCENTS[ nbeats ]]
@@ -48,10 +50,10 @@ class GenRythm:
list = range( int( realDensity * len( downBeats ) ) )
for i in list:
- if random.random() < ( regularity * downBeatRecurence ) and binSelection.count( 1 ) < len( downBeats ):
- binSelection.append( 1 )
+ if random.random() < ( regularity * downBeatRecurence ) and binSelection.count( 1 ) < len( downBeats ):
+ binSelection.append( 1 )
else:
- if binSelection.count( 0 ) < len( downBeats ):
+ if binSelection.count( 0 ) < len( downBeats ):
binSelection.append( 0 )
else:
binSelection.append( 1 )
diff --git a/TamTamMini.activity/Mini/InstrumentPanel.py b/TamTamMini.activity/Mini/InstrumentPanel.py
index 3d93647..103c6f4 100644
--- a/TamTamMini.activity/Mini/InstrumentPanel.py
+++ b/TamTamMini.activity/Mini/InstrumentPanel.py
@@ -6,14 +6,17 @@ import gtk
import time
-import Config
+import common.Config as Config
from common.Util.ThemeWidgets import *
+from common.Util import InstrumentDB
+
Tooltips = Config.Tooltips
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
@@ -72,8 +75,9 @@ class InstrumentPanel( gtk.EventBox ):
if timeout >= 0 and time.time() > timeout: return False
if self.loadStage[0] == 4:
- if not self.loadToolbar( timeout, self.loadStage ):
- return False
+ # hide category row
+ #if not self.loadToolbar( timeout, self.loadStage ):
+ # return False
self.loadStage[0] = 5
if timeout >= 0 and time.time() > timeout: return False
@@ -116,10 +120,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':
@@ -178,6 +182,7 @@ class InstrumentPanel( gtk.EventBox ):
loadStage[1] += 1
if timeout >= 0 and time.time() > timeout: return False
+
self.mainVBox.pack_start(self.loadData["toolbarBox"],False,False)
self.loadData.pop("btn")
@@ -298,6 +303,7 @@ class InstrumentPanel( gtk.EventBox ):
if self.setInstrument:
widget.event( gtk.gdk.Event( gtk.gdk.LEAVE_NOTIFY ) ) # fake the leave event
self.setInstrument(instrument)
+ time.sleep(0.05)
if self.playInstrument: self.playInstrument(instrument)
if self.enterMode:
pass #Close the window
@@ -333,9 +339,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 keys:
+ if self.instrumentDB.instNamed[key].category == "kit":
self.instrumentList.append( key )
self.instrumentList.sort()
self.drawDrums()
diff --git a/TamTamMini.activity/Mini/KeyboardStandAlone.py b/TamTamMini.activity/Mini/KeyboardStandAlone.py
index 436c185..cc86a31 100644
--- a/TamTamMini.activity/Mini/KeyboardStandAlone.py
+++ b/TamTamMini.activity/Mini/KeyboardStandAlone.py
@@ -2,11 +2,12 @@ import pygtk
pygtk.require( '2.0' )
import gtk
-import Config
+import common.Config as Config
from common.Generation.GenerationConstants import GenerationConstants
from common.Util.NoteDB import Note
from common.Util.CSoundNote import CSoundNote
from common.Util.CSoundClient import new_csound_client
+from common.Util import InstrumentDB
KEY_MAP_PIANO = Config.KEY_MAP_PIANO
@@ -14,6 +15,7 @@ KEY_MAP_PIANO = Config.KEY_MAP_PIANO
class KeyboardStandAlone:
def __init__( self, recordingFunction, adjustDurationFunction, getCurrentTick, getPlayState, loop ):
+ self.instrumentDB = InstrumentDB.getRef()
self.csnd = new_csound_client()
self.recording = recordingFunction
self.adjustDuration = adjustDurationFunction
@@ -93,17 +95,17 @@ class KeyboardStandAlone:
#print >>log, 'instrumentName:', instrumentName
pitch = KEY_MAP_PIANO[key]
- if None != Config.INSTRUMENTS[instrumentName].kit:
+ if self.instrumentDB.instNamed[instrumentName].kit != None:
if pitch in GenerationConstants.DRUMPITCH:
pitch = GenerationConstants.DRUMPITCH[pitch]
- #print >>log, 'kit_element: ', Config.KIT_ELEMENT[pitch]
- playkey(36,100, Config.INSTRUMENTS[instrumentName].kit[pitch])
+ #print >>log, 'kit_element: ', Config.KIT_ELEMENT[pitch]
+ playkey(36,100, self.instrumentDB.instNamed[instrumentName].kit[pitch])
else:
if event.state == gtk.gdk.MOD1_MASK:
pitch += 5
- instrument = Config.INSTRUMENTS[ instrumentName ]
+ instrument = self.instrumentDB.instNamed[ instrumentName ]
if instrument.csoundInstrumentId == Config.INST_PERC: #Percussions resonance
playkey( pitch, 60, instrument)
else:
@@ -124,7 +126,7 @@ class KeyboardStandAlone:
if KEY_MAP_PIANO.has_key(key):
csnote = self.key_dict[key]
- if Config.INSTRUMENTSID[ csnote.instrumentId ].csoundInstrumentId == Config.INST_TIED:
+ if self.instrumentDB.instId[ csnote.instrumentId ].csoundInstrumentId == Config.INST_TIED:
csnote.duration = .5
csnote.decay = 0.7
#csnote.amplitude = 1
diff --git a/TamTamMini.activity/Mini/Loop.py b/TamTamMini.activity/Mini/Loop.py
index 49169eb..27ac46c 100755
--- a/TamTamMini.activity/Mini/Loop.py
+++ b/TamTamMini.activity/Mini/Loop.py
@@ -1,4 +1,4 @@
-import Config
+import common.Config as Config
import random
import lps
from common.Generation.Drunk import *
@@ -7,9 +7,11 @@ from common.Util.CSoundClient import new_csound_client
from common.Util.NoteDB import Note
from common.Util.NoteDB import PARAMETER
from common.Generation.GenerationConstants import GenerationConstants
+from common.Util import InstrumentDB
class Loop:
def __init__( self, beat, volume ):
+ self.instrumentDB = InstrumentDB.getRef()
self.notesDict = {}
self.notesList = []
self.beat = beat
@@ -49,10 +51,10 @@ class Loop:
pitch = i[1]
gain = i[2]*self.volume
duration = i[3]
- if Config.INSTRUMENTS[instrument].kit != None:
+ if self.instrumentDB.instNamed[instrument].kit != None:
if GenerationConstants.DRUMPITCH.has_key(pitch):
pitch = GenerationConstants.DRUMPITCH[pitch]
- instrument = Config.INSTRUMENTS[ instrument ].kit[pitch].name
+ instrument = self.instrumentDB.instNamed[ instrument ].kit[pitch].name
pitch = 36
return CSoundNote( onset = onset,
pitch = pitch,
@@ -60,7 +62,7 @@ class Loop:
pan = 0.5,
duration = duration,
trackId = 0,
- instrumentId = Config.INSTRUMENTS[instrument].instrumentId,
+ instrumentId = self.instrumentDB.instNamed[instrument].instrumentId,
reverbSend = reverb,
tied = False,
mode = 'mini')
diff --git a/TamTamMini.activity/Mini/MiniSequencer.py b/TamTamMini.activity/Mini/MiniSequencer.py
index 639b684..991ee13 100644
--- a/TamTamMini.activity/Mini/MiniSequencer.py
+++ b/TamTamMini.activity/Mini/MiniSequencer.py
@@ -3,7 +3,7 @@ pygtk.require( '2.0' )
import gtk
import gobject
import time
-import Config
+import common.Config as Config
from common.Util.CSoundNote import CSoundNote
from common.Util.CSoundClient import new_csound_client
from common.Util.NoteDB import Note
diff --git a/TamTamMini.activity/Mini/NoteStdAlone.py b/TamTamMini.activity/Mini/NoteStdAlone.py
deleted file mode 100644
index a331719..0000000
--- a/TamTamMini.activity/Mini/NoteStdAlone.py
+++ /dev/null
@@ -1,103 +0,0 @@
-import Config
-from common.Util.CSoundClient import CSoundClient
-from common.Generation.GenerationConstants import GenerationConstants
-
-class NoteStdAlone:
- def __init__( self, client,
- onset,
- pitch,
- amplitude,
- pan,
- duration,
- trackId,
- fullDuration = False,
- instrument = Config.FLUTE,
- attack = 0.005,
- decay = 0.095,
- reverbSend = 0.1,
- filterType = 0,
- filterCutoff = 1000,
- tied = False,
- overlap = False,
- instrumentFlag = Config.FLUTE ):
- self.csnd = client
- self.onset = onset
- self.pitch = pitch
- self.amplitude = amplitude
- self.pan = pan
- self.duration = duration
- self.trackId = trackId
- self.instrument = instrument
- self.fullDuration = fullDuration
- self.attack = attack
- self.decay = decay
- self.reverbSend = reverbSend
- self.filterType = filterType
- self.filterCutoff = filterCutoff
- self.tied = tied
- self.overlap = overlap
- if self.instrument == 'drum1kit':
- self.instrumentFlag = Config.DRUM1INSTRUMENTS[ self.pitch ]
- else:
- self.instrumentFlag = self.instrument
-
- def play( self ):
- self.csnd.sendText( self.getText(120) )
-
- def getText( self, tempo ):
- if self.instrument[ 0: 4 ] == 'drum':
- if GenerationConstants.DRUMPITCH.has_key( self.pitch ):
- self.pitch = GenerationConstants.DRUMPITCH[ self.pitch ]
-
- if self.instrument == 'drum1kit':
- self.instrumentFlag = Config.DRUM1INSTRUMENTS[ self.pitch ]
- if self.instrument == 'drum2kit':
- self.instrumentFlag = Config.DRUM2INSTRUMENTS[ self.pitch ]
- if self.instrument == 'drum3kit':
- self.instrumentFlag = Config.DRUM3INSTRUMENTS[ self.pitch ]
- newPitch = 1
- else:
- self.instrumentFlag = self.instrument
- newPitch = pow( GenerationConstants.TWO_ROOT_TWELVE, self.pitch - 36 )
-
- oneTickDuration = (Config.MS_PER_MINUTE / 1000) / tempo / Config.TICKS_PER_BEAT
-
- newDuration = oneTickDuration * self.duration
-
- # condition for tied notes
- if Config.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentId == 101 and self.tied and self.fullDuration:
- newDuration = -1
- # condition for overlaped notes
- if Config.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentId == 102 and self.overlap:
- newDuration = oneTickDuration * self.duration + 1.
-
- if True: newAmplitude = self.amplitude * 0.8
- else : newAmplitude = self.amplitude * music_volume_get( self.trackId )
-
- newAttack = newDuration * self.attack
- if newAttack <= 0.002:
- newAttack = 0.002
-
- newDecay = newDuration * self.decay
- if newDecay <= 0.002:
- newDecay = 0.002
-
- loopStart = Config.INSTRUMENTS[ self.instrumentFlag ].loopStart
- loopEnd = Config.INSTRUMENTS[ self.instrumentFlag ].loopEnd
- crossDur = Config.INSTRUMENTS[ self.instrumentFlag ].crossDur
- return Config.PLAY_NOTE_COMMAND % ( Config.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentId,
- self.trackId,
- 0,
- newDuration,
- newPitch,
- self.reverbSend,
- newAmplitude,
- self.pan,
- Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[ self.instrumentFlag ].instrumentId,
- newAttack,
- newDecay,
- self.filterType,
- self.filterCutoff,
- loopStart,
- loopEnd,
- crossDur )
diff --git a/TamTamMini.activity/Mini/RythmGenerator.py b/TamTamMini.activity/Mini/RythmGenerator.py
index 3231eb8..11df96e 100644
--- a/TamTamMini.activity/Mini/RythmGenerator.py
+++ b/TamTamMini.activity/Mini/RythmGenerator.py
@@ -1,12 +1,14 @@
import random
-import Config
+import common.Config as Config
from common.Util.CSoundNote import CSoundNote
from common.Generation.GenerationConstants import GenerationConstants
from GenRythm import GenRythm
+from common.Util import InstrumentDB
def generator( instrument, nbeats, density, regularity, reverbSend ):
+ instrumentDB = InstrumentDB.getRef()
makeRythm = GenRythm()
noteDuration = GenerationConstants.DOUBLE_TICK_DUR / 2
@@ -18,15 +20,15 @@ def generator( instrument, nbeats, density, regularity, reverbSend ):
filterCutoff = 1000
tied = False
mode = 'mini'
-
+
def makePitchSequence(length, drumPitch):
pitchSequence = []
append = pitchSequence.append
list = range(length)
max = len(drumPitch) - 1
for i in list:
- append(drumPitch[ random.randint( 0, max ) ] )
- return pitchSequence
+ append(drumPitch[ random.randint( 0, max ) ] )
+ return pitchSequence
def makeGainSequence( onsetList ):
gainSequence = []
@@ -36,16 +38,16 @@ def generator( instrument, nbeats, density, regularity, reverbSend ):
gain = random.uniform(GenerationConstants.GAIN_MID_MAX_BOUNDARY, GenerationConstants.GAIN_MAX_BOUNDARY)
elif ( onset % Config.TICKS_PER_BEAT) == 0:
gain = random.uniform(GenerationConstants.GAIN_MID_MIN_BOUNDARY, GenerationConstants.GAIN_MID_MAX_BOUNDARY)
- else:
+ else:
gain = random.uniform(GenerationConstants.GAIN_MIN_BOUNDARY, GenerationConstants.GAIN_MID_MIN_BOUNDARY)
append(gain)
- return gainSequence
-
+ return gainSequence
+
def pageGenerate( regularity, drumPitch ):
barLength = Config.TICKS_PER_BEAT * nbeats
#print 'pageGenerate drumPitch[0] ', drumPitch[0]
- currentInstrument = Config.INSTRUMENTS[ instrument ].kit[ drumPitch[0] ].name
+ currentInstrument = instrumentDB.instNamed[ instrument ].kit[ drumPitch[0] ] #.name
rythmSequence = makeRythm.drumRythmSequence(currentInstrument, nbeats, density, regularity)
pitchSequence = makePitchSequence(len(rythmSequence), drumPitch )
@@ -54,16 +56,16 @@ def generator( instrument, nbeats, density, regularity, reverbSend ):
trackNotes = []
list = range(len(rythmSequence))
for i in list:
- trackNotes.append( CSoundNote( rythmSequence[i], pitchSequence[i], gainSequence[i],
- pan, noteDuration, trackId,
- Config.INSTRUMENTS[instrument].instrumentId, attack,
+ trackNotes.append( CSoundNote( rythmSequence[i], pitchSequence[i], gainSequence[i],
+ pan, noteDuration, trackId,
+ instrumentDB.instNamed[instrument].instrumentId, attack,
decay, reverbSend, filterType, filterCutoff, tied, mode))
return trackNotes
-##################################################################################
- # begin generate()
+##################################################################################
+ # begin generate()
if regularity > 0.75:
- streamOfPitch = GenerationConstants.DRUM_COMPLEXITY1
+ streamOfPitch = GenerationConstants.DRUM_COMPLEXITY1
elif regularity > 0.5:
streamOfPitch = GenerationConstants.DRUM_COMPLEXITY2
elif regularity > 0.25:
diff --git a/TamTamMini.activity/Mini/miniTamTamMain.py b/TamTamMini.activity/Mini/miniTamTamMain.py
index eb73577..5a0bb3c 100644
--- a/TamTamMini.activity/Mini/miniTamTamMain.py
+++ b/TamTamMini.activity/Mini/miniTamTamMain.py
@@ -14,7 +14,7 @@ from common.Util.NoteDB import PARAMETER
import common.Util.Network as Net
-import Config
+import common.Config as Config
from Mini.miniToolbars import playToolbar
from Mini.miniToolbars import recordToolbar
@@ -24,6 +24,7 @@ from common.Util import NoteDB
from common.Util.NoteDB import Note
from common.Util.CSoundClient import new_csound_client
from common.Util.LoopSettings import LoopSettings
+from common.Util import InstrumentDB
from Fillin import Fillin
from KeyboardStandAlone import KeyboardStandAlone
@@ -46,6 +47,7 @@ class miniTamTamMain(gtk.EventBox):
self.set_border_width(Config.MAIN_WINDOW_PADDING)
+ self.instrumentDB = InstrumentDB.getRef()
self.firstTime = False
self.playing = False
self.csnd = new_csound_client()
@@ -55,11 +57,12 @@ class miniTamTamMain(gtk.EventBox):
self.instrument = 'ocarina'
self.regularity = 0.75
self.beat = 4
- self.reverb = 0.
+ self.reverb = 0.1
self.tempo = Config.PLAYER_TEMPO
self.beatDuration = 60.0/self.tempo
self.ticksPerSecond = Config.TICKS_PER_BEAT*self.tempo/60.0
self.rythmInstrument = 'drum1kit'
+ self.csnd.load_drumkit(self.rythmInstrument)
self.muteInst = False
self.drumFillin = Fillin( self.beat, self.tempo, self.rythmInstrument, self.reverb, self.drumVolume )
self.sequencer= MiniSequencer(self.recordStateButton, self.recordOverSensitivity)
@@ -71,7 +74,11 @@ class miniTamTamMain(gtk.EventBox):
for i in range(21):
self.csnd.setTrackVolume( 100, i )
- self.volume = 150
+ for i in range(10):
+ r = str(i+1)
+ self.csnd.load_instrument('guidice' + r)
+
+ self.volume = 100
self.csnd.setMasterVolume(self.volume)
self.sequencer.beat = self.beat
self.loop.beat = self.beat
@@ -90,24 +97,12 @@ class miniTamTamMain(gtk.EventBox):
self.enableKeyboard()
self.setInstrument(self.instrument)
- self.loopSettingsPopup = gtk.Window(gtk.WINDOW_POPUP)
- self.loopSettingsPopup.set_modal(True)
- self.loopSettingsPopup.add_events( gtk.gdk.BUTTON_PRESS_MASK )
- self.loopSettingsPopup.connect("button-release-event", lambda w,e:self.doneLoopSettingsPopup() )
- self.loopSettings = LoopSettings( self.loopSettingsPopup, self.loopSettingsPlayStop, self.loopSettingsChannel, self.doneLoopSettingsPopup )
- self.loopSettingsPopup.add( self.loopSettings )
- self.loopSettingsPlaying = False
-
-
self.drawInstrumentButtons()
self.drawGeneration()
self.show_all()
if 'a good idea' == True:
self.playStartupSound()
- #self.synthLabWindow = None
-
-
self.beatPickup = True
#self.regenerate()
@@ -136,24 +131,18 @@ class miniTamTamMain(gtk.EventBox):
self.syncTimeout = gobject.timeout_add( 1000, self.updateSync )
#-------------------------------------------------------------------
- #Play button Image
- self.playButtonImg = gtk.Image()
- self.playButtonImg.set_from_icon_name('media-playback-start', gtk.ICON_SIZE_LARGE_TOOLBAR)
- self.playButtonImg.show()
-
- #Stop button Image
- self.stopButtonImg = gtk.Image()
- self.stopButtonImg.set_from_icon_name('media-playback-stop', gtk.ICON_SIZE_LARGE_TOOLBAR)
- self.stopButtonImg.show()
# Toolbar
self.activity.activity_toolbar.share.show()
self._playToolbar = playToolbar(self.activity.toolbox, self)
- self._recordToolbar = recordToolbar(self.activity.toolbox, self)
- self.activity.toolbox.add_toolbar(_('Play'), self._playToolbar)
- self.activity.toolbox.add_toolbar(_('Record'), self._recordToolbar)
- self.activity.toolbox.set_current_toolbar(1)
- self._playToolbar.show()
- self._recordToolbar.show()
+
+ ## set to 1 to show play and record tabs ##
+ if 0:
+ self._recordToolbar = recordToolbar(self.activity.toolbox, self)
+ self.activity.toolbox.add_toolbar(_('Play'), self._playToolbar)
+ self.activity.toolbox.add_toolbar(_('Record'), self._recordToolbar)
+ self.activity.toolbox.set_current_toolbar(1)
+ self._playToolbar.show()
+ self._recordToolbar.show()
self.activity.connect( "shared", self.shared )
@@ -243,6 +232,16 @@ class miniTamTamMain(gtk.EventBox):
slidersBox.pack_start(slidersBoxSub)
generateBtnSub = gtk.HBox()
+
+ #playImg = gtk.Image()
+ #playImg.set_from_icon_name('media-playback-start', gtk.ICON_SIZE_LARGE_TOOLBAR)
+ self.playButton = ImageToggleButton(Config.IMAGE_ROOT + 'miniplay.png', Config.IMAGE_ROOT + 'stop.png')
+ #self.playButton.set_relief(gtk.RELIEF_NONE)
+ #self.playButton.set_image(playImg)
+ self.playButton.connect('clicked',self.handlePlayButton)
+ generateBtnSub.pack_start(self.playButton)
+ #self.playButton.set_tooltip(_('Play / Stop'))
+
generateBtn = ImageButton(Config.IMAGE_ROOT + 'dice.png', clickImg_path = Config.IMAGE_ROOT + 'diceblur.png')
generateBtn.connect('button-press-event', self.handleGenerateBtn)
generateBtnSub.pack_start(generateBtn)
@@ -298,52 +297,8 @@ class miniTamTamMain(gtk.EventBox):
self.loopSettingsPlaying = False
self.csnd.inputMessage(Config.CSOUND_STOP_LS_NOTE)
- def doneLoopSettingsPopup(self):
- if self._recordToolbar.loopSetButton.get_active():
- if self.loopSettingsPlaying:
- self.csnd.inputMessage(Config.CSOUND_STOP_LS_NOTE)
- self.loopSettingsPlaying = False
- self._recordToolbar.loopSetButton.set_active(False)
-
- def handleLoopSettingsBtn(self, widget, data=None):
- if widget.get_active():
-
- chooser = gtk.FileChooserDialog(title='Edit SoundFile Preference',action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
-
- #filter = gtk.FileFilter()
- #filter.add_pattern('*.wav')
- #chooser.set_filter(filter)
- chooser.set_current_folder(Config.SNDS_DIR)
-
- for f in chooser.list_shortcut_folder_uris():
- chooser.remove_shortcut_folder_uri(f)
-
- if chooser.run() == gtk.RESPONSE_OK:
- try:
- tempName = chooser.get_filename()
- soundName = os.path.split(tempName)[1]
- except IOError:
- print 'ERROR: failed to load Sound from file %s' % chooser.get_filename()
- chooser.destroy()
- #results = commands.getstatusoutput("csound -U sndinfo %s" % tempName)
- results = commands.getstatusoutput("du -b %s" % tempName)
- if results[0] == 0:
- list = results[1].split()
- #pos = list.index('seconds')
- #soundLength = float(list[pos-1])
- soundLength = float(list[0]) / 2 / 16000.
- self.loopSettings.set_name(soundName)
- self.loopSettings.setButtonState()
- self.loopSettingsPopup.show()
- self.loopSettingsPopup.move( 600, 200 )
- self.timeoutLoad = gobject.timeout_add(1000, self.load_ls_instrument, soundName, soundLength)
- else:
- self.loopSettingsPopup.hide()
-
- def load_ls_instrument(self, soundName, soundLength):
+ def load_ls_instrument(self, soundName):
self.csnd.load_ls_instrument(soundName)
- self.loopSettings.set_values(soundLength)
- gobject.source_remove( self.timeoutLoad )
def drawInstrumentButtons(self):
self.instrumentPanelBox = gtk.HBox()
@@ -376,19 +331,12 @@ class miniTamTamMain(gtk.EventBox):
self._recordToolbar.keyboardRecOverButton.set_active( state )
def recordOverSensitivity( self, state ):
- self._recordToolbar.keyboardRecOverButton.set_sensitive( state )
-
- #def synthLabWindowOpen(self):
- #return self.synthLabWindow != None and self.synthLabWindow.get_property('visible')
+ pass
+ #self._recordToolbar.keyboardRecOverButton.set_sensitive( state )
def loadMicInstrument( self, data ):
self.csnd.load_mic_instrument( data )
- #def closeSynthLab(self):
- #if self.synthLabWindow != None:
- #self.synthLabWindow.destroy()
- #self.synthLabWindow = None
-
def regenerate(self):
def flatten(ll):
rval = []
@@ -538,13 +486,12 @@ class miniTamTamMain(gtk.EventBox):
self.volumeSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'volume' + str(img) + '.png')
def handlePlayButton(self, widget, data = None):
- # use widget.get_active() == False when calling this on 'clicked'
- # use widget.get_active() == True when calling this on button-press-event
+ # use widget.get_active() == False when calling this on 'clicked'
+ # use widget.get_active() == True when calling this on button-press-event
if widget.get_active() == False:
self.drumFillin.stop()
self.sequencer.stopPlayback()
self.csnd.loopPause()
- widget.set_icon_widget(self.playButtonImg)
self.playing = False
else:
if not self.firstTime:
@@ -556,7 +503,6 @@ class miniTamTamMain(gtk.EventBox):
#print "play:: next beat in %f ticks. bpb == %d. setting ticks to %d" % (nextInTicks, self.beat, Config.TICKS_PER_BEAT*self.beat - int(round(nextInTicks)))
self.csnd.loopSetTick( Config.TICKS_PER_BEAT*self.beat - int(round(nextInTicks)) )
self.csnd.loopStart()
- widget.set_icon_widget(self.stopButtonImg)
self.playing = True
@@ -564,15 +510,16 @@ class miniTamTamMain(gtk.EventBox):
#data is drum1kit, drum2kit, or drum3kit
#print 'HANDLE: Generate Button'
self.rythmInstrument = data
- instrumentId = Config.INSTRUMENTS[data].instrumentId
+ self.csnd.load_drumkit(data)
+ instrumentId = self.instrumentDB.instNamed[data].instrumentId
for (o,n) in self.noteList :
self.csnd.loopUpdate(n, NoteDB.PARAMETER.INSTRUMENT, instrumentId, -1)
self.drumFillin.setInstrument( self.rythmInstrument )
def handleGenerateBtn(self , widget , data=None):
self.regenerate()
- if not self._playToolbar.playButton.get_active():
- self._playToolbar.playButton.set_active(True)
+ if not self.playButton.get_active():
+ self.playButton.set_active(True)
#this calls sends a 'clicked' event,
#which might be connected to handlePlayButton
@@ -585,6 +532,7 @@ class miniTamTamMain(gtk.EventBox):
def setInstrument( self , instrument ):
self.instrument = instrument
self.keyboardStandAlone.setInstrument(instrument)
+ self.csnd.load_instrument(instrument)
def playInstrumentNote(self , instrument, secs_per_tick = 0.025):
if not self.muteInst:
@@ -595,7 +543,7 @@ class miniTamTamMain(gtk.EventBox):
pan = 0.5,
duration = 20,
trackId = 1,
- instrumentId = Config.INSTRUMENTS[instrument].instrumentId,
+ instrumentId = self.instrumentDB.instNamed[instrument].instrumentId,
reverbSend = self.reverb,
tied = False,
mode = 'mini'),
diff --git a/TamTamMini.activity/Mini/miniToolbars.py b/TamTamMini.activity/Mini/miniToolbars.py
index 89f623b..9fac3d6 100644
--- a/TamTamMini.activity/Mini/miniToolbars.py
+++ b/TamTamMini.activity/Mini/miniToolbars.py
@@ -1,7 +1,10 @@
#!/usr/bin/env python
import gtk
-import Config
+import gobject
+import os, commands
+import common.Config as Config
+from common.Util.ThemeWidgets import *
from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.toggletoolbutton import ToggleToolButton
@@ -24,14 +27,6 @@ class playToolbar(gtk.Toolbar):
self.tooltips = gtk.Tooltips()
- self.playButton = ToggleToolButton('media-playback-start')
- self.playButton.connect('clicked',self.miniTamTam.handlePlayButton)
- self.insert(self.playButton, -1)
- self.playButton.show()
- self.playButton.set_tooltip(_('Play / Stop'))
-
- _insertSeparator(1)
-
self.balanceSliderImgLeft = gtk.Image()
self.balanceSliderImgRight = gtk.Image()
self.balanceSliderImgLeft.set_from_file(Config.IMAGE_ROOT + 'dru2.png')
@@ -66,7 +61,7 @@ class playToolbar(gtk.Toolbar):
self.reverbSliderImgRightTool = gtk.ToolItem()
self.reverbSliderImgRightTool.add(self.reverbSliderImgRight)
- self.reverbSliderAdj = gtk.Adjustment(value=0, lower=0, upper=1, step_incr=0.1, page_incr=0, page_size=0)
+ self.reverbSliderAdj = gtk.Adjustment(value=0.1, lower=0, upper=1, step_incr=0.1, page_incr=0, page_size=0)
self.reverbSliderAdj.connect("value_changed" , self.miniTamTam.handleReverbSlider)
self.reverbSlider = gtk.HScale(adjustment = self.reverbSliderAdj)
self.reverbSlider.set_size_request(250,15)
@@ -144,8 +139,247 @@ class recordToolbar(gtk.Toolbar):
_insertSeparator()
+ self._loopSettingsPalette = LoopSettingsPalette(_('Add new Sound'), self.miniTamTam)
self.loopSetButton = ToggleToolButton('loop')
- self.loopSetButton.connect('clicked', self.miniTamTam.handleLoopSettingsBtn)
+ self.loopSetButton.set_palette(self._loopSettingsPalette)
self.insert(self.loopSetButton, -1)
self.loopSetButton.show()
- self.loopSetButton.set_tooltip(_('Add new sound'))
+
+class LoopSettingsPalette( Palette ):
+ def __init__( self, label, mini ):
+ Palette.__init__( self, label )
+ self.connect('popup', self.handlePopup)
+ self.connect('popdown', self.handlePopdown)
+
+ self.mini = mini
+
+ self.tooltips = gtk.Tooltips()
+ self.loopedSound = False
+ self.soundLength = 1.00
+ self.start = 0
+ self.end = 1.00
+ self.dur = 0.01
+ self.volume = 1
+ self.register = 0
+ self.ok = True
+
+ self.mainBox = gtk.VBox()
+
+ self.controlsBox = gtk.HBox()
+
+ self.GUI = {}
+
+ self.soundBox = gtk.HBox()
+ self.soundLabel = gtk.Label(_('Sound: '))
+ self.soundMenuBox = BigComboBox()
+ self.sounds = os.listdir(Config.SNDS_DIR)
+ for sound in self.sounds:
+ self.soundMenuBox.append_item(self.sounds.index(sound), sound)
+ self.soundMenuBox.connect('changed', self.handleSound)
+ self.soundBox.pack_start(self.soundLabel, False, False, padding=10)
+ self.soundBox.pack_start(self.soundMenuBox, False, False, padding=10)
+
+ self.mainBox.pack_start(self.soundBox, False, False, 10)
+
+ nameBox = gtk.VBox()
+ self.nameEntry = gtk.Entry()
+ entrycolor = gtk.gdk.Color()
+ self.nameEntry.modify_text(gtk.STATE_NORMAL, entrycolor)
+ self.nameEntry.set_text("name_of_the_sound")
+ nameBox.pack_start(self.nameEntry)
+ self.mainBox.pack_start(nameBox, False, False, 10)
+
+ registerBox = gtk.HBox()
+ self.registerBoxLabel = gtk.Label(_('Register: '))
+ self.registerMenuBox = BigComboBox()
+ self.registers = ['LOW', 'MID', 'HIGH', 'PUNCH']
+ for reg in self.registers:
+ self.registerMenuBox.append_item(self.registers.index(reg), reg)
+ self.registerMenuBox.connect('changed', self.handleRegister)
+ registerBox.pack_start(self.registerBoxLabel, False, False, padding=10)
+ registerBox.pack_end(self.registerMenuBox, False, False, padding=10)
+ self.mainBox.pack_start(registerBox, False, False, 10)
+
+ loopedBox = gtk.HBox()
+ loopedLabel = gtk.Label("Looped sound: ")
+ loopedToggle = ImageToggleButton(Config.IMAGE_ROOT+"checkOff.svg",Config.IMAGE_ROOT+"checkOn.svg")
+ loopedToggle.connect('button-press-event', self.handleLooped )
+ loopedBox.pack_start(loopedLabel, False, False, padding=10)
+ loopedBox.pack_end(loopedToggle, False, False, padding=10)
+ self.mainBox.pack_start(loopedBox, False, False, 10)
+
+ startBox = gtk.VBox()
+ self.startAdjust = gtk.Adjustment( 0.01, 0, 1., .001, .001, 0)
+ self.GUI['startSlider'] = gtk.VScale( adjustment = self.startAdjust )
+ self.startAdjust.connect("value-changed", self.handleStart)
+ self.GUI['startSlider'].set_inverted(True)
+ self.GUI['startSlider'].set_size_request(50, 200)
+ self.GUI['startSlider'].set_digits(3)
+ self.handleStart( self.startAdjust )
+ startBox.pack_start(self.GUI['startSlider'], True, True, 5)
+ self.controlsBox.pack_start(startBox)
+
+ endBox = gtk.VBox()
+ self.endAdjust = gtk.Adjustment( 0.9, 0, 1, .001, .001, 0)
+ self.GUI['endSlider'] = gtk.VScale( adjustment = self.endAdjust )
+ self.endAdjust.connect("value-changed", self.handleEnd)
+ self.GUI['endSlider'].set_inverted(True)
+ self.GUI['endSlider'].set_size_request(50, 200)
+ self.GUI['endSlider'].set_digits(3)
+ self.handleEnd( self.endAdjust )
+ endBox.pack_start(self.GUI['endSlider'], True, True, 5)
+ self.controlsBox.pack_start(endBox)
+
+ durBox = gtk.VBox()
+ self.durAdjust = gtk.Adjustment( 0.01, 0, 0.2, .001, .001, 0)
+ self.GUI['durSlider'] = gtk.VScale( adjustment = self.durAdjust )
+ self.durAdjust.connect("value-changed", self.handleDur)
+ self.GUI['durSlider'].set_inverted(True)
+ self.GUI['durSlider'].set_size_request(50, 200)
+ self.GUI['durSlider'].set_digits(3)
+ self.handleDur( self.durAdjust )
+ durBox.pack_start(self.GUI['durSlider'], True, True, 5)
+ self.controlsBox.pack_start(durBox)
+
+ volBox = gtk.VBox()
+ self.volAdjust = gtk.Adjustment( 1, 0, 2, .01, .01, 0)
+ self.GUI['volSlider'] = gtk.VScale( adjustment = self.volAdjust )
+ self.volAdjust.connect("value-changed", self.handleVol)
+ self.GUI['volSlider'].set_inverted(True)
+ self.GUI['volSlider'].set_size_request(50, 200)
+ self.GUI['volSlider'].set_digits(3)
+ self.handleVol( self.volAdjust )
+ volBox.pack_start(self.GUI['volSlider'], True, True, 5)
+ self.controlsBox.pack_start(volBox)
+
+ self.mainBox.pack_start(self.controlsBox, False, False, 10)
+
+ previewBox = gtk.VBox()
+ self.playStopButton = ImageToggleButton(Config.IMAGE_ROOT + 'miniplay.png', Config.IMAGE_ROOT + 'stop.png')
+ self.playStopButton.connect('button-press-event' , self.handlePlayButton)
+ previewBox.pack_start(self.playStopButton)
+ self.mainBox.pack_start(previewBox, False, False, 10)
+
+ checkBox = gtk.VBox()
+ checkButton = ImageButton(Config.TAM_TAM_ROOT + '/icons/accept.svg')
+ checkButton.connect('clicked' , self.handleCheck)
+ checkBox.pack_start(checkButton)
+ self.mainBox.pack_start(checkBox, False, False, 10)
+
+ self.mainBox.show_all()
+ self.set_content(self.mainBox)
+
+ def handlePopup(self, widget, data=None):
+ self.setButtonState()
+ self.soundMenuBox.remove_all()
+ self.sounds = os.listdir(Config.SNDS_DIR)
+ for sound in self.sounds:
+ self.soundMenuBox.append_item(self.sounds.index(sound), sound)
+ self.nameEntry.set_text("name_of_the_sound")
+
+ def handlePopdown(self, widget, data=None):
+ if self.playStopButton.get_active() == True:
+ self.mini.loopSettingsPlayStop(True, self.loopedSound)
+
+ def handleSound(self, widget, data=None):
+ self.sndname = self.sounds[widget.props.value]
+ fullname = Config.SNDS_DIR + '/' + self.sndname
+ results = commands.getstatusoutput("du -b %s" % fullname)
+ if results[0] == 0:
+ list = results[1].split()
+ soundLength = float(list[0]) / 2 / 16000.
+ self.nameEntry.set_text(self.sndname)
+ self.set_values(soundLength)
+ self.startAdjust.set_all( 0.01, 0, soundLength, .001, .001, 0)
+ self.endAdjust.set_all( soundLength-0.01, 0, soundLength, .001, .001, 0)
+ self.timeoutLoad = gobject.timeout_add(2000, self.loopSettingsDelay)
+
+ def loopSettingsDelay(self):
+ self.mini.load_ls_instrument(self.sndname)
+ gobject.source_remove( self.timeoutLoad )
+
+ def handleCheck(self, widget):
+ if self.nameEntry.get_text() != self.sndname:
+ oldName = self.sndname
+ self.sndname = self.nameEntry.get_text()
+ copy = True
+ else:
+ copy = False
+
+ ofile = open(Config.SNDS_INFO_DIR + '/' + self.sndname, 'w')
+ if self.loopedSound:
+ tied = str(Config.INST_TIED)
+ else:
+ tied = str(Config.INST_SIMP)
+ register = str(self.register)
+ category = 'mysounds'
+ start = str(self.start)
+ end = str(self.end)
+ dur = str(self.dur)
+ vol = str(self.volume)
+
+ ofile.write('TamTam idf v1\n')
+ ofile.write(self.sndname + '\n')
+ ofile.write(tied + '\n')
+ ofile.write(register + '\n')
+ ofile.write(start + '\n')
+ ofile.write(end + '\n')
+ ofile.write(dur + '\n')
+ ofile.write(vol + '\n')
+ ofile.write(self.sndname + '\n')
+ ofile.write(Config.LIB_DIR+"/Images/"+self.sndname+".png\n")
+ ofile.write(category)
+ ofile.close()
+ if copy:
+ (s,o) = commands.getstatusoutput('cp ' + Config.SNDS_DIR + '/' + oldName + ' ' + Config.SNDS_DIR + '/' + self.sndname)
+
+ def set_values(self, soundLength):
+ self.soundLength = soundLength
+ self.handleStart(self.GUI['startSlider'])
+ self.handleEnd(self.GUI['endSlider'])
+
+ def handleLooped(self, widget, data=None):
+ if widget.get_active() == True:
+ self.loopedSound = False
+ else:
+ self.loopedSound = True
+
+ def handleRegister(self, widget, data=None):
+ self.register = self.registers[widget.props.value]
+
+ def handleStart(self, widget, data=None):
+ self.start = self.startAdjust.value
+ if self.start > self.end:
+ self.start = self.end
+ self.mini.loopSettingsChannel('lstart', self.start)
+
+ def handleEnd(self, widget, data=None):
+ self.end = self.endAdjust.value
+ if self.end < self.start:
+ self.end = self.start
+ self.mini.loopSettingsChannel('lend', self.end)
+
+ def handleDur(self, widget, data=None):
+ self.dur = self.durAdjust.value
+ self.mini.loopSettingsChannel('ldur', self.dur)
+
+ def handleVol(self, widget, data=None):
+ self.volume = self.volAdjust.value
+ self.mini.loopSettingsChannel('lvol', self.volume)
+
+ def handlePlayButton(self, widget, data=None):
+ if self.ok:
+ self.mini.loopSettingsPlayStop(widget.get_active(), self.loopedSound)
+ if self.loopedSound == False and widget.get_active() == False:
+ self.timeoutStop = gobject.timeout_add(int(self.soundLength * 1000)+500, self.playButtonState)
+
+ def setButtonState(self):
+ self.ok = False
+ self.playStopButton.set_active(False)
+ self.ok = True
+
+ def playButtonState(self):
+ self.ok = False
+ self.playStopButton.set_active(False)
+ gobject.source_remove(self.timeoutStop)
+ self.ok = True
diff --git a/TamTamMini.activity/TamTamMini.py b/TamTamMini.activity/TamTamMini.py
index 2030a10..83bf59e 100644
--- a/TamTamMini.activity/TamTamMini.py
+++ b/TamTamMini.activity/TamTamMini.py
@@ -8,7 +8,8 @@ import gtk
import gobject
import time
-import Config
+import common.Util.Instruments
+import common.Config as Config
from common.Util.CSoundClient import new_csound_client
from common.Util.Profiler import TP
@@ -60,7 +61,7 @@ class TamTamMini(activity.Activity):
self.mini.setInstrumentPanel( self.instrumentPanel )
self.set_canvas( self.mini )
-
+
self.mini.onActivate(arg = None)
self.show()
@@ -78,7 +79,7 @@ class TamTamMini(activity.Activity):
if Config.DEBUG > 4: print "TamTam::preload returned after", time.time() - t
return True
-
+
def onActive(self, widget = None, event = None):
if widget.props.active == False:
csnd = new_csound_client()
@@ -86,7 +87,7 @@ class TamTamMini(activity.Activity):
else:
csnd = new_csound_client()
csnd.connect(True)
-
+
def onKeyPress(self, widget, event):
pass
@@ -118,6 +119,7 @@ class TamTamMini(activity.Activity):
self.ensure_dir(Config.TUNE_DIR)
self.ensure_dir(Config.SYNTH_DIR)
self.ensure_dir(Config.SNDS_DIR)
+ self.ensure_dir(Config.SNDS_INFO_DIR)
self.ensure_dir(Config.SCRATCH_DIR)
if not os.path.isdir(Config.PREF_DIR):
@@ -129,7 +131,7 @@ class TamTamMini(activity.Activity):
def read_file(self,file_path):
self.metadata['tamtam_subactivity'] = 'mini'
-
+
def write_file(self,file_path):
f = open(file_path,'w')
- f.close()
+ f.close()
diff --git a/TamTamMini.activity/icons/accept.svg b/TamTamMini.activity/icons/accept.svg
new file mode 100755
index 0000000..a2f9e28
--- /dev/null
+++ b/TamTamMini.activity/icons/accept.svg
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14576) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="45px" height="45px" viewBox="0 0 55 55" enable-background="new 0 0 55 55" xml:space="preserve">
+<g>
+
+ <path fill-rule="evenodd" clip-rule="evenodd" fill="none" stroke="#FFFFFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" d="
+ M5.78,28.079c0-12.43,10.071-22.499,22.499-22.499c12.431,0,22.501,10.069,22.501,22.499c0,12.431-10.07,22.501-22.501,22.501
+ C15.851,50.58,5.78,40.51,5.78,28.079z"/>
+</g>
+<g>
+
+ <line fill-rule="evenodd" clip-rule="evenodd" fill="none" stroke="#FFFFFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" x1="16.788" y1="26.691" x2="25.781" y2="38.706"/>
+
+ <line fill-rule="evenodd" clip-rule="evenodd" fill="none" stroke="#FFFFFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" x1="25.781" y1="38.706" x2="39.773" y2="18.704"/>
+</g>
+</svg>