From 1becac24dfa6bd0cee4ae46f4c0b8630bfbb6269 Mon Sep 17 00:00:00 2001 From: jaberg Date: Sun, 07 Jan 2007 21:24:04 +0000 Subject: unify_edit init --- diff --git a/Config.py b/Config.py index b224b0e..55f2d85 100644 --- a/Config.py +++ b/Config.py @@ -1,6 +1,8 @@ +# -*- coding: utf-8 -*- + import os -TAM_TAM_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +TAM_TAM_ROOT = os.path.dirname(os.path.abspath(__file__)) print 'INFO: loaded TAMTAM_ROOT=%s' % TAM_TAM_ROOT #BUFFERING @@ -8,8 +10,8 @@ CSOUND_HORIZON = 0.100 CLOCK_DELAY = 0.04 #PATHS -SOUNDS_DIR = Constants.TAM_TAM_ROOT + "/Resources/Sounds" -FILES_DIR = Constants.TAM_TAM_ROOT + "/Resources" +SOUNDS_DIR = TAM_TAM_ROOT + "/Resources/Sounds" +FILES_DIR = TAM_TAM_ROOT + "/Resources" #SERVER SERVER_ADDRESS = "localhost" @@ -344,7 +346,7 @@ UNLOAD_TABLES_COMMAND = \ ################# LANGUAGE = 'En' -IMAGE_ROOT = Constants.TAM_TAM_ROOT + '/Resources/Images/' +IMAGE_ROOT = TAM_TAM_ROOT + '/Resources/Images/' NOTE_HEIGHT = 6 # pixels NOTE_BORDER_SIZE = 1 @@ -432,3 +434,338 @@ NUMBER_OF_PAGES = 2 MINIMUM_AMPLITUDE = 0 MAXIMUM_AMPLITUDE = 1 + + +#################### +## ToolTips +#################### +class Tooltips: + + #English + if LANGUAGE == 'En': + #miniTamTam + VOL = 'Volume' + REV = 'Reverb' + PLAY = 'Play / Stop' + STOP = 'Stop' + SEQ = 'Sequencer' + GEN = 'Generate' + COMPL = 'Complexity of beat' + BEAT = 'Beats per bar' + TEMPO = 'Tempo' + JAZZ = 'Jazz / Rock Kit' + AFRI = 'African Kit' + ARAB = 'Arabic Kit' + RECMIC = 'Record using the microphone' + RECLAB = 'Open SynthLab to create sounds' + + #Synthlab + SOURCE = 'Source' + EFFECT = 'Effect' + CONTROL = 'Control' + SOUNDOUT = 'Sound Output' + SOUNDDUR = 'Sound Duration' + SAVE = 'Save' + LOAD = 'Load' + SAVEMINI = 'Save to miniTamTam' + CLOSE = 'Close' + RESET = 'Reset' + + #Controls + LFO = 'Low frequency oscillator' + AMP = 'Amplitude' + FREQ = 'Frequency' + WAVEFORM = 'Waveform' + OFFSET = 'Offset' + + RANDOM = 'Random' + MIN = 'Minimum' + MAX = 'Maximum' + FREQ = FREQ + SEED = 'Seed' + + ADSR = 'ADSR Envelope' + ATTACK = 'Attack' + DECAY = 'Decay' + SUSTAIN = 'Sustain' + RELEASE = 'Release' + + #Source + FM = 'Fequency Modulator' + CAR = 'Carrier Frequency' + MOD = 'Modulator Frequency' + INDEX = 'Index' + GAIN = 'Gain' + + BUZZ = 'Buzz' + FREQ = FREQ + NHARM = 'Number of harmonics' + FSLOPE = 'Filter Slope' + GAIN = GAIN + + VCO = 'Voltage Controlled Oscillator' + FREQ = FREQ + WAVEFORM = WAVEFORM + FSLOPE = FSLOPE + GAIN = GAIN + + PLUCK = 'Pluck' + FREQ = FREQ + LFILTER = 'Lowpass Filter' + VIBRATO = 'Vibrato' + GAIN = GAIN + + NOISE = 'Noise' + NOISETYPE = 'Type: White | Pink | Gaussian' + FREQ = FREQ + BANDWITH = 'Bandwith' + GAIN = GAIN + + SAMPLE = 'Sound Sample' + FREQ = FREQ + SAMPLEN = 'Sample Number' + LFILTER = LFILTER + GAIN = GAIN + + VOICE = 'Voice' + FREQ = FREQ + VOWEL = 'Vowel' + VIBRATO = VIBRATO + GAIN = GAIN + + #Effects + DELAY = 'Delay' + FREQ = FREQ + LFILTER = LFILTER + FEEDBACK = 'Feedback' + GAIN = GAIN + + DIST = 'Distortion' + FREQ = FREQ + RESON = 'Resonance' + DISTL = 'Distotion Level' + GAIN = GAIN + + FILTER = 'Filter' + FREQ = FREQ + FSLOPE = FSLOPE + FTYPE = 'Filter type: Low Pass | High Pass | Band Pass' + GAIN = GAIN + + RINGMOD = 'Ring Modulator' + FREQ = FREQ + AMP = 'Amplitude' + WAVEFORM = WAVEFORM + GAIN = GAIN + + REVERB = 'Reverb' + REVERBD = 'Length' + REVERBF = 'Lowpass Filter' + REVERBL = 'Reverb Level' + GAIN = GAIN + + HARMON = 'Harmonizer' + FREQ = FREQ + DRYDELAY = 'Dry delay' + MIX = 'Mix' + GAIN = GAIN + SYNTHTYPE = { } + SYNTHPARA = { 'lfo': [AMP, FREQ, WAVEFORM, OFFSET], + 'rand': [MIN, MAX, FREQ, SEED], + 'adsr': [ATTACK, DECAY, SUSTAIN, RELEASE], + 'fm': [CAR, MOD, INDEX, GAIN], + 'buzz': [FREQ, NHARM, FSLOPE, GAIN], + 'vco': [FREQ, WAVEFORM, FSLOPE, GAIN], + 'pluck': [FREQ, LFILTER, VIBRATO, GAIN], + 'noise': [NOISETYPE, FREQ, BANDWITH, GAIN], + 'sample': [FREQ, SAMPLEN, LFILTER, GAIN], + 'voice': [FREQ, VOWEL, VIBRATO, GAIN], + 'wguide': [FREQ, LFILTER, FEEDBACK, GAIN], + 'distort': [FREQ, RESON, DISTL, GAIN], + 'filter': [FREQ, FSLOPE, FTYPE, GAIN], + 'ring': [FREQ, AMP, WAVEFORM, GAIN], + 'reverb': [REVERBD, REVERBF, REVERBL, GAIN], + 'harmon': [FREQ, DRYDELAY, MIX, GAIN]} + #French + elif LANGUAGE == 'Fr': + #miniTamTam + VOL = 'Volume' + REV = 'Réverbération' + PLAY = 'Lecture / Arrêt' + STOP = 'Stop' + GEN = 'Générer' + COMPL = 'Complexité du rythme' + BEAT = 'Temps par mesure' + TEMPO = 'Tempo' + JAZZ = 'Kit Jazz / Rock' + AFRI = 'Kit Africain' + ARAB = 'Kit Arabe' + RECMIC = 'Enregistrer avec le micro' + RECLAB = 'Ouvrir SynthLab pour créer des sons' + + #Synthlab + SOURCE = 'Source' + EFFECT = 'Effet' + CONTROL = 'Contrôle' + SOUNDOUT = 'Sortie sonore' + SOUNDDUR = 'Durée du son' + SAVE = 'Sauvegarder' + LOAD = 'Ouvrir' + SAVEMINI = 'Sauvegarder dans miniTamTam' + CLOSE = 'Fermer' + RESET = 'Réinitialiser' + + #Controls + LFO = 'Oscillateur basse fréquence' + AMP = 'Amplitude' + FREQ = 'Fréquence' + WAVEFORM = "Forme d'onde'" + RANDOM = 'Aléatoire' + MIN = 'Minimum' + MAX = 'Maximum' + FREQ = FREQ + + ADSR = 'Envelope ADSR' + ATTACK = 'Attaque' + DECAY = 'Chute' + SUSTAIN = 'Tenue' + RELEASE = 'Relâche' + + #Source + FM = 'Modulateur de fréquence' + CAR = 'Fréquence porteuse' + MOD = 'Fréquence modulatrice' + INDEX = 'Index' + GAIN = 'Gain' + + BUZZ = 'Buzz' + FREQ = FREQ + NHARM = "Nombre d'harmoniques" + FSLOPE = 'Pente du filtre' + GAIN = GAIN + + VCO = 'Oscillateur controlé par voltage' + FREQ = FREQ + WAVEFORM = WAVEFORM + FSLOPE = FSLOPE + GAIN = GAIN + + PLUCK = 'Corde pincée' + FREQ = FREQ + GAIN = GAIN + + NOISE = 'Bruit' + NOISETYPE = 'Type: Blanc | Rose | Gaussien' + GAIN = GAIN + + SAMPLE = 'Échantillon sonore' + FREQ = FREQ + SAMPLEN = "Numéro d'échantillon" + GAIN = GAIN + + VOICE = 'Voix' + FREQ = FREQ + VOWEL = 'Voyelle: U->A->I' + + #Effects + DELAY = 'Délai' + FREQ = FREQ + LFILTER = 'Filtre passe-bas' + FEEDBACK = 'Réinjection' + GAIN = GAIN + + DIST = 'Distorsion' + FREQ = FREQ + RESON = 'Résonance' + DISTL = 'Niveau de distosion' + GAIN = GAIN + + FILTER = 'Filtre' + FREQ = FREQ + FSLOPE = FSLOPE + FTYPE = 'Type de filtre: Passe-bas | Passe-haut | Passe-bande' + GAIN = GAIN + + RINGMOD = 'Modulateur par anneaux' + FREQ = FREQ + AMP = 'Amplitude' + GAIN = GAIN + + REVERB = 'Réverbération' + REVERBD = 'Durée' + REVERBF = 'Filtre passe-bas' + REVERBL = 'Niveau de réverbération' + GAIN = GAIN + + HARMON = 'Harmonizer' + FREQ = FREQ + HARMONL = "Niveau de l'harmonizer" + GAIN = GAIN + + +#################### +## KeyMapping +#################### + +# 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/GUI/Core/BackgroundView.py b/Edit/BackgroundView.py index ff6e75f..ff6e75f 100644 --- a/GUI/Core/BackgroundView.py +++ b/Edit/BackgroundView.py diff --git a/GUI/Core/KeyboardInput.py b/Edit/KeyboardInput.py index d1a0d83..d1a0d83 100644 --- a/GUI/Core/KeyboardInput.py +++ b/Edit/KeyboardInput.py diff --git a/GUI/Core/MainWindow.py b/Edit/MainWindow.py index 2a7ab8e..2a7ab8e 100644 --- a/GUI/Core/MainWindow.py +++ b/Edit/MainWindow.py diff --git a/GUI/Core/MicRecordingWindow.py b/Edit/MicRecordingWindow.py index a5424f7..a5424f7 100644 --- a/GUI/Core/MicRecordingWindow.py +++ b/Edit/MicRecordingWindow.py diff --git a/GUI/Core/MixerWindow.py b/Edit/MixerWindow.py index b630856..b630856 100644 --- a/GUI/Core/MixerWindow.py +++ b/Edit/MixerWindow.py diff --git a/GUI/Core/NoteInterface.py b/Edit/NoteInterface.py index 93ffed3..93ffed3 100644 --- a/GUI/Core/NoteInterface.py +++ b/Edit/NoteInterface.py diff --git a/GUI/Core/NoteParametersWindow.py b/Edit/NoteParametersWindow.py index f5be5b5..f5be5b5 100644 --- a/GUI/Core/NoteParametersWindow.py +++ b/Edit/NoteParametersWindow.py diff --git a/GUI/Core/NoteView.py b/Edit/NoteView.py index ac139a1..ac139a1 100644 --- a/GUI/Core/NoteView.py +++ b/Edit/NoteView.py diff --git a/GUI/Core/PageBankView.py b/Edit/PageBankView.py index 8643b24..8643b24 100644 --- a/GUI/Core/PageBankView.py +++ b/Edit/PageBankView.py diff --git a/GUI/Core/PageView.py b/Edit/PageView.py index eddf0d1..eddf0d1 100644 --- a/GUI/Core/PageView.py +++ b/Edit/PageView.py diff --git a/GUI/Core/PositionIndicator.py b/Edit/PositionIndicator.py index aadc4f4..aadc4f4 100644 --- a/GUI/Core/PositionIndicator.py +++ b/Edit/PositionIndicator.py diff --git a/GUI/Core/TrackInterface.py b/Edit/TrackInterface.py index 2490da7..2490da7 100644 --- a/GUI/Core/TrackInterface.py +++ b/Edit/TrackInterface.py diff --git a/GUI/Core/TrackView.py b/Edit/TrackView.py index 0b66abd..0b66abd 100644 --- a/GUI/Core/TrackView.py +++ b/Edit/TrackView.py diff --git a/GUI/Core/TuneInterface.py b/Edit/TuneInterface.py index c6fda09..c6fda09 100644 --- a/GUI/Core/TuneInterface.py +++ b/Edit/TuneInterface.py diff --git a/GUI/Core/TunePageView.py b/Edit/TunePageView.py index f708587..f708587 100644 --- a/GUI/Core/TunePageView.py +++ b/Edit/TunePageView.py diff --git a/GUI/Core/TuneView.py b/Edit/TuneView.py index 63cf468..63cf468 100644 --- a/GUI/Core/TuneView.py +++ b/Edit/TuneView.py diff --git a/Framework/CSound/__init__.py b/Edit/__init__.py index e69de29..e69de29 100644 --- a/Framework/CSound/__init__.py +++ b/Edit/__init__.py diff --git a/Framework/CSound/CSoundConstants.py b/Framework/CSound/CSoundConstants.py deleted file mode 100755 index 05a17e7..0000000 --- a/Framework/CSound/CSoundConstants.py +++ /dev/null @@ -1,314 +0,0 @@ -from Framework.Constants import Constants -from Framework.CSound.Instrument import Instrument - -class CSoundConstants: - #PATHS - SOUNDS_DIR = Constants.TAM_TAM_ROOT + "/Resources/Sounds" - FILES_DIR = Constants.TAM_TAM_ROOT + "/Resources" - - #SERVER - SERVER_ADDRESS = "localhost" - SERVER_PORT = 40007 - - SERVER_REQUIRED = 0 - - INIT_ATTEMPTS = 2 - INIT_DELAY = 1.0 - - #SOUNDS - - # animals - OUNK = "ounk" - DOG = "dog" - DUCK = "duck" - BIRD = "bird" - CAT = "cat" - DUCK2 = "duck2" - HORSE = "horse" - - # synthesis - FM2 = "fm2" - - # melodic percussion - GAM = "gam" - GONG = "gong" - PIANO = "piano" - RHODES = "rhodes" - KALIMBA = "kalimba" - - # non-melodic percussion - DRUM1CHINE = "drum1chine" - DRUM1CRASH = "drum1crash" - DRUM1FLOORTOM = "drum1floortom" - DRUM1HARDRIDE = "drum1hardride" - DRUM1HATPEDAL = "drum1hatpedal" - DRUM1HATSHOULDER = "drum1hatshoulder" - DRUM1KICK = "drum1kick" - DRUM1RIDEBELL = "drum1ridebell" - DRUM1SNARE = "drum1snare" - DRUM1SNARESIDESTICK = "drum1snaresidestick" - DRUM1SPLASH = "drum1splash" - DRUM1TOM = "drum1tom" - DRUM1KIT = "drum1kit" - - DRUM2DARBUKADOOM = "drum2darbukadoom" - DRUM2DARBUKAFINGER = "drum2darbukafinger" - DRUM2DARBUKAPIED = "drum2darbukapied" - DRUM2DARBUKAPIEDSOFT = "drum2darbukapiedsoft" - DRUM2DARBUKAROLL = "drum2darbukaroll" - DRUM2DARBUKASLAP = "drum2darbukaslap" - DRUM2DARBUKATAK = "drum2darbukatak" - DRUM2HATFLANGER = "drum2hatflanger" - DRUM2HATPIED = "drum2hatpied" - - DRUM2HATPIED2 = "drum2hatpied2" - DRUM2TAMBOURINEPIED = "drum2tambourinepied" - DRUM2TAMBOURINEPIEDSOFT = "drum2tambourinepiedsoft" - DRUM2KIT = "drum2kit" - - DRUM3COWBELL = "drum3cowbell" - DRUM3COWBELLTIP = "drum3cowbelltip" - DRUM3CUP = "drum3cup" - DRUM3DJEMBELOW = "drum3djembelow" - DRUM3DJEMBEMID = "drum3djembemid" - DRUM3DJEMBESIDESTICK = "drum3djembesidestick" - DRUM3DJEMBESLAP = "drum3djembeslap" - DRUM3DJEMBESTICKMID = "drum3djembestickmid" - DRUM3METALSTAND = "drum3metalstand" - DRUM3PEDALPERC = "drum3pedalperc" - DRUM3RAINSTICK = "drum3rainstick" - DRUM3TAMBOURINEHIGH = "drum3tambourinehigh" - DRUM3TAMBOURINELOW = "drum3tambourinelow" - DRUM3KIT = "drum3kit" - - # weird - BOTTLE = "bottle" - CLANG = "clang" - CLING = "cling" - DOOR = "door" - LAUGH = "laugh" - OW = "ow" - SHEEP = "sheep" - TCHIWO = "tchiwo" - WATER = "water" - ZAP = "zap" - DICEINST = "diceinst" - GUIDICE1 = "guidice1" - GUIDICE2 = "guidice2" - GUIDICE3 = "guidice3" - GUIDICE4 = "guidice4" - GUIDICE5 = "guidice5" - GUIDICE6 = "guidice6" - GUIDICE7 = "guidice7" - GUIDICE8 = "guidice8" - GUIDICE9 = "guidice9" - GUIDICE10 = "guidice10" - - # string - ACGUIT = "acguit" - BASSE = "basse" - GUIT = "guit" - KOTO = "koto" - MANDO = "mando" - SITAR = "sitar" - VIOLIN = "violin" - - # perc - MARACAS = "maracas" - MARIMBA = "marimba" - TRIANGLE = "triangle" - - # wind - CLARINETTE = "clarinette" - FLUTE = "flute" - TRUMPET = 'trumpet' - VOIX = "voix" - DIDJERIDU = "didjeridu" - HARMONICA = "harmonica" - HARMONIUM = "harmonium" - OCARINA = "ocarina" - SAXO = "saxo" - SHENAI = "shenai" - TUBA = "tuba" - - # recorded snds - MIC1 = "mic1" - MIC2 = "mic2" - MIC3 = "mic3" - MIC4 = "mic4" - - # synthLab snds - LAB1 = "lab1" - LAB2 = "lab2" - LAB3 = "lab3" - LAB4 = "lab4" - - 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_PERC = 5002 - INST_SIMP = 5003 - - INSTRUMENTS = { - OUNK : Instrument( 0, INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 ), - GAM : Instrument( 1, INST_TIED, HIGH, 'melo', 'musicInst', .69388, .7536, .02922 ), - GONG : Instrument( 2, INST_SIMP, LOW, 'melo', 'musicInst', 0, 0, 0 ), - GUIT : Instrument( 3, INST_TIED, MID, 'melo', 'musicInst', .08592, .75126, .33571 ), - KOTO : Instrument( 4, INST_TIED, HIGH, 'melo', 'musicInst', .56523, .70075, .05954 ), - CLARINETTE : Instrument( 5, INST_TIED, MID, 'melo', 'musicInst', .57905, .73319, .04934 ), - FLUTE : Instrument( 6, INST_TIED, MID, 'melo', 'musicInst', .47169, .53693, .02481 ), - MIC1: Instrument( 7, INST_TIED, MID, 'melo', 'mic', .1, .9, .1 ), - MIC2: Instrument( 8, INST_TIED, MID, 'melo', 'mic', .1, .9, .1 ), - MIC3: Instrument( 9, INST_TIED, MID, 'melo', 'mic', .1, .9, .1 ), - MIC4: Instrument( 10, INST_TIED, MID, 'melo', 'mic', .1, .9, .1 ), - DRUM1HATPEDAL: Instrument( 11, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 ), - DRUM1HATSHOULDER: Instrument( 12, INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 ), - DRUM1HARDRIDE: Instrument( 13, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 ), - DRUM1RIDEBELL: Instrument( 14, INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 ), - DRUM1SNARE: Instrument( 15, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 ), - DRUM1SNARESIDESTICK: Instrument( 16, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 ), - DRUM1CRASH: Instrument( 17, INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 ), - DRUM1SPLASH: Instrument( 18, INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 ), - DRUM1TOM: Instrument( 19, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 ), - DRUM1FLOORTOM: Instrument( 20, INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0), - DRUM1CHINE: Instrument( 21, INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 ), - DRUM1KICK: Instrument( 22, INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 ), - PIANO: Instrument( 23, INST_TIED, MID, 'melo', 'musicInst', 2.39418, 2.53339, .01323 ), - DOG: Instrument( 24, INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 ), - DUCK: Instrument( 25, INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 ), - DRUM2DARBUKADOOM: Instrument( 26, INST_SIMP, LOW, 'drum', 'drum', 0, 0 ,0 ), - DRUM2DARBUKAPIED: Instrument( 27, INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 ), - DRUM2DARBUKAPIEDSOFT: Instrument( 28, INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 ), - DRUM2HATFLANGER: Instrument( 29, INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 ), - DRUM2DARBUKATAK: Instrument( 30, INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 ), - DRUM2DARBUKAFINGER: Instrument( 31, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 ), - DRUM2DARBUKAROLL: Instrument( 32, INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 ), - DRUM2DARBUKASLAP: Instrument( 33, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 ), - DRUM2HATPIED: Instrument( 34, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 ), - DRUM2TAMBOURINEPIED: Instrument( 35, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 ), - DRUM2HATPIED2: Instrument( 36, INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 ), - DRUM2TAMBOURINEPIEDSOFT: Instrument( 37, INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 ), - DRUM3COWBELL: Instrument( 38, INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 ), - DRUM3COWBELLTIP: Instrument( 39, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0), - DRUM3CUP: Instrument( 40, INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 ), - DRUM3DJEMBELOW: Instrument( 41, INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 ), - DRUM3DJEMBEMID: Instrument( 42, INST_SIMP, HIGH, 'drum', 'drum', 0, 0, 0 ), - DRUM3DJEMBESIDESTICK: Instrument( 43, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 ), - DRUM3DJEMBESLAP: Instrument( 44, INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 ), - DRUM3DJEMBESTICKMID: Instrument( 45, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 ), - DRUM3METALSTAND: Instrument( 46, INST_SIMP, MID, 'drum', 'drum', 0, 0, 0 ), - DRUM3PEDALPERC: Instrument( 47, INST_SIMP, LOW, 'drum', 'drum', 0, 0, 0 ), - DRUM3RAINSTICK: Instrument( 48, INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 ), - DRUM3TAMBOURINEHIGH: Instrument( 49, INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 ), - DRUM3TAMBOURINELOW: Instrument( 50, INST_SIMP, PUNCH, 'drum', 'drum', 0, 0, 0 ), - HARMONICA: Instrument( 51, INST_TIED, MID, 'melo', 'electronic', .1531, .19188, .01792 ), - FM2: Instrument( 52, INST_TIED, MID, 'melo', 'electronic', .43443, .5784, .05127 ), - BIRD: Instrument( 53, INST_TIED, MID, 'melo', 'animals', .1, 1, .05 ), - CAT: Instrument( 54, INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 ), - DUCK2: Instrument( 55, INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 ), - BOTTLE: Instrument( 56, INST_TIED, MID, 'melo', 'concret', .20532, .41064, .05292 ), - CLANG: Instrument( 57, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ), - OW: Instrument( 58, INST_SIMP, MID, 'melo', 'people', 0, 0, 0 ), - SHEEP: Instrument( 59, INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 ), - WATER: Instrument( 60, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ), - ZAP: Instrument( 61, INST_TIED, MID, 'melo', 'electronic', .299, .7323, .09895 ), - TRUMPET: Instrument( 62, INST_TIED, MID, 'melo', 'musicInst', .39934, .45537, .02729), - MARACAS: Instrument( 63, INST_SIMP, MID, "melo", 'musicInst', 0, 0, 0), - MARIMBA: Instrument( 64, INST_TIED, MID, "melo", 'musicInst', .7096, .81391, .02425), - TRIANGLE: Instrument( 65, INST_TIED, MID, "melo", 'musicInst', 1.21002, 1.31805, .01268), - LAUGH: Instrument( 66, INST_SIMP, MID, 'melo', 'people', 0, 0, 0 ), - VOIX: Instrument( 67, INST_TIED, MID, 'melo', 'people', .89608, .96092, .02343 ), - CLING: Instrument( 68, INST_TIED, MID, 'melo', 'electronic', .09096, .7878, .18026 ), - TCHIWO: Instrument( 69, INST_TIED, MID, 'melo', 'electronic', .91515, 1.00094, .02122 ), - DOOR: Instrument( 70, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ), - BASSE : Instrument( 71, INST_TIED, MID, 'melo', 'musicInst', .58455, .67433, .03638 ), - ACGUIT : Instrument( 72, INST_TIED, MID, 'melo', 'musicInst', .58503, .8667, .13699 ), - DICEINST : Instrument( 73, INST_SIMP, MID, 'melo', 'musicInst', 0, 0, 0 ), - DIDJERIDU : Instrument( 74, INST_TIED, LOW, 'melo', 'musicInst', .55669, 1.73704, .09178 ), - HARMONIUM : Instrument( 75, INST_TIED, MID, 'melo', 'musicInst', .04674, .41073, .18384 ), - HORSE : Instrument( 76, INST_SIMP, MID, 'melo', 'animals', 0, 0, 0 ), - KALIMBA : Instrument( 77, INST_TIED, MID, 'melo', 'musicInst', .20751, .30161, .04658 ), - MANDO : Instrument( 78, INST_TIED, MID, 'melo', 'musicInst', .50167, .54401, .01984 ), - OCARINA : Instrument( 79, INST_TIED, MID, 'melo', 'musicInst', .12122, .18965, .02205 ), - RHODES : Instrument( 80, INST_TIED, MID, 'melo', 'musicInst', .65013, .71429, .02205 ), - SAXO : Instrument( 81, INST_TIED, MID, 'melo', 'musicInst', .53722, .6583, .05264 ), - SHENAI : Instrument( 82, INST_TIED, MID, 'melo', 'musicInst', .29003, .33072, .00634 ), - SITAR : Instrument( 83, INST_TIED, MID, 'melo', 'musicInst', .63187, .67882, .01654 ), - TUBA : Instrument( 84, INST_TIED, LOW, 'melo', 'musicInst', .51063, .58384, .035 ), - VIOLIN : Instrument( 85, INST_TIED, MID, 'melo', 'musicInst', .55094, .82054, .14498 ), - LAB1 : Instrument( 86, INST_SIMP, MID, 'melo', 'musicInst', 0, 0, 0 ), - LAB2 : Instrument( 87, INST_SIMP, MID, 'melo', 'musicInst', 0, 0, 0 ), - LAB3 : Instrument( 88, INST_SIMP, MID, 'melo', 'musicInst', 0, 0, 0 ), - LAB4 : Instrument( 89, INST_SIMP, MID, 'melo', 'musicInst', 0, 0, 0 ), - GUIDICE1: Instrument( 90, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ), - GUIDICE2: Instrument( 91, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ), - GUIDICE3: Instrument( 92, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ), - GUIDICE4: Instrument( 93, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ), - GUIDICE5: Instrument( 94, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ), - GUIDICE6: Instrument( 95, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ), - GUIDICE7: Instrument( 96, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ), - GUIDICE8: Instrument( 97, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ), - GUIDICE9: Instrument( 98, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 ), - GUIDICE10: Instrument( 99, INST_SIMP, MID, 'melo', 'concret', 0, 0, 0 )} - - - DRUM1INSTRUMENTS = { 24 : DRUM1KICK, - 26 : DRUM1FLOORTOM, - 28 : DRUM1TOM, - 30 : DRUM1CHINE, - 32 : DRUM1SPLASH, - 34 : DRUM1CRASH, - 36 : DRUM1SNARESIDESTICK, - 38 : DRUM1SNARESIDESTICK, - 40 : DRUM1SNARE, - 42 : DRUM1RIDEBELL, - 44 : DRUM1HARDRIDE, - 46 : DRUM1HATSHOULDER, - 48 : DRUM1HATPEDAL } - - DRUM2INSTRUMENTS = { 24 : DRUM2DARBUKADOOM, - 26 : DRUM2DARBUKAPIED, - 28 : DRUM2DARBUKAPIEDSOFT, - 30 : DRUM2HATFLANGER, - 32 : DRUM2DARBUKATAK, - 34 : DRUM2DARBUKATAK, - 36 : DRUM2DARBUKAFINGER, - 38 : DRUM2DARBUKAROLL, - 40 : DRUM2DARBUKASLAP, - 42 : DRUM2HATPIED, - 44 : DRUM2TAMBOURINEPIED, - 46 : DRUM2HATPIED2, - 48 : DRUM2TAMBOURINEPIEDSOFT } - - DRUM3INSTRUMENTS = { 24 : DRUM3DJEMBELOW, - 26 : DRUM3PEDALPERC, - 28 : DRUM3DJEMBESLAP, - 30 : DRUM3TAMBOURINEHIGH, - 32 : DRUM3TAMBOURINELOW, - 34 : DRUM3RAINSTICK, - 36 : DRUM3DJEMBEMID, - 38 : DRUM3DJEMBESIDESTICK, - 40 : DRUM3DJEMBESTICKMID, - 42 : DRUM3COWBELL, - 44 : DRUM3COWBELLTIP, - 46 : DRUM3CUP, - 48 : DRUM3METALSTAND } - - RECORDABLE_INSTRUMENTS = set( [ MIC1, MIC2, MIC3, MIC4 ] ) - RECORDABLE_INSTRUMENT_CSOUND_IDS = { MIC1 : 7, - MIC2 : 8, - MIC3 : 9, - MIC4 : 10 } - - #COMMANDS - 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" - 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 10 %d')\n" - UNLOAD_TABLES_COMMAND = "perf.InputMessage('i%d 0 0.1 %d')\n" % (INST_FREE, len(INSTRUMENTS)) - diff --git a/Framework/CSound/CSoundServer.py b/Framework/CSound/CSoundServer.py deleted file mode 100755 index 843fc0e..0000000 --- a/Framework/CSound/CSoundServer.py +++ /dev/null @@ -1,89 +0,0 @@ -import select -import sys -import socket -import csnd -import threading -import time - -from Framework.CSound.CSoundConstants import CSoundConstants - -#---------------------------------------------------------------------- -# This class was borrowed from Simon Schampijer. Thanks Simon! -#---------------------------------------------------------------------- - -# this is a multiple-client csound server -# the listener is put in a separate thread - -class CsoundServerMult: - # server start-up - def __init__(self, addr): - self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.server.bind(addr) - self.size = 8196 - print "*** CsServer: Csound Python server listening at: @%s:%d" % (addr[0], addr[1]) - self.server.listen(32) - self.input = [self.server,sys.stdin] - self.running = 1 - - # this is the interpreter function - # if something is seen on the socket - # it executes it as Python code - def interpret(self): - # run the universal orchestra - csound = csnd.Csound() - - perf = csnd.CsoundPerformanceThread(csound) - - csound.Compile( CSoundConstants.FILES_DIR + '/univorc.csd' ) - perf.Play() - - while self.running: - inputready,outputready,exceptready = select.select(self.input,[],[]) - - for s in inputready: - if s == self.server: - # handle the server socket - client, address = self.server.accept() - print'*** CsServer: Client has been accepted on: ',address - self.input.append(client) - - elif s == sys.stdin: - # handle standard input - junk = sys.stdin.readline() - csound.SetChannel('udprecv.0.on', 0) - perf.Stop() - perf.Join() - csound.Reset() - csound = None - print '*** CsServer: The csound instance has been reset successfully.' - self.running = 0 - - else: - # handle all other sockets - data = s.recv( self.size ) - if data.strip('\n') == 'off()': - csound.SetChannel('udprecv.0.on', 0) - perf.Stop() - perf.Join() - csound.Reset() - csound = None - print '*** CsServer: The csound instance has been reset successfully.' - self.running = 0 - break - - print 'data = ', data - if data: - try: - exec data - except: - pass #print "exception in code: " + data - else: - print '*** CsServer: remove socket: ', s.fileno() - s.close() - self.input.remove(s) - - for i in self.input: - i.close() - self.input.remove(i) - self.server.close() - print '*** CsServer: The server has been closed.' diff --git a/Framework/CSound/Instrument.py b/Framework/CSound/Instrument.py deleted file mode 100644 index ecb22f8..0000000 --- a/Framework/CSound/Instrument.py +++ /dev/null @@ -1,11 +0,0 @@ -class Instrument: - - def __init__( self, instrumentID, csoundInstrumentID, instrumentRegister, soundClass, category, loopStart, loopEnd, crossDur ): - self.instrumentID = instrumentID - self.csoundInstrumentID = csoundInstrumentID - self.instrumentRegister = instrumentRegister - self.soundClass = soundClass - self.category = category - self.loopStart = loopStart - self.loopEnd = loopEnd - self.crossDur = crossDur diff --git a/Framework/Constants.py b/Framework/Constants.py deleted file mode 100644 index 2fc7f12..0000000 --- a/Framework/Constants.py +++ /dev/null @@ -1,28 +0,0 @@ -import os - -class Constants: - #PATHS - #TAM_TAM_ROOT = os.getenv('TAMTAM_ROOT') - TAM_TAM_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - print 'INFO: loaded TAMTAM_ROOT=%s' % TAM_TAM_ROOT - - #DEFAULTS - DEFAULT_TEMPO = 120 - DEFAULT_VOLUME = 0.8 - - #NUMERICAL CONSTANTS - NUMBER_OF_POSSIBLE_PITCHES = 25.0 - MINIMUM_PITCH = 24.0 - MAXIMUM_PITCH = MINIMUM_PITCH + NUMBER_OF_POSSIBLE_PITCHES - 1 - MINIMUM_NOTE_DURATION = 1 # ticks - MS_PER_MINUTE = 60000.0 - TICKS_PER_BEAT = 12 - NUMBER_OF_TRACKS = 5 - NUMBER_OF_PAGES = 2 - - MINIMUM_AMPLITUDE = 0 - MAXIMUM_AMPLITUDE = 1 - - CSOUND_HORIZON = 0.100 - CLOCK_DELAY = 0.04 - diff --git a/Framework/Core/Event.py b/Framework/Core/Event.py deleted file mode 100755 index 123a740..0000000 --- a/Framework/Core/Event.py +++ /dev/null @@ -1,22 +0,0 @@ -#---------------------------------------------------------------------- -# A base class for things that can be played at a given instant -# An onset < 0 implies the Event should be played immediately -#---------------------------------------------------------------------- -class Event: - #----------------------------------- - # initialization - #----------------------------------- - def __init__( self, onset ): - self.onset = onset - - #----------------------------------- - # playback (must be implemented by subclasses) - #----------------------------------- - def play( self ): - raise NotImplementedError - - #----------------------------------- - # adjustment - #----------------------------------- - def adjustOnset( self, amount ): - self.onset += amount diff --git a/Framework/Core/EventPlayer.py b/Framework/Core/EventPlayer.py deleted file mode 100755 index 3b5aa92..0000000 --- a/Framework/Core/EventPlayer.py +++ /dev/null @@ -1,168 +0,0 @@ -import pickle -import time - -import pygtk -pygtk.require( '2.0' ) -import gtk -import gobject -import math - - -from Framework.Constants import Constants -from Framework.CSound.CSoundNote import CSoundNote -from Framework.CSound.CSoundClient import CSoundClient -from Framework.CSound.CSoundConstants import CSoundConstants - -#------------------------------------------------------------------------------ -# A base class used to play a collection of Events at their respective onsets -#------------------------------------------------------------------------------ -class EventPlayer: - #----------------------------------- - # initialization - #----------------------------------- - def __init__( self ): - - self.time0 = 0 - self.horizonDelay = Constants.CSOUND_HORIZON - self.horizonTime = 0 - self.horizonOnset = 0 - - self.clockDelay = Constants.CLOCK_DELAY - self.eventDictionary = {} - - self.currentTick = 0 - - self.playbackTimeout = None - self.tempo = Constants.DEFAULT_TEMPO - - self.send_buffer = "" - - def getCurrentTick(self): - # used by keyboard - return self.currentTick - - def getTempo( self ): - return self.tempo - - - #----------------------------------- - # playback functions - #----------------------------------- - def playing( self ): - return self.playbackTimeout != None - - def startPlayback( self ): - self.time0 = time.time() - self.horizonTime = 0.0 - self.horizonOnset = 0 - #schedule the handler... - self.playbackTimeout = gobject.timeout_add( int ( 1000 * self.clockDelay) , self.handleClock ) - #and call it right away too. - self.handleClock() - - def stopPlayback( self ): - if self.playbackTimeout != None: - gobject.source_remove( self.playbackTimeout ) - self.playbackTimeout = None - self.shutOff() - - # this will happen - def handleClock( self ) : - def onsetCommand( onset, tempo, delay ): - rval = "" - if self.eventDictionary.has_key( onset ): - for event in self.eventDictionary[ onset ]: - rval += event.getText( tempo, delay) - return rval - - onsetPerSecond = self.tempo / 60.0 * Constants.TICKS_PER_BEAT - - nowTime = time.time() - self.time0 - - nextTime = self.horizonTime - nextOnset = self.horizonOnset - horizonTime = nowTime + self.horizonDelay - self.horizonOnset = int( horizonTime * onsetPerSecond ) - self.horizonTime = self.horizonOnset * onsetPerSecond - - self.send_buffer = "" - for i in range( nextOnset, self.horizonOnset ) : - self.delay = i / onsetPerSecond - nowTime - if (self.delay > 0.0 ) : - ev = self.eventDictionary - self.hookTick( ) # may modify currentTick, eventDictionary - self.send_buffer += onsetCommand( self.currentTick, self.tempo, self.delay ) - self.currentTick = self.currentTick + 1 - else : - print 'WARNING: excessive latency... dropping note with delay %f' % self.delay - - if self.send_buffer != "" : - CSoundClient.sendText( self.send_buffer ) - - #this may invoke GUI crap, which may take a long time - self.hookClock() - return True - - #this is meant to handle things that happen once per clock... like the GUI - def hookClock( self ) : - pass - # this is meant to be overridden by things that need to happen on every onset - def hookTick( self ) : - pass - - # - # serialization - # - VERSION = '_testing_' - def serialize(self, f): - pickle.dump( self.VERSION, f) - pickle.dump( self.tempo, f ) - - def unserialize(self, f): - if pickle.load( f ) != self.VERSION : - raise WrongVersionError - self.tempo = pickle.load( f ) - - # hack for shutOff tied notes when stop playing ( don't work when tracks are selected, probably not for mute... - def shutOff( self ): - for track in range( Constants.NUMBER_OF_TRACKS ): - for i in range( 3 ): - csoundInstrument = i + 101 - CSoundClient.sendText( CSoundConstants. PLAY_NOTE_OFF_COMMAND % ( csoundInstrument, track ) ) - - #----------------------------------- - # add/remove event functions (event(s) must be Event instances) - #----------------------------------- - def add( self, event ): - self.addToDictionary( self.eventDictionary ) - - def addToDictionary( self, event, eventDictionary ): - if eventDictionary.has_key( event.onset ): - eventDictionary[ event.onset ].add( event ) - else: - eventDictionary[ event.onset ] = set( [ event ] ) - - def addMultiple( self, events ): - self.addMultipleToDictionary( events, self.eventDictionary ) - - def addMultipleToDictionary( self, events, eventDictionary ): - for event in events: - self.addToDictionary( event, eventDictionary ) - - def remove( self, event ): - self.removeFromDictionary( event, self.eventDictionary ) - - def removeFromDictionary( self, event, eventDictionary ): - if eventDictionary.has_key( event.onset ) and event in eventDictionary[ event.onset ]: - eventDictionary[ event.onset ].remove( event ) - - def removeMultiple( self, events ): - self.removeMultipleFromDictionary( events, self.eventDictionary ) - - def removeMultipleFromDictionary( self, events, eventDictionary ): - for event in events: - self.removeFromDictionary( event, eventDictionary ) - - def clear( self ): - self.eventDictionary.clear() - diff --git a/Framework/Core/PagePlayer.py b/Framework/Core/PagePlayer.py deleted file mode 100644 index 519cbe7..0000000 --- a/Framework/Core/PagePlayer.py +++ /dev/null @@ -1,251 +0,0 @@ -import pickle -import time - -from TrackPlayerBase import TrackPlayerBase - -from Framework.Constants import Constants -from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.Generation.Generator import GenerationParameters - -class PagePlayer( TrackPlayerBase ): - - DEFAULT_BEATS_PER_PAGE = 4 - - def __init__( self, trackIDs, updateTickCallback, updatePageCallback ): - TrackPlayerBase.__init__( self, trackIDs ) - - self.updatePageCallback = updatePageCallback - self.updateTickCallback = updateTickCallback - - #to pickle - self.beatsPerPage = self.DEFAULT_BEATS_PER_PAGE - self.pageBeatsDictionary = {} - self.trackIDs = trackIDs - self.tunePages = [] #list of pageID keys - self.currentPageIndex = -1 - self.currentPageID = -1 - self.trackDictionary = {} #map [ trackID : [ pageID : events ] ] - self.selectedPageIDs = set() - - self.pageDictionary = {} #map: [ pageID : [ onset : events ] ] - self.playingTune = False - self.needPageCall = False - - #initialize dictionary - for trackID in trackIDs: - self.trackDictionary[ trackID ] = {} - - def addPage( self, pageID ): - self.pageDictionary[ pageID ] = {} - self.pageBeatsDictionary[ pageID ] = self.DEFAULT_BEATS_PER_PAGE - - for trackID in self.trackIDs: - self.trackDictionary[ trackID ][ pageID ] = [] - - def setPage( self, index, pageID ): - self.tunePageOrder[ index ] = pageID - - def getTunePages( self ): - return self.tunePages - - def setCurrentPageIndex( self, pageIndex ): - if self.currentPageIndex != pageIndex: - self.currentPageIndex = pageIndex - - self.eventDictionary = self.pageDictionary[ self.tunePages[ pageIndex ] ] - #NOTE: this function is so slow (60ms on my machine), and runs in X (high priority) - # that it fux up playback - # we use this flag to put off updating the page until hookClock - self.needPageCall = True - - def setPlayPage( self, pageID ): - self.playingTune = False - self.currentPageID = pageID - - self.updatePageDictionary() - self.updatePageCallback() - - def setPlayTune( self, pageIndex ): - self.playingTune = True - self.currentPageIndex = pageIndex - - self.updatePageDictionary() - self.updatePageCallback() - - def getSelectedPageIDs( self ): - return self.selectedPageIDs - - #----------------------------------- - # playback overrides - #----------------------------------- - - def hookTick( self ) : - #pass up the hierarchy - TrackPlayerBase.hookTick( self ) - - if self.currentTick >= Constants.TICKS_PER_BEAT * self.getBeats(): - - #reset to a new page - self.currentTick = 0 - if self.playingTune: - if self.currentPageIndex >= len( self.tunePages ) - 1: - self.setCurrentPageIndex( 0 ) - else: - self.setCurrentPageIndex( self.currentPageIndex + 1 ) -# print 'hookTick: tunePages', self.tunePages -# print 'hookTick: self.currentPageIndex', self.tunePages - - def hookClock( self ): - TrackPlayerBase.hookClock( self ) - if self.needPageCall: - self.updatePageCallback() - self.needPageCall = False - fraction = float(self.currentTick) / float(Constants.TICKS_PER_BEAT * self.getBeats()) - self.updateTickCallback( fraction ) - - #----------------------------------- - # add/remove/update methods - #----------------------------------- - def addToPage( self, trackID, pageID, event ): - self.addToDictionary( event, self.pageDictionary[ pageID ] ) - self.trackDictionary[ trackID ][ pageID ].add( event ) - - def addMultipleToPage( self, trackID, pageID, events ): - for event in events: - self.addToPage( trackID, pageID, event ) - - def removePage( self, pageID ): - del self.pageDictionary[ pageID ] - for trackID in self.trackIDs: - del self.trackDictionary[ trackID ][ pageID ] - - def removeFromPage( self, trackID, pageID, event ): - self.removeFromDictionary( event, pageDictionary[ pageID ] ) - self.trackPageDictionary[ trackID ][ pageID ].remove( event ) - - def removeMultipleFromPage( self, trackID, pageID, events ): - for event in events: - self.removeFromPage( trackID, pageID, event ) - - #TODO this should be removed when TrackPlayer (and TrackPlayerBase) get removed - # we should then always call updatePageDictionary - def update( self ): - self.updatePageDictionary() - - def updatePageDictionary( self ): - self.clear() - - for pageID in self.pageDictionary.keys(): - self.pageDictionary[ pageID ].clear() - - for trackID in self.trackIDs.difference( self.mutedTrackIDs ): - self.addMultipleToDictionary( self.trackDictionary[ trackID ][ pageID ], self.pageDictionary[ pageID ] ) - - if self.playingTune: - self.eventDictionary = self.pageDictionary[ self.tunePages[ self.currentPageIndex ] ] - else: - self.eventDictionary = self.pageDictionary[ self.currentPageID ] - - def updatePage( self, trackID, pageID, events = [] ): - print 'pagePlayer::updatePage ', pageID - if self.trackDictionary.has_key( trackID ) and self.trackDictionary[ trackID ].has_key( pageID ): - del self.trackDictionary[ trackID ][ pageID ] - - self.addPage( trackID, pageID, events ) - - #----------------------------------- - # tempo/beats-per-page methods - #----------------------------------- - - def getBeats( self ): - return self.pageBeatsDictionary[ self.currentPageID ] - - def setBeats( self, beats ): - self.setBeatsForPage( self, beats, self.tunePages[ currentPageIndex ] ) - - def setBeatsPerPage( self, beats, pageID ): - self.pageBeatsDictionary[ pageID ] = beats - - #----------------------------------- - # misc methods - #----------------------------------- - def toggleSelectPage( self, pageID ): - toggle( self.selectedPageIDs, pageID ) - - def getEvents( self, trackID ): - if self.playingTune: - return self.getEventsForPage( trackID, self.tunePages[ self.currentPageIndex ] ) - else: - return self.getEventsForPage( trackID, self.currentPageID ) - - def getEventsForPage( self, trackID, pageID ): - return self.trackDictionary[ trackID ][ pageID ] - - # data is a tuple ( trackID, instrumentName ) - def setInstrument( self, data ): - trackID = data[0] - instrument = data[1] - - self.trackInstruments[ trackID ] = instrument - - if self.trackDictionary.has_key( trackID ): - for pageID in self.trackDictionary[ trackID ].keys(): - for event in self.getEventsForPage( trackID, pageID ): - event.instrument = instrument - - def getTrackInstruments( self ): - return self.trackInstruments - - def getTrackDictionary( self ): - return self.trackDictionary - - def setTrackDictionary( self, dict): - self.trackDictionary = dict - - def getSelectedTrackIDs( self ): - return self.selectedTrackIDs - - def getCurrentPageID( self ): - if self.playingTune: - return self.tunePages[ self.currentPageIndex ] - else: - return self.currentPageID - - # - # serialization - # - def serialize(self, f): - TrackPlayerBase.serialize(self, f) - - pickle.dump( self.pageBeatsDictionary, f ) - pickle.dump( self.trackIDs, f ) - pickle.dump( self.tunePages, f ) - pickle.dump( self.currentPageIndex, f ) - pickle.dump( self.currentPageID, f ) - pickle.dump( self.trackDictionary, f ) - pickle.dump( self.selectedPageIDs, f ) - pickle.dump( self.playingTune, f) - - print 'PagePlayer::serialize tunePages', self.tunePages - print 'PagePlayer::serialize currentPageIndex', self.currentPageIndex - print 'PagePlayer::serialize currentPageID', self.currentPageID - print 'PagePlayer::serialize playingTune', self.playingTune - - def unserialize(self, f): - TrackPlayerBase.unserialize(self, f ) - - self.pageBeatsDictionary = pickle.load( f ) - self.trackIDs = pickle.load( f ) - self.tunePages = pickle.load( f ) - self.currentPageIndex = pickle.load( f ) - self.currentPageID = pickle.load( f ) - self.trackDictionary = pickle.load( f ) - self.selectedPageIDs = pickle.load( f ) - self.playingTune = pickle.load(f) - - print 'PagePlayer::unserialize tunePages', self.tunePages - print 'PagePlayer::unserialize currentPageIndex', self.currentPageIndex - print 'PagePlayer::unserialize currentPageID', self.currentPageID - print 'PagePlayer::unserialize playingTune', self.playingTune - - self.updatePageDictionary() diff --git a/Framework/Core/TrackPlayer.py b/Framework/Core/TrackPlayer.py deleted file mode 100755 index a7e8f7e..0000000 --- a/Framework/Core/TrackPlayer.py +++ /dev/null @@ -1,88 +0,0 @@ -from TrackPlayerBase import TrackPlayerBase - -from Framework.Generation.Generator import Generator -from Framework.Generation.Generator import GenerationParameters -from Framework.CSound.CSoundConstants import CSoundConstants - -#------------------------------------------------------------------------------ -# A Track is a collection of events. -# TrackPlayer allows the user to create, generate, manipulate and play Tracks -#------------------------------------------------------------------------------ -class TrackPlayer( TrackPlayerBase ): - #----------------------------------- - # initialization - #----------------------------------- - def __init__( self, getTempoCallback, getBeatsPerPageCallback, playTickCallback, volumeFunctions, trackIDs ): - TrackPlayerBase.__init__( self, getTempoCallback, getBeatsPerPageCallback, playTickCallback, volumeFunctions, trackIDs ) - - self.trackDictionary = {} #maps trackIDs to lists of events - - #----------------------------------- - # add/remove/update methods - #----------------------------------- - def addTrack( self, trackID, instrument, events = [] ): - if ( len( events ) != 0 ) and ( trackID not in self.mutedTrackIDs ): - self.addMultiple( events ) - - self.trackDictionary[ trackID ] = events - self.trackInstruments[ trackID ] = instrument - - def addToTrack( self, trackID, event ): - self.add( event ) - self.trackDictionary[ trackID ].add( event ) - - def addMultipleToTrack( self, trackID, events ): - self.addMultiple( events ) - for event in events: - self.trackDictionary[ trackID ].add( event ) - - def removeTrack( self, trackID ): - if self.trackDictionary.has_key( trackID ): - self.removeMultiple( self.trackDictionary[ trackID ] ) - del self.trackDictionary[ trackID ] - - def removeFromTrack( self, trackID, event ): - self.remove( event ) - self.trackDictionary[ trackID ].remove( event ) - - def removeMultipleFromTrack( self, trackID, events ): - self.removeMultiple( events ) - for event in events: - self.trackDictionary[ trackID ].remove( event ) - - def updateTrack( self, trackID, events = [] ): - if self.trackDictionary.has_key( trackID ): - self.removeTrack( trackID ) - - # TODO: this stuff is temporary and should be done in Generator - # i.e. generated notes should already have their instrument set to - # self.trackInstruments[ trackID ] - if self.trackInstruments.has_key( trackID ): - instrument = self.trackInstruments[ trackID ] - else: - instrument = CSoundConstants.CELLO - for event in events: - event.instrument = instrument - - self.addTrack( trackID, instrument, events ) - - #----------------------------------- - # misc methods - #----------------------------------- - def getEvents( self, trackID ): - return self.trackDictionary[ trackID ] - - def update( self ): - self.clear() - - for trackID in self.getActiveTrackIDs(): - self.addMultiple( self.trackDictionary[ trackID ] ) - - def generate( self, generationParameters = GenerationParameters() ): - if len( self.selectedTrackIDs ) == 0: - trackIDs = self.trackIDs - else: - trackIDs = self.selectedTrackIDs - - for trackID in trackIDs: - self.updateTrack( trackID, self.generator.generate( generationParameters, trackID, self.trackDictionary ) ) \ No newline at end of file diff --git a/Framework/Core/TrackPlayerBase.py b/Framework/Core/TrackPlayerBase.py deleted file mode 100644 index a96589a..0000000 --- a/Framework/Core/TrackPlayerBase.py +++ /dev/null @@ -1,112 +0,0 @@ -import pickle - -from EventPlayer import EventPlayer -from Framework.Constants import Constants -from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.CSound.CSoundNote import CSoundNote -from Framework.CSound.CSoundClient import CSoundClient - -class TrackPlayerBase( EventPlayer ): - #----------------------------------- - # initialization - #----------------------------------- - def __init__( self, trackIDs ): - EventPlayer.__init__( self ) - - self.trackIDs = set( trackIDs ) - self.selectedTrackIDs = set() - self.mutedTrackIDs = set() - self.trackInstruments = {} #maps trackIDs to instrumentNames - self.trackVolumes = {} #maps trackIDs to floats (volume) - - CSoundNote.getVolumeCallback = self.getTrackVolume - - for id in self.trackIDs : - if id == 0 : - self.trackInstruments[ id ] = CSoundConstants.FLUTE - elif id == 1 : - self.trackInstruments[ id ] = CSoundConstants.FLUTE - elif id == 2 : - self.trackInstruments[ id ] = CSoundConstants.PIZZ - elif id == 3 : - self.trackInstruments[ id ] = CSoundConstants.PIZZ - elif id == 4 : - self.trackInstruments[ id ] = CSoundConstants.CELLO - elif id == 5 : - self.trackInstruments[ id ] = CSoundConstants.DRUM1KIT - else : - self.trackInstruments[ id ] = CSoundConstants.DRUM1KIT - - self.trackVolumes[ id ] = Constants.DEFAULT_VOLUME - - - def getTrackVolume( self, trackID ): - if self.trackVolumes.has_key( trackID ): - return self.trackVolumes[ trackID ] - else: - return Constants.DEFAULT_VOLUME - - #----------------------------------- - # toggle methods - #----------------------------------- - def toggleSelectTrack( self, trackID ): - self.toggle( self.selectedTrackIDs, trackID ) - self.update() - - def toggleMuteTrack( self, trackID ): - self.toggle( self.mutedTrackIDs, trackID ) - self.update() - - def toggle( self, set, object ): - if object in set: - set.discard( object ) - else: - set.add( object ) - for i in range( 3 ): - csoundInstrument = i + 101 - CSoundClient.sendText( CSoundConstants. PLAY_NOTE_OFF_COMMAND % ( csoundInstrument, object ) ) - - #----------------------------------- - # misc methods - #----------------------------------- - def getActiveTrackIDs( self ): - if len( self.selectedTrackIDs ) == 0: - return self.trackIDs - else: - return self.selectedTrackIDs - - # data is a tuple ( trackID, instrumentName ) - def setInstrument( self, data ): - trackID = data[0] - instrument = data[1] - for event in self.getEvents( trackID ): - event.instrument = instrument - - self.trackInstruments[ trackID ] = instrument - - def update( self ): - raise NotImplementedError - - # - # serialization - # - def serialize(self, f): - EventPlayer.serialize(self, f) - - pickle.dump( self.pageBeatsDictionary, f ) - pickle.dump( self.trackIDs, f ) - pickle.dump( self.selectedTrackIDs, f ) - pickle.dump( self.mutedTrackIDs, f ) - pickle.dump( self.trackInstruments, f ) - pickle.dump( self.trackVolumes, f ) - - - def unserialize(self, f): - EventPlayer.unserialize(self, f ) - - self.pageBeatsDictionary = pickle.load( f ) - self.trackIDs = pickle.load( f ) - self.selectedTrackIDs = pickle.load( f ) - self.mutedTrackIDs = pickle.load( f ) - self.trackInstruments = pickle.load( f ) - self.trackVolumes = pickle.load( f ) diff --git a/Framework/Music.py b/Framework/Music.py deleted file mode 100644 index ea950ee..0000000 --- a/Framework/Music.py +++ /dev/null @@ -1,181 +0,0 @@ -import pickle -import time -import bisect - -from Framework.Constants import Constants -from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.Generation.Generator import GenerationParameters - -_nid = 1 -_noteids = {} -_sid = 1 -_subset = {} -_notebin = [] -_data = {} -_listeners = [] - -def _newsid(): - while _subset.has_key(_sid): - _sid = _sid + 1 -def _newnid(): - while _noteids.has_key(_nid): - _nid = _nid + 1 - -def music_init(): - - #[ volume, ... ] - _data['track_volume'] = [0.8] * Constants.NUMBER_OF_TRACKS - _data['track_mute'] = [False] * Constants.NUMBER_OF_TRACKS - - #[ instrument index, ... ] - track_inst = [ CSoundConstants.FLUTE, CSoundConstants.KOTO, CSoundConstants.GAM, CSoundConstants.GAM, - CSoundConstants.GUIT, CSoundConstants.DRUM1KIT, CSoundConstants.DRUM1KIT ] - - _data['track_inst'] = track_inst + [CSoundConstants.FLUTE] * (Constants.NUMBER_OF_TRACKS - len( track_inst) ) - #{ pageId: { [track 0 = note list], [track 2 = note list], ... ] } - _data['page_notes'] = {} - #{ pageId: ticks } - _data['page_ticks'] = {} - _data['page_beats'] = {} - _data['tempo'] = Constants.DEFAULT_TEMPO - _data['tune'] = [] - - _subset[0] = _notebin - -def music_addListener( fn ): - _listeners.append(fn) - -def music_create(params, wantSubSet = False): - keys = [] - - map( lambda x: x('add', keys), _listeners) - - return - -def music_delete(sid): - pass - -def music_update(sid): - def setDirty(x): x['dirty'] = True - map( setDirty, _subset[sid]) - map( lambda x: x('update', sid), _listeners) - -def music_forget(sid): - del _subset[sid] - -def music_get(sid): - return _subset[sid] - -def music_filter(test, psid): - _newsid() - _subset[_sid] = filter( test, _subset[psid] ) - return _sid - - -def music_page_start( pid, nbeats): - _data['page_notes'][pid] = map(lambda i : [], range(Constants.NUMBER_OF_TRACKS)) - _data['page_beats'][pid] = nbeats - _data['page_ticks'][pid] = nbeats * Constants.TICKS_PER_BEAT - - -def music_addNotes_fromDict( dict, replace = True ): - - # dict == { trackId : { pageId : notelist } } - noteList = [] - page_notes = _data['page_notes'] - for tid in dict: - pdict = dict[tid] - for pid in pdict: - if len( pdict[pid] ) > 0 : - if replace: page_notes[pid][tid] = [] - _track = page_notes[pid][tid] - for note in pdict[pid]: - bisect.insort( _track, (note['onset'], note)) - noteList += map( lambda (o,note): note, _track ) #shallow copy! - _subset[0] += noteList - - map( lambda x: x('add', noteList), _listeners) - -def music_addNotes( noteList ): - for note in noteList: - bisect.insort( _data['page_notes'][note['pageID']][note['trackID']], (note['onset'], note)) - _subset[0].append(note) - map( lambda x: x('add', noteList), _listeners) - -def music_setNotes( noteList ): - map( lambda x: x('set', noteList), _listeners) - -def music_delNotes( noteList ): - for note in noteList: - _subset[0].remove(note) - _data['page_notes'][note['pageID']][note['trackID']].remove( (note['onset'], note)) - map( lambda x: x('del', noteList), _listeners) - -def music_getNotes( pages, tracks ): - # unify given pages and tracks into a single note list - notes = [] - offset = 0 - _ticks = _data['page_ticks'] - _notes = _data['page_notes'] - for pid in pages: - if _notes.has_key(pid): - for tid in tracks: - notes += map( lambda (onset,note) : (onset + offset, note ), _notes[pid][tid]) - #print len(_notes[pid][tid]) - offset = offset + _ticks[pid] - else: - print 'WARNING: requesting notes from non-existing page ', pid - #print len(notes) - - notes.sort() - return notes - -def music_save(f): - pickle.dump( _data, f ) -def music_load(f): - _data = pickle.load( f ) - -def music_volume_get(track): - return _data['track_volume'][track] -def music_volume_set(track, vol): - _data['track_volume'][track] = vol - -def music_mute_get(track): - return _data['track_mute'][track] -def music_mute_set(track, mute): - _data['track_mute'][track] = mute - -def music_effective_volume_get(track): - if _data['track_mute'][track]: - return 0.0 - else: - return _data['track_volume'][track] - -def music_trackInstrument_get(track): - return _data['track_inst'][track] -def music_trackInstrument_set(track, inst): - _data['track_inst'][track] = inst - -def music_tempo_set( tempo ): - _data['tempo'] = tempo -def music_tempo_get( ): - return _data['tempo'] - -def music_duration_get( pid ): - print 'pid',pid - return _data['page_ticks'][pid] -def music_beats_get( pid ): - return _data['page_beats'][pid] -def music_beats_set( pid, beats ): - _data['page_beats'][pid] = beats - _data['page_ticks'][pid] = beats * Constants.TICKS_PER_BEAT - -def music_tune_get( ): - return _data['tune'] -def music_tune_set( tune ): - _data['tune'] = tune - -def music_allnotes(): - global _notebin - return _notebin - diff --git a/Framework/Note.py b/Framework/Note.py deleted file mode 100644 index b9bbbf2..0000000 --- a/Framework/Note.py +++ /dev/null @@ -1,112 +0,0 @@ -from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.Generation.GenerationConstants import GenerationConstants -from Framework.Music import * - -def note_new( - onset, - pitch, - amplitude, - pan, - duration, - trackID, - pageID, - fullDuration = False, - instrument = CSoundConstants.FLUTE, - attack = 0.002, - decay = 0.098, - reverbSend = 0.1, - filterType = 0, - filterCutoff = 1000, - tied = False, - overlap = False, - instrumentFlag = CSoundConstants.FLUTE ): - - note = {} - note['onset'] = onset - note['pitch'] = pitch - note['amplitude'] = amplitude - note['pan'] = pan - note['duration'] = duration - note['trackID'] = trackID - note['pageID'] = pageID - note['fullDuration'] = fullDuration - note['attack'] = attack - note['decay'] = decay - note['reverbSend'] = reverbSend - note['filterType'] = filterType - note['filterCutoff'] = filterCutoff - note['tied'] = tied - note['overlap'] = overlap - note['dirty'] = True - - if instrument == 'drum1kit': - note['instrumentFlag'] = CSoundConstants.DRUM1INSTRUMENTS[ pitch ] - else: - note['instrumentFlag'] = instrument - - return note - -def note_refresh_play_cmd( note, preVolume, secs_per_tick ): - if music_trackInstrument_get( note['trackID'] ) == 'drum1kit': - if GenerationConstants.DRUMPITCH.has_key( note['pitch'] ): - print note['pitch'] - note['pitch'] = GenerationConstants.DRUMPITCH[ note['pitch'] ] - - note['instrumentFlag'] = CSoundConstants.DRUM1INSTRUMENTS[ note['pitch'] ] - newPitch = 1 - else: - note['instrumentFlag'] = music_trackInstrument_get( note['trackID'] ) - newPitch = GenerationConstants.TRANSPOSE[ note['pitch'] - 24 ] - - duration = secs_per_tick * note['duration'] - #print 'hahaha', secs_per_tick, ' ', duration - - # condition for tied notes - if CSoundConstants.INSTRUMENTS[ note['instrumentFlag'] ].csoundInstrumentID == 101 and note['tied'] and note['fullDuration']: - duration = -1.0 - # condition for overlaped notes - if CSoundConstants.INSTRUMENTS[ note['instrumentFlag'] ].csoundInstrumentID == 102 and note['overlap']: - duration += 1.0 - - newAmplitude = note['amplitude'] * preVolume - - newAttack = duration * note['attack'] - if newAttack <= 0.002: - newAttack = 0.002 - - newDecay = duration * note['decay'] - if newDecay <= 0.002: - newDecay = 0.002 - - note['play_cmd'] = CSoundConstants.PLAY_NOTE_COMMAND_MINUS_DELAY % \ - ( CSoundConstants.INSTRUMENTS[ note['instrumentFlag'] ].csoundInstrumentID, - note['trackID'], - '%f', #delay, - duration, - newPitch, - note['reverbSend'], - newAmplitude, - note['pan'], - CSoundConstants.INSTRUMENT_TABLE_OFFSET + CSoundConstants.INSTRUMENTS[ note['instrumentFlag'] ].instrumentID, - newAttack, - newDecay, - note['filterType'], - note['filterCutoff'] ) - -def note_getText( note, preVolume, secs_per_tick, delay ): - if note['dirty'] : - note_refresh_play_cmd( note, preVolume, secs_per_tick ) - note['dirty'] = False - if delay < 0.0 : - print 'ERROR: you cant send note with negative delay', delay - - if music_effective_volume_get( note['trackID'] ) > 0.0 : - #print 'getText', note['trackID'], note['onset'], note['play_cmd'] % float(delay) - return note['play_cmd'] % float(delay) - else: - return '' - -from Framework.CSound.CSoundClient import CSoundClient -def note_play(note, preVolume = 1.0, secs_per_tick = 0.1, delay = 0 ): - CSoundClient.sendText( note_getText( note, preVolume, secs_per_tick, delay)) - diff --git a/Framework/__init__.py b/Framework/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/Framework/__init__.py +++ /dev/null diff --git a/GUI/Core/KeyMapping.py b/GUI/Core/KeyMapping.py deleted file mode 100644 index 6af06a2..0000000 --- a/GUI/Core/KeyMapping.py +++ /dev/null @@ -1,60 +0,0 @@ -# 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 = {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 \ No newline at end of file diff --git a/GUI/Core/__init__.py b/GUI/Core/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/GUI/Core/__init__.py +++ /dev/null diff --git a/GUI/GUIConstants.py b/GUI/GUIConstants.py deleted file mode 100644 index a6897f9..0000000 --- a/GUI/GUIConstants.py +++ /dev/null @@ -1,65 +0,0 @@ -from Framework.Constants import Constants - -class GUIConstants: - LANGUAGE = 'En' - IMAGE_ROOT = Constants.TAM_TAM_ROOT + '/Resources/Images/' - - NOTE_HEIGHT = 6 # pixels - NOTE_BORDER_SIZE = 1 - NOTE_BORDER_SIZE_DIV2 = NOTE_BORDER_SIZE/2.0 - MAIN_WINDOW_PADDING = 5 - TRACK_SPACING = 1 - BORDER_SIZE = 2 - BORDER_SIZE_DIV2 = BORDER_SIZE/2.0 - BORDER_SIZE_MUL2 = BORDER_SIZE*2 - BEAT_LINE_SIZE = 1 - BEAT_LINE_SIZE_DIV2 = BEAT_LINE_SIZE/2.0 - PLAYHEAD_SIZE = 2 - PLAYHEAD_SIZE_DIV2 = PLAYHEAD_SIZE/2.0 - - INST_BCK_COLOR = '#979DA8' - PANEL_BCK_COLOR = '#FFFFFF' - PANEL_COLOR = '#707F93' - PANEL_RADIUS = 10 - - PAGE_BORDER_SIZE = 2 - PAGE_SELECTED_BORDER_SIZE = 5 - PAGE_WIDTH = 100 - PAGE_HEIGHT = 25 - - PAGE_THUMBNAIL_WIDTH = 70 - PAGE_THUMBNAIL_WIDTH_DIV2 = PAGE_THUMBNAIL_WIDTH/2 - PAGE_THUMBNAIL_HEIGHT = 50 - PAGE_THUMBNAIL_PADDING = 4 - PAGE_THUMBNAIL_PADDING_MUL2 = PAGE_THUMBNAIL_PADDING*2 - PAGE_THUMBNAIL_PADDING_DIV2 = PAGE_THUMBNAIL_PADDING/2 - - NUMBER_OF_PAGE_BANK_ROWS = 2 - NUMBER_OF_PAGE_BANK_COLUMNS = 20 - - -# hardware keycodes for mod keys -MOD_LSHIFT = 50 -MOD_RSHIFT = 62 -MOD_LCTRL = 37 -MOD_RCTRL = 109 -MOD_LALT = 64 -MOD_RALT = 113 - -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() diff --git a/GUI/Generation/__init__.py b/GUI/Generation/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/GUI/Generation/__init__.py +++ /dev/null diff --git a/GUI/SynthLab/__init__.py b/GUI/SynthLab/__init__.py deleted file mode 100755 index e69de29..0000000 --- a/GUI/SynthLab/__init__.py +++ /dev/null diff --git a/GUI/Tooltips.py b/GUI/Tooltips.py deleted file mode 100644 index f21bdc7..0000000 --- a/GUI/Tooltips.py +++ /dev/null @@ -1,272 +0,0 @@ -# -*- coding: utf-8 -*- -from GUI.GUIConstants import GUIConstants - -class Tooltips: - - #English - if GUIConstants.LANGUAGE == 'En': - #miniTamTam - VOL = 'Volume' - REV = 'Reverb' - PLAY = 'Play / Stop' - STOP = 'Stop' - SEQ = 'Sequencer' - GEN = 'Generate' - COMPL = 'Complexity of beat' - BEAT = 'Beats per bar' - TEMPO = 'Tempo' - JAZZ = 'Jazz / Rock Kit' - AFRI = 'African Kit' - ARAB = 'Arabic Kit' - RECMIC = 'Record using the microphone' - RECLAB = 'Open SynthLab to create sounds' - - #Synthlab - SOURCE = 'Source' - EFFECT = 'Effect' - CONTROL = 'Control' - SOUNDOUT = 'Sound Output' - SOUNDDUR = 'Sound Duration' - SAVE = 'Save' - LOAD = 'Load' - SAVEMINI = 'Save to miniTamTam' - CLOSE = 'Close' - RESET = 'Reset' - - #Controls - LFO = 'Low frequency oscillator' - AMP = 'Amplitude' - FREQ = 'Frequency' - WAVEFORM = 'Waveform' - OFFSET = 'Offset' - - RANDOM = 'Random' - MIN = 'Minimum' - MAX = 'Maximum' - FREQ = FREQ - SEED = 'Seed' - - ADSR = 'ADSR Envelope' - ATTACK = 'Attack' - DECAY = 'Decay' - SUSTAIN = 'Sustain' - RELEASE = 'Release' - - #Source - FM = 'Fequency Modulator' - CAR = 'Carrier Frequency' - MOD = 'Modulator Frequency' - INDEX = 'Index' - GAIN = 'Gain' - - BUZZ = 'Buzz' - FREQ = FREQ - NHARM = 'Number of harmonics' - FSLOPE = 'Filter Slope' - GAIN = GAIN - - VCO = 'Voltage Controlled Oscillator' - FREQ = FREQ - WAVEFORM = WAVEFORM - FSLOPE = FSLOPE - GAIN = GAIN - - PLUCK = 'Pluck' - FREQ = FREQ - LFILTER = 'Lowpass Filter' - VIBRATO = 'Vibrato' - GAIN = GAIN - - NOISE = 'Noise' - NOISETYPE = 'Type: White | Pink | Gaussian' - FREQ = FREQ - BANDWITH = 'Bandwith' - GAIN = GAIN - - SAMPLE = 'Sound Sample' - FREQ = FREQ - SAMPLEN = 'Sample Number' - LFILTER = LFILTER - GAIN = GAIN - - VOICE = 'Voice' - FREQ = FREQ - VOWEL = 'Vowel' - VIBRATO = VIBRATO - GAIN = GAIN - - #Effects - DELAY = 'Delay' - FREQ = FREQ - LFILTER = LFILTER - FEEDBACK = 'Feedback' - GAIN = GAIN - - DIST = 'Distortion' - FREQ = FREQ - RESON = 'Resonance' - DISTL = 'Distotion Level' - GAIN = GAIN - - FILTER = 'Filter' - FREQ = FREQ - FSLOPE = FSLOPE - FTYPE = 'Filter type: Low Pass | High Pass | Band Pass' - GAIN = GAIN - - RINGMOD = 'Ring Modulator' - FREQ = FREQ - AMP = 'Amplitude' - WAVEFORM = WAVEFORM - GAIN = GAIN - - REVERB = 'Reverb' - REVERBD = 'Length' - REVERBF = 'Lowpass Filter' - REVERBL = 'Reverb Level' - GAIN = GAIN - - HARMON = 'Harmonizer' - FREQ = FREQ - DRYDELAY = 'Dry delay' - MIX = 'Mix' - GAIN = GAIN - SYNTHTYPE = { } - SYNTHPARA = { 'lfo': [AMP, FREQ, WAVEFORM, OFFSET], - 'rand': [MIN, MAX, FREQ, SEED], - 'adsr': [ATTACK, DECAY, SUSTAIN, RELEASE], - 'fm': [CAR, MOD, INDEX, GAIN], - 'buzz': [FREQ, NHARM, FSLOPE, GAIN], - 'vco': [FREQ, WAVEFORM, FSLOPE, GAIN], - 'pluck': [FREQ, LFILTER, VIBRATO, GAIN], - 'noise': [NOISETYPE, FREQ, BANDWITH, GAIN], - 'sample': [FREQ, SAMPLEN, LFILTER, GAIN], - 'voice': [FREQ, VOWEL, VIBRATO, GAIN], - 'wguide': [FREQ, LFILTER, FEEDBACK, GAIN], - 'distort': [FREQ, RESON, DISTL, GAIN], - 'filter': [FREQ, FSLOPE, FTYPE, GAIN], - 'ring': [FREQ, AMP, WAVEFORM, GAIN], - 'reverb': [REVERBD, REVERBF, REVERBL, GAIN], - 'harmon': [FREQ, DRYDELAY, MIX, GAIN]} - #French - elif GUIConstants.LANGUAGE == 'Fr': - #miniTamTam - VOL = 'Volume' - REV = 'Réverbération' - PLAY = 'Lecture / Arrêt' - STOP = 'Stop' - GEN = 'Générer' - COMPL = 'Complexité du rythme' - BEAT = 'Temps par mesure' - TEMPO = 'Tempo' - JAZZ = 'Kit Jazz / Rock' - AFRI = 'Kit Africain' - ARAB = 'Kit Arabe' - RECMIC = 'Enregistrer avec le micro' - RECLAB = 'Ouvrir SynthLab pour créer des sons' - - #Synthlab - SOURCE = 'Source' - EFFECT = 'Effet' - CONTROL = 'Contrôle' - SOUNDOUT = 'Sortie sonore' - SOUNDDUR = 'Durée du son' - SAVE = 'Sauvegarder' - LOAD = 'Ouvrir' - SAVEMINI = 'Sauvegarder dans miniTamTam' - CLOSE = 'Fermer' - RESET = 'Réinitialiser' - - #Controls - LFO = 'Oscillateur basse fréquence' - AMP = 'Amplitude' - FREQ = 'Fréquence' - WAVEFORM = "Forme d'onde'" - RANDOM = 'Aléatoire' - MIN = 'Minimum' - MAX = 'Maximum' - FREQ = FREQ - - ADSR = 'Envelope ADSR' - ATTACK = 'Attaque' - DECAY = 'Chute' - SUSTAIN = 'Tenue' - RELEASE = 'Relâche' - - #Source - FM = 'Modulateur de fréquence' - CAR = 'Fréquence porteuse' - MOD = 'Fréquence modulatrice' - INDEX = 'Index' - GAIN = 'Gain' - - BUZZ = 'Buzz' - FREQ = FREQ - NHARM = "Nombre d'harmoniques" - FSLOPE = 'Pente du filtre' - GAIN = GAIN - - VCO = 'Oscillateur controlé par voltage' - FREQ = FREQ - WAVEFORM = WAVEFORM - FSLOPE = FSLOPE - GAIN = GAIN - - PLUCK = 'Corde pincée' - FREQ = FREQ - GAIN = GAIN - - NOISE = 'Bruit' - NOISETYPE = 'Type: Blanc | Rose | Gaussien' - GAIN = GAIN - - SAMPLE = 'Échantillon sonore' - FREQ = FREQ - SAMPLEN = "Numéro d'échantillon" - GAIN = GAIN - - VOICE = 'Voix' - FREQ = FREQ - VOWEL = 'Voyelle: U->A->I' - - #Effects - DELAY = 'Délai' - FREQ = FREQ - LFILTER = 'Filtre passe-bas' - FEEDBACK = 'Réinjection' - GAIN = GAIN - - DIST = 'Distorsion' - FREQ = FREQ - RESON = 'Résonance' - DISTL = 'Niveau de distosion' - GAIN = GAIN - - FILTER = 'Filtre' - FREQ = FREQ - FSLOPE = FSLOPE - FTYPE = 'Type de filtre: Passe-bas | Passe-haut | Passe-bande' - GAIN = GAIN - - RINGMOD = 'Modulateur par anneaux' - FREQ = FREQ - AMP = 'Amplitude' - GAIN = GAIN - - REVERB = 'Réverbération' - REVERBD = 'Durée' - REVERBF = 'Filtre passe-bas' - REVERBL = 'Niveau de réverbération' - GAIN = GAIN - - HARMON = 'Harmonizer' - FREQ = FREQ - HARMONL = "Niveau de l'harmonizer" - GAIN = GAIN - - - - - - - diff --git a/GUI/__init__.py b/GUI/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/GUI/__init__.py +++ /dev/null diff --git a/Framework/Generation/Drunk.py b/Generation/Drunk.py index 5a36b11..5a36b11 100755 --- a/Framework/Generation/Drunk.py +++ b/Generation/Drunk.py diff --git a/Framework/Generation/GenerationConstants.py b/Generation/GenerationConstants.py index 74b1aec..74b1aec 100755 --- a/Framework/Generation/GenerationConstants.py +++ b/Generation/GenerationConstants.py diff --git a/GUI/Generation/GenerationParametersWindow.py b/Generation/GenerationParametersWindow.py index a6fdb63..5964566 100755 --- a/GUI/Generation/GenerationParametersWindow.py +++ b/Generation/GenerationParametersWindow.py @@ -2,9 +2,9 @@ import pygtk pygtk.require('2.0') import gtk -from Framework.Generation.Generator import GenerationParameters -from Framework.Generation.Generator import VariationParameters -from Framework.Generation.GenerationConstants import GenerationConstants +from Generation.Generator import GenerationParameters +from Generation.Generator import VariationParameters +from Generation.GenerationConstants import GenerationConstants class GenerationParametersWindow( gtk.Window ): def __init__( self, generateFunction, variateFunction, handleCloseWindowCallback ): diff --git a/Framework/Generation/GenerationPitch.py b/Generation/GenerationPitch.py index 795ce51..bc38ee1 100644 --- a/Framework/Generation/GenerationPitch.py +++ b/Generation/GenerationPitch.py @@ -1,8 +1,8 @@ import random import Drunk -from Framework.Constants import Constants -from Framework.Generation.GenerationConstants import GenerationConstants +import Config +from Generation.GenerationConstants import GenerationConstants class GenerationPitch: def __init__( self ): @@ -50,7 +50,7 @@ class GenerationPitch: pitchSequence = [] pitchMethod = self.harmonicChooseMethod( parameters.pattern ) for onset in rythmSequence: - beat = int( onset / Constants.TICKS_PER_BEAT ) + beat = int( onset / Config.TICKS_PER_BEAT ) pitchSequence.append( ( table_pitch[ harmonicSequence[ beat ] [ pitchMethod.getNextValue(3, ( len( harmonicSequence[ beat ]) - 1) ) ]] ) + GenerationConstants.DEFAULT_TONIQUE ) # pitchSequence.append( ( table_pitch[ random.choice( harmonicSequence[ beat ] ) ] ) + GenerationConstants.DEFAULT_TONIQUE ) return pitchSequence diff --git a/Framework/Generation/GenerationRythm.py b/Generation/GenerationRythm.py index 5d95732..fef9d42 100644 --- a/Framework/Generation/GenerationRythm.py +++ b/Generation/GenerationRythm.py @@ -1,8 +1,8 @@ import Utils import random -from Framework.Generation.GenerationConstants import GenerationConstants -from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.Constants import Constants + +import Config +from Generation.GenerationConstants import GenerationConstants class GenerationRythm: def __init__( self, trackInstrument, barLength ): @@ -26,7 +26,7 @@ class GenerationRythm: onsetDelta = GenerationConstants.TABLE_ONSET_VALUES[ currentOnsetValue ] - for i in range( int( self.barLength / Constants.TICKS_PER_BEAT * 8 ) ): + for i in range( int( self.barLength / Config.TICKS_PER_BEAT * 8 ) ): if self.count == 0: currentOnsetValue = onsetValue + ( random.randint( 0, onsetDeviation ) - ( onsetDeviation / 2 ) ) if currentOnsetValue < 0: @@ -96,50 +96,50 @@ class GenerationRythm: beats = [] countDown = 0 onsetTime = None - beatsPerPage = int( self.barLength / Constants.TICKS_PER_BEAT ) + beatsPerPage = int( self.barLength / Config.TICKS_PER_BEAT ) - if CSoundConstants.INSTRUMENTS[ self.trackInstrument ].instrumentRegister == CSoundConstants.PUNCH: + if Config.INSTRUMENTS[ self.trackInstrument ].instrumentRegister == Config.PUNCH: registerDensity = 0.5 downBeatRecurence = 4 for beat in range( beatsPerPage ): - beats.append( beat * Constants.TICKS_PER_BEAT ) + beats.append( beat * Config.TICKS_PER_BEAT ) for i in range( len( beats ) ): print ( beats[ GenerationConstants.PUNCH_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) downBeats.append( ( beats[ GenerationConstants.PUNCH_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) ) for downBeat in downBeats: - upBeats.append( ( downBeat[ 0 ] + Constants.TICKS_PER_BEAT , downBeat[ 1 ] ) ) + upBeats.append( ( downBeat[ 0 ] + Config.TICKS_PER_BEAT , downBeat[ 1 ] ) ) - if CSoundConstants.INSTRUMENTS[ self.trackInstrument ].instrumentRegister == CSoundConstants.LOW: + if Config.INSTRUMENTS[ self.trackInstrument ].instrumentRegister == Config.LOW: registerDensity =1.5 downBeatRecurence = 4 for beat in range( beatsPerPage ): - beats.append( beat * Constants.TICKS_PER_BEAT ) + beats.append( beat * Config.TICKS_PER_BEAT ) for i in range( len( beats ) ): downBeats.append( ( beats[ GenerationConstants.LOW_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) ) for downBeat in downBeats: - upBeats.append( ( downBeat[ 0 ] + Constants.TICKS_PER_BEAT / 2 , downBeat[ 1 ] ) ) + upBeats.append( ( downBeat[ 0 ] + Config.TICKS_PER_BEAT / 2 , downBeat[ 1 ] ) ) - if CSoundConstants.INSTRUMENTS[ self.trackInstrument ].instrumentRegister == CSoundConstants.MID: + if Config.INSTRUMENTS[ self.trackInstrument ].instrumentRegister == Config.MID: registerDensity = 1 downBeatRecurence = 1 for beat in range( beatsPerPage ): - beats.append( beat * Constants.TICKS_PER_BEAT ) - beats.append( beat * Constants.TICKS_PER_BEAT + ( Constants.TICKS_PER_BEAT / 2 ) ) + beats.append( beat * Config.TICKS_PER_BEAT ) + beats.append( beat * Config.TICKS_PER_BEAT + ( Config.TICKS_PER_BEAT / 2 ) ) for i in range( len( beats ) ): downBeats.append( ( beats[ GenerationConstants.MID_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) ) for downBeat in downBeats: - upBeats.append( ( downBeat[ 0 ] + Constants.TICKS_PER_BEAT / 4 , downBeat[ 1 ] ) ) + upBeats.append( ( downBeat[ 0 ] + Config.TICKS_PER_BEAT / 4 , downBeat[ 1 ] ) ) - if CSoundConstants.INSTRUMENTS[ self.trackInstrument ].instrumentRegister == CSoundConstants.HIGH: + if Config.INSTRUMENTS[ self.trackInstrument ].instrumentRegister == Config.HIGH: registerDensity = 1.5 downBeatRecurence = 1 for beat in range( beatsPerPage ): - beats.append( beat * Constants.TICKS_PER_BEAT ) - beats.append( beat * Constants.TICKS_PER_BEAT + ( Constants.TICKS_PER_BEAT / 2 ) ) + beats.append( beat * Config.TICKS_PER_BEAT ) + beats.append( beat * Config.TICKS_PER_BEAT + ( Config.TICKS_PER_BEAT / 2 ) ) for i in range( len( beats ) ): downBeats.append( ( beats[ GenerationConstants.HIGH_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) ) for downBeat in downBeats: - upBeats.append( ( downBeat[ 0 ] + Constants.TICKS_PER_BEAT / 4 , downBeat[ 1 ] ) ) + upBeats.append( ( downBeat[ 0 ] + Config.TICKS_PER_BEAT / 4 , downBeat[ 1 ] ) ) for i in range( int( parameters.density * registerDensity * len( downBeats ) ) ): if random.randint( 0, 100 ) < ( parameters.rythmRegularity * 100 * downBeatRecurence ) and binSelection.count( 1 ) < len( downBeats ): diff --git a/Framework/Generation/Generator.py b/Generation/Generator.py index c4e9870..447f24c 100755 --- a/Framework/Generation/Generator.py +++ b/Generation/Generator.py @@ -1,16 +1,16 @@ import random import math + import Utils import Drunk -from Framework.Constants import Constants -from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.CSound.CSoundNote import CSoundNote -from Framework.Generation.VariationPitch import * -from Framework.Generation.VariationRythm import * -from Framework.Generation.GenerationConstants import GenerationConstants -from Framework.Generation.GenerationRythm import GenerationRythm -from Framework.Generation.GenerationPitch import GenerationPitch +import Config +from Util.CSoundNote import CSoundNote +from Generation.VariationPitch import * +from Generation.VariationRythm import * +from Generation.GenerationConstants import GenerationConstants +from Generation.GenerationRythm import GenerationRythm +from Generation.GenerationPitch import GenerationPitch class GenerationParameters: def __init__( self, @@ -60,7 +60,7 @@ def generator1( for onset in onsetList: if onset == 0: gain = random.uniform(GenerationConstants.GAIN_MID_MAX_BOUNDARY, GenerationConstants.GAIN_MAX_BOUNDARY) - elif ( onset % Constants.TICKS_PER_BEAT) == 0: + elif ( onset % Config.TICKS_PER_BEAT) == 0: gain = random.uniform(GenerationConstants.GAIN_MID_MIN_BOUNDARY, GenerationConstants.GAIN_MID_MAX_BOUNDARY) else: gain = random.uniform(GenerationConstants.GAIN_MIN_BOUNDARY, GenerationConstants.GAIN_MID_MIN_BOUNDARY) @@ -78,18 +78,18 @@ def generator1( else: fullDurationSequence.append(False) - if CSoundConstants.INSTRUMENTS[ currentInstrument ].soundClass == 'drum': + if Config.INSTRUMENTS[ currentInstrument ].soundClass == 'drum': duration = GenerationConstants.DOUBLE_TICK_DUR / 2 durationSequence.append(duration) - if CSoundConstants.INSTRUMENTS[ currentInstrument ].soundClass == 'drum': + if Config.INSTRUMENTS[ currentInstrument ].soundClass == 'drum': durationSequence.append( GenerationConstants.DOUBLE_TICK_DUR / 2) else: durationSequence.append(( barLength - onsetList[-1]) * Utils.prob2( table_duration )) fullDurationSequence.append(False) elif len( onsetList ) == 1: - if CSoundConstants.INSTRUMENTS[ currentInstrument ].soundClass == 'drum': + if Config.INSTRUMENTS[ currentInstrument ].soundClass == 'drum': durationSequence.append( GenerationConstants.DOUBLE_TICK_DUR / 2 ) else: durationSequence.append( ( barLength - onsetList[ 0 ] ) * Utils.prob2( table_duration )) @@ -98,9 +98,9 @@ def generator1( def pageGenerate( parameters, trackID, pageID, selectedPageCount, lastPageID, trackOfNotes, drumPitch = None ): trackNotes = trackOfNotes - barLength = Constants.TICKS_PER_BEAT * nbeats + barLength = Config.TICKS_PER_BEAT * nbeats if drumPitch: - currentInstrument = CSoundConstants.DRUM1INSTRUMENTS[ drumPitch[ 0 ] ] + currentInstrument = Config.DRUM1INSTRUMENTS[ drumPitch[ 0 ] ] else: drumPitch = [ 36 ] currentInstrument = instrument[ trackID ] @@ -112,10 +112,10 @@ def generator1( GenerationConstants.ARTICULATION_SCALE_STEPS) table_pitch = GenerationConstants.SCALES[parameters.scale] - if CSoundConstants.INSTRUMENTS[ currentInstrument ].soundClass == 'drum': + if Config.INSTRUMENTS[ currentInstrument ].soundClass == 'drum': rythmSequence = makeRythm.drumRythmSequence(parameters) pitchSequence = makePitch.drumPitchSequence(len(rythmSequence), parameters, drumPitch, table_pitch ) - elif CSoundConstants.INSTRUMENTS[ currentInstrument ].soundClass == 'melo': + elif Config.INSTRUMENTS[ currentInstrument ].soundClass == 'melo': if parameters.rythmMethod == 0: rythmSequence = makeRythm.celluleRythmSequence(parameters) elif parameters.rythmMethod == 1: diff --git a/Framework/Generation/Utils.py b/Generation/Utils.py index 7f00525..7f00525 100755 --- a/Framework/Generation/Utils.py +++ b/Generation/Utils.py diff --git a/Framework/Generation/VariationPitch.py b/Generation/VariationPitch.py index 5a2b151..5a2b151 100644 --- a/Framework/Generation/VariationPitch.py +++ b/Generation/VariationPitch.py diff --git a/Framework/Generation/VariationRythm.py b/Generation/VariationRythm.py index 460f4f4..460f4f4 100644 --- a/Framework/Generation/VariationRythm.py +++ b/Generation/VariationRythm.py diff --git a/Framework/Core/__init__.py b/Generation/__init__.py index e69de29..e69de29 100644 --- a/Framework/Core/__init__.py +++ b/Generation/__init__.py diff --git a/Old/LLTimer/CVS/Entries b/Old/LLTimer/CVS/Entries deleted file mode 100644 index 3293941..0000000 --- a/Old/LLTimer/CVS/Entries +++ /dev/null @@ -1,5 +0,0 @@ -/retemodule.cpp/1.1.1.1/Wed Sep 7 15:48:28 2005// -D/dse//// -D/sf//// -/Makefile/1.2/Thu Sep 8 03:13:00 2005// -/setup.py/1.2/Wed Sep 7 21:23:23 2005// diff --git a/Old/LLTimer/CVS/Repository b/Old/LLTimer/CVS/Repository deleted file mode 100644 index a70aca6..0000000 --- a/Old/LLTimer/CVS/Repository +++ /dev/null @@ -1 +0,0 @@ -Gamme/librete/python_interface diff --git a/Old/LLTimer/CVS/Root b/Old/LLTimer/CVS/Root deleted file mode 100644 index 8137245..0000000 --- a/Old/LLTimer/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -:pserver:eckdoug@cvs.iro.umontreal.ca:/home/cvs/cvslisa/cvsroot diff --git a/Old/LLTimer/Makefile b/Old/LLTimer/Makefile deleted file mode 100644 index 88fe864..0000000 --- a/Old/LLTimer/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -default: -# For this project we don't really want things installed properly... just want the lltimer.so in the tamtam directory -# python setup.py build install --home=$(TAMTAM_ROOT) - python setup.py build - cp build/lib*/* $(TAMTAM_ROOT) -clean: - rm -rf build - - - - - diff --git a/Old/LLTimer/build/lib.linux-i686-2.4/lltimer.so b/Old/LLTimer/build/lib.linux-i686-2.4/lltimer.so deleted file mode 100755 index 87cf86e..0000000 --- a/Old/LLTimer/build/lib.linux-i686-2.4/lltimer.so +++ /dev/null Binary files differ diff --git a/Old/LLTimer/build/temp.linux-i686-2.4/lltimer.o b/Old/LLTimer/build/temp.linux-i686-2.4/lltimer.o deleted file mode 100644 index 03552a7..0000000 --- a/Old/LLTimer/build/temp.linux-i686-2.4/lltimer.o +++ /dev/null Binary files differ diff --git a/Old/LLTimer/lltimer.cpp b/Old/LLTimer/lltimer.cpp deleted file mode 100644 index ff20d79..0000000 --- a/Old/LLTimer/lltimer.cpp +++ /dev/null @@ -1,191 +0,0 @@ -#include "Python.h" -#include "Numeric/arrayobject.h" - -#include -#include - -static int lltimerState=0; -static int callbackSet=0; -static unsigned long lltimerMSecs=1000; -static PyObject * pyCbFunction; -static PyObject * arglist = Py_BuildValue("()"); -static PyObject * LltimerError; -static pthread_t thread; - - - -extern "C" -{ - - //adapted from csound5 code (Vercoe et.al) - static void millisleep(size_t milliseconds) { - struct timespec ts; - register size_t n, s; - - s = milliseconds / (size_t) 1000; - n = milliseconds - (s * (size_t) 1000); - n = (size_t) ((int) n * 1000000); - ts.tv_sec = (time_t) s; - ts.tv_nsec = (long) n; - while (nanosleep(&ts, &ts) != 0) - ; - } - - //return a timestamp in msecs - //this is a millisecond timestamp. - static timeval startTime; - static int startTimeInit=0; - static unsigned long timestamp() { - if (startTimeInit==0) { - gettimeofday(&startTime,NULL); - startTimeInit=1; - return 0; - } - timeval currTime; - gettimeofday(&currTime,NULL); - return (unsigned long)((currTime.tv_sec - startTime.tv_sec)*1000 + (currTime.tv_usec - startTime.tv_usec)/1000) ; - } - - //this is a millisecond delta timestamp - static timeval lastTime; - static int startDTimeInit=0; - static unsigned long dtimestamp() { - if (startDTimeInit==0) { - gettimeofday(&lastTime,NULL); - startDTimeInit=1; - return 0; - } - timeval currTime; - gettimeofday(&currTime,NULL); - unsigned long retval= (unsigned long)((currTime.tv_sec - lastTime.tv_sec)*1000 + (currTime.tv_usec - lastTime.tv_usec)/1000) ; - lastTime.tv_sec=currTime.tv_sec; - lastTime.tv_usec=currTime.tv_usec; - return retval; - } - - - - - void * periodicTimer(void * ignore) { - if (callbackSet==0) { - printf("No callback set!\n"); - } else { - //try to update the priority of scheduler - struct sched_param param; - param.sched_priority = 50; // Is this the best number? - int sresult = sched_setscheduler( 0, SCHED_RR, ¶m); - printf("Reult for setscheduler %i\n",sresult); - - // Check we have done what we hoped. - int sched = sched_getscheduler(0); - switch (sched) { - case SCHED_RR: - printf( " RR scheduler loaded \n" ); // running as root I now get this. - break; - case SCHED_FIFO: - printf( " FIFO scheudler loaded\n" ); - break; - default: - printf( " priority = %d \n",sched ); - } - - - //now loop on our callback - unsigned long starttime=timestamp(); - unsigned long nexttime=starttime+lltimerMSecs; - while (lltimerState==1) { - PyEval_CallObject(pyCbFunction, arglist); - unsigned long sleeptime = nexttime-timestamp(); - if (sleeptime>0) { - millisleep(sleeptime); - } else { - printf("LLTIMER: Cannot keep up. Slowing timer from %li to %li\n",lltimerMSecs,lltimerMSecs*2); - lltimerMSecs*=2; - } - nexttime+=lltimerMSecs; - } - } - return NULL; - } - - - - - - //creates and starts timer. - static PyObject * lltimer_timeout_add(PyObject * self, PyObject * args) { - int msecs=1000; - - //parse args to be sure it was called as lltimer.start(msecs) - if (!PyArg_ParseTuple(args, "iO:timeout_add", &msecs,&pyCbFunction)) { - printf("Error in LLTimer.start. Syntax: lltimer.timeout_add(msecs,callback)\n"); - return NULL; - } - - lltimerMSecs=(unsigned long) msecs; - - if (!PyCallable_Check(pyCbFunction)) { - PyErr_SetString(PyExc_TypeError, "Callback function must be callable"); - return NULL; - } - Py_XINCREF(pyCbFunction); /* Add a reference to new callback */ - callbackSet=1; - - if (lltimerState==0) { - //create and start the timer (Thanks to Gary Scavone @ McGill Univ. and his RtAudio for help on this!) - pthread_attr_t attr; - pthread_attr_init(&attr); - //pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - pthread_attr_setschedpolicy(&attr, SCHED_RR); - int err = pthread_create(&thread, &attr, periodicTimer, NULL); - //pthread_attr_destroy(&attr); - if (err) { - printf("Error initializing pthread\n"); - lltimerState=0; - } else { - printf("PThread initialized\n"); - lltimerState=1; - } - } else { - printf("Timer already started\n"); - } - - return Py_BuildValue("i", lltimerState); - } - - - - static PyObject * lltimer_stop(PyObject * self, PyObject * args) { - char *argStr; - if (!PyArg_ParseTuple(args, "", &argStr)) { - printf("Error in LLTimer stop. Syntax: stop()\n"); - return NULL; - } - lltimerState=0; - return Py_BuildValue("i", 0); - } - - -} - - - -static PyMethodDef LltimerMethods[] = { - {"stop", lltimer_stop, METH_VARARGS}, - {"timeout_add", lltimer_timeout_add, METH_VARARGS}, - {NULL, NULL} /* Sentinel */ -}; - - -extern "C" -{ - void initlltimer() { - PyObject *m, *d; - m = Py_InitModule("lltimer", LltimerMethods); - d = PyModule_GetDict(m); - LltimerError = PyErr_NewException("lltimer.error", NULL, NULL); - PyDict_SetItemString(d, "error", LltimerError); - import_array(); - } -} - diff --git a/Old/LLTimer/setup.py b/Old/LLTimer/setup.py deleted file mode 100755 index 166ee64..0000000 --- a/Old/LLTimer/setup.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -import distutils.sysconfig -from distutils.core import setup, Extension -import os, sys -from glob import glob - - - - -#ext_package = 'lltimer,' -#ext_modules = ext_modules, -setup (name = "lltimer", - version = "0.0.1", - description = "Low-Latency Periodic Timer", - long_description = """Low-Latency Periodic Timer""", - author = "Douglas Eck", - author_email = "eckdoug@iro.umontreal.ca", - url = "http://www.iro.umontreal.ca/~eckdoug", - ext_modules = [Extension('lltimer',['lltimer.cpp'])] - ) - - - - diff --git a/Old/lltimer.so b/Old/lltimer.so deleted file mode 100755 index 1a551b6..0000000 --- a/Old/lltimer.so +++ /dev/null Binary files differ diff --git a/Old/profilertest.py b/Old/profilertest.py deleted file mode 100755 index 3df262b..0000000 --- a/Old/profilertest.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/python - -import time - -from Framework.Core.Profiler import TaskProfiler - -TP = TaskProfiler() - - -for j in range(1,10): - t1 = time.time() - TP.ProfileBegin( "test" ) - print time.time() - t1 - for i in range(1,100000):i=i - t1 = time.time() - TP.ProfileEnd( "test" ) - print time.time() - t1 - -TP.ProfileBegin( "alah" ) -for i in range(1,100000):j=i -TP.ProfileEnd("alah") -TP.ProfileBegin( "blah" ) -for i in range(1,100000):j=i -TP.ProfileEnd("blah") - -print TP.ProfilePrint( "test" ) - -print TP.PrintAll() diff --git a/Old/timetest.py b/Old/timetest.py deleted file mode 100755 index 5373027..0000000 --- a/Old/timetest.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/python -import pygtk -pygtk.require( '2.0' ) -import gtk -import gobject -import time -import sys - -from GUI.Core.MainWindow import MainWindow -from Framework.Constants import Constants -from Framework.CSound.CSoundClient import CSoundClient -from Framework.CSound.CSoundServer import CsoundServerMult -from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.Generation.GenerationConstants import GenerationConstants - -import lltimer - -class TimerWithCallback : - def __init__(self,msecs,typ) : - self.typ=typ - if typ=="gtk": - gobject.timeout_add( msecs, self.printTime) - elif typ=="pthread" : - lltimer.timeout_add(msecs,self.printTime) - else : - print "Unknown timer type.",typ,"Cannot continue" - sys.exit(0) - - self.maxerr=0; - self.cumerr=0; - self.ctr=0; - self.msecs=msecs - self.lasttime=-1 - self.starttime = time.time() - def printTime(self) : - if self.lasttime==-1 : - self.lasttime=time.time() - else : - currtime = time.time() - diff = currtime-self.lasttime - self.lasttime = currtime - - if currtime>(self.starttime+2) : #print errors but ignore first 2 seconds - err= (diff*1000)-self.msecs - if abs(err)>self.maxerr : - self.maxerr=abs(err) - self.ctr+=1 - self.cumerr+=abs(err) - print "%4.2f %s mserr=%4.2fms mxerr=%4.2fms meanerr=%4.2fms" % \ - ((currtime-self.starttime),self.typ,err,self.maxerr,(self.cumerr/self.ctr)) - else : - print "Not timing first 2 seconds" - - - self.genDumbNote() - - return True - - - - - def genDumbNote(self) : - print "Genning note" - # duration for CSound is in seconds - newPitch = 60 - newDuration = 100 - newAmplitude = 100 - instr = CSoundConstants.FLUTE - trackId= 1 - reverbSend = 0 - pan = 0.5 - return CSoundConstants.PLAY_NOTE_COMMAND % ( CSoundConstants.INSTRUMENTS[ instr ].csoundInstrumentID, - trackId, - newDuration, - newPitch, - reverbSend, - newAmplitude, - pan, - CSoundConstants.INSTRUMENT_TABLE_OFFSET + CSoundConstants.INSTRUMENTS[ instr ].instrumentID ) - - - -if __name__ == "__main__": - CSoundClient.initialize() - tamTam = MainWindow() - - - if len(sys.argv)<2 or not (sys.argv[1]=="gtk" or sys.argv[1]=="pthread" or sys.argv[1]=="none"): - print "Usage timetest.py " - print "Note: you must be root or suid to benefit from pthread enhanced timing" - sys.exit(0) - - if not sys.argv[1]=="none" : - t=TimerWithCallback(1000,sys.argv[1]) - else : - print "No timer started" - gtk.main() - diff --git a/Player/GenRythm.py b/Player/GenRythm.py index c607d07..0cba969 100644 --- a/Player/GenRythm.py +++ b/Player/GenRythm.py @@ -1,8 +1,8 @@ import random -from Framework.Generation.GenerationConstants import GenerationConstants -from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.Constants import Constants -from Framework.Generation.Utils import * +import Config + +from Generation.GenerationConstants import GenerationConstants +from Generation.Utils import * class GenRythm: def __init__( self, instrument, barLength, nbeats ): @@ -20,49 +20,49 @@ class GenRythm: density = 0.8 countDown = 0 onsetTime = None - beatsPerPage = int( self.barLength / Constants.TICKS_PER_BEAT ) + beatsPerPage = int( self.barLength / Config.TICKS_PER_BEAT ) - if CSoundConstants.INSTRUMENTS[ self.instrument ].instrumentRegister == CSoundConstants.PUNCH: + if Config.INSTRUMENTS[ self.instrument ].instrumentRegister == Config.PUNCH: registerDensity = 0.5 downBeatRecurence = 4 for beat in range( beatsPerPage ): - beats.append( beat * Constants.TICKS_PER_BEAT ) + beats.append( beat * Config.TICKS_PER_BEAT ) for i in range( len( beats ) ): downBeats.append( ( beats[ GenerationConstants.PUNCH_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) ) for downBeat in downBeats: - upBeats.append( ( downBeat[ 0 ] + Constants.TICKS_PER_BEAT , downBeat[ 1 ] ) ) + upBeats.append( ( downBeat[ 0 ] + Config.TICKS_PER_BEAT , downBeat[ 1 ] ) ) - if CSoundConstants.INSTRUMENTS[ self.instrument ].instrumentRegister == CSoundConstants.LOW: + if Config.INSTRUMENTS[ self.instrument ].instrumentRegister == Config.LOW: registerDensity =1.5 downBeatRecurence = 4 for beat in range( beatsPerPage ): - beats.append( beat * Constants.TICKS_PER_BEAT ) + beats.append( beat * Config.TICKS_PER_BEAT ) for i in range( len( beats ) ): downBeats.append( ( beats[ GenerationConstants.LOW_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) ) for downBeat in downBeats: - upBeats.append( ( downBeat[ 0 ] + Constants.TICKS_PER_BEAT / 2 , downBeat[ 1 ] ) ) + upBeats.append( ( downBeat[ 0 ] + Config.TICKS_PER_BEAT / 2 , downBeat[ 1 ] ) ) - if CSoundConstants.INSTRUMENTS[ self.instrument ].instrumentRegister == CSoundConstants.MID: + if Config.INSTRUMENTS[ self.instrument ].instrumentRegister == Config.MID: registerDensity = .75 downBeatRecurence = 1 for beat in range( beatsPerPage ): - beats.append( beat * Constants.TICKS_PER_BEAT ) - beats.append( beat * Constants.TICKS_PER_BEAT + ( Constants.TICKS_PER_BEAT / 2 ) ) + beats.append( beat * Config.TICKS_PER_BEAT ) + beats.append( beat * Config.TICKS_PER_BEAT + ( Config.TICKS_PER_BEAT / 2 ) ) for i in range( len( beats ) ): downBeats.append( ( beats[ GenerationConstants.MID_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) ) for downBeat in downBeats: - upBeats.append( ( downBeat[ 0 ] + Constants.TICKS_PER_BEAT / 4 , downBeat[ 1 ] ) ) + upBeats.append( ( downBeat[ 0 ] + Config.TICKS_PER_BEAT / 4 , downBeat[ 1 ] ) ) - if CSoundConstants.INSTRUMENTS[ self.instrument ].instrumentRegister == CSoundConstants.HIGH: + if Config.INSTRUMENTS[ self.instrument ].instrumentRegister == Config.HIGH: registerDensity = 1.5 downBeatRecurence = 1 for beat in range( beatsPerPage ): - beats.append( beat * Constants.TICKS_PER_BEAT ) - beats.append( beat * Constants.TICKS_PER_BEAT + ( Constants.TICKS_PER_BEAT / 2 ) ) + beats.append( beat * Config.TICKS_PER_BEAT ) + beats.append( beat * Config.TICKS_PER_BEAT + ( Config.TICKS_PER_BEAT / 2 ) ) for i in range( len( beats ) ): downBeats.append( ( beats[ GenerationConstants.HIGH_ACCENTS[ beatsPerPage ][ i ] ], pow( float( len( beats ) - i) / len( beats ), 1.5 ) * 100.) ) for downBeat in downBeats: - upBeats.append( ( downBeat[ 0 ] + Constants.TICKS_PER_BEAT / 4 , downBeat[ 1 ] ) ) + upBeats.append( ( downBeat[ 0 ] + Config.TICKS_PER_BEAT / 4 , downBeat[ 1 ] ) ) for i in range( int( density * registerDensity * len( downBeats ) ) ): if random.randint( 0, 100 ) < ( regularity * 100 * downBeatRecurence ) and binSelection.count( 1 ) < len( downBeats ): diff --git a/Player/KeyboardStandAlone.py b/Player/KeyboardStandAlone.py index 7b41c1b..4c64317 100644 --- a/Player/KeyboardStandAlone.py +++ b/Player/KeyboardStandAlone.py @@ -2,11 +2,12 @@ import pygtk pygtk.require( '2.0' ) import gtk +import Config +#TODO: this is a suprising dependency... what's up?? +from Generation.GenerationConstants import GenerationConstants from Player.NoteStdAlone import NoteStdAlone -from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.Generation.GenerationConstants import GenerationConstants -from GUI.Core.KeyMapping import KEY_MAP_PIANO +KEY_MAP_PIANO = Config.KEY_MAP_PIANO class KeyboardStandAlone: def __init__( self, client, recordingFunction, adjustDurationFunction, getCurrentTick ): @@ -47,16 +48,16 @@ class KeyboardStandAlone: pitch = GenerationConstants.DRUMPITCH[ pitch ] if instrument == 'drum1kit': - instrument = CSoundConstants.DRUM1INSTRUMENTS[ pitch ] + instrument = Config.DRUM1INSTRUMENTS[ pitch ] if instrument == 'drum2kit': - instrument = CSoundConstants.DRUM2INSTRUMENTS[ pitch ] + instrument = Config.DRUM2INSTRUMENTS[ pitch ] if instrument == 'drum3kit': - instrument = CSoundConstants.DRUM3INSTRUMENTS[ pitch ] + instrument = Config.DRUM3INSTRUMENTS[ pitch ] pitch = 36 duration = 100 - if CSoundConstants.INSTRUMENTS[instrument].csoundInstrumentID == CSoundConstants.INST_PERC: #Percussions resonance + if Config.INSTRUMENTS[instrument].csoundInstrumentID == Config.INST_PERC: #Percussions resonance duration = 60 # Create and play the note self.key_dict[key] = NoteStdAlone(client = self.csnd, @@ -89,7 +90,7 @@ class KeyboardStandAlone: key = event.hardware_keycode if KEY_MAP_PIANO.has_key(key): - if CSoundConstants.INSTRUMENTS[ self.key_dict[key].instrument].csoundInstrumentID == CSoundConstants.INST_TIED: + if Config.INSTRUMENTS[ self.key_dict[key].instrument].csoundInstrumentID == Config.INST_TIED: self.key_dict[key].duration = 1 self.key_dict[key].decay = 0.88 self.key_dict[key].amplitude = 1 diff --git a/Player/NoteStdAlone.py b/Player/NoteStdAlone.py index 9722899..a64bd64 100644 --- a/Player/NoteStdAlone.py +++ b/Player/NoteStdAlone.py @@ -1,7 +1,6 @@ -from Framework.Constants import Constants -from Framework.CSound.CSoundClient import CSoundClient -from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.Generation.GenerationConstants import GenerationConstants +import Config +from Util.CSoundClient import CSoundClient +from Generation.GenerationConstants import GenerationConstants class NoteStdAlone: def __init__( self, client, @@ -12,7 +11,7 @@ class NoteStdAlone: duration, trackID, fullDuration = False, - instrument = CSoundConstants.FLUTE, + instrument = Config.FLUTE, attack = 0.005, decay = 0.095, reverbSend = 0.1, @@ -20,7 +19,7 @@ class NoteStdAlone: filterCutoff = 1000, tied = False, overlap = False, - instrumentFlag = CSoundConstants.FLUTE ): + instrumentFlag = Config.FLUTE ): self.csnd = client self.onset = onset self.pitch = pitch @@ -38,7 +37,7 @@ class NoteStdAlone: self.tied = tied self.overlap = overlap if self.instrument == 'drum1kit': - self.instrumentFlag = CSoundConstants.DRUM1INSTRUMENTS[ self.pitch ] + self.instrumentFlag = Config.DRUM1INSTRUMENTS[ self.pitch ] else: self.instrumentFlag = self.instrument @@ -51,25 +50,25 @@ class NoteStdAlone: self.pitch = GenerationConstants.DRUMPITCH[ self.pitch ] if self.instrument == 'drum1kit': - self.instrumentFlag = CSoundConstants.DRUM1INSTRUMENTS[ self.pitch ] + self.instrumentFlag = Config.DRUM1INSTRUMENTS[ self.pitch ] if self.instrument == 'drum2kit': - self.instrumentFlag = CSoundConstants.DRUM2INSTRUMENTS[ self.pitch ] + self.instrumentFlag = Config.DRUM2INSTRUMENTS[ self.pitch ] if self.instrument == 'drum3kit': - self.instrumentFlag = CSoundConstants.DRUM3INSTRUMENTS[ self.pitch ] + self.instrumentFlag = Config.DRUM3INSTRUMENTS[ self.pitch ] newPitch = 1 else: self.instrumentFlag = self.instrument newPitch = pow( GenerationConstants.TWO_ROOT_TWELVE, self.pitch - 36 ) - oneTickDuration = (Constants.MS_PER_MINUTE / 1000) / tempo / Constants.TICKS_PER_BEAT + oneTickDuration = (Config.MS_PER_MINUTE / 1000) / tempo / Config.TICKS_PER_BEAT newDuration = oneTickDuration * self.duration # condition for tied notes - if CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID == 101 and self.tied and self.fullDuration: + if Config.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID == 101 and self.tied and self.fullDuration: newDuration = -1 # condition for overlaped notes - if CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID == 102 and self.overlap: + if Config.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID == 102 and self.overlap: newDuration = oneTickDuration * self.duration + 1. if True: newAmplitude = self.amplitude * 0.8 @@ -83,10 +82,10 @@ class NoteStdAlone: if newDecay <= 0.002: newDecay = 0.002 - loopStart = CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].loopStart - loopEnd = CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].loopEnd - crossDur = CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].crossDur - return CSoundConstants.PLAY_NOTE_COMMAND % ( CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID, + 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, @@ -94,7 +93,7 @@ class NoteStdAlone: self.reverbSend, newAmplitude, self.pan, - CSoundConstants.INSTRUMENT_TABLE_OFFSET + CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].instrumentID, + Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[ self.instrumentFlag ].instrumentID, newAttack, newDecay, self.filterType, diff --git a/Player/RythmGenerator.py b/Player/RythmGenerator.py index e92e081..4e141ec 100644 --- a/Player/RythmGenerator.py +++ b/Player/RythmGenerator.py @@ -1,10 +1,9 @@ import random import math -from Framework.Constants import Constants -from Framework.CSound.CSoundConstants import CSoundConstants +import Config from Player.NoteStdAlone import NoteStdAlone -from Framework.Generation.GenerationConstants import GenerationConstants +from Generation.GenerationConstants import GenerationConstants from Player.GenRythm import GenRythm def generator( instrument, nbeats, regularity, reverbSend, client ): @@ -20,7 +19,7 @@ def generator( instrument, nbeats, regularity, reverbSend, client ): for onset in onsetList: if onset == 0: gain = random.uniform(GenerationConstants.GAIN_MID_MAX_BOUNDARY, GenerationConstants.GAIN_MAX_BOUNDARY) - elif ( onset % Constants.TICKS_PER_BEAT) == 0: + elif ( onset % Config.TICKS_PER_BEAT) == 0: gain = random.uniform(GenerationConstants.GAIN_MID_MIN_BOUNDARY, GenerationConstants.GAIN_MID_MAX_BOUNDARY) else: gain = random.uniform(GenerationConstants.GAIN_MIN_BOUNDARY, GenerationConstants.GAIN_MID_MIN_BOUNDARY) @@ -41,13 +40,13 @@ def generator( instrument, nbeats, regularity, reverbSend, client ): return durationSequence, fullDurationSequence def pageGenerate( regularity, drumPitch ): - barLength = Constants.TICKS_PER_BEAT * nbeats + barLength = Config.TICKS_PER_BEAT * nbeats if instrument == 'drum1kit': - currentInstrument = CSoundConstants.DRUM1INSTRUMENTS[ drumPitch[ 0 ] ] + currentInstrument = Config.DRUM1INSTRUMENTS[ drumPitch[ 0 ] ] elif instrument == 'drum2kit': - currentInstrument = CSoundConstants.DRUM2INSTRUMENTS[ drumPitch[ 0 ] ] + currentInstrument = Config.DRUM2INSTRUMENTS[ drumPitch[ 0 ] ] elif instrument == 'drum3kit': - currentInstrument = CSoundConstants.DRUM3INSTRUMENTS[ drumPitch[ 0 ] ] + currentInstrument = Config.DRUM3INSTRUMENTS[ drumPitch[ 0 ] ] makeRythm = GenRythm( currentInstrument, barLength, nbeats ) diff --git a/Player/RythmPlayer.py b/Player/RythmPlayer.py index ba0b11a..cfd54b7 100644 --- a/Player/RythmPlayer.py +++ b/Player/RythmPlayer.py @@ -3,10 +3,9 @@ pygtk.require( '2.0' ) import gtk import gobject -from Framework.Constants import Constants -from Framework.CSound.CSoundNote import CSoundNote -from Framework.CSound.CSoundClient import CSoundClient -from Framework.CSound.CSoundConstants import CSoundConstants +import Config +from Util.CSoundNote import CSoundNote +from Util.CSoundClient import CSoundClient class RythmPlayer: def __init__( self, client, recordButtonState ): @@ -98,7 +97,7 @@ class RythmPlayer: self.startLooking = 0 self.currentTick = self.currentTick + 1 - if self.currentTick >= (Constants.TICKS_PER_BEAT * self.beat): + if self.currentTick >= (Config.TICKS_PER_BEAT * self.beat): if self.recordState: self.recordState = 0 self.sequencerPlayback = 1 diff --git a/GUI/StandalonePlayer.py b/Player/StandalonePlayer.py index 9d80f61..77b1aa3 100755..100644 --- a/GUI/StandalonePlayer.py +++ b/Player/StandalonePlayer.py @@ -4,23 +4,24 @@ import gtk import os import random -from Framework.Constants import Constants -from GUI.GUIConstants import GUIConstants -from Framework.CSound.CSoundConstants import CSoundConstants +import Config + +from Util.ThemeWidgets import * +from Util.Credits import Credits + from Player.KeyboardStandAlone import KeyboardStandAlone from Player.NoteStdAlone import NoteStdAlone from Player.RythmPlayer import RythmPlayer from Player.RythmGenerator import * -from GUI.Core.ThemeWidgets import * -from GUI.Credits import Credits -from GUI.SynthLab.SynthLabWindow import SynthLabWindow -from GUI.Tooltips import Tooltips +from SynthLab.SynthLabWindow import SynthLabWindow + +Tooltips = Config.Tooltips class StandAlonePlayer( gtk.EventBox ): def __init__(self, client): gtk.EventBox.__init__( self) - self.set_border_width(GUIConstants.MAIN_WINDOW_PADDING) + self.set_border_width(Config.MAIN_WINDOW_PADDING) self.csnd = client @@ -69,7 +70,7 @@ class StandAlonePlayer( gtk.EventBox ): eventbox = gtk.EventBox() eventbox.connect('button-press-event', self.handleLogoPress) logo = gtk.Image() - logo.set_from_file(GUIConstants.IMAGE_ROOT + 'tamtam_rouge.png') + logo.set_from_file(Config.IMAGE_ROOT + 'tamtam_rouge.png') eventbox.add(logo) self.middleBox.add(eventbox) @@ -83,14 +84,14 @@ class StandAlonePlayer( gtk.EventBox ): self.creditsOpen = state def drawSliders( self ): - mainSliderBox = RoundHBox(fillcolor = GUIConstants.PANEL_COLOR, bordercolor = GUIConstants.PANEL_BCK_COLOR, radius = GUIConstants.PANEL_RADIUS) - mainSliderBox.set_border_width(GUIConstants.BORDER_SIZE) + mainSliderBox = RoundHBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS) + mainSliderBox.set_border_width(Config.BORDER_SIZE) reverbSliderBox = gtk.HBox() self.reverbSliderBoxImgTop = gtk.Image() - self.reverbSliderBoxImgTop.set_from_file(GUIConstants.IMAGE_ROOT + 'reverb0.png') + self.reverbSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'reverb0.png') reverbAdjustment = gtk.Adjustment(value=self.reverb, lower=0, upper=1, step_incr=0.1, page_incr=0, page_size=0) - reverbSlider = ImageHScale( GUIConstants.IMAGE_ROOT + "sliderbutred.png", reverbAdjustment, 7 ) + reverbSlider = ImageHScale( Config.IMAGE_ROOT + "sliderbutred.png", reverbAdjustment, 7 ) reverbSlider.set_inverted(False) reverbSlider.set_size_request(350,15) reverbAdjustment.connect("value_changed" , self.handleReverbSlider) @@ -100,9 +101,9 @@ class StandAlonePlayer( gtk.EventBox ): volumeSliderBox = gtk.HBox() self.volumeSliderBoxImgTop = gtk.Image() - self.volumeSliderBoxImgTop.set_from_file(GUIConstants.IMAGE_ROOT + 'volume2.png') + self.volumeSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'volume2.png') volumeAdjustment = gtk.Adjustment(value=self.volume, lower=0, upper=100, step_incr=1, page_incr=0, page_size=0) - volumeSlider = ImageHScale( GUIConstants.IMAGE_ROOT + "sliderbutviolet.png", volumeAdjustment, 7 ) + volumeSlider = ImageHScale( Config.IMAGE_ROOT + "sliderbutviolet.png", volumeAdjustment, 7 ) volumeSlider.set_inverted(False) volumeSlider.set_size_request(350,15) volumeAdjustment.connect("value_changed" , self.handleVolumeSlider) @@ -117,18 +118,18 @@ class StandAlonePlayer( gtk.EventBox ): def drawGeneration( self ): - slidersBox = RoundVBox(fillcolor = GUIConstants.PANEL_COLOR, bordercolor = GUIConstants.PANEL_BCK_COLOR, radius = GUIConstants.PANEL_RADIUS) - slidersBox.set_border_width(GUIConstants.BORDER_SIZE) - geneButtonBox = RoundHBox(fillcolor = GUIConstants.PANEL_COLOR, bordercolor = GUIConstants.PANEL_BCK_COLOR, radius = GUIConstants.PANEL_RADIUS) - geneButtonBox.set_border_width(GUIConstants.BORDER_SIZE) - transportBox = RoundHBox(fillcolor = GUIConstants.PANEL_COLOR, bordercolor = GUIConstants.PANEL_BCK_COLOR, radius = GUIConstants.PANEL_RADIUS) - transportBox.set_border_width(GUIConstants.BORDER_SIZE) + slidersBox = RoundVBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS) + slidersBox.set_border_width(Config.BORDER_SIZE) + geneButtonBox = RoundHBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS) + geneButtonBox.set_border_width(Config.BORDER_SIZE) + transportBox = RoundHBox(fillcolor = Config.PANEL_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS) + transportBox.set_border_width(Config.BORDER_SIZE) geneSliderBox = gtk.VBox() self.geneSliderBoxImgTop = gtk.Image() - self.geneSliderBoxImgTop.set_from_file(GUIConstants.IMAGE_ROOT + 'complex6.png') + self.geneSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'complex6.png') geneAdjustment = gtk.Adjustment(value=self.regularity, lower=0, upper=1, step_incr=0.01, page_incr=0, page_size=0) - geneSlider = ImageVScale( GUIConstants.IMAGE_ROOT + "sliderbutbleu.png", geneAdjustment, 5 ) + geneSlider = ImageVScale( Config.IMAGE_ROOT + "sliderbutbleu.png", geneAdjustment, 5 ) geneSlider.set_inverted(False) geneSlider.set_size_request(15,408) geneAdjustment.connect("value_changed" , self.handleGenerationSlider) @@ -139,9 +140,9 @@ class StandAlonePlayer( gtk.EventBox ): beatSliderBox = gtk.VBox() self.beatSliderBoxImgTop = gtk.Image() - self.beatSliderBoxImgTop.set_from_file(GUIConstants.IMAGE_ROOT + 'beat3.png') + self.beatSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'beat3.png') beatAdjustment = gtk.Adjustment(value=self.beat, lower=2, upper=12, step_incr=1, page_incr=0, page_size=0) - beatSlider = ImageVScale( GUIConstants.IMAGE_ROOT + "sliderbutjaune.png", beatAdjustment, 5, snap = 1 ) + beatSlider = ImageVScale( Config.IMAGE_ROOT + "sliderbutjaune.png", beatAdjustment, 5, snap = 1 ) beatSlider.set_inverted(True) beatSlider.set_size_request(15,408) beatAdjustment.connect("value_changed" , self.handleBeatSlider) @@ -152,9 +153,9 @@ class StandAlonePlayer( gtk.EventBox ): tempoSliderBox = gtk.VBox() self.tempoSliderBoxImgTop = gtk.Image() - self.tempoSliderBoxImgTop.set_from_file(GUIConstants.IMAGE_ROOT + 'tempo5.png') + self.tempoSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'tempo5.png') tempoAdjustment = gtk.Adjustment(value=self.tempo, lower=40, upper=240, step_incr=1, page_incr=1, page_size=1) - tempoSlider = ImageVScale( GUIConstants.IMAGE_ROOT + "sliderbutvert.png", tempoAdjustment, 5) + tempoSlider = ImageVScale( Config.IMAGE_ROOT + "sliderbutvert.png", tempoAdjustment, 5) tempoSlider.set_inverted(True) tempoSlider.set_size_request(15,408) tempoAdjustment.connect("value_changed" , self.setTempo) @@ -168,7 +169,7 @@ class StandAlonePlayer( gtk.EventBox ): slidersBoxSub.pack_start(tempoSliderBox) slidersBox.pack_start(slidersBoxSub) - generateBtn = ImageButton(GUIConstants.IMAGE_ROOT + 'dice.png', click_image_path = GUIConstants.IMAGE_ROOT + 'diceblur.png') + generateBtn = ImageButton(Config.IMAGE_ROOT + 'dice.png', click_image_path = Config.IMAGE_ROOT + 'diceblur.png') generateBtn.connect('clicked', self.handleGenerateBtn) slidersBox.pack_start(generateBtn) self.tooltips.set_tip(generateBtn,Tooltips.GEN) @@ -177,13 +178,13 @@ class StandAlonePlayer( gtk.EventBox ): geneSubBox = gtk.VBox() geneSubBoxTop = gtk.HBox() - generationDrumBtn1 = ImageRadioButton(group = None , mainImg_path = GUIConstants.IMAGE_ROOT + 'drum1kit.png' , altImg_path = GUIConstants.IMAGE_ROOT + 'drum1kitselgen.png') + generationDrumBtn1 = ImageRadioButton(group = None , mainImg_path = Config.IMAGE_ROOT + 'drum1kit.png' , altImg_path = Config.IMAGE_ROOT + 'drum1kitselgen.png') generationDrumBtn1.connect('clicked' , self.handleGenerationDrumBtn , 'drum1kit') geneSubBoxTop.pack_start(generationDrumBtn1) - generationDrumBtn2 = ImageRadioButton(group = generationDrumBtn1 , mainImg_path = GUIConstants.IMAGE_ROOT + 'drum2kit.png' , altImg_path = GUIConstants.IMAGE_ROOT + 'drum2kitselgen.png') + generationDrumBtn2 = ImageRadioButton(group = generationDrumBtn1 , mainImg_path = Config.IMAGE_ROOT + 'drum2kit.png' , altImg_path = Config.IMAGE_ROOT + 'drum2kitselgen.png') generationDrumBtn2.connect('clicked' , self.handleGenerationDrumBtn , 'drum2kit') geneSubBoxTop.pack_start(generationDrumBtn2) - generationDrumBtn3 = ImageRadioButton(group = generationDrumBtn1 , mainImg_path = GUIConstants.IMAGE_ROOT + 'drum3kit.png' , altImg_path = GUIConstants.IMAGE_ROOT + 'drum3kitselgen.png') + generationDrumBtn3 = ImageRadioButton(group = generationDrumBtn1 , mainImg_path = Config.IMAGE_ROOT + 'drum3kit.png' , altImg_path = Config.IMAGE_ROOT + 'drum3kitselgen.png') generationDrumBtn3.connect('clicked' , self.handleGenerationDrumBtn , 'drum3kit') geneSubBox.pack_start(geneSubBoxTop, True) geneSubBox.pack_start(generationDrumBtn3, True) @@ -193,10 +194,10 @@ class StandAlonePlayer( gtk.EventBox ): self.tooltips.set_tip(generationDrumBtn3,Tooltips.AFRI) #Transport Button Box - self.seqRecordButton = ImageToggleButton(GUIConstants.IMAGE_ROOT + 'record2.png', GUIConstants.IMAGE_ROOT + 'record2sel.png') + self.seqRecordButton = ImageToggleButton(Config.IMAGE_ROOT + 'record2.png', Config.IMAGE_ROOT + 'record2sel.png') self.seqRecordButton.connect('clicked', self.rythmPlayer.handleRecordButton ) - self.playStopButton = ImageToggleButton(GUIConstants.IMAGE_ROOT + 'play.png', GUIConstants.IMAGE_ROOT + 'stop.png') + self.playStopButton = ImageToggleButton(Config.IMAGE_ROOT + 'play.png', Config.IMAGE_ROOT + 'stop.png') self.playStopButton.connect('clicked' , self.handlePlayButton) transportBox.pack_start(self.seqRecordButton) transportBox.pack_start(self.playStopButton) @@ -222,9 +223,9 @@ class StandAlonePlayer( gtk.EventBox ): for row in range(rows): hBox = gtk.HBox() for instrument in self.getInstrumentList()[row*ROW_LEN:(row+1)*ROW_LEN]: - instBox = RoundVBox(fillcolor = GUIConstants.INST_BCK_COLOR, bordercolor = GUIConstants.PANEL_BCK_COLOR, radius = GUIConstants.PANEL_RADIUS) - instBox.set_border_width(GUIConstants.BORDER_SIZE) - instButton = ImageRadioButton(self.firstInstButton, GUIConstants.IMAGE_ROOT + instrument + '.png' , GUIConstants.IMAGE_ROOT + instrument + 'sel.png', GUIConstants.IMAGE_ROOT + instrument + 'sel.png') + instBox = RoundVBox(fillcolor = Config.INST_BCK_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS) + instBox.set_border_width(Config.BORDER_SIZE) + instButton = ImageRadioButton(self.firstInstButton, Config.IMAGE_ROOT + instrument + '.png' , Config.IMAGE_ROOT + instrument + 'sel.png', Config.IMAGE_ROOT + instrument + 'sel.png') if self.firstInstButton == None: self.firstInstButton = instButton instButton.connect('clicked' , self.handleInstrumentButtonClick , instrument) @@ -237,11 +238,11 @@ class StandAlonePlayer( gtk.EventBox ): hbox = gtk.HBox() for n in ['mic1','mic2','mic3','mic4']: - vbox1 = RoundVBox(fillcolor = GUIConstants.INST_BCK_COLOR, bordercolor = GUIConstants.PANEL_BCK_COLOR, radius = GUIConstants.PANEL_RADIUS) - vbox1.set_border_width(GUIConstants.BORDER_SIZE) + vbox1 = RoundVBox(fillcolor = Config.INST_BCK_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS) + vbox1.set_border_width(Config.BORDER_SIZE) - micBtn = ImageRadioButton(self.firstInstButton, GUIConstants.IMAGE_ROOT + n + '.png' , GUIConstants.IMAGE_ROOT + n + 'sel.png', GUIConstants.IMAGE_ROOT + n + 'sel.png') - micRecBtn = ImageButton(GUIConstants.IMAGE_ROOT + 'record.png' , GUIConstants.IMAGE_ROOT + 'recordhi.png', GUIConstants.IMAGE_ROOT + 'recordsel.png') + micBtn = ImageRadioButton(self.firstInstButton, Config.IMAGE_ROOT + n + '.png' , Config.IMAGE_ROOT + n + 'sel.png', Config.IMAGE_ROOT + n + 'sel.png') + micRecBtn = ImageButton(Config.IMAGE_ROOT + 'record.png' , Config.IMAGE_ROOT + 'recordhi.png', Config.IMAGE_ROOT + 'recordsel.png') self.tooltips.set_tip(micRecBtn,Tooltips.RECMIC) micBtn.connect('clicked', self.handleInstrumentButtonClick, n) @@ -253,11 +254,11 @@ class StandAlonePlayer( gtk.EventBox ): hbox.add(vbox1) for n in ['lab1','lab2','lab3','lab4']: - vbox2 = RoundVBox(fillcolor = GUIConstants.INST_BCK_COLOR, bordercolor = GUIConstants.PANEL_BCK_COLOR, radius = GUIConstants.PANEL_RADIUS) - vbox2.set_border_width(GUIConstants.BORDER_SIZE) + vbox2 = RoundVBox(fillcolor = Config.INST_BCK_COLOR, bordercolor = Config.PANEL_BCK_COLOR, radius = Config.PANEL_RADIUS) + vbox2.set_border_width(Config.BORDER_SIZE) - synthBtn = ImageRadioButton(self.firstInstButton, GUIConstants.IMAGE_ROOT + n + '.png', GUIConstants.IMAGE_ROOT + n + 'sel.png', GUIConstants.IMAGE_ROOT + n + 'sel.png') - synthRecBtn = ImageButton(GUIConstants.IMAGE_ROOT + 'record.png' , GUIConstants.IMAGE_ROOT + 'recordhi.png', GUIConstants.IMAGE_ROOT + 'recordsel.png') + synthBtn = ImageRadioButton(self.firstInstButton, Config.IMAGE_ROOT + n + '.png', Config.IMAGE_ROOT + n + 'sel.png', Config.IMAGE_ROOT + n + 'sel.png') + synthRecBtn = ImageButton(Config.IMAGE_ROOT + 'record.png' , Config.IMAGE_ROOT + 'recordhi.png', Config.IMAGE_ROOT + 'recordsel.png') self.tooltips.set_tip(synthRecBtn,Tooltips.RECLAB) synthBtn.connect('clicked', self.handleInstrumentButtonClick, n) @@ -312,7 +313,7 @@ class StandAlonePlayer( gtk.EventBox ): def handleGenerationSlider(self, adj): img = int(adj.value * 7)+1 - self.geneSliderBoxImgTop.set_from_file(GUIConstants.IMAGE_ROOT + 'complex' + str(img) + '.png') + self.geneSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'complex' + str(img) + '.png') def handleGenerationSliderRelease(self, widget, event): self.regularity = widget.get_adjustment().value @@ -320,7 +321,7 @@ class StandAlonePlayer( gtk.EventBox ): def handleBeatSlider(self, adj): img = self.scale(int(adj.value),2,12,1,11) - self.beatSliderBoxImgTop.set_from_file(GUIConstants.IMAGE_ROOT + 'beat' + str(img) + '.png') + self.beatSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'beat' + str(img) + '.png') print img def handleBeatSliderRelease(self, widget, event): @@ -332,12 +333,12 @@ class StandAlonePlayer( gtk.EventBox ): self.volume = int(adj.value) self.csnd.setMasterVolume(self.volume) img = int(self.scale(self.volume,0,100,0,3.9)) - self.volumeSliderBoxImgTop.set_from_file(GUIConstants.IMAGE_ROOT + 'volume' + str(img) + '.png') + self.volumeSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'volume' + str(img) + '.png') def handleReverbSlider(self, adj): self.reverb = adj.value img = int(self.scale(self.reverb,0,1,0,4)) - self.reverbSliderBoxImgTop.set_from_file(GUIConstants.IMAGE_ROOT + 'reverb' + str(img) + '.png') + self.reverbSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'reverb' + str(img) + '.png') self.keyboardStandAlone.setReverb(self.reverb) def handlePlayButton(self, widget, data = None): @@ -371,7 +372,7 @@ class StandAlonePlayer( gtk.EventBox ): def setTempo(self,adj): self.rythmPlayer.setTempo(int(adj.value)) img = int((adj.value - 40) /26.)+1 - self.tempoSliderBoxImgTop.set_from_file(GUIConstants.IMAGE_ROOT + 'tempo' + str(img) + '.png') + self.tempoSliderBoxImgTop.set_from_file(Config.IMAGE_ROOT + 'tempo' + str(img) + '.png') def playInstrumentNote(self , instrument): note = NoteStdAlone( client = self.csnd, @@ -392,8 +393,8 @@ class StandAlonePlayer( gtk.EventBox ): self.playInstrumentNote('guidice' + r) def getInstrumentList(self): - cleanInstrumentList = [instrument for instrument in CSoundConstants.INSTRUMENTS.keys() if instrument[0:4] != 'drum' and instrument[0:3] != 'mic' and instrument[0:3] != 'lab' and instrument[0:4] != 'guid'] - cleanInstrumentList.sort(lambda g,l: cmp(CSoundConstants.INSTRUMENTS[g].category, CSoundConstants.INSTRUMENTS[l].category) ) + cleanInstrumentList = [instrument for instrument in Config.INSTRUMENTS.keys() if instrument[0:4] != 'drum' and instrument[0:3] != 'mic' and instrument[0:3] != 'lab' and instrument[0:4] != 'guid'] + cleanInstrumentList.sort(lambda g,l: cmp(Config.INSTRUMENTS[g].category, Config.INSTRUMENTS[l].category) ) return cleanInstrumentList + ['drum1kit', 'drum2kit', 'drum3kit'] def destroy( self, widget ): diff --git a/Player/StandalonePlayerOld.py b/Player/StandalonePlayerOld.py index cc03ab4..c95c381 100644 --- a/Player/StandalonePlayerOld.py +++ b/Player/StandalonePlayerOld.py @@ -9,6 +9,8 @@ from Framework.CSound.CSoundConstants import CSoundConstants from Player.KeyboardStandAlone import KeyboardStandAlone from Player.NoteStdAlone import NoteStdAlone +raise 'dont use this class, its the old one' + class StandAlonePlayer( gtk.Window ): def __init__(self): @@ -173,4 +175,4 @@ class StandAlonePlayer( gtk.Window ): if __name__ == "__main__": standAlonePlayer = StandAlonePlayer() #start the gtk event loop - gtk.main() \ No newline at end of file + gtk.main() diff --git a/GUI/SynthLab/SynthLabParametersWindow.py b/SynthLab/SynthLabParametersWindow.py index 4418949..d63b936 100644 --- a/GUI/SynthLab/SynthLabParametersWindow.py +++ b/SynthLab/SynthLabParametersWindow.py @@ -2,12 +2,11 @@ import pygtk pygtk.require('2.0') import gtk -from GUI.Core.KeyMapping import * -from GUI.Core.ThemeWidgets import * -from GUI.GUIConstants import GUIConstants +import Config +from Util.ThemeWidgets import * from SynthLab.SynthLabConstants import SynthLabConstants -from Framework.Constants import Constants -from GUI.Tooltips import Tooltips + +Tooltips = Config.Tooltips class SynthLabParametersWindow( gtk.Window ): def __init__( self, instanceID, synthObjectsParameters, writeTables, playNoteFunction ): @@ -18,7 +17,7 @@ class SynthLabParametersWindow( gtk.Window ): self.set_default_size(30, 300) self.set_border_width(0) self.set_decorated(False) - self.mainBox = RoundVBox(fillcolor=GUIConstants.PANEL_COLOR, bordercolor=GUIConstants.INST_BCK_COLOR) + self.mainBox = RoundVBox(fillcolor=Config.PANEL_COLOR, bordercolor=Config.INST_BCK_COLOR) self.mainBox.set_border_width(1) self.mainBox.set_radius(10) self.typeBox = gtk.HBox(False, 0) @@ -71,28 +70,28 @@ class SynthLabParametersWindow( gtk.Window ): self.p1Adjust = gtk.Adjustment(slider1Init, slider1Min, slider1Max, slider1Step, slider1Step, 0) self.p1Adjust.connect("value-changed", self.sendTables) - self.slider1 = ImageVScale(Constants.TAM_TAM_ROOT + '/Resources/Images/sliderbutred.png', self.p1Adjust, 7, snap = slider1Snap) + self.slider1 = ImageVScale(Config.TAM_TAM_ROOT + '/Resources/Images/sliderbutred.png', self.p1Adjust, 7, snap = slider1Snap) self.slider1.set_inverted(True) self.slider1.set_size_request(50, 150) self.sliderBox.pack_start(self.slider1, True, False) self.p2Adjust = gtk.Adjustment(slider2Init, slider2Min, slider2Max, slider2Step, slider2Step, 0) self.p2Adjust.connect("value-changed", self.sendTables) - self.slider2 = ImageVScale(Constants.TAM_TAM_ROOT + '/Resources/Images/sliderbutred.png', self.p2Adjust, 7, snap = slider2Snap) + self.slider2 = ImageVScale(Config.TAM_TAM_ROOT + '/Resources/Images/sliderbutred.png', self.p2Adjust, 7, snap = slider2Snap) self.slider2.set_inverted(True) self.slider2.set_size_request(50, 150) self.sliderBox.pack_start(self.slider2, True, False) self.p3Adjust = gtk.Adjustment(slider3Init, slider3Min, slider3Max, slider3Step, slider3Step, 0) self.p3Adjust.connect("value-changed", self.sendTables) - self.slider3 = ImageVScale(Constants.TAM_TAM_ROOT + '/Resources/Images/sliderbutred.png', self.p3Adjust, 7, snap = slider3Snap) + self.slider3 = ImageVScale(Config.TAM_TAM_ROOT + '/Resources/Images/sliderbutred.png', self.p3Adjust, 7, snap = slider3Snap) self.slider3.set_inverted(True) self.slider3.set_size_request(50, 150) self.sliderBox.pack_start(self.slider3, True, False) self.p4Adjust = gtk.Adjustment(slider4Init, 0, 1, .01, .01, 0) self.p4Adjust.connect("value-changed", self.sendTables) - self.slider4 = ImageVScale(Constants.TAM_TAM_ROOT + '/Resources/Images/sliderbutred.png', self.p4Adjust, 7) + self.slider4 = ImageVScale(Config.TAM_TAM_ROOT + '/Resources/Images/sliderbutred.png', self.p4Adjust, 7) self.slider4.set_digits(2) self.slider4.set_value_pos(2) self.slider4.set_inverted(True) @@ -106,7 +105,7 @@ class SynthLabParametersWindow( gtk.Window ): self.tooltips.set_tip(self.slider4, Tooltips.SYNTHPARA[selectedType][3] + ': ' + self.recallSliderValue(4)) self.mainBox.pack_start(self.sliderBox) - closeButton = ImageButton(Constants.TAM_TAM_ROOT + '/Resources/Images/close.png' ) + closeButton = ImageButton(Config.TAM_TAM_ROOT + '/Resources/Images/close.png' ) closeButton.connect('clicked', self.destroy ) self.mainBox.pack_start(closeButton) @@ -118,13 +117,13 @@ class SynthLabParametersWindow( gtk.Window ): self.hide() def onKeyPress(self,widget,event): - midiPitch = KEY_MAP[event.hardware_keycode] + midiPitch = Config.KEY_MAP[event.hardware_keycode] if midiPitch not in self.playingPitch: self.playingPitch.append( midiPitch ) self.playNoteFunction( midiPitch ) def onKeyRelease( self, widget, event ): - midiPitch = KEY_MAP[event.hardware_keycode] + midiPitch = Config.KEY_MAP[event.hardware_keycode] if midiPitch in self.playingPitch: self.playingPitch.remove( midiPitch ) @@ -207,9 +206,9 @@ class SynthLabParametersWindow( gtk.Window ): def initRadioButton( self, labelList, labelList2, methodCallback, box, active ): for i in range( len( labelList ) ): if i == 0: - button = ImageRadioButton( group = None, mainImg_path = GUIConstants.IMAGE_ROOT + labelList[i] + '.png', altImg_path = GUIConstants.IMAGE_ROOT + labelList2[i] + '.png' ) + button = ImageRadioButton( group = None, mainImg_path = Config.IMAGE_ROOT + labelList[i] + '.png', altImg_path = Config.IMAGE_ROOT + labelList2[i] + '.png' ) else: - button = ImageRadioButton( group = button, mainImg_path = GUIConstants.IMAGE_ROOT + labelList[i] + '.png', altImg_path = GUIConstants.IMAGE_ROOT + labelList2[i] + '.png' ) + button = ImageRadioButton( group = button, mainImg_path = Config.IMAGE_ROOT + labelList[i] + '.png', altImg_path = Config.IMAGE_ROOT + labelList2[i] + '.png' ) if i == active: button.set_active(True) button.connect( "toggled", methodCallback, i ) diff --git a/GUI/SynthLab/SynthLabWindow.py b/SynthLab/SynthLabWindow.py index 9400975..a8729a9 100755..100644 --- a/GUI/SynthLab/SynthLabWindow.py +++ b/SynthLab/SynthLabWindow.py @@ -5,22 +5,21 @@ import gobject import time import shelve -from GUI.Core.KeyMapping import * -from GUI.Core.ThemeWidgets import * -from GUI.GUIConstants import GUIConstants -from GUI.Tooltips import Tooltips -from Framework.CSound.CSoundClient import CSoundClient -from Framework.Constants import Constants -from GUI.SynthLab.SynthLabParametersWindow import SynthLabParametersWindow +import Config +from Util.ThemeWidgets import * +from Util.CSoundClient import CSoundClient +from SynthLab.SynthLabParametersWindow import SynthLabParametersWindow from SynthLab.SynthObjectsParameters import SynthObjectsParameters from SynthLab.SynthLabConstants import SynthLabConstants +Tooltips = Config.Tooltips + class SynthLabWindow( gtk.Window ): def __init__( self, client, table ): gtk.Window.__init__( self, gtk.WINDOW_TOPLEVEL ) color = gtk.gdk.color_parse('#FFFFFF') self.modify_bg(gtk.STATE_NORMAL, color) - self.set_border_width(GUIConstants.MAIN_WINDOW_PADDING) + self.set_border_width(Config.MAIN_WINDOW_PADDING) self.csnd = client self.table = table self.set_decorated(False) @@ -48,11 +47,11 @@ class SynthLabWindow( gtk.Window ): self.set_title("Synth Lab") self.mainBox = gtk.VBox() self.subBox = gtk.HBox() - self.drawingBox = RoundVBox(fillcolor=GUIConstants.INST_BCK_COLOR) - self.drawingBox.set_border_width(GUIConstants.BORDER_SIZE) + self.drawingBox = RoundVBox(fillcolor=Config.INST_BCK_COLOR) + self.drawingBox.set_border_width(Config.BORDER_SIZE) self.drawingBox.set_radius(10) - self.presetBox = RoundVBox(fillcolor=GUIConstants.PANEL_COLOR) - self.presetBox.set_border_width(GUIConstants.BORDER_SIZE) + self.presetBox = RoundVBox(fillcolor=Config.PANEL_COLOR) + self.presetBox.set_border_width(Config.BORDER_SIZE) self.presetBox.set_radius(10) self.presetBox.set_size_request(100, 790) self.subBox.pack_start(self.drawingBox, True, True) @@ -60,19 +59,19 @@ class SynthLabWindow( gtk.Window ): self.mainBox.pack_start(self.subBox) self.commandBox = gtk.HBox() - self.sliderBox = RoundHBox(fillcolor=GUIConstants.PANEL_COLOR) - self.sliderBox.set_border_width(GUIConstants.BORDER_SIZE) + self.sliderBox = RoundHBox(fillcolor=Config.PANEL_COLOR) + self.sliderBox.set_border_width(Config.BORDER_SIZE) self.sliderBox.set_radius(10) self.commandBox.pack_start(self.sliderBox) - self.buttonBox = RoundHBox(fillcolor=GUIConstants.PANEL_COLOR) - self.buttonBox.set_border_width(GUIConstants.BORDER_SIZE) + self.buttonBox = RoundHBox(fillcolor=Config.PANEL_COLOR) + self.buttonBox.set_border_width(Config.BORDER_SIZE) self.buttonBox.set_radius(10) self.commandBox.pack_start(self.buttonBox) self.mainBox.pack_start(self.commandBox) self.drawingArea = gtk.DrawingArea() self.drawingArea.set_size_request(1080, 790) - self.col = gtk.gdk.color_parse(GUIConstants.INST_BCK_COLOR) + self.col = gtk.gdk.color_parse(Config.INST_BCK_COLOR) self.drawingArea.modify_bg(gtk.STATE_NORMAL, self.col) self.drawingArea.add_events(gtk.gdk.BUTTON_PRESS_MASK) self.drawingArea.add_events(gtk.gdk.BUTTON_RELEASE_MASK) @@ -84,31 +83,31 @@ class SynthLabWindow( gtk.Window ): self.drawingBox.pack_start(self.drawingArea, False, False, 5) self.presets = self.initRadioButton(SynthLabConstants.PRESET, self.presetCallback, self.presetBox) self.durLabel = gtk.Image() - self.durLabel.set_from_file(GUIConstants.IMAGE_ROOT + 'dur2.png') + self.durLabel.set_from_file(Config.IMAGE_ROOT + 'dur2.png') self.durAdjust = gtk.Adjustment(1.5, .5, 4, .01, .01, 0) self.durAdjust.connect("value-changed", self.handleDuration) - self.durationSlider = ImageHScale( Constants.TAM_TAM_ROOT + "/Resources/Images/sliderbutviolet.png", self.durAdjust, 7 ) + self.durationSlider = ImageHScale( Config.TAM_TAM_ROOT + "/Resources/Images/sliderbutviolet.png", self.durAdjust, 7 ) self.durationSlider.set_inverted(False) self.durationSlider.set_size_request(750, 30) self.sliderBox.pack_start(self.durationSlider, True, True, 5) self.sliderBox.pack_start(self.durLabel, False, padding=10) - saveButton = ImageButton(Constants.TAM_TAM_ROOT + '/Resources/Images/save.png') + saveButton = ImageButton(Config.TAM_TAM_ROOT + '/Resources/Images/save.png') saveButton.connect("clicked", self.handleSave, None) self.buttonBox.pack_start(saveButton, False, False, 2) - loadButton = ImageButton(Constants.TAM_TAM_ROOT + '/Resources/Images/load.png') + loadButton = ImageButton(Config.TAM_TAM_ROOT + '/Resources/Images/load.png') loadButton.connect("clicked", self.handleLoad, None) self.buttonBox.pack_start(loadButton, False, False, 2) - self.recordButton = ImageToggleButton(GUIConstants.IMAGE_ROOT + 'record2.png', GUIConstants.IMAGE_ROOT + 'record2sel.png') + self.recordButton = ImageToggleButton(Config.IMAGE_ROOT + 'record2.png', Config.IMAGE_ROOT + 'record2sel.png') self.recordButton.connect("clicked", self.recordSound) self.buttonBox.pack_start(self.recordButton, False, False, 2) - resetButton = ImageButton(Constants.TAM_TAM_ROOT + '/Resources/Images/reset.png') + resetButton = ImageButton(Config.TAM_TAM_ROOT + '/Resources/Images/reset.png') resetButton.connect("clicked", self.handleReset, None) self.buttonBox.pack_start(resetButton, False, False, 2) - closeButton = ImageButton(Constants.TAM_TAM_ROOT + '/Resources/Images/close.png') + closeButton = ImageButton(Config.TAM_TAM_ROOT + '/Resources/Images/close.png') closeButton.connect("clicked", self.handleClose, None) self.buttonBox.pack_start(closeButton, False, False, 2) @@ -125,7 +124,7 @@ class SynthLabWindow( gtk.Window ): self.presetCallback(self.presets,0) def onKeyPress(self,widget,event): - midiPitch = KEY_MAP[event.hardware_keycode] + midiPitch = Config.KEY_MAP[event.hardware_keycode] if midiPitch not in self.playingPitch: if self.recordWait == 0: self.playingPitch.append( midiPitch ) @@ -147,14 +146,14 @@ class SynthLabWindow( gtk.Window ): self.wait = gobject.timeout_add((int(self.duration*1000)) , self.resetRecord ) def onKeyRelease( self, widget, event ): - midiPitch = KEY_MAP[event.hardware_keycode] + midiPitch = Config.KEY_MAP[event.hardware_keycode] if midiPitch in self.playingPitch: self.playingPitch.remove( midiPitch ) def handleDuration( self, data ): self.duration = self.durAdjust.value img = int((self.duration - .5) * 1.425 + 1) - self.durLabel.set_from_file(GUIConstants.IMAGE_ROOT + 'dur' + str(img) + '.png') + self.durLabel.set_from_file(Config.IMAGE_ROOT + 'dur' + str(img) + '.png') def playNote( self, midiPitch ): cpsPitch = 261.626*pow(1.0594633, midiPitch-36) @@ -473,15 +472,15 @@ class SynthLabWindow( gtk.Window ): for i in range(13): if i < 4: img = SynthLabConstants.CHOOSE_TYPE_PLUS[0][typesList[i]] - self.pixbufs.append(gtk.gdk.pixbuf_new_from_file(GUIConstants.IMAGE_ROOT + img + '.png')) + self.pixbufs.append(gtk.gdk.pixbuf_new_from_file(Config.IMAGE_ROOT + img + '.png')) elif i < 8: img = SynthLabConstants.CHOOSE_TYPE_PLUS[1][typesList[i]] - self.pixbufs.append(gtk.gdk.pixbuf_new_from_file(GUIConstants.IMAGE_ROOT + img + '.png')) + self.pixbufs.append(gtk.gdk.pixbuf_new_from_file(Config.IMAGE_ROOT + img + '.png')) elif i < 12: img = SynthLabConstants.CHOOSE_TYPE_PLUS[2][typesList[i]] - self.pixbufs.append(gtk.gdk.pixbuf_new_from_file(GUIConstants.IMAGE_ROOT + img + '.png')) + self.pixbufs.append(gtk.gdk.pixbuf_new_from_file(Config.IMAGE_ROOT + img + '.png')) else: - self.pixbufs.append(gtk.gdk.pixbuf_new_from_file(Constants.TAM_TAM_ROOT + '/Resources/Images/speaker.png')) + self.pixbufs.append(gtk.gdk.pixbuf_new_from_file(Config.TAM_TAM_ROOT + '/Resources/Images/speaker.png')) def handleSave(self, widget, data): chooser = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE,gtk.RESPONSE_OK)) @@ -545,7 +544,7 @@ class SynthLabWindow( gtk.Window ): def presetCallback( self, widget, data ): preset = 'synthFile' + str(data+1) - f = shelve.open( Constants.TAM_TAM_ROOT + '/Resources/SynthFiles/' + preset, 'r') + f = shelve.open( Config.TAM_TAM_ROOT + '/Resources/SynthFiles/' + preset, 'r') self.loadState(f) f.close() @@ -553,8 +552,8 @@ class SynthLabWindow( gtk.Window ): for i in range( len( labelList ) ): label = labelList[i] if i == 0: - button = ImageRadioButton( group = None, mainImg_path = GUIConstants.IMAGE_ROOT + label + '.png', altImg_path = GUIConstants.IMAGE_ROOT + label + 'sel.png' ) + button = ImageRadioButton( group = None, mainImg_path = Config.IMAGE_ROOT + label + '.png', altImg_path = Config.IMAGE_ROOT + label + 'sel.png' ) else: - button = ImageRadioButton( group = button, mainImg_path = GUIConstants.IMAGE_ROOT + label + '.png', altImg_path = GUIConstants.IMAGE_ROOT + label + 'sel.png' ) + button = ImageRadioButton( group = button, mainImg_path = Config.IMAGE_ROOT + label + '.png', altImg_path = Config.IMAGE_ROOT + label + 'sel.png' ) button.connect( "toggled", methodCallback, i ) box.pack_start( button, True, True ) diff --git a/TamTam.py b/TamTam.py index 1df2c49..36edd43 100755 --- a/TamTam.py +++ b/TamTam.py @@ -5,25 +5,21 @@ import pygtk pygtk.require( '2.0' ) import gtk -import Framework.CSound.CSoundClient as CSoundClient -from Framework.Constants import Constants -from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.CSound.CSoundServer import CsoundServerMult +import Config +import Util.CSoundClient as CSoundClient +from Util.Profiler import TP +from Player.StandalonePlayer import StandAlonePlayer +#from Edit.Core.MainWindow import MainWindow -from GUI.StandalonePlayer import StandAlonePlayer -from GUI.Core.MainWindow import MainWindow -from Framework.Core.Profiler import TP - - -#csnd = CSoundClient.CSoundClientSocket( CSoundConstants.SERVER_ADDRESS, CSoundConstants.SERVER_PORT, os.getpid() ) +#csnd = CSoundClient.CSoundClientSocket( Config.SERVER_ADDRESS, Config.SERVER_PORT, os.getpid() ) #csnd = CSoundClient.CSoundClientPerf( '/usr/share/olpc-csound-server/univorc.csd' ) -csnd = CSoundClient.CSoundClientPerf( Constants.TAM_TAM_ROOT + '/Resources/univorc.csd' ) +csnd = CSoundClient.CSoundClientPerf( Config.TAM_TAM_ROOT + '/Resources/univorc.csd' ) csnd.initialize(True) csnd.setMasterVolume(100.0) -CSoundClient.CSoundClient = csnd +CSoundClient.CSoundClient = csnd #Dodgy move: TODO: remove this global variable. diff --git a/Framework/CSound/CSoundClient.py b/Util/CSoundClient.py index 5946066..b72ce92 100755..100644 --- a/Framework/CSound/CSoundClient.py +++ b/Util/CSoundClient.py @@ -6,7 +6,7 @@ import sys import threading import time -from Framework.CSound.CSoundConstants import CSoundConstants +import Config #---------------------------------------------------------------------- # A CSound client used to send messages to the CSound server @@ -18,15 +18,15 @@ class CSoundClientBase: self.sendText("csound.SetChannel('masterVolume', %f)\n" % volume) def micRecording( self, table ): - mess = CSoundConstants.MIC_RECORDING_COMMAND % table + mess = Config.MIC_RECORDING_COMMAND % table # print mess self.sendText( mess ) def load_instruments( self ): - for instrumentSoundFile in CSoundConstants.INSTRUMENTS.keys(): - fileName = CSoundConstants.SOUNDS_DIR + "/" + instrumentSoundFile - instrumentID = CSoundConstants.INSTRUMENT_TABLE_OFFSET + CSoundConstants.INSTRUMENTS[ instrumentSoundFile ].instrumentID - mess = CSoundConstants.LOAD_INSTRUMENT_COMMAND % ( instrumentID, fileName ) + for instrumentSoundFile in Config.INSTRUMENTS.keys(): + fileName = Config.SOUNDS_DIR + "/" + instrumentSoundFile + instrumentID = Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[ instrumentSoundFile ].instrumentID + mess = Config.LOAD_INSTRUMENT_COMMAND % ( instrumentID, fileName ) self.sendText( mess ) def startTime(self): @@ -57,12 +57,12 @@ class CSoundClientSocket( CSoundClientBase ): try: self.socket.send( text ) except socket.error: - if CSoundConstants.SERVER_REQUIRED : + if Config.SERVER_REQUIRED : print 'ERROR: no CSound server. Ignoring message: %s' % text def initialize( self, init = True ): if init : - n = CSoundConstants.INIT_ATTEMPTS + n = Config.INIT_ATTEMPTS self.socket = socket.socket() self.connected = False while n > 0 and not self.connected: @@ -71,12 +71,12 @@ class CSoundClientSocket( CSoundClientBase ): self.connected = True self.load_instruments() except socket.error: - if CSoundConstants.SERVER_REQUIRED : + if Config.SERVER_REQUIRED : print 'ERROR: no CSound server. Ignoring connection request.' - time.sleep(CSoundConstants.INIT_DELAY) + time.sleep(Config.INIT_DELAY) n = n - 1 else : #un-init - self.sendText( CSoundConstants.UNLOAD_TABLES_COMMAND ) + self.sendText( Config.UNLOAD_TABLES_COMMAND ) del self.socket class CSoundClientPerf( CSoundClientBase ): @@ -96,8 +96,8 @@ class CSoundClientPerf( CSoundClientBase ): if not self.on : return self.on = False #self.csound.SetChannel('udprecv.0.on', 0) - print CSoundConstants.UNLOAD_TABLES_COMMAND - self.sendText( CSoundConstants.UNLOAD_TABLES_COMMAND ) + print Config.UNLOAD_TABLES_COMMAND + self.sendText( Config.UNLOAD_TABLES_COMMAND ) print 'PERF STOP' self.perf.Stop() #print 'SLEEP' diff --git a/Framework/CSound/CSoundNote.py b/Util/CSoundNote.py index 1fcd8aa..168d267 100755 --- a/Framework/CSound/CSoundNote.py +++ b/Util/CSoundNote.py @@ -1,9 +1,6 @@ -from Framework.Core.Event import Event -from Framework.Constants import Constants -from Framework.CSound.CSoundClient import CSoundClient -from Framework.CSound.CSoundConstants import CSoundConstants -from Framework.CSound.CSoundClient import CSoundClient -from Framework.Generation.GenerationConstants import GenerationConstants +import Config +from Util.CSoundClient import CSoundClient +from Generation.GenerationConstants import GenerationConstants #---------------------------------------------------------------------- # TODO: extend this hierarchy to include a Note base class # i.e. Event -> Note -> CSoundNote @@ -14,6 +11,24 @@ from Framework.Generation.GenerationConstants import GenerationConstants # An Event subclass that represents a CSound note event #---------------------------------------------------------------------- +class Event: + #----------------------------------- + # initialization + #----------------------------------- + def __init__( self, onset ): + self.onset = onset + + #----------------------------------- + # playback (must be implemented by subclasses) + #----------------------------------- + def play( self ): + raise NotImplementedError + + #----------------------------------- + # adjustment + #----------------------------------- + def adjustOnset( self, amount ): + self.onset += amount class CSoundNote( Event ): #----------------------------------- # initialization @@ -25,7 +40,7 @@ class CSoundNote( Event ): duration, trackID, fullDuration = False, - instrument = CSoundConstants.FLUTE, + instrument = Config.FLUTE, attack = 0.002, decay = 0.098, reverbSend = 0.1, @@ -33,7 +48,7 @@ class CSoundNote( Event ): filterCutoff = 1000, tied = False, overlap = False, - instrumentFlag = CSoundConstants.FLUTE ): + instrumentFlag = Config.FLUTE ): Event.__init__( self, onset ) self.onset = onset @@ -52,7 +67,7 @@ class CSoundNote( Event ): self.tied = tied self.overlap = overlap if self.instrument == 'drum1kit': - self.instrumentFlag = CSoundConstants.DRUM1INSTRUMENTS[ self.pitch ] + self.instrumentFlag = Config.DRUM1INSTRUMENTS[ self.pitch ] else: self.instrumentFlag = self.instrument @@ -106,7 +121,7 @@ class CSoundNote( Event ): print self.pitch self.pitch = GenerationConstants.DRUMPITCH[ self.pitch ] - self.instrumentFlag = CSoundConstants.DRUM1INSTRUMENTS[ self.pitch ] + self.instrumentFlag = Config.DRUM1INSTRUMENTS[ self.pitch ] newPitch = 1 else: self.instrumentFlag = self.instrument @@ -117,10 +132,10 @@ class CSoundNote( Event ): newDuration = oneTickDuration * self.duration # condition for tied notes - if CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID == 101 and self.tied and self.fullDuration: + if Config.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID == 101 and self.tied and self.fullDuration: newDuration = -1 # condition for overlaped notes - if CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID == 102 and self.overlap: + if Config.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID == 102 and self.overlap: newDuration = oneTickDuration * self.duration + 1. if True: newAmplitude = self.amplitude * 0.8 @@ -134,7 +149,7 @@ class CSoundNote( Event ): if newDecay <= 0.002: newDecay = 0.002 - return CSoundConstants.PLAY_NOTE_COMMAND % ( CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID, + return Config.PLAY_NOTE_COMMAND % ( Config.INSTRUMENTS[ self.instrumentFlag ].csoundInstrumentID, self.trackID, delay, newDuration, @@ -142,7 +157,7 @@ class CSoundNote( Event ): self.reverbSend, newAmplitude, self.pan, - CSoundConstants.INSTRUMENT_TABLE_OFFSET + CSoundConstants.INSTRUMENTS[ self.instrumentFlag ].instrumentID, + Config.INSTRUMENT_TABLE_OFFSET + Config.INSTRUMENTS[ self.instrumentFlag ].instrumentID, newAttack, newDecay, self.filterType, diff --git a/GUI/Credits.py b/Util/Credits.py index c8d2644..c8d2644 100644 --- a/GUI/Credits.py +++ b/Util/Credits.py diff --git a/Framework/NoteLooper.py b/Util/NoteLooper.py index d355303..d355303 100644 --- a/Framework/NoteLooper.py +++ b/Util/NoteLooper.py diff --git a/Framework/Core/Profiler.py b/Util/Profiler.py index 338589e..338589e 100644 --- a/Framework/Core/Profiler.py +++ b/Util/Profiler.py diff --git a/GUI/Core/ThemeWidgets.py b/Util/ThemeWidgets.py index 23b54e7..23b54e7 100644 --- a/GUI/Core/ThemeWidgets.py +++ b/Util/ThemeWidgets.py diff --git a/Framework/Generation/__init__.py b/Util/__init__.py index e69de29..e69de29 100644 --- a/Framework/Generation/__init__.py +++ b/Util/__init__.py diff --git a/olpc_get_stuff.sh b/scripts/olpc_get_stuff.sh index e2fb272..e2fb272 100644 --- a/olpc_get_stuff.sh +++ b/scripts/olpc_get_stuff.sh diff --git a/scripts/update-index-all.sh b/scripts/update-index-all.sh new file mode 100755 index 0000000..30dd058 --- /dev/null +++ b/scripts/update-index-all.sh @@ -0,0 +1,5 @@ + #!/bin/sh + +for F in $( git-status | grep modified | cut -f 2 | cut -d ' ' -f 4 ) ; do + git-update-index $F +done -- cgit v0.9.1