From 138653b35fe9ed1ccc651fd988fac4b14e83f71a Mon Sep 17 00:00:00 2001 From: Oli Date: Fri, 19 Oct 2007 08:10:01 +0000 Subject: removed old and unused files --- (limited to 'common/Util') diff --git a/common/Util/Instrument_.py b/common/Util/Instrument_.py deleted file mode 100644 index 5bc74b3..0000000 --- a/common/Util/Instrument_.py +++ /dev/null @@ -1,392 +0,0 @@ -#!/bin/env python -import os - -############## -## SOUNDS -############## - -#INSTRUMENTS ( csound table, csound instrument, register, instrumentClass, category ) -CSOUND_INSTRUMENT = {'inst_free' : 5000, 'inst_tied' : 5001, 'inst_simp': 5011, 'inst_perc': 5021} - -SOUND_ROOT = os.getenv("HOME") + '/cvs/tamtam/snd' -KIT_ROOT = SOUND_ROOT + "/drum" -INST_ROOT = SOUND_ROOT + "/inst" - -INST = {} -inst_load_dynamic = 0 -class Instrument: - REGISTER = {'low': 0, 'mid':1, 'high':2, 'punch':3} - def __init__( self, name, csoundInstrumentName, registerName, category, loopStart, loopEnd, crossDur, wav, img ): - self.name = name - self.instrumentId = len(INST) - self.csoundInstrumentName = csoundInstrumentName - self.csoundInstrumentId = CSOUND_INSTRUMENT[csoundInstrumentName] - self.register = registerName - self.category = category - self.loopStart = loopStart - self.loopEnd = loopEnd - self.crossDur = crossDur - self.wav = wav - self.img = img - - if None == self.wav: self.wav = os.getenv('HOME') + 'cvs/tamtam/Resources/Sounds/' + name - if None == self.img: self.wav = os.getenv('HOME') + 'cvs/tamtam/Resources/Images/' + name - - INST[name] = self - -if inst_load_dynamic: - for I in os.listdir(INST_ROOT): - print 'inst:', I -else: - Instrument( 'mic1', 'inst_tied', 'mid', 'mic', .01, .99, .01, None, None) - Instrument( 'mic2', 'inst_tied', 'mid', 'mic', .01, .99, .01, None, None) - Instrument( "mic3", 'inst_tied', 'mid', 'mic', .01, .99, .01, None, None) - Instrument( "mic4", 'inst_tied', 'mid', 'mic', .01, .99, .01, None, None) - Instrument( "lab1", 'inst_simp', 'mid', 'lab', 0, 0, 0, None, None) - Instrument( "lab2", 'inst_simp', 'mid', 'lab', 0, 0, 0, None, None) - Instrument( "lab3", 'inst_simp', 'mid', 'lab', 0, 0, 0, None, None) - Instrument( "lab4", 'inst_simp', 'mid', 'lab', 0, 0, 0, None, None) - Instrument( "lab5", 'inst_simp', 'mid', 'lab', 0, 0, 0, None, None) - Instrument( "lab6", 'inst_simp', 'mid', 'lab', 0, 0, 0, None, None) - Instrument( "ounk", 'inst_simp', 'mid', 'animals', 0, 0, 0 , None, None) - Instrument( "gam", 'inst_tied', 'high', 'percussions', .69388, .7536, .02922 , None, None) - Instrument( "guit", 'inst_tied', 'mid', 'strings', .08592, .75126, .33571 , None, None) - Instrument( "koto", 'inst_tied', 'high', 'strings', .56523, .70075, .05954 , None, None) - Instrument( "clarinette", 'inst_tied', 'mid', 'winds', .57905, .73319, .04934 , None, None) - Instrument( "flute", 'inst_tied', 'mid', 'winds', .47169, .53693, .02481 , None, None) - Instrument( "drum1hatpedal", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum1hatshoulder", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum1hardride", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum1ridebell", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum1snare", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum1snaresidestick", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum1crash", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum1splash", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum1tom", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum1floortom", 'inst_simp', 'low', 'drum', 0, 0, 0, None, None) - Instrument( "drum1chine", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum1kick", 'inst_simp', 'low', 'drum', 0, 0, 0 , None, None) - Instrument( "piano", 'inst_tied', 'mid', 'keyboard', 2.39418, 2.53339, .01323 , None, None) - Instrument( "dog", 'inst_simp', 'mid', 'animals', 0, 0, 0 , None, None) - Instrument( "duck", 'inst_simp', 'mid', 'animals', 0, 0, 0 , None, None) - Instrument( "drum2darbukadoom", 'inst_simp', 'low', 'drum', 0, 0 ,0 , None, None) - Instrument( "drum2darbukapied", 'inst_simp', 'low', 'drum', 0, 0, 0 , None, None) - Instrument( "drum2darbukapiedsoft", 'inst_simp', 'low', 'drum', 0, 0, 0 , None, None) - Instrument( "drum2hatflanger", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum2darbukatak", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum2darbukafinger", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum2darbukaroll", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum2darbukaslap", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum2hatpied", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum2tambourinepied", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum2hatpied2", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum2tambourinepiedsoft", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum3cowbell", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum3cowbelltip", 'inst_simp', 'mid', 'drum', 0, 0, 0, None, None) - Instrument( "drum3cup", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum3djembelow", 'inst_simp', 'low', 'drum', 0, 0, 0 , None, None) - Instrument( "drum3djembemid", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum3djembesidestick", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum3djembeslap", 'inst_simp', 'low', 'drum', 0, 0, 0 , None, None) - Instrument( "drum3djembestickmid", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum3metalstand", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum3pedalperc", 'inst_simp', 'low', 'drum', 0, 0, 0 , None, None) - Instrument( "drum3rainstick", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum3tambourinehigh", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum3tambourinelow", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "harmonica", 'inst_tied', 'mid', 'winds', .1531, .19188, .01792 , None, None) - Instrument( "alarm", 'inst_tied', 'mid', 'concret', .02, .19133, .01 , None, None) - Instrument( "bird", 'inst_tied', 'mid', 'animals', .1, 1, .05 , None, None) - Instrument( "cat", 'inst_simp', 'mid', 'animals', 0, 0, 0 , None, None) - Instrument( "duck2", 'inst_simp', 'mid', 'animals', 0, 0, 0 , None, None) - Instrument( "bottle", 'inst_tied', 'mid', 'concret', .20532, .41064, .05292 , None, None) - Instrument( "clang", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "ow", 'inst_simp', 'mid', 'people', 0, 0, 0 , None, None) - Instrument( "sheep", 'inst_simp', 'mid', 'animals', 0, 0, 0 , None, None) - Instrument( "water", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "zap", 'inst_tied', 'mid', 'electronic', .299, .7323, .09895 , None, None) - Instrument( "trumpet", 'inst_tied', 'mid', 'winds', .39934, .45537, .02729, None, None) - Instrument( "bubbles", 'inst_tied', 'mid', 'concret', 0.02, 1.177, 0.02, None, None) - Instrument( "marimba", 'inst_tied', 'mid', 'percussions', .26545, .33098, .03087, None, None) - Instrument( "triangle", 'inst_tied', 'mid', 'percussions', 1.21002, 1.31805, .01268, None, None) - Instrument( "laugh", 'inst_simp', 'mid', 'people', 0, 0, 0 , None, None) - Instrument( "voix", 'inst_tied', 'mid', 'people', .89608, .96092, .02343 , None, None) - Instrument( "cling", 'inst_tied', 'mid', 'electronic', .09096, .7878, .18026 , None, None) - Instrument( "byke", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "door", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "basse", 'inst_tied', 'mid', 'strings', .58455, .67433, .03638 , None, None) - Instrument( "acguit", 'inst_tied', 'mid', 'strings', .58503, .8667, .13699 , None, None) - Instrument( "diceinst", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "didjeridu", 'inst_tied', 'low', 'winds', .55669, 1.73704, .09178 , None, None) - Instrument( "harmonium", 'inst_tied', 'mid', 'keyboard', .04674, .41073, .18384 , None, None) - Instrument( "horse", 'inst_simp', 'mid', 'animals', 0, 0, 0 , None, None) - Instrument( "kalimba", 'inst_tied', 'mid', 'percussions', .20751, .30161, .04658 , None, None) - Instrument( "mando", 'inst_tied', 'mid', 'strings', .50167, .54401, .01984 , None, None) - Instrument( "ocarina", 'inst_tied', 'mid', 'winds', .06612, .19033, .01776 , None, None) - Instrument( "rhodes", 'inst_tied', 'mid', 'keyboard', .65013, .71429, .02205 , None, None) - Instrument( "saxo", 'inst_tied', 'mid', 'winds', .53722, .6583, .05264 , None, None) - Instrument( "shenai", 'inst_tied', 'mid', 'winds', .29003, .33072, .00634 , None, None) - Instrument( "sitar", 'inst_tied', 'mid', 'strings', .63187, .67882, .01654 , None, None) - Instrument( "tuba", 'inst_tied', 'low', 'winds', .51063, .58384, .035 , None, None) - Instrument( "violin", 'inst_tied', 'mid', 'strings', .105, .30656, .028 , None, None) - Instrument( "guidice1", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "guidice2", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "guidice3", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "guidice4", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "guidice5", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "guidice6", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "guidice7", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "guidice8", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "guidice9", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "guidice10", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "drum4afrofeet", 'inst_simp', 'low', 'drum', 0, 0 ,0 , None, None) - Instrument( "drum4fingersn", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum4mutecuic", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum4stompbass", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum4tambouri", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum4tr707clap", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum4tr707open", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum4tr808closed", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum4tr808sn", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum4tr909bass", 'inst_simp', 'low', 'drum', 0, 0, 0 , None, None) - Instrument( "drum4tr909kick", 'inst_simp', 'low', 'drum', 0, 0, 0 , None, None) - Instrument( "drum4tr909sn", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum5timablesslap", 'inst_simp', 'low', 'drum', 0, 0, 0 , None, None) - Instrument( "drum5congagraveouvert", 'inst_simp', 'low', 'drum', 0, 0, 0 , None, None) - Instrument( "drum5timablesaiguslap", 'inst_simp', 'low', 'drum', 0, 0, 0 , None, None) - Instrument( "drum5congagraveferme", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum5guiroretour", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum5vibraslap", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum5congaaiguouvert", 'inst_simp', 'mid', 'drum', 0, 0 ,0 , None, None) - Instrument( "drum5quicamedium", 'inst_simp', 'punch', 'drum', 0, 0, 0 , None, None) - Instrument( "drum5quicaaigu", 'inst_simp', 'mid', 'drum', 0, 0, 0 , None, None) - Instrument( "drum5agogograve", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum5bongoaiguouvert", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum5agogoaigu", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "drum5bongograveouvert", 'inst_simp', 'high', 'drum', 0, 0, 0 , None, None) - Instrument( "camera", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "car", 'inst_tied', 'mid', 'concret', .67, 1.05761, .01 , None, None) - Instrument( "chimes", 'inst_tied', 'mid', 'percussions', .09, 2.97633, .01 , None, None) - Instrument( "crash", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "guit2", 'inst_tied', 'mid', 'strings', .33, 1.1583, .02 , None, None) - Instrument( "plane", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) - Instrument( "slap", 'inst_simp', 'mid', 'concret', 0, 0, 0 , None, None) -INST_byId = {} -for i in INST: - INST_byId[ INST[i].instrumentId] = INST[i] - -KIT_ELEMENT = 24 * [0] -for i in range(0,13): - KIT_ELEMENT += 2 * [i] - -KIT = {} -drum_load_dynamic = 0 -if drum_load_dynamic: - for D in os.listdir(KIT_ROOT): - print 'drum:',D -else: - KIT = { - 'drum1kit' : [ 'drum1kick', 'drum1floortom', 'drum1tom', - 'drum1chine', 'drum1splash', 'drum1crash', - 'drum1snaresidestick', 'drum1snaresidestick', 'drum1snare', - 'drum1ridebell', 'drum1hardride', 'drum1hatshoulder', - 'drum1hatpedal'], - 'drum2kit' : [ "drum2darbukadoom", "drum2darbukapied", "drum2darbukapiedsoft", - "drum2hatflanger", "drum2darbukatak", "drum2darbukatak", - "drum2darbukafinger", "drum2darbukaroll", "drum2darbukaslap", - "drum2hatpied", "drum2tambourinepied", "drum2hatpied2", - "drum2tambourinepiedsoft"], - 'drum3kit' : [ "drum3djembelow", "drum3pedalperc", "drum3djembeslap", - "drum3tambourinehigh", "drum3tambourinelow", "drum3rainstick", - "drum3djembemid", "drum3djembesidestick", "drum3djembestickmid", - "drum3cowbell", "drum3cowbelltip", "drum3cup", - "drum3metalstand"], - 'drum4kit' : [ "drum4afrofeet", "drum4tr909kick", "drum4tr909bass", - "drum4stompbass", "drum4tr707open", "drum4mutecuic", - "drum4tr808sn", "drum4tr707clap", "drum4tr909sn", - "drum4tambouri", "drum4fingersn", "drum4fingersn", - "drum4tr808closed" ], - 'drum5kit' : [ "drum5timablesslap", "drum5timablesaiguslap", "drum5congagraveouvert", - "drum5quicamedium", "drum5guiroretour", "drum5vibraslap", - "drum5congagraveferme", "drum5quicaaigu", "drum5congaaiguouvert", - "drum5agogoaigu", "drum5bongograveouvert", "drum5agogograve", - "drum5bongoaiguouvert" ] - } - -for name in KIT: - KIT[name] = [ INST[e] for e in KIT[name] ] - -if 0: - _nextInstrumentId = [0] - INSTRUMENTS = {} - write_instrument_config = 0 - hard_coded_instruments = 0 - if hard_coded_instruments: - def _addInstrument( name, csoundInstrumentId, instrumentRegister, soundClass, category, loopStart, loopEnd, crossDur, kit = None ): - if write_instrument_config: - if (kit == None): - blah = file('snd/'+name+'.snd', 'w') - print >>blah, (csoundInstrumentId, instrumentRegister, soundClass, category, loopStart, loopEnd, crossDur) - blah.close() - else: - sys.exit(1) - - INSTRUMENTS[name] = Instrument( name, _nextInstrumentId[0], csoundInstrumentId, instrumentRegister, soundClass, category, loopStart, loopEnd, crossDur, kit ) - _nextInstrumentId[0] += 1 - - 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 ) - - else: - - sndlist = os.listdir('snd/') - #print sndlist - sndpaths = [p for p in sndlist if p[-4:] == '.snd'] - - #load the normal instruments - for sndpath in sndpaths: - name = sndpath[0:-4] - sndfile = file('snd/'+sndpath, 'r') - line = sndfile.readline() - #print sndpath, line - tup = eval(line) - if len(tup) == 7: - csoundInstrumentId, instrumentRegister, soundClass, category, loopStart, loopEnd, crossDur = tup - INSTRUMENTS[name] = Instrument( name, _nextInstrumentId[0], - csoundInstrumentId, instrumentRegister, soundClass, - category, loopStart, loopEnd, crossDur, None, None, None ) - else: - print 'loading a gooddmammn img and wav thing!' - csoundInstrumentId, instrumentRegister, soundClass, category, loopStart, loopEnd, crossDur, wav, img = tup - INSTRUMENTS[name] = Instrument( name, _nextInstrumentId[0], - csoundInstrumentId, instrumentRegister, soundClass, - category, loopStart, loopEnd, crossDur, None , wav, img) - _nextInstrumentId[0] += 1 - sndfile.close() - - #load the kits - if 0: - kitpaths = [p for p in sndlist if p[-4:] == '.kit'] #don't use these for now.. - for kitpath in kitpaths: - kitidx = int( kitpath[4] ) - print kitpath, kitidx - exec "DRUM%iKIT = {} ; curkit = DRUM%iKIT" % (kitidx,kitidx) - name = kitpath[0:-4] - kitfile = file('snd/'+ kitpath, 'r') - line = kitfile.readline() - print kitpath, line - - keyval = eval(line) - for kv in keyval: - curkit[kv[0]] = INSTRUMENTS[kv[1]] - - #csoundInstrumentId, instrumentRegister, soundClass, category, loopStart, loopEnd, crossDur = eval( line ) - INSTRUMENTS[name] = Instrument( name, _nextInstrumentId[0], 0, 0, 0, "kit", 0, 0, 0, curkit) - _nextInstrumentId[0] += 1 - kitfile.close() - - else: - def _addInstrument( name, csoundInstrumentId, instrumentRegister, soundClass, category, loopStart, loopEnd, crossDur, kit = None ): - blah = file('snd/' + name + '.kit', 'w') - print >>blah, [(k, kit[k].name) for k in kit.keys()] - blah.close() - INSTRUMENTS[name] = Instrument( name, _nextInstrumentId[0], csoundInstrumentId, instrumentRegister, soundClass, category, loopStart, loopEnd, crossDur, kit ) - _nextInstrumentId[0] += 1 - print INSTRUMENTS[name] - - - _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 ) - - #import sys - #sys.exit(0) - - 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 } diff --git a/common/Util/NoteLooper.py b/common/Util/NoteLooper.py deleted file mode 100644 index be6f0b6..0000000 --- a/common/Util/NoteLooper.py +++ /dev/null @@ -1,199 +0,0 @@ -import pickle -import time -import bisect - -import pygtk -pygtk.require( '2.0' ) -import gtk -import gobject - -import common.Config as Config -from common.Util.CSoundNote import CSoundNote #maybe not actually used, but dependence is there. All notes are assumed to be CSoundNotes -from common.Generation.GenerationConstants import GenerationConstants - -#------------------------------------------------------------------------------ -# A base class used to play a collection of Events at their respective onsets -#------------------------------------------------------------------------------ -class NoteLooper_DONTUSE: - - #PRIVATE - DRIFT = 0.01 #careful about changing this... coordinate with instrument 5777 - - #PUBLIC - - def __init__( self, range_sec, ticks_per_sec ): - self.ticks_per_sec = ticks_per_sec # ticks last this long - self.secs_per_tick = 1.0 / ticks_per_sec # precomputed inverse - self.range_sec = range_sec # notes are checked-for, this many seconds in advance - - self.duration = 0 # number of ticks in playback loop - self.loops = 0 # number of elapsed loops - self.notes = [] # sorted list of (onset, noteptr, cache) - - self.time0 = time.time() + 1000000 # the real time at which tick == 0 (sometimes retro-active) - - #self.time_start # remember to call NoteLooper.startTime - # at the same time as you call - # CSoundClient.startTime() - def setTick( self, tick ): - time_time = time.time() - self.time0 = time_time - tick * self.secs_per_tick - self.loops = tick // self.duration - self.hIdx = bisect.bisect_left(self.notes, tick - self.duration * self.loops ) - - def setRate( self, ticks_per_sec): - if ticks_per_sec != self.ticks_per_sec: - secs_per_tick = 1.0 / ticks_per_sec - - time_time = time.time() - curtick = self.getTick( time_time, False ) - curticktime = curtick * self.secs_per_tick + self.time0 - - self.ticks_per_sec = ticks_per_sec - self.secs_per_tick = secs_per_tick - self.time0 = curticktime - curtick * secs_per_tick - self.notes = [ (o,n,'',z) for (o,n,c,z) in self.notes ] #clear cache - self.loops = 0 - - def setDuration( self, duration ): - self.time0 += self.loops * self.duration * self.secs_per_tick - self.loops = 0 - self.duration = duration - - def getTick(self, t, domod): #t is for time - if domod : - return ( int( ( t - self.time0 ) * self.ticks_per_sec ) ) % self.duration - else : - return ( int( ( t - self.time0 ) * self.ticks_per_sec ) ) - - def next( self ) : - time_time = time.time() - #tickhorizon is tick where we'll be after range_sec - tickhorizon = self.getTick( self.range_sec + time_time, False ) - time0_time = self.time0 - self.time_start + self.DRIFT - - if tickhorizon < 0 : return [] - if len(self.notes) == 0 : return [] - - def cache_cmd(secs_per_tick, amplitude, pitch, inst, trackId, duration, tied, fullDuration, overlap, attack, decay, reverbSend, filterType, filterCutoff, pan ): - if inst[0:4] == 'drum': - if pitch in GenerationConstants.DRUMPITCH: - key = GenerationConstants.DRUMPITCH[ pitch ] - else: - key = pitch - - if inst == 'drum1kit': - inst = Config.DRUM1INSTRUMENTS[ key ] - if inst == 'drum2kit': - inst = Config.DRUM2INSTRUMENTS[ key ] - if inst == 'drum3kit': - inst = Config.DRUM3INSTRUMENTS[ key ] - pitch = 1 - - else: - pitch = GenerationConstants.TRANSPOSE[ pitch - 24 ] - - # condition for tied notes - if Config.INSTRUMENTS[ inst ].csoundInstrumentId == 101 and tied and fullDuration: - duration= -1.0 - # condition for overlaped notes - if Config.INSTRUMENTS[ inst ].csoundInstrumentId == 102 and overlap: - duration += 1.0 - - attack = max( 0.002, duration * attack) - decay = max( 0.002, duration * decay) - - rval = Config.PLAY_NOTE_COMMAND_MINUS_DELAY % \ - ( Config.INSTRUMENTS[ inst ].csoundInstrumentId, - trackId, - '%f', #delay, - duration, - pitch, - reverbSend, - amplitude, - pan, - Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[ inst ].instrumentId, - attack, - decay, - filterType, filterCutoff ) - return rval - - def getText(i, secs_per_tick, time_offset): - (onset,note,cache,z) = self.notes[i] - if cache == '' or note.nchanges != z : - self.notes[i] = \ - ( - onset, - note, - cache_cmd( - secs_per_tick, - note.amplitude, # * track-level mixer rate - note.pitch, - note.instrumentFlag, - note.trackId, - note.duration * self.secs_per_tick, - note.tied, - note.fullDuration, - note.overlap, - note.attack, - note.decay, - note.reverbSend, - note.filterType, - note.filterCutoff, - note.pan), - note.nchanges - ) - rval = self.notes[i][2] % float(onset * self.secs_per_tick + time_offset) - return rval - - prev_secs = (self.loops * self.duration) * self.secs_per_tick - rval = [] - while self.notes[self.hIdx][0] + self.loops * self.duration < tickhorizon: - rval.append ( getText(self.hIdx, self.secs_per_tick, prev_secs + time0_time ) ) - self.hIdx += 1 - if self.hIdx == len(self.notes): - self.hIdx = 0 - self.loops += 1 - prev_secs += self.duration * self.secs_per_tick - - return rval - - def insert( self, notes): - def insertMany(): - self.notes += [ ( notes[i][0], notes[i][1], '', 0 ) for i in xrange(len(notes)) ] - self.notes.sort() - def insertFew(): - for i in xrange(len(notes)): - t = (notes[i][0], notes[i][1],'',0) - l = bisect.bisect_left(self.notes, t ) - self.notes.insert(l, t) - - if len(notes) >= 1: - insertMany() - else: - insertFew() - self.hIdx = bisect.bisect_left(self.notes, self.getTick(self.range_sec + time.time(), True)) - - def remove(self, note): - def removeFew(): - i = 0 - while i < len(self.notes): - if self.notes[i][1] in note: - del self.notes[i] - else: - i += 1 - - def removeMany(): - self.notes = [t for t in self.notes if t[1] not in note] - - if len(idset) >= 0: #just guessing here, should do some timing tests to see if this is good or no - removeMany() - else: - removeFew() - self.hIdx = bisect.bisect_left(self.notes, self.getTick(self.range_sec + time.time(), True)) - - def clear(self): - self.notes = [] - - def startTime(self): - self.time_start = time.time() diff --git a/common/Util/Sound.py b/common/Util/Sound.py deleted file mode 100644 index 37edf8f..0000000 --- a/common/Util/Sound.py +++ /dev/null @@ -1,289 +0,0 @@ -import bisect -import csnd -import os -import socket -import select -import sys -import thread -import time - -from sugar import env -import common.Config as Config - -from common.Util.CSoundNote import CSoundNote #maybe not actually used, but dependence is there. All notes are assumed to be CSoundNotes -from common.Generation.GenerationConstants import GenerationConstants - -class Sound: - #TODO: remove - def inputMessage(self, txt): - self.perf.InputMessage(txt) - - #PRIVATE - DRIFT = 0.01 #careful about changing this... coordinate with instrument 5777 - def loop_work(self, sleeptime): - def next( ) : - time_time = time.time() - #tickhorizon is tick where we'll be after range_sec - tickhorizon = self.getTick( self.range_sec + time_time, False ) - time0_time = self.time0 - self.time_start + self.DRIFT - - if tickhorizon < 0 : return [] - if len(self.notes) == 0 : return [] - - def cache_cmd(secs_per_tick, amplitude, pitch, inst, trackId, duration, tied, fullDuration, overlap, attack, decay, reverbSend, filterType, filterCutoff, pan ): - if inst[0:4] == 'drum': - if pitch in GenerationConstants.DRUMPITCH: - key = GenerationConstants.DRUMPITCH[ pitch ] - else: - key = pitch - - if inst == 'drum1kit': - inst = Config.DRUM1INSTRUMENTS[ key ] - if inst == 'drum2kit': - inst = Config.DRUM2INSTRUMENTS[ key ] - if inst == 'drum3kit': - inst = Config.DRUM3INSTRUMENTS[ key ] - pitch = 1 - - else: - pitch = GenerationConstants.TRANSPOSE[ pitch - 24 ] - - # condition for tied notes - if Config.INSTRUMENTS[ inst ].csoundInstrumentId == 101 and tied and fullDuration: - duration= -1.0 - # condition for overlaped notes - if Config.INSTRUMENTS[ inst ].csoundInstrumentId == 102 and overlap: - duration += 1.0 - - attack = max( 0.002, duration * attack) - decay = max( 0.002, duration * decay) - - rval = Config.PLAY_NOTE_COMMAND_MINUS_DELAY % \ - ( Config.INSTRUMENTS[ inst ].csoundInstrumentId, - trackId, - '%f', #delay, - duration, - pitch, - reverbSend, - amplitude, - pan, - Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[ inst ].instrumentId, - attack, - decay, - filterType, filterCutoff ) - return rval - - def getText(i, secs_per_tick, time_offset): - (onset,note,cache,z) = self.notes[i] - if cache == '' or note.nchanges != z : - self.notes[i] = \ - ( - onset, - note, - cache_cmd( - secs_per_tick, - note.amplitude, # * track-level mixer rate - note.pitch, - note.instrumentFlag, - note.trackId, - note.duration * self.secs_per_tick, - note.tied, - note.fullDuration, - note.overlap, - note.attack, - note.decay, - note.reverbSend, - note.filterType, - note.filterCutoff, - note.pan), - note.nchanges - ) - rval = self.notes[i][2] % float(onset * self.secs_per_tick + time_offset) - return rval - - prev_secs = (self.loops * self.duration) * self.secs_per_tick - rval = [] - while self.notes[self.hIdx][0] + self.loops * self.duration < tickhorizon: - rval.append ( getText(self.hIdx, self.secs_per_tick, prev_secs + time0_time ) ) - self.hIdx += 1 - if self.hIdx == len(self.notes): - self.hIdx = 0 - self.loops += 1 - prev_secs += self.duration * self.secs_per_tick - - return rval - - #thread.start_new_thread( testtimer, (0,) ) - m = 0.0 - while self.thread_continue: - t0 = time.time() - time.sleep(sleeptime) - t1 = time.time() - if t1 - t0 > 2.0 * sleeptime : - print 'critical lagginess: ', t1 - t0 - if m < t1 - t0: - m = t1 - t0 - print t1, ' timer max = ', m - if self.playing : - cmds = self.next() - for c in cmds: - self.perf.InputMessage( c ) - - # create the object, and launch the loop thread - def __init__(self, orc, range_sec, ticks_per_sec ): - self.orc = orc - self.up = False - self.ticks_per_sec = ticks_per_sec # ticks last this long - self.secs_per_tick = 1.0 / ticks_per_sec # precomputed inverse - self.range_sec = range_sec # notes are checked-for, this many seconds in advance - self.duration = 1 # number of ticks in playback loop - self.loops = 0 # number of elapsed loops - self.notes = [] # sorted list of (onset, noteptr, cache) - self.time0 = time.time() + 1000000 # the real time at which tick == 0 (sometimes retro-active) - self.thread_continue = 1 - self.playing = False - #self.thread = thread.start_new_thread( self.loop_work, (0.040,) ) - self.csound = csnd.Csound() - - # join the loop thread, clean up everything. - def uninit(self): - #self.thread_continue = 0 - #self.thread.join() - #if self.up : - # self.lower() - self.csound.Reset() - pass - - # (re)start playback and seize the sound device - def connect(self): - def startTime(): - if not self.up : - debug_print (1, "ERROR: Sound::startTime, performance thread isn't up yet.") - return - self.perf.InputMessage('i 5999 0.0 60000000') - self.time_start = time.time() - # if a note event is sent to csound before or simultaneous to this one, then it will not play correctly. - # thus we sleep right here, to (ideally) let csound pick up the message. - # NB: match this to the constant in the instrument 5777 of the csound orcestra - time.sleep(0.1) - def load_instruments( ): - home_path = env.get_profile_path() + Config.PREF_DIR - for instrumentSoundFile in Config.INSTRUMENTS.keys(): - if instrumentSoundFile[0:3] == 'mic' or instrumentSoundFile[0:3] == 'lab': - fileName = home_path + '/' + instrumentSoundFile - else: - fileName = Config.SOUNDS_DIR + "/" + instrumentSoundFile - instrumentId = Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[ instrumentSoundFile ].instrumentId - self.load_instruments(instrumentId, fileName) - if self.up : - debug_print(3, 'Sound::raise() already up.') - return - self.up = True - self.perf = csnd.CsoundPerformanceThread(self.csound) - self.csound.Compile( self.orc ) - self.perf.Play() - load_instruments() - start_time() - debug_print(5, 'Sound::raise succeeded') - - # stop playback and free the sound device - def disconnect(self): - def unload_instruments(): - self.perf.InputMessage('i%d 0 0.1 %d' % (Config.INST_FREE, len(Config.INSTRUMENTS))) - - if not self.up : - debug_print(3, 'Sound::lower() already down.') - return - self.up = False - unload_instruments() - self.perf.Stop() - rval = self.perf.Join() - self.csound.Reset() - debug_print(5, 'Sound::lower() succeeded') - - def micRecording( self, table ): - self.perf.InputMessage('i5201 0 5 %d' % table) - def load_instrument(self, id, fname): - self.perf.InputMessage('f%d 0 0 -1 \"%s\" 0 0 0' % (id, fname )) - def load_mic_instrument( self, inst ): - home_path = env.get_profile_path() + Config.PREF_DIR - fileName = home_path + '/' + inst - instrumentId = Config.INSTRUMENT_TABLE_OFFSET + int(fileName[-1]) + 6 - self.load_instrument(instrumentId, fileName) - - def setMasterVolume(self, volume): - self.csound.SetChannel('masterVolume',volume ) - - def loop_start(self): - self.playing = True - - def loop_stop(self): - self.playing = False - - def loop_getTick(self, t, domod): #t is for time - if domod : - return ( int( ( t - self.time0 ) * self.ticks_per_sec ) ) % self.duration - else : - return ( int( ( t - self.time0 ) * self.ticks_per_sec ) ) - - def loop_setTick( self, tick ): - time_time = time.time() - self.time0 = time_time - tick * self.secs_per_tick - self.loops = tick // self.duration - self.hIdx = bisect.bisect_left(self.notes, tick - self.duration * self.loops ) - - def loop_setRate( self, ticks_per_sec): - if ticks_per_sec != self.ticks_per_sec: - secs_per_tick = 1.0 / ticks_per_sec - - time_time = time.time() - curtick = self.getTick( time_time, False ) - curticktime = curtick * self.secs_per_tick + self.time0 - - self.ticks_per_sec = ticks_per_sec - self.secs_per_tick = secs_per_tick - self.time0 = curticktime - curtick * secs_per_tick - self.notes = [ (o,n,'',z) for (o,n,c,z) in self.notes ] #clear cache - self.loops = 0 - - def loop_setDuration( self, duration ): - self.time0 += self.loops * self.duration * self.secs_per_tick - self.loops = 0 - self.duration = duration - - def loop_insert( self, notes): - def insertMany(): - self.notes += [ ( notes[i][0], notes[i][1], '', 0 ) for i in xrange(len(notes)) ] - self.notes.sort() - def insertFew(): - for i in xrange(len(notes)): - t = (notes[i][0], notes[i][1],'',0) - l = bisect.bisect_left(self.notes, t ) - self.notes.insert(l, t) - - if len(notes) >= 1: - insertMany() - else: - insertFew() - self.hIdx = bisect.bisect_left(self.notes, self.getTick(self.range_sec + time.time(), True)) - - def loop_remove(self, note): - def removeFew(): - i = 0 - while i < len(self.notes): - if self.notes[i][1] in note: - del self.notes[i] - else: - i += 1 - - def removeMany(): - self.notes = [t for t in self.notes if t[1] not in note] - - if len(idset) >= 0: #just guessing here, should do some timing tests to see if this is good or no - removeMany() - else: - removeFew() - self.hIdx = bisect.bisect_left(self.notes, self.getTick(self.range_sec + time.time(), True)) - - def loop_clear(self): - self.notes = [] -- cgit v0.9.1