From 454ad3c473b3ff5081b18f00b516402794f2741d Mon Sep 17 00:00:00 2001 From: Thorin Date: Mon, 11 Jun 2012 15:03:02 +0000 Subject: version 4, new toolbar and fixes --- diff --git a/COPYING b/COPYING index 2070779..2070779 100644..100755 --- a/COPYING +++ b/COPYING diff --git a/City/CsSched.py b/City/CsSched.py index d3288dc..c86e3dd 100755 --- a/City/CsSched.py +++ b/City/CsSched.py @@ -16,7 +16,8 @@ #You should have received a copy of the GNU General Public License #along with this program; if not, write to the Free Software #Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -import csnd, heapq +import csnd +from heapq import heappush, heappop from CsHelpers import * class Csound: @@ -28,12 +29,25 @@ class Csound: def __repr__(self): return "Precompiled Csound object" - -class Sched: - def __init__(self): - self.queue = [] +class Sched( object ): + queue = [] + time = 0 + def __init__(self, kr=172.265625, tempo=60): + self.kr = kr + self.tempo = 60 + def _increment(self): + "return the time increment value" + return (1.0 / self.kr) * (60.0 / self.tempo) + def poll(self, inc): + "increments the time value, and evaluates items scheduled in the past" + self.time += (1.0 / self.kr) * (self.tempo / 60.0) #increment the time. The question is... should I let Csound store the time. No GIL that way. hmmm. + for i in self.queue: + if self.time >= i[0]: + obj = heappop(self.queue) + (obj[1] (*obj[2])) + else: break def schedEvent(self, time, func, *args): - heapq.heappush(self.queue, (time, func, args)) + heappush(self.queue, (time, func, args)) def getTime(self): if self: return self.queue[0][0] @@ -51,13 +65,24 @@ class Sched: return self.queue[0][2] def __len__(self): return len(self.queue) - def __repr__(self): - return str(self.queue) - + def __add__(self, integer): + "returns now + time value" + return self.now() + integer + def __rshift__(self, beat): + "returns the next nth beat time" + return ceil(self.now()) + beat + def __div__(self, barlength): + "where barlength is the number of beats in a bar, returns a tuple of the current time represented in the form (bar no. , beat no)" + return divmod(self.now(), barlength) + def now(self): + return self.time + def reset(self, reset=0): + self.time = reset + class CsoundChan: - "a container for Csound channel data" + "an empty container for Csound channel data" #type is either Audio, Control, or String - #Dirction = INput or Output + #Direction = INput or Output #subType = interger, linear or exponential #default = default value #minval = suggested minimum @@ -98,7 +123,6 @@ def channels(csound): return result - class CsoundPerformer: def pollScheduler(self, schedObj): st = schedObj.getTime() @@ -107,10 +131,11 @@ class CsoundPerformer: if t >= st: obj = heapq.heappop(schedObj.queue) (obj[1] (*obj[2])) - def __init__(self, schedObj, orcObj, *cs): + def __init__(self, metro, orcObj, *cs): "SchedObj is a Csound timer instance, orcObJ is a CsOrcConstructor Object" - self.Timer = csnd.CsoundTimer() - self.schedObj = schedObj + #self.Timer = csnd.CsoundTimer() + self.metro = metro + #self.schedObj = schedObj self.orcObj = orcObj if len(cs) == 0: cs = Csound() @@ -118,9 +143,9 @@ class CsoundPerformer: else: self.csound = cs[0] self.csound.setOrchestra(orcObj.exportOrc()) self.csound.setScore(orcObj.sco) - self.time = 0 + if platform == "Sugar": - self.csound.setCommand("csound -b256 -B2048 -odac --expression-opt --sched=1 -d -m0 /tmp/tmp.orc /tmp/tmp.sco") + self.csound.setCommand("csound -b256 -B2048 -+rtaudio=alsa -odac --expression-opt --sched=1 -d -m0 /tmp/tmp.orc /tmp/tmp.sco") else: self.csound.setCommand("csound -b256 -B2048 -odac --expression-opt -d -m0 /tmp/tmp.orc /tmp/tmp.sco") self.csound.exportForPerformance() @@ -128,9 +153,10 @@ class CsoundPerformer: self.Channels = channels(self.csound) self.perf = csnd.CsoundPerformanceThread(self.csound) self.perf.Play() - self.perf.SetProcessCallback(self.pollScheduler, schedObj) + self.perf.SetProcessCallback(self.metro.poll, 0) def perfTime(self): - return self.Timer.GetRealTime() + return self.metro.now() + #return self.Timer.GetRealTime() def Stop(self): self.perf.Stop() #self.perf.Join() diff --git a/City/Images/blues1.svg b/City/Images/blues1.svg new file mode 100755 index 0000000..961972d --- /dev/null +++ b/City/Images/blues1.svg @@ -0,0 +1,110 @@ + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/City/Images/blues2.svg b/City/Images/blues2.svg new file mode 100755 index 0000000..a205ba5 --- /dev/null +++ b/City/Images/blues2.svg @@ -0,0 +1,110 @@ + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/City/Images/city1.svg b/City/Images/city1.svg new file mode 100755 index 0000000..4225c5c --- /dev/null +++ b/City/Images/city1.svg @@ -0,0 +1,156 @@ + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/City/Images/city2.svg b/City/Images/city2.svg new file mode 100755 index 0000000..ecdf148 --- /dev/null +++ b/City/Images/city2.svg @@ -0,0 +1,156 @@ + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/City/Images/country1.svg b/City/Images/country1.svg new file mode 100755 index 0000000..78f5e8f --- /dev/null +++ b/City/Images/country1.svg @@ -0,0 +1,33 @@ + + + + + + +]> + + + + + + + diff --git a/City/Images/country2.svg b/City/Images/country2.svg new file mode 100755 index 0000000..f8fa346 --- /dev/null +++ b/City/Images/country2.svg @@ -0,0 +1,33 @@ + + + + + + +]> + + + + + + + diff --git a/City/Images/density1.svg b/City/Images/density1.svg new file mode 100755 index 0000000..ec23498 --- /dev/null +++ b/City/Images/density1.svg @@ -0,0 +1,19 @@ + + + + + + + +]> + + + + + + + + + + diff --git a/City/Images/density2.svg b/City/Images/density2.svg new file mode 100755 index 0000000..0318f55 --- /dev/null +++ b/City/Images/density2.svg @@ -0,0 +1,19 @@ + + + + + + + +]> + + + + + + + + + + diff --git a/City/Images/jam2jamXO_2.png b/City/Images/jam2jamXO_2.png index 893b4c2..893b4c2 100644..100755 --- a/City/Images/jam2jamXO_2.png +++ b/City/Images/jam2jamXO_2.png Binary files differ diff --git a/City/Images/jam2jamXO_4.png b/City/Images/jam2jamXO_4.png new file mode 100755 index 0000000..52da4b8 --- /dev/null +++ b/City/Images/jam2jamXO_4.png Binary files differ diff --git a/City/Images/latin1.svg b/City/Images/latin1.svg new file mode 100755 index 0000000..1d1c4ff --- /dev/null +++ b/City/Images/latin1.svg @@ -0,0 +1,1330 @@ + + + + + + +]> + + + + + + style="fill:&fill_color;;fill:&fill_color;; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/City/Images/latin2.svg b/City/Images/latin2.svg new file mode 100755 index 0000000..7c243cc --- /dev/null +++ b/City/Images/latin2.svg @@ -0,0 +1,1330 @@ + + + + + + +]> + + + + + + style="fill:&fill_color;;fill:&fill_color;; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/City/Images/length1.svg b/City/Images/length1.svg new file mode 100755 index 0000000..466005d --- /dev/null +++ b/City/Images/length1.svg @@ -0,0 +1,15 @@ + + + + + + +]> + + + + + + + diff --git a/City/Images/length2.svg b/City/Images/length2.svg new file mode 100755 index 0000000..70399d3 --- /dev/null +++ b/City/Images/length2.svg @@ -0,0 +1,15 @@ + + + + + + +]> + + + + + + + diff --git a/City/Images/pitch1.svg b/City/Images/pitch1.svg new file mode 100755 index 0000000..34fd44d --- /dev/null +++ b/City/Images/pitch1.svg @@ -0,0 +1,14 @@ + + + + + +]> + + + + + + + diff --git a/City/Images/pitch2.svg b/City/Images/pitch2.svg new file mode 100755 index 0000000..f7d34ed --- /dev/null +++ b/City/Images/pitch2.svg @@ -0,0 +1,15 @@ + + + + + +]> + + + + + + + + diff --git a/City/Images/reggae1.svg b/City/Images/reggae1.svg new file mode 100755 index 0000000..609ba91 --- /dev/null +++ b/City/Images/reggae1.svg @@ -0,0 +1,56 @@ + + + + + +]> + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/City/Images/reggae2.svg b/City/Images/reggae2.svg new file mode 100755 index 0000000..5b18353 --- /dev/null +++ b/City/Images/reggae2.svg @@ -0,0 +1,56 @@ + + + + + +]> + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/City/Images/timbre1.svg b/City/Images/timbre1.svg new file mode 100755 index 0000000..c971d26 --- /dev/null +++ b/City/Images/timbre1.svg @@ -0,0 +1,14 @@ + + + + + + +]> + + + + + + diff --git a/City/Images/timbre2.svg b/City/Images/timbre2.svg new file mode 100755 index 0000000..888a6e3 --- /dev/null +++ b/City/Images/timbre2.svg @@ -0,0 +1,14 @@ + + + + + + +]> + + + + + + diff --git a/City/Images/volume1.svg b/City/Images/volume1.svg new file mode 100755 index 0000000..a7120f2 --- /dev/null +++ b/City/Images/volume1.svg @@ -0,0 +1,14 @@ + + +]> + + + + + + + + + + \ No newline at end of file diff --git a/City/Images/volume2.svg b/City/Images/volume2.svg new file mode 100755 index 0000000..2f7a052 --- /dev/null +++ b/City/Images/volume2.svg @@ -0,0 +1,14 @@ + + +]> + + + + + + + + + + \ No newline at end of file diff --git a/City/Scenes/Blues/AudioFiles/BassAudio/BassC2[41-48-50].aif b/City/Scenes/Blues/AudioFiles/BassAudio/BassC2[41-48-50].aif index 3e3fd98..3e3fd98 100644..100755 --- a/City/Scenes/Blues/AudioFiles/BassAudio/BassC2[41-48-50].aif +++ b/City/Scenes/Blues/AudioFiles/BassAudio/BassC2[41-48-50].aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/BassAudio/BassC3[59-60-62].aif b/City/Scenes/Blues/AudioFiles/BassAudio/BassC3[59-60-62].aif index bd3ab7f..bd3ab7f 100644..100755 --- a/City/Scenes/Blues/AudioFiles/BassAudio/BassC3[59-60-62].aif +++ b/City/Scenes/Blues/AudioFiles/BassAudio/BassC3[59-60-62].aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/BassAudio/BassC4[70-72-78].aif b/City/Scenes/Blues/AudioFiles/BassAudio/BassC4[70-72-78].aif index f9ec61b..f9ec61b 100644..100755 --- a/City/Scenes/Blues/AudioFiles/BassAudio/BassC4[70-72-78].aif +++ b/City/Scenes/Blues/AudioFiles/BassAudio/BassC4[70-72-78].aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/BassAudio/BassF#2[51-54-58].aif b/City/Scenes/Blues/AudioFiles/BassAudio/BassF#2[51-54-58].aif index c099d56..c099d56 100644..100755 --- a/City/Scenes/Blues/AudioFiles/BassAudio/BassF#2[51-54-58].aif +++ b/City/Scenes/Blues/AudioFiles/BassAudio/BassF#2[51-54-58].aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif b/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif index 475ac71..475ac71 100644..100755 --- a/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif +++ b/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif b/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif index f89023c..f89023c 100644..100755 --- a/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif +++ b/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif b/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif index fd1a6c5..fd1a6c5 100644..100755 --- a/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif +++ b/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif b/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif index b4d5964..b4d5964 100644..100755 --- a/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif +++ b/City/Scenes/Blues/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/DrumsAudio/C1_kick_drum.aif b/City/Scenes/Blues/AudioFiles/DrumsAudio/C1_kick_drum.aif index cedbae3..cedbae3 100644..100755 --- a/City/Scenes/Blues/AudioFiles/DrumsAudio/C1_kick_drum.aif +++ b/City/Scenes/Blues/AudioFiles/DrumsAudio/C1_kick_drum.aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/DrumsAudio/D1_snare_drum.aif b/City/Scenes/Blues/AudioFiles/DrumsAudio/D1_snare_drum.aif index 4ff68d0..4ff68d0 100644..100755 --- a/City/Scenes/Blues/AudioFiles/DrumsAudio/D1_snare_drum.aif +++ b/City/Scenes/Blues/AudioFiles/DrumsAudio/D1_snare_drum.aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/DrumsAudio/F#1_closed_hi_hat.aif b/City/Scenes/Blues/AudioFiles/DrumsAudio/F#1_closed_hi_hat.aif index ef60aac..ef60aac 100644..100755 --- a/City/Scenes/Blues/AudioFiles/DrumsAudio/F#1_closed_hi_hat.aif +++ b/City/Scenes/Blues/AudioFiles/DrumsAudio/F#1_closed_hi_hat.aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/DrumsAudio/Tamborine 22 16 Mono.aif b/City/Scenes/Blues/AudioFiles/DrumsAudio/Tamborine 22 16 Mono.aif index 6b6f85f..6b6f85f 100644..100755 --- a/City/Scenes/Blues/AudioFiles/DrumsAudio/Tamborine 22 16 Mono.aif +++ b/City/Scenes/Blues/AudioFiles/DrumsAudio/Tamborine 22 16 Mono.aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/LeadAudio/B2_guitar.aif b/City/Scenes/Blues/AudioFiles/LeadAudio/B2_guitar.aif index 9a06c2f..9a06c2f 100644..100755 --- a/City/Scenes/Blues/AudioFiles/LeadAudio/B2_guitar.aif +++ b/City/Scenes/Blues/AudioFiles/LeadAudio/B2_guitar.aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/LeadAudio/B3_guitar.aif b/City/Scenes/Blues/AudioFiles/LeadAudio/B3_guitar.aif index a229b76..a229b76 100644..100755 --- a/City/Scenes/Blues/AudioFiles/LeadAudio/B3_guitar.aif +++ b/City/Scenes/Blues/AudioFiles/LeadAudio/B3_guitar.aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/LeadAudio/E2_guitar.aif b/City/Scenes/Blues/AudioFiles/LeadAudio/E2_guitar.aif index 0df7f1e..0df7f1e 100644..100755 --- a/City/Scenes/Blues/AudioFiles/LeadAudio/E2_guitar.aif +++ b/City/Scenes/Blues/AudioFiles/LeadAudio/E2_guitar.aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/LeadAudio/E3_guitar.aif b/City/Scenes/Blues/AudioFiles/LeadAudio/E3_guitar.aif index e8f5be5..e8f5be5 100644..100755 --- a/City/Scenes/Blues/AudioFiles/LeadAudio/E3_guitar.aif +++ b/City/Scenes/Blues/AudioFiles/LeadAudio/E3_guitar.aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/LeadAudio/E4_guitar.aif b/City/Scenes/Blues/AudioFiles/LeadAudio/E4_guitar.aif index 9909889..9909889 100644..100755 --- a/City/Scenes/Blues/AudioFiles/LeadAudio/E4_guitar.aif +++ b/City/Scenes/Blues/AudioFiles/LeadAudio/E4_guitar.aif Binary files differ diff --git a/City/Scenes/Blues/AudioFiles/LeadAudio/E5_guitar.aif b/City/Scenes/Blues/AudioFiles/LeadAudio/E5_guitar.aif index f1f7076..f1f7076 100644..100755 --- a/City/Scenes/Blues/AudioFiles/LeadAudio/E5_guitar.aif +++ b/City/Scenes/Blues/AudioFiles/LeadAudio/E5_guitar.aif Binary files differ diff --git a/City/Scenes/Blues/Blues_Data.txt b/City/Scenes/Blues/Blues_Data.txt index 6542e85..6542e85 100644..100755 --- a/City/Scenes/Blues/Blues_Data.txt +++ b/City/Scenes/Blues/Blues_Data.txt diff --git a/City/Scenes/Blues/MidiFiles/Bass.mid b/City/Scenes/Blues/MidiFiles/Bass.mid index 16967a5..16967a5 100644..100755 --- a/City/Scenes/Blues/MidiFiles/Bass.mid +++ b/City/Scenes/Blues/MidiFiles/Bass.mid Binary files differ diff --git a/City/Scenes/Blues/MidiFiles/Chords.mid b/City/Scenes/Blues/MidiFiles/Chords.mid index 139be9d..139be9d 100644..100755 --- a/City/Scenes/Blues/MidiFiles/Chords.mid +++ b/City/Scenes/Blues/MidiFiles/Chords.mid Binary files differ diff --git a/City/Scenes/Blues/MidiFiles/Drums.mid b/City/Scenes/Blues/MidiFiles/Drums.mid index 576167d..576167d 100644..100755 --- a/City/Scenes/Blues/MidiFiles/Drums.mid +++ b/City/Scenes/Blues/MidiFiles/Drums.mid Binary files differ diff --git a/City/Scenes/Blues/MidiFiles/Lead.mid b/City/Scenes/Blues/MidiFiles/Lead.mid index b7636d6..b7636d6 100644..100755 --- a/City/Scenes/Blues/MidiFiles/Lead.mid +++ b/City/Scenes/Blues/MidiFiles/Lead.mid Binary files differ diff --git a/City/Scenes/City/City_Data.txt b/City/Scenes/City/City_Data.txt index 525850e..525850e 100644..100755 --- a/City/Scenes/City/City_Data.txt +++ b/City/Scenes/City/City_Data.txt diff --git a/City/Scenes/Country/AudioFiles/BassAudio/BassC2[41-48-50].aif b/City/Scenes/Country/AudioFiles/BassAudio/BassC2[41-48-50].aif index 3e3fd98..3e3fd98 100644..100755 --- a/City/Scenes/Country/AudioFiles/BassAudio/BassC2[41-48-50].aif +++ b/City/Scenes/Country/AudioFiles/BassAudio/BassC2[41-48-50].aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/BassAudio/BassC3[59-60-62].aif b/City/Scenes/Country/AudioFiles/BassAudio/BassC3[59-60-62].aif index bd3ab7f..bd3ab7f 100644..100755 --- a/City/Scenes/Country/AudioFiles/BassAudio/BassC3[59-60-62].aif +++ b/City/Scenes/Country/AudioFiles/BassAudio/BassC3[59-60-62].aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/BassAudio/BassC4[70-72-78].aif b/City/Scenes/Country/AudioFiles/BassAudio/BassC4[70-72-78].aif index f9ec61b..f9ec61b 100644..100755 --- a/City/Scenes/Country/AudioFiles/BassAudio/BassC4[70-72-78].aif +++ b/City/Scenes/Country/AudioFiles/BassAudio/BassC4[70-72-78].aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/BassAudio/BassF#2[51-54-58].aif b/City/Scenes/Country/AudioFiles/BassAudio/BassF#2[51-54-58].aif index c099d56..c099d56 100644..100755 --- a/City/Scenes/Country/AudioFiles/BassAudio/BassF#2[51-54-58].aif +++ b/City/Scenes/Country/AudioFiles/BassAudio/BassF#2[51-54-58].aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif b/City/Scenes/Country/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif index 475ac71..475ac71 100644..100755 --- a/City/Scenes/Country/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif +++ b/City/Scenes/Country/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif b/City/Scenes/Country/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif index f89023c..f89023c 100644..100755 --- a/City/Scenes/Country/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif +++ b/City/Scenes/Country/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif b/City/Scenes/Country/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif index fd1a6c5..fd1a6c5 100644..100755 --- a/City/Scenes/Country/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif +++ b/City/Scenes/Country/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif b/City/Scenes/Country/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif index b4d5964..b4d5964 100644..100755 --- a/City/Scenes/Country/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif +++ b/City/Scenes/Country/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/DrumsAudio/C1_kick_drum.aif b/City/Scenes/Country/AudioFiles/DrumsAudio/C1_kick_drum.aif index 2b00005..2b00005 100644..100755 --- a/City/Scenes/Country/AudioFiles/DrumsAudio/C1_kick_drum.aif +++ b/City/Scenes/Country/AudioFiles/DrumsAudio/C1_kick_drum.aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/LeadAudio/B2_guitar.aif b/City/Scenes/Country/AudioFiles/LeadAudio/B2_guitar.aif index 9a06c2f..9a06c2f 100644..100755 --- a/City/Scenes/Country/AudioFiles/LeadAudio/B2_guitar.aif +++ b/City/Scenes/Country/AudioFiles/LeadAudio/B2_guitar.aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/LeadAudio/B3_guitar.aif b/City/Scenes/Country/AudioFiles/LeadAudio/B3_guitar.aif index a229b76..a229b76 100644..100755 --- a/City/Scenes/Country/AudioFiles/LeadAudio/B3_guitar.aif +++ b/City/Scenes/Country/AudioFiles/LeadAudio/B3_guitar.aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/LeadAudio/E2_guitar.aif b/City/Scenes/Country/AudioFiles/LeadAudio/E2_guitar.aif index 0df7f1e..0df7f1e 100644..100755 --- a/City/Scenes/Country/AudioFiles/LeadAudio/E2_guitar.aif +++ b/City/Scenes/Country/AudioFiles/LeadAudio/E2_guitar.aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/LeadAudio/E3_guitar.aif b/City/Scenes/Country/AudioFiles/LeadAudio/E3_guitar.aif index e8f5be5..e8f5be5 100644..100755 --- a/City/Scenes/Country/AudioFiles/LeadAudio/E3_guitar.aif +++ b/City/Scenes/Country/AudioFiles/LeadAudio/E3_guitar.aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/LeadAudio/E4_guitar.aif b/City/Scenes/Country/AudioFiles/LeadAudio/E4_guitar.aif index 9909889..9909889 100644..100755 --- a/City/Scenes/Country/AudioFiles/LeadAudio/E4_guitar.aif +++ b/City/Scenes/Country/AudioFiles/LeadAudio/E4_guitar.aif Binary files differ diff --git a/City/Scenes/Country/AudioFiles/LeadAudio/E5_guitar.aif b/City/Scenes/Country/AudioFiles/LeadAudio/E5_guitar.aif index f1f7076..f1f7076 100644..100755 --- a/City/Scenes/Country/AudioFiles/LeadAudio/E5_guitar.aif +++ b/City/Scenes/Country/AudioFiles/LeadAudio/E5_guitar.aif Binary files differ diff --git a/City/Scenes/Country/Country_Data.txt b/City/Scenes/Country/Country_Data.txt index 4dcdc4e..4dcdc4e 100644..100755 --- a/City/Scenes/Country/Country_Data.txt +++ b/City/Scenes/Country/Country_Data.txt diff --git a/City/Scenes/Latin/AudioFiles/BassAudio/BassC2[41-48-50].aif b/City/Scenes/Latin/AudioFiles/BassAudio/BassC2[41-48-50].aif index f510c60..f510c60 100644..100755 --- a/City/Scenes/Latin/AudioFiles/BassAudio/BassC2[41-48-50].aif +++ b/City/Scenes/Latin/AudioFiles/BassAudio/BassC2[41-48-50].aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/BassAudio/BassC3[59-60-62].aif b/City/Scenes/Latin/AudioFiles/BassAudio/BassC3[59-60-62].aif index e1c38ad..e1c38ad 100644..100755 --- a/City/Scenes/Latin/AudioFiles/BassAudio/BassC3[59-60-62].aif +++ b/City/Scenes/Latin/AudioFiles/BassAudio/BassC3[59-60-62].aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/BassAudio/BassC4[70-72-78].aif b/City/Scenes/Latin/AudioFiles/BassAudio/BassC4[70-72-78].aif index 1c3d78d..1c3d78d 100644..100755 --- a/City/Scenes/Latin/AudioFiles/BassAudio/BassC4[70-72-78].aif +++ b/City/Scenes/Latin/AudioFiles/BassAudio/BassC4[70-72-78].aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/BassAudio/BassF#2[51-54-58].aif b/City/Scenes/Latin/AudioFiles/BassAudio/BassF#2[51-54-58].aif index ab7abe4..ab7abe4 100644..100755 --- a/City/Scenes/Latin/AudioFiles/BassAudio/BassF#2[51-54-58].aif +++ b/City/Scenes/Latin/AudioFiles/BassAudio/BassF#2[51-54-58].aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ C4 22 16 mono.aif b/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ C4 22 16 mono.aif index 28f851c..28f851c 100644..100755 --- a/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ C4 22 16 mono.aif +++ b/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ C4 22 16 mono.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ C5 22 16 mono.aif b/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ C5 22 16 mono.aif index 58d58e2..58d58e2 100644..100755 --- a/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ C5 22 16 mono.aif +++ b/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ C5 22 16 mono.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ G3 22 16 mono.aif b/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ G3 22 16 mono.aif index d4a8320..d4a8320 100644..100755 --- a/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ G3 22 16 mono.aif +++ b/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ G3 22 16 mono.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ G4 22 16 mono.aif b/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ G4 22 16 mono.aif index 6aad12c..6aad12c 100644..100755 --- a/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ G4 22 16 mono.aif +++ b/City/Scenes/Latin/AudioFiles/ChordsAudio/Organ G4 22 16 mono.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo C#3 22 16 Mono.aif b/City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo C#3 22 16 Mono.aif index d63f7c1..d63f7c1 100644..100755 --- a/City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo C#3 22 16 Mono.aif +++ b/City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo C#3 22 16 Mono.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo C3 22 16 Mono.aif b/City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo C3 22 16 Mono.aif index 546e609..546e609 100644..100755 --- a/City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo C3 22 16 Mono.aif +++ b/City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo C3 22 16 Mono.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo D3 22 16 Mono.aif b/City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo D3 22 16 Mono.aif index e947c9a..e947c9a 100644..100755 --- a/City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo D3 22 16 Mono.aif +++ b/City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo D3 22 16 Mono.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/DrumsAudio/ClosedhatF#1.aif b/City/Scenes/Latin/AudioFiles/DrumsAudio/ClosedhatF#1.aif index f170804..f170804 100644..100755 --- a/City/Scenes/Latin/AudioFiles/DrumsAudio/ClosedhatF#1.aif +++ b/City/Scenes/Latin/AudioFiles/DrumsAudio/ClosedhatF#1.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/DrumsAudio/Kick-C1.aif b/City/Scenes/Latin/AudioFiles/DrumsAudio/Kick-C1.aif index 7204bf6..7204bf6 100644..100755 --- a/City/Scenes/Latin/AudioFiles/DrumsAudio/Kick-C1.aif +++ b/City/Scenes/Latin/AudioFiles/DrumsAudio/Kick-C1.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/DrumsAudio/Shaker 22 16 Mono.aif b/City/Scenes/Latin/AudioFiles/DrumsAudio/Shaker 22 16 Mono.aif index cb70adf..cb70adf 100644..100755 --- a/City/Scenes/Latin/AudioFiles/DrumsAudio/Shaker 22 16 Mono.aif +++ b/City/Scenes/Latin/AudioFiles/DrumsAudio/Shaker 22 16 Mono.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/DrumsAudio/Snare-D1.aif b/City/Scenes/Latin/AudioFiles/DrumsAudio/Snare-D1.aif index de03f64..de03f64 100644..100755 --- a/City/Scenes/Latin/AudioFiles/DrumsAudio/Snare-D1.aif +++ b/City/Scenes/Latin/AudioFiles/DrumsAudio/Snare-D1.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/DrumsAudio/TambF#2.aif b/City/Scenes/Latin/AudioFiles/DrumsAudio/TambF#2.aif index 0eb9de9..0eb9de9 100644..100755 --- a/City/Scenes/Latin/AudioFiles/DrumsAudio/TambF#2.aif +++ b/City/Scenes/Latin/AudioFiles/DrumsAudio/TambF#2.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets A4 22 16 mono.aif b/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets A4 22 16 mono.aif index df3c59a..df3c59a 100644..100755 --- a/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets A4 22 16 mono.aif +++ b/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets A4 22 16 mono.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets C4 22 16 mono.aif b/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets C4 22 16 mono.aif index 918da75..918da75 100644..100755 --- a/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets C4 22 16 mono.aif +++ b/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets C4 22 16 mono.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets E3 22 16 mono.aif b/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets E3 22 16 mono.aif index 7f8ffd9..7f8ffd9 100644..100755 --- a/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets E3 22 16 mono.aif +++ b/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets E3 22 16 mono.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets F4 22 16 mono.aif b/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets F4 22 16 mono.aif index 9e5bb5f..9e5bb5f 100644..100755 --- a/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets F4 22 16 mono.aif +++ b/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets F4 22 16 mono.aif Binary files differ diff --git a/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets G3 22 16 mono.aif b/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets G3 22 16 mono.aif index 15f0639..15f0639 100644..100755 --- a/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets G3 22 16 mono.aif +++ b/City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets G3 22 16 mono.aif Binary files differ diff --git a/City/Scenes/Latin/Latin_Data.txt b/City/Scenes/Latin/Latin_Data.txt index b9f739c..b9f739c 100644..100755 --- a/City/Scenes/Latin/Latin_Data.txt +++ b/City/Scenes/Latin/Latin_Data.txt diff --git a/City/Scenes/Latin/MidiFiles/Bass.mid b/City/Scenes/Latin/MidiFiles/Bass.mid index cbc12a4..cbc12a4 100644..100755 --- a/City/Scenes/Latin/MidiFiles/Bass.mid +++ b/City/Scenes/Latin/MidiFiles/Bass.mid Binary files differ diff --git a/City/Scenes/Latin/MidiFiles/Chords.mid b/City/Scenes/Latin/MidiFiles/Chords.mid index d27fb73..d27fb73 100644..100755 --- a/City/Scenes/Latin/MidiFiles/Chords.mid +++ b/City/Scenes/Latin/MidiFiles/Chords.mid Binary files differ diff --git a/City/Scenes/Latin/MidiFiles/Drums.mid b/City/Scenes/Latin/MidiFiles/Drums.mid index 4ab7c9c..4ab7c9c 100644..100755 --- a/City/Scenes/Latin/MidiFiles/Drums.mid +++ b/City/Scenes/Latin/MidiFiles/Drums.mid Binary files differ diff --git a/City/Scenes/Latin/MidiFiles/Lead.mid b/City/Scenes/Latin/MidiFiles/Lead.mid index 407d400..407d400 100644..100755 --- a/City/Scenes/Latin/MidiFiles/Lead.mid +++ b/City/Scenes/Latin/MidiFiles/Lead.mid Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/BassAudio/BassC2[41-48-50].aif b/City/Scenes/Reggae/AudioFiles/BassAudio/BassC2[41-48-50].aif index 3e3fd98..3e3fd98 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/BassAudio/BassC2[41-48-50].aif +++ b/City/Scenes/Reggae/AudioFiles/BassAudio/BassC2[41-48-50].aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/BassAudio/BassC3[59-60-62].aif b/City/Scenes/Reggae/AudioFiles/BassAudio/BassC3[59-60-62].aif index bd3ab7f..bd3ab7f 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/BassAudio/BassC3[59-60-62].aif +++ b/City/Scenes/Reggae/AudioFiles/BassAudio/BassC3[59-60-62].aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/BassAudio/BassC4[70-72-78].aif b/City/Scenes/Reggae/AudioFiles/BassAudio/BassC4[70-72-78].aif index f9ec61b..f9ec61b 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/BassAudio/BassC4[70-72-78].aif +++ b/City/Scenes/Reggae/AudioFiles/BassAudio/BassC4[70-72-78].aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/BassAudio/BassF#2[51-54-58].aif b/City/Scenes/Reggae/AudioFiles/BassAudio/BassF#2[51-54-58].aif index c099d56..c099d56 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/BassAudio/BassF#2[51-54-58].aif +++ b/City/Scenes/Reggae/AudioFiles/BassAudio/BassF#2[51-54-58].aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif b/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif index 475ac71..475ac71 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif +++ b/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif b/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif index f89023c..f89023c 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif +++ b/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif b/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif index fd1a6c5..fd1a6c5 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif +++ b/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif b/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif index b4d5964..b4d5964 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif +++ b/City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/DrumsAudio/ClosedhatF#1.aif b/City/Scenes/Reggae/AudioFiles/DrumsAudio/ClosedhatF#1.aif index f170804..f170804 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/DrumsAudio/ClosedhatF#1.aif +++ b/City/Scenes/Reggae/AudioFiles/DrumsAudio/ClosedhatF#1.aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/DrumsAudio/Kick-C1.aif b/City/Scenes/Reggae/AudioFiles/DrumsAudio/Kick-C1.aif index 7204bf6..7204bf6 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/DrumsAudio/Kick-C1.aif +++ b/City/Scenes/Reggae/AudioFiles/DrumsAudio/Kick-C1.aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/DrumsAudio/OpenhatA#1.aif b/City/Scenes/Reggae/AudioFiles/DrumsAudio/OpenhatA#1.aif index 4f5f0b4..4f5f0b4 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/DrumsAudio/OpenhatA#1.aif +++ b/City/Scenes/Reggae/AudioFiles/DrumsAudio/OpenhatA#1.aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/DrumsAudio/Snare-D1.aif b/City/Scenes/Reggae/AudioFiles/DrumsAudio/Snare-D1.aif index de03f64..de03f64 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/DrumsAudio/Snare-D1.aif +++ b/City/Scenes/Reggae/AudioFiles/DrumsAudio/Snare-D1.aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/DrumsAudio/TambF#2.aif b/City/Scenes/Reggae/AudioFiles/DrumsAudio/TambF#2.aif index 0eb9de9..0eb9de9 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/DrumsAudio/TambF#2.aif +++ b/City/Scenes/Reggae/AudioFiles/DrumsAudio/TambF#2.aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/LeadAudio/B2_guitar.aif b/City/Scenes/Reggae/AudioFiles/LeadAudio/B2_guitar.aif index 9a06c2f..9a06c2f 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/LeadAudio/B2_guitar.aif +++ b/City/Scenes/Reggae/AudioFiles/LeadAudio/B2_guitar.aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/LeadAudio/B3_guitar.aif b/City/Scenes/Reggae/AudioFiles/LeadAudio/B3_guitar.aif index a229b76..a229b76 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/LeadAudio/B3_guitar.aif +++ b/City/Scenes/Reggae/AudioFiles/LeadAudio/B3_guitar.aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/LeadAudio/E2_guitar.aif b/City/Scenes/Reggae/AudioFiles/LeadAudio/E2_guitar.aif index 0df7f1e..0df7f1e 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/LeadAudio/E2_guitar.aif +++ b/City/Scenes/Reggae/AudioFiles/LeadAudio/E2_guitar.aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/LeadAudio/E3_guitar.aif b/City/Scenes/Reggae/AudioFiles/LeadAudio/E3_guitar.aif index e8f5be5..e8f5be5 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/LeadAudio/E3_guitar.aif +++ b/City/Scenes/Reggae/AudioFiles/LeadAudio/E3_guitar.aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/LeadAudio/E4_guitar.aif b/City/Scenes/Reggae/AudioFiles/LeadAudio/E4_guitar.aif index 9909889..9909889 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/LeadAudio/E4_guitar.aif +++ b/City/Scenes/Reggae/AudioFiles/LeadAudio/E4_guitar.aif Binary files differ diff --git a/City/Scenes/Reggae/AudioFiles/LeadAudio/E5_guitar.aif b/City/Scenes/Reggae/AudioFiles/LeadAudio/E5_guitar.aif index f1f7076..f1f7076 100644..100755 --- a/City/Scenes/Reggae/AudioFiles/LeadAudio/E5_guitar.aif +++ b/City/Scenes/Reggae/AudioFiles/LeadAudio/E5_guitar.aif Binary files differ diff --git a/City/Scenes/Reggae/MidiFiles/Bass.mid b/City/Scenes/Reggae/MidiFiles/Bass.mid index be414ec..be414ec 100644..100755 --- a/City/Scenes/Reggae/MidiFiles/Bass.mid +++ b/City/Scenes/Reggae/MidiFiles/Bass.mid Binary files differ diff --git a/City/Scenes/Reggae/MidiFiles/Chords.mid b/City/Scenes/Reggae/MidiFiles/Chords.mid index 1feebaa..1feebaa 100644..100755 --- a/City/Scenes/Reggae/MidiFiles/Chords.mid +++ b/City/Scenes/Reggae/MidiFiles/Chords.mid Binary files differ diff --git a/City/Scenes/Reggae/MidiFiles/Drums.mid b/City/Scenes/Reggae/MidiFiles/Drums.mid index bf2f5be..bf2f5be 100644..100755 --- a/City/Scenes/Reggae/MidiFiles/Drums.mid +++ b/City/Scenes/Reggae/MidiFiles/Drums.mid Binary files differ diff --git a/City/Scenes/Reggae/MidiFiles/Lead.mid b/City/Scenes/Reggae/MidiFiles/Lead.mid index 2a0d2be..2a0d2be 100644..100755 --- a/City/Scenes/Reggae/MidiFiles/Lead.mid +++ b/City/Scenes/Reggae/MidiFiles/Lead.mid Binary files differ diff --git a/City/Scenes/Reggae/Reggae_Data.txt b/City/Scenes/Reggae/Reggae_Data.txt index cc23d84..cc23d84 100644..100755 --- a/City/Scenes/Reggae/Reggae_Data.txt +++ b/City/Scenes/Reggae/Reggae_Data.txt diff --git a/InstrumentPanel.py b/InstrumentPanel.py index 9cc303f..9cc303f 100644..100755 --- a/InstrumentPanel.py +++ b/InstrumentPanel.py diff --git a/J2JToolbar.py b/J2JToolbar.py deleted file mode 100755 index 54b9b22..0000000 --- a/J2JToolbar.py +++ /dev/null @@ -1,325 +0,0 @@ -#This python module is part of the Jam2Jam XO Activity, March, 2010 -# -#Copyright (C) 2010 Thorin Kerr & Andrew Brown -# -#This program is free software; you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation; either version 2 of the License, or any -#later version. -# -#This program is distributed in the hope that it will be useful, but -#WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. -# -#You should have received a copy of the GNU General Public License -#along with this program; if not, write to the Free Software -#Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -import gtk, gst, thread, tempfile, time, os -import pygame -import olpcgames -from gettext import gettext as _ -from sugar.graphics.toolbutton import ToolButton - -import logging - -log = logging.getLogger('City run') -log.setLevel(logging.DEBUG) - -ImagePath = os.path.dirname(os.path.abspath(__file__)) + "/City/Images" - -GST_PIPE = ['v4l2src', 'ffmpegcolorspace', 'pngenc'] - - - -from sugar.graphics.toolcombobox import ToolComboBox - - - -class readScenes(object): - def __init__(self, scpath): - self.scpath = scpath - self.scene_names = [dir for dir in os.listdir(self.scpath) if os.path.isdir(self.scpath + '/' + dir)] - self.scene_data = [] - for n in self.scene_names: - fp = self.scpath + "/" + n - mdfile = [open(fp + '/' + f) for f in os.listdir(fp) if os.path.isfile(fp + "/" + f) and f.startswith(n)] - if mdfile: - result = {"Name":n} - defaults = {} - for line in mdfile[0]: - if line.startswith('#') or line.startswith('\n'): - pass - else: - keyvals = line.split('=') - if len(keyvals) == 2: - key = keyvals[0].upper() - val = (keyvals[1][:-1] if keyvals[1][-1] == '\n' else keyvals[1]) - if key.startswith('TEMPO'): - result['Tempo'] = val.replace(' ','') - elif key.startswith('KEY'): - result['Key'] = val.replace(' ','') - elif key.startswith('MODE'): - result['Mode'] = val.replace(' ','') - else: - pass - else: - raise IOError, "Bad Scene Meta Data file: %s" %keyvals - result['Defaults'] = {} - self.scene_data.append(result) - else: - raise IOError, "Can't find Meta Data file in %s Scene" %n - def scene_instruct(self, name): - "returns a list of strings suitable to give to a ScenePlayer object for creating a scene" - for scd in self.scene_data: - if scd['Name'] == name: - collected = [name] - for k in ['Key', 'Mode', 'Tempo', 'Defaults']: - try: - collected.append(str(scd[k])) - except KeyError: - collected.append('None') - return collected - def get_scene_list(self): - "returns a list of scene strings for the toolbar, with City as the default" - ordered_names = self.scene_names[:] - if 'City' in ordered_names: - ordered_names.insert(0,ordered_names.pop(ordered_names.index('City'))) - return [self.scene_instruct(s) for s in ordered_names] - -class CameraSnap(object): - """A class representing the OLPC camera.""" - def __init__(self): - log.info("CameraSnap init") - snap_file, self.snap_path = tempfile.mkstemp(suffix = '.png') - pipe = GST_PIPE + ['filesink location=%s' % self.snap_path] - self.pipe = gst.parse_launch('!'.join(pipe)) - self.bus = self.pipe.get_bus() - log.info("tempfile is %s " %self.snap_path) - def Snap(self): - """Take a snapshot.""" - log.info("about to set pipe state to PLAY") - self.pipe.set_state(gst.STATE_PLAYING) - log.info("about to poll") - thread.start_new_thread(self.bus.poll, (gst.MESSAGE_EOS, -1)) - for i in xrange(60): - time.sleep(0.18) - if os.path.getsize(self.snap_path) > 0: break - else: raise IOError, "Error writing camera snap to file" - return self.snap_path - def Stop(self): - self.pipe.set_state(gst.STATE_NULL) - - -class Jam2JamToolBar(gtk.Toolbar): - def __init__(self, activity): - gtk.Toolbar.__init__(self) - self.activity = activity - self.parameters = ['Density', 'Pitch', 'Length', 'Timbre', 'Volume'] # no tempo here. - scene_stuff = readScenes(self.activity._ScenePath) - self.scenes = scene_stuff.get_scene_list() - print "SCENE DATA IS ", self.scenes - #self.scenes = [['City', 'A', 'minor pentatonic'], ['City', 'G#', 'major']] #this data needs to be obtained from directories - self.play_pause_state = 'Playing' - self.scene_init = True - - # Separator - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - self.insert(separator, -1) - - #Horizontal Parameter control combobox - self._add_widget(gtk.Label(_('Horizontal:'))) - self._Hparameter_combo = ToolComboBox() - for i, f in enumerate(self.parameters): - self._Hparameter_combo.combo.append_item(i, f) - self._Hparameter_combo.combo.connect('changed', self._Hparameter_change_cb) - self._add_widget(self._Hparameter_combo) - self._Hparameter_combo.combo.set_active(0) - - # Separator - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - separator.show() - self.insert(separator, -1) - - #Vertical Parameter control combobox - self._add_widget(gtk.Label(_('Vertical:'))) - self._Vparameter_combo = ToolComboBox() - for j, k in enumerate(self.parameters): - self._Vparameter_combo.combo.append_item(j, k) - self._Vparameter_combo.combo.connect('changed', self._Vparameter_change_cb) - self._add_widget(self._Vparameter_combo) - self._Vparameter_combo.combo.set_active(1) - - # Separator - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - separator.show() - self.insert(separator, -1) - - - #Scene Selection control combobox - self._add_widget(gtk.Label(_('Scene:'))) - self._Scene_combo = ToolComboBox() - for l, m in enumerate(self.scenes): - self._Scene_combo.combo.append_item(l, m[0]) - self._Scene_combo.combo.connect('changed', self._Scene_change_cb) - self._add_widget(self._Scene_combo) - #ought to do this safely somehow. - self._Scene_combo.combo.set_active(0) - self.scene_init = False - - # Separator - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - separator.show() - self.insert(separator, -1) - - - #Camera Button - self.camera_ready = True - camera_icon = ImagePath + "/camera-external.svg" - camera_busy_icon = ImagePath + "/camera-busy.svg" - self.camera_image, self.camera_busy_image = gtk.Image(), gtk.Image() - self.camera_image.set_from_file(camera_icon) - self.camera_busy_image.set_from_file(camera_busy_icon) - self.camera_image.show() - #camera_busy_image.show() - self._cameraButton = ToolButton() - self._cameraButton.set_icon_widget(self.camera_image) - self._cameraButton.connect('clicked', self._cameraSnap_cb) - self._cameraButton.set_tooltip(_('Snapshot')) - self.insert(self._cameraButton, -1) - self._cameraButton.show() - - # Separator - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - separator.show() - self.insert(separator, -1) - - #Play/Pause Button - pause_icon = ImagePath + "/media-playback-pause.svg" - play_icon = ImagePath + "/media-playback-start.svg" - self.pause_image = gtk.Image() - self.pause_image.set_from_file(pause_icon) - - self.play_image = gtk.Image() - self.play_image.set_from_file(play_icon) - - self._pauseButton = ToolButton() - self._pauseButton.connect('clicked', self._pause_cb) - self.pause_image.show() - self._pauseButton.set_icon_widget(self.pause_image) - self._pauseButton.set_tooltip(_('Pause')) - #self._toggleplay_pause() - self.insert(self._pauseButton, -1) - self._pauseButton.show() - - # Separator - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - separator.show() - self.insert(separator, -1) - - - def _add_widget(self, widget, expand=False): - tool_item = gtk.ToolItem() - tool_item.set_expand(expand) - tool_item.add(widget) - widget.show() - self.insert(tool_item, -1) - tool_item.show() - - def _toggleplay_pause(self): - if self.play_pause_state == "Playing": - self.activity.jamScene.music_player.pause() - self.play_image.show() - self._pauseButton.set_icon_widget(self.play_image) - self._pauseButton.set_tooltip(_('Play')) - self.play_pause_state = "Paused" - else: - self.activity.jamScene.music_player.resume() - self.pause_image.show() - self._pauseButton.set_icon_widget(self.pause_image) - self._pauseButton.set_tooltip(_('Pause')) - self.play_pause_state = "Playing" - try: - self.activity._pgc.grab_focus() - except AttributeError: - pass - - def _show_busy_camera(self): - self.camera_ready = False - self.camera_busy_image.show() - self._cameraButton.set_icon_widget(self.camera_busy_image) - self._cameraButton.set_tooltip(_('Please wait...')) - - def _show_active_camera(self): - self.camera_image.show() - self._cameraButton.set_icon_widget(self.camera_image) - self._cameraButton.set_tooltip(_('Snap')) - self.camera_ready = True - - def _Hparameter_change_cb(self, widget): - param = "Parameter|Horizontal|" + self.parameters[self._Hparameter_combo.combo.get_active()] - olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=param)) - try: - self.activity._pgc.grab_focus() - except AttributeError: - pass - - def _Vparameter_change_cb(self, widget): - param = "Parameter|Vertical|" + self.parameters[self._Vparameter_combo.combo.get_active()] - olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=param)) - try: - self.activity._pgc.grab_focus() - except AttributeError: - pass - - def _Scene_change_cb(self, widget): - if self.scene_init: - pass - else: - selection = self.scenes[self._Scene_combo.combo.get_active()] - scene = "Reload|" + '|'.join(map(lambda x: str(x), selection)) - olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=scene)) - try: - self.activity._pgc.grab_focus() - except AttributeError: - pass - - ### functions to assist calls from pygame - def deactivate_scene_change(self): - self._Scene_combo.set_sensitive(False) - def reactivate_scene_change(self): - self._Scene_combo.set_sensitive(True) - def set_horizontal_parameter(self, param): - ndx = self.parameters.index(param) - self._Hparameter_combo.combo.set_active(ndx) - def set_vertical_parameter(self, param): - ndx = self.parameters.index(param) - self._Vparameter_combo.combo.set_active(ndx) - - def _cameraSnap_cb(self, widget): - "Here I could wrap a camera event..." - def snaptime(): - snap = CameraSnap() - self.activity.cameras_loaded.append(snap) - picpath = snap.Snap() - self.activity.load_image(picpath) - snap.Stop() - self._show_active_camera() - self.activity._pgc.grab_focus() - if self.camera_ready: - self._show_busy_camera() - thread.start_new_thread(snaptime, ()) - else: - log.info('Ignoring request to use camera, as camera is currently busy') - - def _pause_cb(self, widget): - self._toggleplay_pause() - log.info("Play/Pause Button pressed") - diff --git a/J2JToolbar.py~ b/J2JToolbar.py~ deleted file mode 100755 index 2e66eaa..0000000 --- a/J2JToolbar.py~ +++ /dev/null @@ -1,319 +0,0 @@ -#This python module is part of the Jam2Jam XO Activity, March, 2010 -# -#Copyright (C) 2010 Thorin Kerr & Andrew Brown -# -#This program is free software; you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation; either version 2 of the License, or any -#later version. -# -#This program is distributed in the hope that it will be useful, but -#WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. -# -#You should have received a copy of the GNU General Public License -#along with this program; if not, write to the Free Software -#Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -import gtk, gst, thread, tempfile, time, os -import pygame -import olpcgames -from gettext import gettext as _ -from sugar.graphics.toolbutton import ToolButton -from sugar.graphics.toolcombobox import ToolComboBox -import logging - -log = logging.getLogger('City run') -log.setLevel(logging.DEBUG) - -ImagePath = os.path.dirname(os.path.abspath(__file__)) + "/City/Images" - -GST_PIPE = ['v4l2src', 'ffmpegcolorspace', 'pngenc'] - -class readScenes(object): - def __init__(self, scpath): - self.scpath = scpath - self.scene_names = [dir for dir in os.listdir(self.scpath) if os.path.isdir(self.scpath + '/' + dir)] - self.scene_data = [] - for n in self.scene_names: - fp = self.scpath + "/" + n - mdfile = [open(fp + '/' + f) for f in os.listdir(fp) if os.path.isfile(fp + "/" + f) and f.startswith(n)] - if mdfile: - result = {"Name":n} - defaults = {} - for line in mdfile[0]: - if line.startswith('#') or line.startswith('\n'): - pass - else: - keyvals = line.split('=') - if len(keyvals) == 2: - key = keyvals[0].upper() - val = (keyvals[1][:-1] if keyvals[1][-1] == '\n' else keyvals[1]) - if key.startswith('TEMPO'): - result['Tempo'] = val.replace(' ','') - elif key.startswith('KEY'): - result['Key'] = val.replace(' ','') - elif key.startswith('MODE'): - result['Mode'] = val.replace(' ','') - else: - pass - else: - raise IOError, "Bad Scene Meta Data file: %s" %keyvals - result['Defaults'] = {} - self.scene_data.append(result) - else: - raise IOError, "Can't find Meta Data file in %s Scene" %n - def scene_instruct(self, name): - "returns a list of strings suitable to give to a ScenePlayer object for creating a scene" - for scd in self.scene_data: - if scd['Name'] == name: - collected = [name] - for k in ['Key', 'Mode', 'Tempo', 'Defaults']: - try: - collected.append(str(scd[k])) - except KeyError: - collected.append('None') - return collected - def get_scene_list(self): - "returns a list of scene strings for the toolbar, with City as the default" - ordered_names = self.scene_names[:] - if 'City' in ordered_names: - ordered_names.insert(0,ordered_names.pop(ordered_names.index('City'))) - return [self.scene_instruct(s) for s in ordered_names] - -class CameraSnap(object): - """A class representing the OLPC camera.""" - def __init__(self): - log.info("CameraSnap init") - snap_file, self.snap_path = tempfile.mkstemp(suffix = '.png') - pipe = GST_PIPE + ['filesink location=%s' % self.snap_path] - self.pipe = gst.parse_launch('!'.join(pipe)) - self.bus = self.pipe.get_bus() - log.info("tempfile is %s " %self.snap_path) - def Snap(self): - """Take a snapshot.""" - log.info("about to set pipe state to PLAY") - self.pipe.set_state(gst.STATE_PLAYING) - log.info("about to poll") - thread.start_new_thread(self.bus.poll, (gst.MESSAGE_EOS, -1)) - for i in xrange(60): - time.sleep(0.18) - if os.path.getsize(self.snap_path) > 0: break - else: raise IOError, "Error writing camera snap to file" - return self.snap_path - def Stop(self): - self.pipe.set_state(gst.STATE_NULL) - - -class Jam2JamToolBar(gtk.Toolbar): - def __init__(self, activity): - gtk.Toolbar.__init__(self) - self.activity = activity - self.parameters = ['Density', 'Pitch', 'Length', 'Timbre', 'Volume'] # no tempo here. - scene_stuff = readScenes(self.activity._ScenePath) - self.scenes = scene_stuff.get_scene_list() - print "SCENE DATA IS ", self.scenes - #self.scenes = [['City', 'A', 'minor pentatonic'], ['City', 'G#', 'major']] #this data needs to be obtained from directories - self.play_pause_state = 'Playing' - self.scene_init = True - - # Separator - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - self.insert(separator, -1) - - #Horizontal Parameter control combobox - self._add_widget(gtk.Label(_('Horizontal:'))) - self._Hparameter_combo = ToolComboBox() - for i, f in enumerate(self.parameters): - self._Hparameter_combo.combo.append_item(i, f) - self._Hparameter_combo.combo.connect('changed', self._Hparameter_change_cb) - self._add_widget(self._Hparameter_combo) - self._Hparameter_combo.combo.set_active(0) - - # Separator - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - separator.show() - self.insert(separator, -1) - - #Vertical Parameter control combobox - self._add_widget(gtk.Label(_('Vertical:'))) - self._Vparameter_combo = ToolComboBox() - for j, k in enumerate(self.parameters): - self._Vparameter_combo.combo.append_item(j, k) - self._Vparameter_combo.combo.connect('changed', self._Vparameter_change_cb) - self._add_widget(self._Vparameter_combo) - self._Vparameter_combo.combo.set_active(1) - - # Separator - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - separator.show() - self.insert(separator, -1) - - - #Scene Selection control combobox - self._add_widget(gtk.Label(_('Scene:'))) - self._Scene_combo = ToolComboBox() - for l, m in enumerate(self.scenes): - self._Scene_combo.combo.append_item(l, m[0]) - self._Scene_combo.combo.connect('changed', self._Scene_change_cb) - self._add_widget(self._Scene_combo) - #ought to do this safely somehow. - self._Scene_combo.combo.set_active(0) - self.scene_init = False - - # Separator - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - separator.show() - self.insert(separator, -1) - - - #Camera Button - self.camera_ready = True - camera_icon = ImagePath + "/camera-external.svg" - camera_busy_icon = ImagePath + "/camera-busy.svg" - self.camera_image, self.camera_busy_image = gtk.Image(), gtk.Image() - self.camera_image.set_from_file(camera_icon) - self.camera_busy_image.set_from_file(camera_busy_icon) - self.camera_image.show() - #camera_busy_image.show() - self._cameraButton = ToolButton() - self._cameraButton.set_icon_widget(self.camera_image) - self._cameraButton.connect('clicked', self._cameraSnap_cb) - self._cameraButton.set_tooltip(_('Snapshot')) - self.insert(self._cameraButton, -1) - self._cameraButton.show() - - # Separator - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - separator.show() - self.insert(separator, -1) - - #Play/Pause Button - pause_icon = ImagePath + "/media-playback-pause.svg" - play_icon = ImagePath + "/media-playback-start.svg" - self.pause_image = gtk.Image() - self.pause_image.set_from_file(pause_icon) - - self.play_image = gtk.Image() - self.play_image.set_from_file(play_icon) - - self._pauseButton = ToolButton() - self._pauseButton.connect('clicked', self._pause_cb) - self.pause_image.show() - self._pauseButton.set_icon_widget(self.pause_image) - self._pauseButton.set_tooltip(_('Pause')) - #self._toggleplay_pause() - self.insert(self._pauseButton, -1) - self._pauseButton.show() - - # Separator - separator = gtk.SeparatorToolItem() - separator.set_draw(True) - separator.show() - self.insert(separator, -1) - - - def _add_widget(self, widget, expand=False): - tool_item = gtk.ToolItem() - tool_item.set_expand(expand) - tool_item.add(widget) - widget.show() - self.insert(tool_item, -1) - tool_item.show() - - def _toggleplay_pause(self): - if self.play_pause_state == "Playing": - self.activity.jamScene.music_player.pause() - self.play_image.show() - self._pauseButton.set_icon_widget(self.play_image) - self._pauseButton.set_tooltip(_('Play')) - self.play_pause_state = "Paused" - else: - self.activity.jamScene.music_player.resume() - self.pause_image.show() - self._pauseButton.set_icon_widget(self.pause_image) - self._pauseButton.set_tooltip(_('Pause')) - self.play_pause_state = "Playing" - try: - self.activity._pgc.grab_focus() - except AttributeError: - pass - - def _show_busy_camera(self): - self.camera_ready = False - self.camera_busy_image.show() - self._cameraButton.set_icon_widget(self.camera_busy_image) - self._cameraButton.set_tooltip(_('Please wait...')) - - def _show_active_camera(self): - self.camera_image.show() - self._cameraButton.set_icon_widget(self.camera_image) - self._cameraButton.set_tooltip(_('Snap')) - self.camera_ready = True - - def _Hparameter_change_cb(self, widget): - param = "Parameter|Horizontal|" + self.parameters[self._Hparameter_combo.combo.get_active()] - olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=param)) - try: - self.activity._pgc.grab_focus() - except AttributeError: - pass - - def _Vparameter_change_cb(self, widget): - param = "Parameter|Vertical|" + self.parameters[self._Vparameter_combo.combo.get_active()] - olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=param)) - try: - self.activity._pgc.grab_focus() - except AttributeError: - pass - - def _Scene_change_cb(self, widget): - if self.scene_init: - pass - else: - selection = self.scenes[self._Scene_combo.combo.get_active()] - scene = "Reload|" + '|'.join(map(lambda x: str(x), selection)) - olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=scene)) - try: - self.activity._pgc.grab_focus() - except AttributeError: - pass - - ### functions to assist calls from pygame - def deactivate_scene_change(self): - self._Scene_combo.set_sensitive(False) - def reactivate_scene_change(self): - self._Scene_combo.set_sensitive(True) - def set_horizontal_parameter(self, param): - ndx = self.parameters.index(param) - self._Hparameter_combo.combo.set_active(ndx) - def set_vertical_parameter(self, param): - ndx = self.parameters.index(param) - self._Vparameter_combo.combo.set_active(ndx) - - def _cameraSnap_cb(self, widget): - "Here I could wrap a camera event..." - def snaptime(): - snap = CameraSnap() - self.activity.cameras_loaded.append(snap) - picpath = snap.Snap() - self.activity.load_image(picpath) - snap.Stop() - self._show_active_camera() - self.activity._pgc.grab_focus() - if self.camera_ready: - self._show_busy_camera() - thread.start_new_thread(snaptime, ()) - else: - log.info('Ignoring request to use camera, as camera is currently busy') - - def _pause_cb(self, widget): - self._toggleplay_pause() - log.info("Play/Pause Button pressed") - diff --git a/J2JToolbars.py b/J2JToolbars.py new file mode 100755 index 0000000..f5a739f --- /dev/null +++ b/J2JToolbars.py @@ -0,0 +1,621 @@ +#This python module is part of the Jam2Jam XO Activity, March, 2010 +# +#Copyright (C) 2010 Thorin Kerr & Andrew Brown +# +#This program is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 2 of the License, or any +#later version. +# +#This program is distributed in the hope that it will be useful, but +#WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program; if not, write to the Free Software +#Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import sugar.activity +from sugar.activity.activity import get_bundle_path +from olpcgames import activity +import gtk, gst, thread, tempfile, time, os, types +import pygame, olpcgames +from gettext import gettext as _ + +_NEW_TOOLBAR_SUPPORT = True + +from sugar.graphics.toolbutton import ToolButton #used in both old and new toolbars, but I suspect the new toolbar could use ToolbarButton instead. + +try: + from sugar.graphics.toolbarbox import ToolbarBox #new toolbar + from sugar.graphics.toolbarbox import ToolbarButton #new toolbar + from sugar.activity.widgets import StopButton #new toolbar + from mybutton import AltButton #new toolbar +except: + _NEW_TOOLBAR_SUPPORT = True + from sugar.graphics.toolcombobox import ToolComboBox #only needs to be imported if using old toolbar + +import logging +log = logging.getLogger('City run') +log.setLevel(logging.DEBUG) +log.info("imported AltButton, inherits from ToolbarButton\n") + +ImagePath = get_bundle_path() + "/City/Images" + +GST_PIPE = ['v4l2src', 'ffmpegcolorspace', 'pngenc'] + +class readScenes(object): + def __init__(self, scpath): + self.scpath = scpath + self.scene_names = [dir for dir in os.listdir(self.scpath) if os.path.isdir(self.scpath + '/' + dir)] + self.scene_data = [] + for n in self.scene_names: + fp = self.scpath + "/" + n + mdfile = [open(fp + '/' + f) for f in os.listdir(fp) if os.path.isfile(fp + "/" + f) and f.startswith(n)] + if mdfile: + result = {"Name":n} + defaults = {} + for line in mdfile[0]: + if line.startswith('#') or line.startswith('\n'): + pass + else: + keyvals = line.split('=') + if len(keyvals) == 2: + key = keyvals[0].upper() + val = (keyvals[1][:-1] if keyvals[1][-1] == '\n' else keyvals[1]) + if key.startswith('TEMPO'): + result['Tempo'] = val.replace(' ','') + elif key.startswith('KEY'): + result['Key'] = val.replace(' ','') + elif key.startswith('MODE'): + result['Mode'] = val.replace(' ','') + else: + pass + else: + raise IOError, "Bad Scene Meta Data file: %s" %keyvals + result['Defaults'] = {} + self.scene_data.append(result) + else: + raise IOError, "Can't find Meta Data file in %s Scene" %n + def scene_instruct(self, name): + "returns a list of strings suitable to give to a ScenePlayer object for creating a scene" + for scd in self.scene_data: + if scd['Name'] == name: + collected = [name] + for k in ['Key', 'Mode', 'Tempo', 'Defaults']: + try: + collected.append(str(scd[k])) + except KeyError: + collected.append('None') + return collected + def get_scene_list(self): + "returns a list of scene strings for the toolbar, with City as the default" + ordered_names = self.scene_names[:] + if 'City' in ordered_names: + ordered_names.insert(0,ordered_names.pop(ordered_names.index('City'))) + return [self.scene_instruct(s) for s in ordered_names] + +class CameraSnap(object): + """A class representing the OLPC camera.""" + def __init__(self): + log.info("CameraSnap init") + snap_file, self.snap_path = tempfile.mkstemp(suffix = '.png') + pipe = GST_PIPE + ['filesink location=%s' % self.snap_path] + self.pipe = gst.parse_launch('!'.join(pipe)) + self.bus = self.pipe.get_bus() + log.info("tempfile is %s " %self.snap_path) + def Snap(self): + """Take a snapshot.""" + log.info("about to set pipe state to PLAY") + self.pipe.set_state(gst.STATE_PLAYING) + log.info("about to poll") + thread.start_new_thread(self.bus.poll, (gst.MESSAGE_EOS, -1)) + for i in xrange(60): + time.sleep(0.18) + if os.path.getsize(self.snap_path) > 0: break + else: raise IOError, "Error writing camera snap to file" + return self.snap_path + def Stop(self): + self.pipe.set_state(gst.STATE_NULL) + +#old toolbar +class Jam2JamToolBar(gtk.Toolbar): + def __init__(self, activity): + gtk.Toolbar.__init__(self) + self.activity = activity + self.parameters = ['Density', 'Pitch', 'Length', 'Timbre', 'Volume'] # no tempo here. + scene_stuff = readScenes(self.activity._ScenePath) + self.scenes = scene_stuff.get_scene_list() + #example of scene data. This gets read from file + #self.scenes = [['City', 'A', 'minor pentatonic'], ['City', 'G#', 'major']] #this data needs to be obtained from directories + self.play_pause_state = 'Playing' + self.scene_init = True + + # Separator + separator = gtk.SeparatorToolItem() + separator.set_draw(True) + self.insert(separator, -1) + + #Horizontal Parameter control combobox + self._add_widget(gtk.Label(_('Horizontal:'))) + self._Hparameter_combo = ToolComboBox() + for i, f in enumerate(self.parameters): + self._Hparameter_combo.combo.append_item(i, f) + self._Hparameter_combo.combo.connect('changed', self._Hparameter_change_cb) + self._add_widget(self._Hparameter_combo) + self._Hparameter_combo.combo.set_active(0) + + # Separator + separator = gtk.SeparatorToolItem() + separator.set_draw(True) + separator.show() + self.insert(separator, -1) + + #Vertical Parameter control combobox + self._add_widget(gtk.Label(_('Vertical:'))) + self._Vparameter_combo = ToolComboBox() + for j, k in enumerate(self.parameters): + self._Vparameter_combo.combo.append_item(j, k) + self._Vparameter_combo.combo.connect('changed', self._Vparameter_change_cb) + self._add_widget(self._Vparameter_combo) + self._Vparameter_combo.combo.set_active(1) + + # Separator + separator = gtk.SeparatorToolItem() + separator.set_draw(True) + separator.show() + self.insert(separator, -1) + + #Scene Selection control combobox + self._add_widget(gtk.Label(_('Scene:'))) + self._Scene_combo = ToolComboBox() + for l, m in enumerate(self.scenes): + self._Scene_combo.combo.append_item(l, m[0]) + self._Scene_combo.combo.connect('changed', self._Scene_change_cb) + self._add_widget(self._Scene_combo) + #ought to do this safely somehow. + self._Scene_combo.combo.set_active(0) + self.scene_init = False + + # Separator + separator = gtk.SeparatorToolItem() + separator.set_draw(True) + separator.show() + self.insert(separator, -1) + + #Camera Button + self.camera_ready = True + camera_icon = ImagePath + "/camera-external.svg" + camera_busy_icon = ImagePath + "/camera-busy.svg" + self.camera_image, self.camera_busy_image = gtk.Image(), gtk.Image() + self.camera_image.set_from_file(camera_icon) + self.camera_busy_image.set_from_file(camera_busy_icon) + self.camera_image.show() + #camera_busy_image.show() + self._cameraButton = ToolButton() + self._cameraButton.set_icon_widget(self.camera_image) + self._cameraButton.connect('clicked', self._cameraSnap_cb) + self._cameraButton.set_tooltip(_('Snapshot')) + self.insert(self._cameraButton, -1) + self._cameraButton.show() + + # Separator + separator = gtk.SeparatorToolItem() + separator.set_draw(True) + separator.show() + self.insert(separator, -1) + + #Play/Pause Button + pause_icon = ImagePath + "/media-playback-pause.svg" + play_icon = ImagePath + "/media-playback-start.svg" + self.pause_image = gtk.Image() + self.pause_image.set_from_file(pause_icon) + + self.play_image = gtk.Image() + self.play_image.set_from_file(play_icon) + + self._pauseButton = ToolButton() + self._pauseButton.connect('clicked', self._pause_cb) + self.pause_image.show() + self._pauseButton.set_icon_widget(self.pause_image) + self._pauseButton.set_tooltip(_('Pause')) + #self._toggleplay_pause() + self.insert(self._pauseButton, -1) + self._pauseButton.show() + + # Separator + separator = gtk.SeparatorToolItem() + separator.set_draw(True) + separator.show() + self.insert(separator, -1) + + + def _add_widget(self, widget, expand=False): + tool_item = gtk.ToolItem() + tool_item.set_expand(expand) + tool_item.add(widget) + widget.show() + self.insert(tool_item, -1) + tool_item.show() + + def _toggleplay_pause(self): + if self.play_pause_state == "Playing": + self.activity.jamScene.music_player.pause() + self.play_image.show() + self._pauseButton.set_icon_widget(self.play_image) + self._pauseButton.set_tooltip(_('Play')) + self.play_pause_state = "Paused" + else: + self.activity.jamScene.music_player.resume() + self.pause_image.show() + self._pauseButton.set_icon_widget(self.pause_image) + self._pauseButton.set_tooltip(_('Pause')) + self.play_pause_state = "Playing" + try: + self.activity._pgc.grab_focus() + except AttributeError: + pass + + def _show_busy_camera(self): + self.camera_ready = False + self.camera_busy_image.show() + self._cameraButton.set_icon_widget(self.camera_busy_image) + self._cameraButton.set_tooltip(_('Please wait...')) + + def _show_active_camera(self): + self.camera_image.show() + self._cameraButton.set_icon_widget(self.camera_image) + self._cameraButton.set_tooltip(_('Snap')) + self.camera_ready = True + + def _Hparameter_change_cb(self, widget): + param = "Parameter|Horizontal|" + self.parameters[self._Hparameter_combo.combo.get_active()] + olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=param)) + try: + self.activity._pgc.grab_focus() + except AttributeError: + pass + + def _Vparameter_change_cb(self, widget): + param = "Parameter|Vertical|" + self.parameters[self._Vparameter_combo.combo.get_active()] + olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=param)) + try: + self.activity._pgc.grab_focus() + except AttributeError: + pass + + def _Scene_change_cb(self, widget): + if self.scene_init: + pass + else: + selection = self.scenes[self._Scene_combo.combo.get_active()] + scene = "Reload|" + '|'.join(map(lambda x: str(x), selection)) + olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=scene)) + try: + self.activity._pgc.grab_focus() + except AttributeError: + pass + + ### functions to assist calls from pygame + def deactivate_scene_change(self): + self._Scene_combo.set_sensitive(False) + def reactivate_scene_change(self): + self._Scene_combo.set_sensitive(True) + def set_horizontal_parameter(self, param): + ndx = self.parameters.index(param) + self._Hparameter_combo.combo.set_active(ndx) + def set_vertical_parameter(self, param): + ndx = self.parameters.index(param) + self._Vparameter_combo.combo.set_active(ndx) + + def _cameraSnap_cb(self, widget): + "Here I could wrap a camera event..." + def snaptime(): + snap = CameraSnap() + self.activity.cameras_loaded.append(snap) + picpath = snap.Snap() + self.activity.load_image(picpath) + snap.Stop() + self._show_active_camera() + self.activity._pgc.grab_focus() + if self.camera_ready: + self._show_busy_camera() + thread.start_new_thread(snaptime, ()) + else: + log.info('Ignoring request to use camera, as camera is currently busy') + + def _pause_cb(self, widget): + self._toggleplay_pause() + log.info("Play/Pause Button pressed") + + +class J2J_Toolbar_Redirect( object ): + "This object provides an API interface for pygame calls to the new toolbars" + def __init__(self, activity_toolbar, horizontal_toolbar, vertical_toolbar, scene_toolbar): + self.horizontal_toolbar = horizontal_toolbar + self.vertical_toolbar = vertical_toolbar + self.activity_toolbar = activity_toolbar + def deactivate_scene_change(self): + "The music style menu gets frozen when jamming on a network" + stb = self.activity_toolbar.nameID['Music'] + stb.set_sensitive(False) + def reactivate_scene_change(self): + stb = self.activity_toolbar.nameID['Music'] + stb.set_sensitive(True) + def set_horizontal_parameter(self, param): + log.info("set_horizontal_parameter received %s" %param) + self.horizontal_toolbar.set_horizontal_parameter(param) + def set_vertical_parameter(self, param): + log.info("set_vertical_parameter received %s" %param) + self.vertical_toolbar.set_vertical_parameter(param) + + +#should probably tidy these toolbars up. Subclass them. +class Jam2JamActivityToolbar( gtk.Toolbar ): + def __init__(self, activity): + log.info('entering __init__ in Jam2JamActivityToolbar') + self.toolbar_box = ToolbarBox() + log.info('made the activity toolbar_box') + self.activity = activity + activity_button = AltButton(activity) + log.info ('made the ALT BUTTON') + self.toolbar_box.toolbar.insert(activity_button, 0) + activity_button.show() + self.nameID = {} + + def addCallback(self, func): + "used to add a callback function to buttons, make sure you do this before trying to add the button" + result = types.MethodType(func, self) + self.__setattr__(func.__name__, result) + + def addToolBarButton(self, nameID, icon_name, toolbar=None): + "I wonder if this can be merged with the ad button below?" + button = ToolbarButton( + page=toolbar, + icon_name=icon_name) + self.toolbar_box.toolbar.insert(button, -1) + button.show() + toolbar.show() + self.nameID.update({nameID:button}) + + def addSeparator(self): + separator = gtk.SeparatorToolItem() + separator.set_draw(True) + separator.show() + self.toolbar_box.toolbar.insert(separator, -1) + + def addButton(self, nameID, image1path, image2path, tooltip1, tooltip2, cb): + button = ToolButton() + log.info("addButtonIMAGE PATH ____ " + image1path ) + button.image1 = gtk.Image() + button.image1.set_from_file(image1path) + button.image2 = gtk.Image() + button.image2.set_from_file(image2path) + button.image1.show() + button.tooltip1, button.tooltip2 = tooltip1, tooltip2 + button.set_icon_widget(button.image1) + button.connect('clicked', cb) + button.set_tooltip(_(button.tooltip1)) + button.nameID = nameID + self.toolbar_box.toolbar.insert(button, -1) + button.show() + self.nameID.update({nameID:button}) + + def addStopButton(self): + separator = gtk.SeparatorToolItem() + separator.props.draw = False + separator.set_expand(True) + separator.show() + self.toolbar_box.toolbar.insert(separator, -1) + stop_button = StopButton(self.activity) + stop_button.props.accelerator = 'Q' + self.toolbar_box.toolbar.insert(stop_button, -1) + stop_button.show() + + def getToolItem(self, nameID): + return self.nameID[nameID] + + def play_pause_cb(self, button): + if self.activity.play_pause_state == "Playing": + self.activity.jamScene.music_player.pause() + button.image2.show() + button.set_icon_widget(button.image2) + button.set_tooltip(_('Play')) + self.activity.play_pause_state = "Paused" + else: + self.activity.jamScene.music_player.resume() + button.image1.show() + button.set_icon_widget(button.image1) + button.set_tooltip(_('Pause')) + self.activity.play_pause_state = "Playing" + try: + self.activity._pgc.grab_focus() + except AttributeError: + pass + + def camera_cb(self, button): + "Here I could wrap a camera event..." + if not hasattr(self, 'camera_ready'): self.camera_ready = True + def show_busy_camera(button): + self.camera_ready = False + button.image2.show() + button.set_icon_widget(button.image2) + button.set_tooltip(_('Please wait...')) + def show_active_camera(button): + button.image1.show() + button.set_icon_widget(button.image1) + button.set_tooltip(_('Snap')) + self.camera_ready = True + def snaptime(button): + snap = CameraSnap() + self.activity.cameras_loaded.append(snap) + picpath = snap.Snap() + self.activity.load_image(picpath) + snap.Stop() + show_active_camera(button) + self.activity._pgc.grab_focus() + if self.camera_ready: + show_busy_camera(button) + thread.start_new_thread(snaptime, (button,)) + else: + log.info('Ignoring request to use camera, as camera is currently busy') + + +class Jam2JamParameterToolbar(gtk.Toolbar): + def __init__(self, activity): + gtk.Toolbar.__init__(self) + self.activity = activity + self.parameters = ['Pitch', 'Timbre', 'Density', 'Volume', 'Length'] # no tempo here yet. + self.scene_init = True + self.activeButton = None + + def addButton(self, nameID, image1path, image2path, tooltip1, tooltip2, cb): + button = ToolButton() + button.image1 = gtk.Image() + button.image1.set_from_file(image1path) + button.image2 = gtk.Image() + button.image2.set_from_file(image2path) + button.image1.show() + button.nameID = nameID + button.tooltip1, button.tooltip2 = tooltip1, tooltip2 + button.set_icon_widget(button.image1) + button.connect('clicked', cb) + button.set_tooltip(_(button.tooltip1)) + button.active = False + self.insert(button, -1) + button.show() + return button + + def toggleButtonIcon(self, button): + if button.active: + button.image1.show() + button.set_icon_widget(button.image1) + button.set_tooltip(_(button.tooltip1)) + button.active = False + else: + button.image2.show() + button.set_icon_widget(button.image2) + button.set_tooltip(_(button.tooltip2)) + button.active = True + + + def addSeparator(self): + separator = gtk.SeparatorToolItem() + separator.set_draw(True) + separator.show() + self.insert(separator, -1) + + def set_horizontal_parameter(self, param): + buttons = self.get_children() + for b in buttons: + if b.nameID == param: + self.set_horizontal_cb(b) + break + else: + raise TypeError('%s keystroke is not a recognised parameter' %param) + + def set_horizontal_cb(self, button): + log.info('button pressed - %s' %button.nameID) + if self.activeButton: self.toggleButtonIcon(self.activeButton) + self.activeButton = button + self.toggleButtonIcon(self.activeButton) + param = "Parameter|Horizontal|" + button.nameID + olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=param)) + try: + self.activity._pgc.grab_focus() + except AttributeError: + pass + + def set_vertical_parameter(self, param): + buttons = self.get_children() + for b in buttons: + if b.nameID == param: + self.set_vertical_cb(b) + break + else: + raise TypeError('%s keystroke is not a recognised parameter' %param) + + def set_vertical_cb(self, button): + log.info('button pressed - %s' %button.nameID) + if self.activeButton: self.toggleButtonIcon(self.activeButton) + self.activeButton = button + self.toggleButtonIcon(self.activeButton) + param = "Parameter|Vertical|" + button.nameID + olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=param)) + try: + self.activity._pgc.grab_focus() + except AttributeError: + pass + + +class Jam2JamSceneToolbar(gtk.Toolbar): + "Toolbar which sets musicl styles" + def __init__(self, activity): + gtk.Toolbar.__init__(self) + self.activity = activity + scene_stuff = readScenes(self.activity._ScenePath) + self.scenes = scene_stuff.get_scene_list() + log.info("SCENE DATA IS %s" %self.scenes) + #format of self.scenes + #self.scenes = [['City', 'A', 'minor pentatonic'], ['City', 'G#', 'major']] #this data is read from file + self.play_pause_state = 'Playing' + self.activeButton = None + #self.scene_init = True + + def addButton(self, nameID, image1path, image2path, tooltip1, tooltip2, cb): + button = ToolButton() + button.image1 = gtk.Image() + button.image1.set_from_file(image1path) + button.image2 = gtk.Image() + button.image2.set_from_file(image2path) + button.image1.show() + button.nameID = nameID + button.tooltip1, button.tooltip2 = tooltip1, tooltip2 + button.set_icon_widget(button.image1) + button.connect('clicked', cb) + button.set_tooltip(_(button.tooltip1)) + button.active = False + self.insert(button, -1) + button.show() + return button + + def toggleButtonIcon(self, button): + if button.active: + button.image1.show() + button.set_icon_widget(button.image1) + button.set_tooltip(_(button.tooltip1)) + button.active = False + else: + button.image2.show() + button.set_icon_widget(button.image2) + button.set_tooltip(_(button.tooltip2)) + button.active = True + + def _get_scene_data(self, button): + button_name = button.nameID + for item in self.scenes: + if item[0] == button_name: return item + else: + raise IOError('could not match button name %s to scene data %s' %(button_name, self.scenes)) + + def scene_change_cb(self, button): + log.info("scene change requested: %s" %button.nameID) + if self.activeButton: self.toggleButtonIcon(self.activeButton) + self.activeButton = button + self.toggleButtonIcon(self.activeButton) + selection = self._get_scene_data(button) + #Scene message should look like this: "Reload|name|key:mode|tempo|defaults" + scene = "Reload|" + '|'.join(map(lambda x: str(x), selection)) + olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=scene)) + try: + self.activity._pgc.grab_focus() + except AttributeError: + pass + + def addSeparator(self): + separator = gtk.SeparatorToolItem() + separator.set_draw(True) + separator.show() + self.insert(separator, -1) + diff --git a/MANIFEST b/MANIFEST index c91c5a1..b84da94 100644..100755 --- a/MANIFEST +++ b/MANIFEST @@ -1,175 +1,207 @@ -activity.py InstrumentPanel.py -J2JToolbar.py -run.py setup.py +J2JToolbars.py +mybutton.py +activity.py +run.py arrow40b-mask.xbm arrow40b.xbm -MANIFEST.in POTFILES.in +MANIFEST.in NEWS README COPYING activity/activity.svg activity/activity.info -City/__init__.py City/City.py -City/CsHelpers.py +City/Tracks.py +City/OrcBuilder.py City/CsSched.py City/midiImport.py -City/OrcBuilder.py City/Parameters.py City/setup.py -City/Tracks.py -City/Scenes/Reggae/AudioFiles/LeadAudio/B2_guitar.aif -City/Scenes/Reggae/AudioFiles/LeadAudio/B3_guitar.aif +City/CsHelpers.py +City/__init__.py +City/Scenes/City/AudioFiles/LeadAudio/keys-good[52-60-63]_001_001mn_000.aif +City/Scenes/City/AudioFiles/LeadAudio/keys-good[88-96-99]_001_001mn_000.aif +City/Scenes/City/AudioFiles/LeadAudio/keys-good[76-84-87]_001_001mn_000.aif +City/Scenes/City/AudioFiles/LeadAudio/keys-good[28-36-39]_001_001mn_000.aif +City/Scenes/City/AudioFiles/LeadAudio/keys-good[40-48-51]_001_001mn_000.aif +City/Scenes/City/AudioFiles/LeadAudio/keys-good[64-72-75]_001_001mn_000.aif +City/Scenes/City/AudioFiles/BassAudio/Dance1Bass[52-60-63]mn_000.aif +City/Scenes/City/AudioFiles/BassAudio/Dance1Bass[28-36-39]mn_000.aif +City/Scenes/City/AudioFiles/BassAudio/Dance1Bass[40-48-51]mn_000.aif +City/Scenes/City/AudioFiles/DrumsAudio/Dance1openedhat4[42-42-42].aif +City/Scenes/City/AudioFiles/DrumsAudio/Dance1909snare3[38-38-38].aif +City/Scenes/City/AudioFiles/DrumsAudio/Dance1909kick7[36-36-36].aif +City/Scenes/City/AudioFiles/DrumsAudio/Dance1closedhat11[39-39-39].aif +City/Scenes/City/AudioFiles/DrumsAudio/Dance1SHAKER_1[46-46-46].aif +City/Scenes/City/AudioFiles/ChordsAudio/Dance1Pad[64-72-75]mn_000.aif +City/Scenes/City/AudioFiles/ChordsAudio/Dance1Pad[88-96-99]mn_000.aif +City/Scenes/City/AudioFiles/ChordsAudio/Dance1Pad[76-84-87]mn_000.aif +City/Scenes/City/AudioFiles/ChordsAudio/Dance1Pad[100-108-111]mn_000.aif +City/Scenes/Country/AudioFiles/LeadAudio/E2_guitar.aif +City/Scenes/Country/AudioFiles/LeadAudio/E5_guitar.aif +City/Scenes/Country/AudioFiles/LeadAudio/E3_guitar.aif +City/Scenes/Country/AudioFiles/LeadAudio/B2_guitar.aif +City/Scenes/Country/AudioFiles/LeadAudio/E4_guitar.aif +City/Scenes/Country/AudioFiles/LeadAudio/B3_guitar.aif +City/Scenes/Country/AudioFiles/BassAudio/BassC4[70-72-78].aif +City/Scenes/Country/AudioFiles/BassAudio/BassF#2[51-54-58].aif +City/Scenes/Country/AudioFiles/BassAudio/BassC2[41-48-50].aif +City/Scenes/Country/AudioFiles/BassAudio/BassC3[59-60-62].aif +City/Scenes/Country/AudioFiles/DrumsAudio/F#1_closed_hi_hat.aif +City/Scenes/Country/AudioFiles/DrumsAudio/D1_snare_drum.aif +City/Scenes/Country/AudioFiles/DrumsAudio/C#1_rim_shot.aif +City/Scenes/Country/AudioFiles/DrumsAudio/C1_kick_drum.aif +City/Scenes/Country/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif +City/Scenes/Country/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif +City/Scenes/Country/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif +City/Scenes/Country/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif +City/Scenes/Blues/AudioFiles/LeadAudio/E2_guitar.aif +City/Scenes/Blues/AudioFiles/LeadAudio/E5_guitar.aif +City/Scenes/Blues/AudioFiles/LeadAudio/E3_guitar.aif +City/Scenes/Blues/AudioFiles/LeadAudio/B2_guitar.aif +City/Scenes/Blues/AudioFiles/LeadAudio/E4_guitar.aif +City/Scenes/Blues/AudioFiles/LeadAudio/B3_guitar.aif +City/Scenes/Blues/AudioFiles/BassAudio/BassC4[70-72-78].aif +City/Scenes/Blues/AudioFiles/BassAudio/BassF#2[51-54-58].aif +City/Scenes/Blues/AudioFiles/BassAudio/BassC2[41-48-50].aif +City/Scenes/Blues/AudioFiles/BassAudio/BassC3[59-60-62].aif +City/Scenes/Blues/AudioFiles/DrumsAudio/F#1_closed_hi_hat.aif +City/Scenes/Blues/AudioFiles/DrumsAudio/Tamborine 22 16 Mono.aif +City/Scenes/Blues/AudioFiles/DrumsAudio/D1_snare_drum.aif +City/Scenes/Blues/AudioFiles/DrumsAudio/C1_kick_drum.aif +City/Scenes/Blues/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif +City/Scenes/Blues/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif +City/Scenes/Blues/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif +City/Scenes/Blues/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif City/Scenes/Reggae/AudioFiles/LeadAudio/E2_guitar.aif +City/Scenes/Reggae/AudioFiles/LeadAudio/E5_guitar.aif City/Scenes/Reggae/AudioFiles/LeadAudio/E3_guitar.aif +City/Scenes/Reggae/AudioFiles/LeadAudio/B2_guitar.aif City/Scenes/Reggae/AudioFiles/LeadAudio/E4_guitar.aif -City/Scenes/Reggae/AudioFiles/LeadAudio/E5_guitar.aif +City/Scenes/Reggae/AudioFiles/LeadAudio/B3_guitar.aif +City/Scenes/Reggae/AudioFiles/BassAudio/BassC4[70-72-78].aif +City/Scenes/Reggae/AudioFiles/BassAudio/BassF#2[51-54-58].aif +City/Scenes/Reggae/AudioFiles/BassAudio/BassC2[41-48-50].aif +City/Scenes/Reggae/AudioFiles/BassAudio/BassC3[59-60-62].aif City/Scenes/Reggae/AudioFiles/DrumsAudio/ClosedhatF#1.aif -City/Scenes/Reggae/AudioFiles/DrumsAudio/Kick-C1.aif City/Scenes/Reggae/AudioFiles/DrumsAudio/OpenhatA#1.aif -City/Scenes/Reggae/AudioFiles/DrumsAudio/Snare-D1.aif City/Scenes/Reggae/AudioFiles/DrumsAudio/TambF#2.aif -City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif -City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif +City/Scenes/Reggae/AudioFiles/DrumsAudio/Kick-C1.aif +City/Scenes/Reggae/AudioFiles/DrumsAudio/Snare-D1.aif City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif -City/Scenes/Reggae/AudioFiles/BassAudio/BassC2[41-48-50].aif -City/Scenes/Reggae/AudioFiles/BassAudio/BassC3[59-60-62].aif -City/Scenes/Reggae/AudioFiles/BassAudio/BassC4[70-72-78].aif -City/Scenes/Reggae/AudioFiles/BassAudio/BassF#2[51-54-58].aif +City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif +City/Scenes/Reggae/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets A4 22 16 mono.aif -City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets C4 22 16 mono.aif City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets E3 22 16 mono.aif City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets F4 22 16 mono.aif City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets G3 22 16 mono.aif -City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo C#3 22 16 Mono.aif -City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo C3 22 16 Mono.aif -City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo D3 22 16 Mono.aif +City/Scenes/Latin/AudioFiles/LeadAudio/Trumpets C4 22 16 mono.aif +City/Scenes/Latin/AudioFiles/BassAudio/BassC4[70-72-78].aif +City/Scenes/Latin/AudioFiles/BassAudio/BassF#2[51-54-58].aif +City/Scenes/Latin/AudioFiles/BassAudio/BassC2[41-48-50].aif +City/Scenes/Latin/AudioFiles/BassAudio/BassC3[59-60-62].aif City/Scenes/Latin/AudioFiles/DrumsAudio/ClosedhatF#1.aif +City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo C3 22 16 Mono.aif +City/Scenes/Latin/AudioFiles/DrumsAudio/TambF#2.aif City/Scenes/Latin/AudioFiles/DrumsAudio/Kick-C1.aif +City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo D3 22 16 Mono.aif City/Scenes/Latin/AudioFiles/DrumsAudio/Shaker 22 16 Mono.aif +City/Scenes/Latin/AudioFiles/DrumsAudio/Bongo C#3 22 16 Mono.aif City/Scenes/Latin/AudioFiles/DrumsAudio/Snare-D1.aif -City/Scenes/Latin/AudioFiles/DrumsAudio/TambF#2.aif City/Scenes/Latin/AudioFiles/ChordsAudio/Organ C4 22 16 mono.aif -City/Scenes/Latin/AudioFiles/ChordsAudio/Organ C5 22 16 mono.aif City/Scenes/Latin/AudioFiles/ChordsAudio/Organ G3 22 16 mono.aif City/Scenes/Latin/AudioFiles/ChordsAudio/Organ G4 22 16 mono.aif -City/Scenes/Latin/AudioFiles/BassAudio/BassC2[41-48-50].aif -City/Scenes/Latin/AudioFiles/BassAudio/BassC3[59-60-62].aif -City/Scenes/Latin/AudioFiles/BassAudio/BassC4[70-72-78].aif -City/Scenes/Latin/AudioFiles/BassAudio/BassF#2[51-54-58].aif -City/Scenes/Country/AudioFiles/LeadAudio/B2_guitar.aif -City/Scenes/Country/AudioFiles/LeadAudio/B3_guitar.aif -City/Scenes/Country/AudioFiles/LeadAudio/E2_guitar.aif -City/Scenes/Country/AudioFiles/LeadAudio/E3_guitar.aif -City/Scenes/Country/AudioFiles/LeadAudio/E4_guitar.aif -City/Scenes/Country/AudioFiles/LeadAudio/E5_guitar.aif -City/Scenes/Country/AudioFiles/DrumsAudio/C#1_rim_shot.aif -City/Scenes/Country/AudioFiles/DrumsAudio/C1_kick_drum.aif -City/Scenes/Country/AudioFiles/DrumsAudio/D1_snare_drum.aif -City/Scenes/Country/AudioFiles/DrumsAudio/F#1_closed_hi_hat.aif -City/Scenes/Country/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif -City/Scenes/Country/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif -City/Scenes/Country/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif -City/Scenes/Country/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif -City/Scenes/Country/AudioFiles/BassAudio/BassC2[41-48-50].aif -City/Scenes/Country/AudioFiles/BassAudio/BassC3[59-60-62].aif -City/Scenes/Country/AudioFiles/BassAudio/BassC4[70-72-78].aif -City/Scenes/Country/AudioFiles/BassAudio/BassF#2[51-54-58].aif -City/Scenes/City/AudioFiles/LeadAudio/keys-good[28-36-39]_001_001mn_000.aif -City/Scenes/City/AudioFiles/LeadAudio/keys-good[40-48-51]_001_001mn_000.aif -City/Scenes/City/AudioFiles/LeadAudio/keys-good[52-60-63]_001_001mn_000.aif -City/Scenes/City/AudioFiles/LeadAudio/keys-good[64-72-75]_001_001mn_000.aif -City/Scenes/City/AudioFiles/LeadAudio/keys-good[76-84-87]_001_001mn_000.aif -City/Scenes/City/AudioFiles/LeadAudio/keys-good[88-96-99]_001_001mn_000.aif -City/Scenes/City/AudioFiles/DrumsAudio/Dance1909kick7[36-36-36].aif -City/Scenes/City/AudioFiles/DrumsAudio/Dance1909snare3[38-38-38].aif -City/Scenes/City/AudioFiles/DrumsAudio/Dance1closedhat11[39-39-39].aif -City/Scenes/City/AudioFiles/DrumsAudio/Dance1openedhat4[42-42-42].aif -City/Scenes/City/AudioFiles/DrumsAudio/Dance1SHAKER_1[46-46-46].aif -City/Scenes/City/AudioFiles/ChordsAudio/Dance1Pad[100-108-111]mn_000.aif -City/Scenes/City/AudioFiles/ChordsAudio/Dance1Pad[64-72-75]mn_000.aif -City/Scenes/City/AudioFiles/ChordsAudio/Dance1Pad[76-84-87]mn_000.aif -City/Scenes/City/AudioFiles/ChordsAudio/Dance1Pad[88-96-99]mn_000.aif -City/Scenes/City/AudioFiles/BassAudio/Dance1Bass[28-36-39]mn_000.aif -City/Scenes/City/AudioFiles/BassAudio/Dance1Bass[40-48-51]mn_000.aif -City/Scenes/City/AudioFiles/BassAudio/Dance1Bass[52-60-63]mn_000.aif -City/Scenes/Blues/AudioFiles/LeadAudio/B2_guitar.aif -City/Scenes/Blues/AudioFiles/LeadAudio/B3_guitar.aif -City/Scenes/Blues/AudioFiles/LeadAudio/E2_guitar.aif -City/Scenes/Blues/AudioFiles/LeadAudio/E3_guitar.aif -City/Scenes/Blues/AudioFiles/LeadAudio/E4_guitar.aif -City/Scenes/Blues/AudioFiles/LeadAudio/E5_guitar.aif -City/Scenes/Blues/AudioFiles/DrumsAudio/C1_kick_drum.aif -City/Scenes/Blues/AudioFiles/DrumsAudio/D1_snare_drum.aif -City/Scenes/Blues/AudioFiles/DrumsAudio/F#1_closed_hi_hat.aif -City/Scenes/Blues/AudioFiles/DrumsAudio/Tamborine 22 16 Mono.aif -City/Scenes/Blues/AudioFiles/ChordsAudio/epnoC4[70-72-73].aif -City/Scenes/Blues/AudioFiles/ChordsAudio/epnoC5[82-84-90].aif -City/Scenes/Blues/AudioFiles/ChordsAudio/epnoE3[63-64-65].aif -City/Scenes/Blues/AudioFiles/ChordsAudio/epnoE4[74-76-77].aif -City/Scenes/Blues/AudioFiles/BassAudio/BassC2[41-48-50].aif -City/Scenes/Blues/AudioFiles/BassAudio/BassC3[59-60-62].aif -City/Scenes/Blues/AudioFiles/BassAudio/BassC4[70-72-78].aif -City/Scenes/Blues/AudioFiles/BassAudio/BassF#2[51-54-58].aif -City/Scenes/Reggae/MidiFiles/Bass.mid -City/Scenes/Reggae/MidiFiles/Chords.mid -City/Scenes/Reggae/MidiFiles/Drums.mid -City/Scenes/Reggae/MidiFiles/Lead.mid -City/Scenes/Latin/MidiFiles/Bass.mid -City/Scenes/Latin/MidiFiles/Chords.mid -City/Scenes/Latin/MidiFiles/Drums.mid -City/Scenes/Latin/MidiFiles/Lead.mid -City/Scenes/Country/MidiFiles/Bass.mid -City/Scenes/Country/MidiFiles/Chords.mid -City/Scenes/Country/MidiFiles/Drums.mid -City/Scenes/Country/MidiFiles/Lead.mid -City/Scenes/City/MidiFiles/Bass.mid +City/Scenes/Latin/AudioFiles/ChordsAudio/Organ C5 22 16 mono.aif +City/Scenes/City/MidiFiles/Lead.mid City/Scenes/City/MidiFiles/Chords.mid +City/Scenes/City/MidiFiles/Bass.mid City/Scenes/City/MidiFiles/Drums.mid -City/Scenes/City/MidiFiles/Lead.mid -City/Scenes/Blues/MidiFiles/Bass.mid +City/Scenes/Country/MidiFiles/Lead.mid +City/Scenes/Country/MidiFiles/Chords.mid +City/Scenes/Country/MidiFiles/Bass.mid +City/Scenes/Country/MidiFiles/Drums.mid +City/Scenes/Blues/MidiFiles/Lead.mid City/Scenes/Blues/MidiFiles/Chords.mid +City/Scenes/Blues/MidiFiles/Bass.mid City/Scenes/Blues/MidiFiles/Drums.mid -City/Scenes/Blues/MidiFiles/Lead.mid -City/Images/Bass.png -City/Images/Chords.png +City/Scenes/Reggae/MidiFiles/Lead.mid +City/Scenes/Reggae/MidiFiles/Chords.mid +City/Scenes/Reggae/MidiFiles/Bass.mid +City/Scenes/Reggae/MidiFiles/Drums.mid +City/Scenes/Latin/MidiFiles/Lead.mid +City/Scenes/Latin/MidiFiles/Chords.mid +City/Scenes/Latin/MidiFiles/Bass.mid +City/Scenes/Latin/MidiFiles/Drums.mid +City/Images/jam2jamXO_4.png City/Images/Drums.png -City/Images/jam2jamXO_2.png +City/Images/Video.png City/Images/Lead.png +City/Images/Bass.png City/Images/Mic.png -City/Images/Video.png -City/Images/camera-busy.svg +City/Images/jam2jamXO_2.png +City/Images/Chords.png +City/Images/density1.svg +City/Images/country1.svg +City/Images/length1.svg +City/Images/timbre1.svg +City/Images/pitch1.svg +City/Images/timbre2.svg +City/Images/reggae1.svg City/Images/camera-external.svg -City/Images/media-playback-pause.svg +City/Images/latin2.svg +City/Images/city1.svg +City/Images/city2.svg +City/Images/blues1.svg +City/Images/country2.svg City/Images/media-playback-start.svg -City/Scenes/Reggae/Reggae_Data.txt -City/Scenes/Latin/Latin_Data.txt -City/Scenes/Country/Country_Data.txt +City/Images/camera-busy.svg +City/Images/volume1.svg +City/Images/density2.svg +City/Images/pitch2.svg +City/Images/reggae2.svg +City/Images/length2.svg +City/Images/latin1.svg +City/Images/volume2.svg +City/Images/media-playback-pause.svg +City/Images/blues2.svg City/Scenes/City/City_Data.txt +City/Scenes/Country/Country_Data.txt City/Scenes/Blues/Blues_Data.txt +City/Scenes/Reggae/Reggae_Data.txt +City/Scenes/Latin/Latin_Data.txt +icons/music2.svg +icons/Latin-edit1.svg +icons/city-edit2.svg +icons/vertical5.svg +icons/Reggae-edit1.svg +icons/music.svg +icons/city-edit1.svg +icons/Country-edit1.svg +icons/horizontal5.svg po/POTFILES.in +po/Jam2Jam.pot olpcgames/COPYING -olpcgames/__init__.py -olpcgames/_cairoimage.py -olpcgames/_gtkmain.py -olpcgames/_version.py -olpcgames/activity.py -olpcgames/buildmanifest.py -olpcgames/camera.py -olpcgames/canvas.py -olpcgames/dbusproxy.py -olpcgames/eventwrap.py -olpcgames/gtkEvent.py -olpcgames/mesh.py -olpcgames/pangofont.py -olpcgames/pausescreen.py olpcgames/svgsprite.py olpcgames/textsprite.py olpcgames/util.py +olpcgames/pausescreen.py +olpcgames/dbusproxy.py +olpcgames/_version.py +olpcgames/_gtkmain.py +olpcgames/canvas.py olpcgames/video.py +olpcgames/mesh.py +olpcgames/pangofont.py +olpcgames/camera.py +olpcgames/gtkEvent.py +olpcgames/_cairoimage.py +olpcgames/eventwrap.py +olpcgames/activity.py +olpcgames/__init__.py +olpcgames/buildmanifest.py +olpcgames/data/sleeping_svg.py olpcgames/data/__init__.py -olpcgames/data/sleeping_svg.py \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index 5b14813..986a838 100755 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,7 @@ include *.py *.xbm *.in NEWS README COPYING recursive-include activity *.svg *.info recursive-include City *.py *.aif *.mid *.png *.svg *.txt +recursive-include icons *.svg include po/POTFILES.in include olpcgames/COPYING recursive-include olpcgames *.py diff --git a/README b/README index 840bff8..840bff8 100644..100755 --- a/README +++ b/README diff --git a/activity.py b/activity.py index 63b031a..033c694 100755 --- a/activity.py +++ b/activity.py @@ -1,6 +1,6 @@ -#This python module is part of the Jam2Jam XO Activity, March, 2010 +#This python module is part of the Jam2Jam XO Activity, March, 2012 # -#Copyright (C) 2010 Thorin Kerr & Andrew Brown +#Copyright (C) 2012 Thorin Kerr & Andrew Brown # #This program is free software; you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by @@ -16,36 +16,51 @@ #along with this program; if not, write to the Free Software #Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -import pygame -import olpcgames -from sugar.graphics.toolbutton import ToolButton -import sugar.activity -from sugar.activity.activity import Activity, ActivityToolbox + +import pygame, olpcgames from olpcgames import activity -from J2JToolbar import Jam2JamToolBar +import sugar.activity +from sugar.activity.activity import get_bundle_path +ImagePath = get_bundle_path() + "/City/Images" + + +import gtk.gdk from gettext import gettext as _ import logging, os log = logging.getLogger( 'City run' ) log.setLevel( logging.DEBUG ) - log.info( """ LOG From activity.py!!""") from olpcgames import mesh, util +_NEW_TOOLBAR_SUPPORT = True + +try: + from sugar.graphics.toolbarbox import ToolbarBox #superfluous import here, but we need to detect sugar versions post 0.86 + from J2JToolbars import J2J_Toolbar_Redirect + from J2JToolbars import Jam2JamActivityToolbar, Jam2JamParameterToolbar, Jam2JamSceneToolbar +except: + _NEW_TOOLBAR_SUPPORT = False + from sugar.activity.activity import ActivityToolbox + from J2JToolbars import Jam2JamToolBar #NOW ONLY GETS IMPORTED WHEN OLD TOOLBARS ARE USED + + class Activity(activity.PyGameActivity): """Your Sugar activity""" game_name = 'run:main' game_title = _('Jam2Jam') game_size = None - _ScenePath = (os.path.dirname(os.path.abspath(__file__)) + "/City/Scenes") + _ScenePath = (get_bundle_path() + "/City/Scenes") def __init__(self, handle): + self.handle = handle activity.PyGameActivity.__init__(self, handle) self.snap_store = [] self.cameras_loaded = [] self.playArea = None self.jamScene = None + self.play_pause_state = 'Playing' def load_image(self, picpath): picsurf = pygame.image.load(picpath) @@ -53,52 +68,123 @@ class Activity(activity.PyGameActivity): picsurfwidth = picsurf.get_width() destwidth = self.playArea.width scale = float(destwidth) / picsurfwidth - newarea = (picsurfwidth * scale, picsurf.get_height() * scale) + newarea = (int(picsurfwidth * scale), int(picsurf.get_height() * scale)) picsurf = pygame.transform.scale(picsurf, newarea) self.snap_store.append(picsurf) - def build_toolbar(self): - log.info ("building toolbar") + if _NEW_TOOLBAR_SUPPORT: + log.info("building NEW toolbar\n") + return self.build_new_toolbar() + else: + log.info("buiding OLD toolbar \n") + return self.build_old_toolbar() + def build_old_toolbar(self): toolbox = ActivityToolbox(self) - #remove the 'keep' button. We've no need to save data at the moment. activityToolbar = toolbox.get_activity_toolbar() activityToolbar.keep.props.visible = False self.J2JToolbar = Jam2JamToolBar(self) + toolbox.add_toolbar("Transform", self.J2JToolbar) self.set_toolbox(toolbox) self.J2JToolbar.show() toolbox.show() + self.toolbox.set_current_toolbar(1) - def shared_cb(*args, **kwargs): - log.info( 'Shared CB: %s, %s', args, kwargs ) - try: - mesh.activity_shared(self) - except Exception, err: - log.error( """Failure signaling activity sharing to mesh module: %s""", util.get_traceback(err) ) - else: - log.info( 'mesh activity shared message sent, trying to grab focus' ) - try: - self._pgc.grab_focus() - except Exception, err: - log.warn( 'Focus failed: %s', err ) - else: - log.info( 'asserting focus' ) - assert self._pgc.is_focus(), """Did not successfully set pygame canvas focus""" - sharermessage = "Shared:StartBeat" - olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=sharermessage)) - log.info( 'callback finished' ) - def joined_cb(*args, **kwargs): - log.info( 'joined CB: %s, %s', args, kwargs ) - mesh.activity_joined(self) - self._pgc.grab_focus() - joinedmessage = "Joined:CeasePlayer" - olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=joinedmessage)) - self.connect("shared", shared_cb) - self.connect("joined", joined_cb) + + self.connect("shared", self.shared_cb) + self.connect("joined", self.joined_cb) + if self.get_shared(): - joined_cb() + self.joined_cb() log.info ("FINISHED building toolbar") return toolbox + def build_new_toolbar(self): + log.info ("building new toolbar") + + activity_toolbar = Jam2JamActivityToolbar(self) + Horizontal_Toolbar = Jam2JamParameterToolbar(self) + Vertical_Toolbar = Jam2JamParameterToolbar(self) + Scene_Toolbar = Jam2JamSceneToolbar(self) + self.J2JToolbar = J2J_Toolbar_Redirect(activity_toolbar, Horizontal_Toolbar, Vertical_Toolbar, Scene_Toolbar) #the pygame interface + + + activity_toolbar.addToolBarButton("Horizontal", "horizontal5", Horizontal_Toolbar) + + activity_toolbar.addToolBarButton("Vertical", "vertical5", Vertical_Toolbar) + activity_toolbar.addSeparator() + activity_toolbar.addToolBarButton("Music", "music2", Scene_Toolbar) + activity_toolbar.addSeparator() + + activity_toolbar.addButton('Camera', + ImagePath + "/camera-external.svg", + ImagePath + "/camera-busy.svg", + "Take a picture", "processing, please wait", + activity_toolbar.camera_cb) + + activity_toolbar.addButton('PlayPause', + ImagePath + "/media-playback-pause.svg", + ImagePath + "/media-playback-start.svg", + "Pause", "Play", + activity_toolbar.play_pause_cb) + activity_toolbar.addStopButton() + parameters = ['Pitch', 'Timbre', 'Density', 'Volume', 'Length'] + + for p in parameters: + h = Horizontal_Toolbar.addButton(p, + ImagePath + "/" + p.lower() + "1.svg", + ImagePath + "/" + p.lower() + "2.svg", + p, p + "-active", + Horizontal_Toolbar.set_horizontal_cb) + v = Vertical_Toolbar.addButton(p, + ImagePath + "/" + p.lower() + "1.svg", + ImagePath + "/" + p.lower() + "2.svg", + p, p + "-active", + Vertical_Toolbar.set_vertical_cb) + if p == 'Density': Horizontal_Toolbar.set_horizontal_cb(h) + if p == 'Pitch': Vertical_Toolbar.set_horizontal_cb(v) + Horizontal_Toolbar.show() + Vertical_Toolbar.show() + + scenes = ['City', 'Country', 'Latin', 'Blues', 'Reggae'] + for s in scenes: + bs = Scene_Toolbar.addButton(s, ImagePath + "/" + s.lower() + "1.svg", + ImagePath + "/" + s.lower() + "2.svg", + s, s + "-active", + Scene_Toolbar.scene_change_cb) + if s == 'City': Scene_Toolbar.scene_change_cb(bs) + + self.connect("shared", self.shared_cb) + self.connect("joined", self.joined_cb) + if self.get_shared(): self.joined_cb() + + self.set_toolbar_box(activity_toolbar.toolbar_box) + activity_toolbar.toolbar_box.show() + vpb = activity_toolbar.nameID['Horizontal'] + vpb.set_expanded(True) + return activity_toolbar.toolbar_box + + def shared_cb(self, *args, **kwargs): + log.info( 'Shared CB: %s, %s', args, kwargs ) + try: + mesh.activity_shared(self) + except Exception, err: + log.error( """Failure signaling activity sharing to mesh module: %s""", util.get_traceback(err) ) + else: + log.info( 'mesh activity shared message sent' ) + try: + self._pgc.grab_focus() + except Exception, err: + log.warn( 'Focus failed: %s', err ) + else: + assert self._pgc.is_focus(), """Did not successfully set pygame canvas focus""" + sharermessage = "Shared:StartBeat" + olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=sharermessage)) + def joined_cb(self, *args, **kwargs): + log.info( 'joined CB: %s, %s', args, kwargs ) + mesh.activity_joined(self) + self._pgc.grab_focus() + joinedmessage = "Joined:CeasePlayer" + olpcgames.eventwrap.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action=joinedmessage)) diff --git a/activity/activity.info b/activity/activity.info index db379ba..2e29860 100755 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,6 +1,6 @@ [Activity] name = Jam2Jam -activity_version = 3 +activity_version = 4 host_version = 1 bundle_id = au.net.acid.Jam2Jam1 icon = activity diff --git a/icons/Country-edit1.svg b/icons/Country-edit1.svg new file mode 100755 index 0000000..1c98784 --- /dev/null +++ b/icons/Country-edit1.svg @@ -0,0 +1,33 @@ + + + + + + +]> + + + + + + + diff --git a/icons/Latin-edit1.svg b/icons/Latin-edit1.svg new file mode 100755 index 0000000..891929b --- /dev/null +++ b/icons/Latin-edit1.svg @@ -0,0 +1,1330 @@ + + + + + + +]> + + + + + + style="fill:&fill_color;;fill:&fill_color;; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/icons/Reggae-edit1.svg b/icons/Reggae-edit1.svg new file mode 100755 index 0000000..c29d374 --- /dev/null +++ b/icons/Reggae-edit1.svg @@ -0,0 +1,109 @@ + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/city-edit1.svg b/icons/city-edit1.svg new file mode 100755 index 0000000..ce9f220 --- /dev/null +++ b/icons/city-edit1.svg @@ -0,0 +1,158 @@ + + + + + +]> + + Buildings icon + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/city-edit2.svg b/icons/city-edit2.svg new file mode 100755 index 0000000..350fe42 --- /dev/null +++ b/icons/city-edit2.svg @@ -0,0 +1,158 @@ + + + + + +]> + + Buildings icon + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/horizontal5.svg b/icons/horizontal5.svg new file mode 100755 index 0000000..0e9e93b --- /dev/null +++ b/icons/horizontal5.svg @@ -0,0 +1,20 @@ + + + + + + +]> + + + + + diff --git a/icons/music.svg b/icons/music.svg new file mode 100755 index 0000000..40d90fb --- /dev/null +++ b/icons/music.svg @@ -0,0 +1,10 @@ + + + +]> + + + + + \ No newline at end of file diff --git a/icons/music2.svg b/icons/music2.svg new file mode 100755 index 0000000..e42af64 --- /dev/null +++ b/icons/music2.svg @@ -0,0 +1,20 @@ + + + + + +]> + + + + + + + diff --git a/icons/vertical5.svg b/icons/vertical5.svg new file mode 100755 index 0000000..f889c5f --- /dev/null +++ b/icons/vertical5.svg @@ -0,0 +1,20 @@ + + + + + + +]> + + + + diff --git a/mybutton.py b/mybutton.py new file mode 100755 index 0000000..cabe2ef --- /dev/null +++ b/mybutton.py @@ -0,0 +1,62 @@ +print "HERE IS MYEDITEDBUTTON\n" +import gtk +import gconf + +from sugar.graphics.toolbarbox import ToolbarButton + +from sugar.activity.widgets import ActivityToolbar + +from sugar.graphics.xocolor import XoColor + +from sugar.graphics.icon import Icon + +from sugar.bundle.activitybundle import ActivityBundle + + +def _create_activity_icon(metadata): + print "_create_activity_icon was called" + if metadata.get('icon-color', ''): + color = XoColor(metadata['icon-color']) + else: + client = gconf.client_get_default() + color = XoColor(client.get_string('/desktop/sugar/user/color')) + from sugar.activity.activity import get_bundle_path + print "Where is the bundle path? :", get_bundle_path() + bundle = ActivityBundle(get_bundle_path()) + icon = Icon(file=bundle.get_icon(), xo_color=color) + return icon + + +class AltButton(ToolbarButton): + def __init__(self, activity, **kwargs): + print "alternativeMY ACTIviTy tOOLbARbUTTON init\n" + toolbar = ActivityToolbar(activity, orientation_left=True) + toolbar.stop.hide() + toolbar.keep.hide() + ToolbarButton.__init__(self, page=toolbar,**kwargs) + icon = _create_activity_icon(activity.metadata) + self.set_icon_widget(icon) + icon.show() + + +class test2: + def __init__(self): + print "passed test2, old style class" + + +def test3(x): + print "passed test3, just a function" + + +class MyAlternativeToolbarButton(ToolbarButton): + def __init__(self, activity, **kwargs): + print "MY Alternative tOOLbARbUTTON init\n" + toolbar = ActivityToolbar(activity, orientation_left=True) + toolbar.stop.hide() + toolbar.keep.hide() + ToolbarButton.__init__(self, page=toolbar,**kwargs) + icon = _create_activity_icon(activity.metadata) + self.set_icon_widget(icon) + icon.show() + + diff --git a/po/Jam2Jam.pot b/po/Jam2Jam.pot new file mode 100755 index 0000000..ea26853 --- /dev/null +++ b/po/Jam2Jam.pot @@ -0,0 +1,59 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-06-05 23:09-0700\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: activity/activity.info:2 activity.py:52 +msgid "Jam2Jam" +msgstr "" + +#: J2JToolbars.py:141 +msgid "Horizontal:" +msgstr "" + +#: J2JToolbars.py:156 +msgid "Vertical:" +msgstr "" + +#: J2JToolbars.py:171 +msgid "Scene:" +msgstr "" + +#: J2JToolbars.py:199 +msgid "Snapshot" +msgstr "" + +#: J2JToolbars.py:222 J2JToolbars.py:253 J2JToolbars.py:430 +msgid "Pause" +msgstr "" + +#: J2JToolbars.py:247 J2JToolbars.py:424 +msgid "Play" +msgstr "" + +#: J2JToolbars.py:264 J2JToolbars.py:444 +msgid "Please wait..." +msgstr "" + +#: J2JToolbars.py:269 J2JToolbars.py:448 +msgid "Snap" +msgstr "" + +#: olpcgames/canvas.py:151 +#, python-format +msgid "%s Source" +msgstr "" diff --git a/po/POTFILES.in b/po/POTFILES.in index 79fe2d7..e1b394e 100644..100755 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,5 +1,6 @@ -activity.py InstrumentPanel.py -J2JToolbar.py -run.py -setup.py \ No newline at end of file +setup.py +J2JToolbars.py +mybutton.py +activity.py +run.py \ No newline at end of file diff --git a/run.py b/run.py index 242ad90..9fc17bf 100644..100755 --- a/run.py +++ b/run.py @@ -35,11 +35,13 @@ import City.City as City log = logging.getLogger( 'City run' ) log.setLevel( logging.DEBUG ) + +log.info('PLATFORM = %s' %platform) def buildInstruments(names, imgpath, screensize, scale): "returns a list of Instrument objects, loaded with images" Instruments = [Instrument(names[i]) for i in range(len(names))] imagefiles = ResourceList(imgpath, '.png') - startx = 0 + startx = 30 for i in Instruments: for f in imagefiles: if i.name.startswith(f[:4]): @@ -85,10 +87,12 @@ class jamScene( object ): self._syncloop_running = 0 global schedEvent, now schedEvent = self.scene.TimeQueue.schedEvent - now = self.scene.cs.perfTime - self.screen = screen + now = self.scene.cs.perfTime + self.screen = screen screenRect = screen.get_rect() + print "SCREENRECT IS .........", screenRect self.screenSize = screen.get_size() + print "SCREENSIZE IS ---------", self.screenSize self.playArea = pygame.Rect(screenRect.left,screenRect.top, screenRect.width, screenRect.height * 0.8) if olpcgames.ACTIVITY: olpcgames.ACTIVITY.playArea = self.playArea @@ -128,9 +132,9 @@ class jamScene( object ): self.snap_store = (olpcgames.ACTIVITY.snap_store if platform == 'Sugar' else []) self.feedbackgroundImage = None if self.screenSize == (1200, 780): - self.setbackgroundImage(pygame.image.load(ImagePath + "/jam2jamXO_2.png").convert()) + self.setbackgroundImage(pygame.image.load(ImagePath + "/jam2jamXO_4.png").convert()) else: - bgi = pygame.image.load(ImagePath + "/jam2jamXO_2.png").convert() + bgi = pygame.image.load(ImagePath + "/jam2jamXO_4.png").convert() bgi_scaled = pygame.transform.scale(bgi, self.playArea.size) self.setbackgroundImage(bgi_scaled) self.panel = pygame.Surface((self.panelArea.width, self.panelArea.height)) diff --git a/run.py~ b/run.py~ deleted file mode 100644 index 242ad90..0000000 --- a/run.py~ +++ /dev/null @@ -1,576 +0,0 @@ -#! /usr/bin/env python - -#This python module is part of the Jam2Jam XO Activity, March, 2010 -# -#Copyright (C) 2010 Thorin Kerr & Andrew Brown -# -#This program is free software; you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation; either version 2 of the License, or any -#later version. -# -#This program is distributed in the hope that it will be useful, but -#WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. -# -#You should have received a copy of the GNU General Public License -#along with this program; if not, write to the Free Software -#Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -import subprocess -import logging, olpcgames -import olpcgames.pausescreen as pausescreen -import olpcgames.mesh as mesh -from olpcgames import camera -from sugar.presence import presenceservice -from threading import Timer -from math import ceil, sqrt - - -from City.CsHelpers import * -from City.Parameters import Instrument -import City.City as City - -log = logging.getLogger( 'City run' ) -log.setLevel( logging.DEBUG ) - -def buildInstruments(names, imgpath, screensize, scale): - "returns a list of Instrument objects, loaded with images" - Instruments = [Instrument(names[i]) for i in range(len(names))] - imagefiles = ResourceList(imgpath, '.png') - startx = 0 - for i in Instruments: - for f in imagefiles: - if i.name.startswith(f[:4]): - i.loadImage(ImagePath+'/'+f, scale) - i.x = screensize[0] * 0.8 - startx - i.y = (screensize[1] - i.image.get_size()[1]) * 0.5 - i.Touch = True - startx = startx + (screensize[0] * 0.8) / len(Instruments) - return Instruments - -def getInstrumentParameters(scene, inm): - "return a list of parameters values for the instrument, in order of PNAMES" - pobj = scene.Params - result = [] - for pnm in PNAMES: - result.append(pobj.getValue(pnm, inm)) - return result - -def setInstrumentParameters(scene, inm, vlst): - "sets parameters for an instrument" - pobj = scene.Params - for pnm,val in zip(PNAMES, vlst): - pobj.setValue(pnm, inm, val) - return True - -KEYCODES = {276:"Nudge|Left", 275:"Nudge|Right", 274:"Nudge|Down", 273:"Nudge|Up", - 260:"Nudge|Left", 262:"Nudge|Right", 258:"Nudge|Down", 264:"Nudge|Up", - 263: "Instrument|Bass", 257:"Instrument|Chords", 265:"Instrument|Lead", 259:"Instrument|Drums", - 49: "Instrument|Bass", 50:"Instrument|Chords", 51:"Instrument|Lead", 52:"Instrument|Drums", - 112: "Parameter|Pitch", 118:"Parameter|Volume", 100:"Parameter|Density", 108:"Parameter|Length", 116:"Parameter|Timbre", - 304: "Modifier|Shift"} - - -class jamScene( object ): - def __init__(self, screen, scene = 'City', key = 'A', mode = 'minor', tempo = 120, initial_parameters = {}): - self.scene = City.ScenePlayer(scene, key, mode, tempo, initial_parameters) - self.music_player = City.makePlayer(self.scene) - self.beatEstimator = beatEstimator(self.music_player.tempoMult, 0.17, self.music_player.beatlimit) - self.pending_instrument_assignment = [] - self.latency_counter = 0 - self.latency = [0.07] - self.latency_time_ID = {} - self._syncloop_running = 0 - global schedEvent, now - schedEvent = self.scene.TimeQueue.schedEvent - now = self.scene.cs.perfTime - self.screen = screen - screenRect = screen.get_rect() - self.screenSize = screen.get_size() - self.playArea = pygame.Rect(screenRect.left,screenRect.top, screenRect.width, screenRect.height * 0.8) - if olpcgames.ACTIVITY: - olpcgames.ACTIVITY.playArea = self.playArea - olpcgames.ACTIVITY.jamScene = self - self.panelArea = pygame.Rect(screenRect.left,screenRect.height * 0.8, screenRect.width, screenRect.height * 0.2) - self.TemplateInstruments = buildInstruments(INAMES, ImagePath, self.playArea.size, 2) - for oni in self.TemplateInstruments: - oni.activate() - self.PanelInstruments = buildInstruments(INAMES, ImagePath, self.panelArea.size, 1.5) - for pnl in self.PanelInstruments: - pnl.Touch = True - pnl.activate() - imagesize = self.TemplateInstruments[0].image.get_size() - self.panelSize = (self.screenSize[0], imagesize[1] + 10) - #movement limits - self.xmin = self.playArea.left + imagesize[0] * 0.5 - self.xmax = self.playArea.right - imagesize[0] * 0.5 - self.ymax = self.playArea.bottom - imagesize[1] * 0.5 - self.ymin = self.playArea.top + imagesize[1] * 0.5 - #interface key codes - self.keycode = KEYCODES - #various states - self.keyActions = [] - self.selectedInstrument = self.TemplateInstruments[0] - self.occupiedInstruments = {self.selectedInstrument.name: None} - self.myself = None - self.sharer = False - self.connected = False - self.timeTally = [] - self.running = True - self.Vparam = "Pitch" - self.Hparam = "Density" - #interface controls - self.movingInstrument = False - #initial draw - panelColour = (0,0,0) - self.snap_store = (olpcgames.ACTIVITY.snap_store if platform == 'Sugar' else []) - self.feedbackgroundImage = None - if self.screenSize == (1200, 780): - self.setbackgroundImage(pygame.image.load(ImagePath + "/jam2jamXO_2.png").convert()) - else: - bgi = pygame.image.load(ImagePath + "/jam2jamXO_2.png").convert() - bgi_scaled = pygame.transform.scale(bgi, self.playArea.size) - self.setbackgroundImage(bgi_scaled) - self.panel = pygame.Surface((self.panelArea.width, self.panelArea.height)) - self.panel.fill(panelColour) - self.screen.blit(self.panel, self.panelArea) - pygame.display.flip() - for pnl in self.PanelInstruments: pnl.y = pnl.y() + self.playArea.height - def setbackgroundImage(self, img): - self.backgroundImage = img - self.screen.blit(self.backgroundImage, (0,0), self.playArea) - self.selectedInstrument.Touch = True - def updatePanel(self): - "redraw panel icons" - for pi in self.PanelInstruments: - if not pi.Touch: - pass - else: - if pi.name in self.occupiedInstruments: - pi.deactivate() - else: - pi.activate() - self.screen.blit(pi.image, pi.Rect) - pi.Touch = False - def runloop(self): - "main game loop" - clock = pygame.time.Clock() - imgcnt = 0 - self.music_player.playLoop(now()) - while self.running: - events = (pausescreen.get_events(sleep_timeout = 43200) if platform == 'Sugar' else pygame.event.get()) - for event in events: - self.eventAction(event) - for act in self.keyActions: - self.interfaceAction(act) - if self.feedbackgroundImage: - self.setbackgroundImage(self.feedbackgroundImage) - self.feedbackgroundImage = None - self.updateInspos() - self.updatePanel() - if platform == 'Sugar': currentcnt = len(self.snap_store) - else: currentcnt = 0 - if imgcnt == currentcnt: - pass - else: - self.music_player.picture_cycle = [self, True] - imgcnt = currentcnt - pygame.display.flip() - clock.tick(25) - def updateInspos(self): - "animate selected instrument." - ins = self.selectedInstrument - if ins.Touch: - xval = self.scene.Params.getValue(self.Hparam, ins.name) - yval = self.scene.Params.getValue(self.Vparam, ins.name) - xpos = rescale(xval, 0,1,self.xmin, self.xmax) - ypos = rescale(yval, 0,1,self.ymax, self.ymin) - self.screen.blit(self.backgroundImage, ins.Rect, ins.Rect) - ins.ctr = (xpos, ypos) - ins.Touch = False - self.screen.blit(ins.image, ins.Rect) - def sendSync(self): - "Tell audio loop to broadcast time and beat messages" - if self._syncloop_running: - self.music_player.sendSync = True - log.info("sent sync") - schedEvent(now() + 10.7, self.sendSync) - def setselectedInstrument(self, ins): - "select the instrument onscreen" - self.selectedInstrument = ins - if ins.name not in self.occupiedInstruments: - self.occupiedInstruments.update({ins.name:str(self.myself)}) - self.selectedInstrument.Touch = True - def eventAction(self, event): - "detect events, and select action" - if event.type == pygame.QUIT: - self.music_player.freeze() - self.running = False - elif event.type == pygame.USEREVENT: - if hasattr(event, "action"): - if event.action.startswith("Parameter"): - args = event.action.split('|') - if args[1] == "Horizontal": - self.Hparam = args[2] - self.selectedInstrument.Touch = True - elif args[1] == "Vertical": - self.Vparam = args[2] - self.selectedInstrument.Touch = True - else: - raise ValueError, 'Unknown Parameter Action %s' %args - elif event.action.startswith('Reload'): - #should look always like this: "Reload|name|key:mode|tempo|defaults" - args = event.action.split('|') - name = args[1] - key = ('E' if args[2] == 'None' else args[2]) - mode = ('minor' if args[3] == 'None' else args[3]) - tempo = (117 if args[4] == 'None' else int(args[4])) - d = eval(args[5]) - defaults = (d if d else {}) - self.load_scene(name, key, mode, tempo, defaults) #this call blocks - if self.pending_instrument_assignment: #now check if we are waiting to assign instruments and params. - self.receiveMessage("AuthorisedInstrument|%s|%s" %(self.pending_instrument_assignment[0], self.pending_instrument_assignment[1]), self.myself) - elif event.action.startswith("Shared"): - self.sharer = "Pending" - log.info("Sharing activity") - elif event.action.startswith("Joined"): - log.info("Joined Activity") - else: - log.debug("unknown parameter change: %s", event.action) - else: log.debug("ignoring USEREVENT %s", event) - elif event.type == pygame.MOUSEBUTTONDOWN: - x,y = event.pos - Ins = self.selectedInstrument - if Ins.Rect.collidepoint(x,y): - self.movingInstrument = Ins - else: - for Panndx in range(len(self.PanelInstruments)): - Pan = self.PanelInstruments[Panndx] - if Pan.Rect.collidepoint(x,y): - if Pan.active: self.requestInstrument(Pan.name) - break - elif event.type == pygame.MOUSEMOTION: - if self.movingInstrument: - insname = self.movingInstrument.name - self.scene.Params.setValue(self.Hparam, insname, rescale(event.pos[0], self.playArea.left, self.playArea.right, 0, 1)) - self.scene.Params.setValue(self.Vparam, insname, limit(rescale(event.pos[1], self.playArea.bottom, self.playArea.top, 0, 1), 0,1)) - self.movingInstrument.Touch = True - elif event.type == pygame.MOUSEBUTTONUP: - self.movingInstrument = False - elif platform == 'Sugar' and event.type == mesh.CONNECT: - log.info( """Connected to the mesh!| %s""", event ) - self.connected = True - self.music_player.resetBeat() - elif event.type == pygame.KEYDOWN: - try: - iaction = self.keycode[event.key] - self.keyActions.append(iaction) - except KeyError: - pass - elif event.type == pygame.KEYUP: - try: - self.keyActions.remove(self.keycode[event.key]) - except ValueError: pass - except KeyError: pass - elif self.connected and event.type == mesh.PARTICIPANT_ADD: - if not self.myself: self.myself = mesh.my_handle() - if event.handle == self.myself: - if self.sharer == "Pending": self.sharer = self.myself - elif len(self.occupiedInstruments) == 4: - pass - else: - if self.sharer == self.myself: - giveupInstrument = [p for p in self.PanelInstruments if p.active][0].name - giveupparameters = getInstrumentParameters(self.scene, giveupInstrument) - mesh.send_to(event.handle, "Welcome|%s|%s|%s" %(self.scene.scene_name, giveupInstrument, giveupparameters)) - self.stealInstrument(giveupInstrument, handle = event.handle) - if self.connected: mesh.broadcast('Occupied|%s' %self.occupiedInstruments) - olpcgames.ACTIVITY.J2JToolbar.deactivate_scene_change() - if len(self.occupiedInstruments) >= 2 and not self._syncloop_running: - self._syncloop_running = True - self.sendSync() - else: - self.latency_checker() - log.info("Waiting to be assigned instrument from sharer") - elif self.connected and event.type == mesh.PARTICIPANT_REMOVE: - "return instrument to the sharer if a jammer leaves." - try: - relname = [n for n in self.occupiedInstruments if self.occupiedInstruments[n] == str(event.handle)][0] - relpanel = [p for p in self.PanelInstruments if p.name == relname][0] - del self.occupiedInstruments[relname] - relpanel.Touch = True - if self.sharer == self.myself: - self.music_player.mutelist.remove(relname) - if len(self.occupiedInstruments) == 1: - olpcgames.ACTIVITY.J2JToolbar.reactivate_scene_change() - if len(self.occupiedInstruments) <= 1: - self._syncloop_running = False - except IndexError: log.debug("Index error while removing jammer %s occ = %s" %(str(event.handle), self.occupiedInstruments)) - except KeyError: pass - except ValueError: pass - if self.sharer == self.myself: mesh.broadcast('Occupied|%s' %self.occupiedInstruments) - log.info( """Removed jammer| %s""", event ) - elif self.connected and (event.type == mesh.MESSAGE_MULTI or event.type == mesh.MESSAGE_UNI): - if event.handle == self.myself: - pass - else: - self.receiveMessage(event.content, event.handle) - def interfaceAction(self, iaction): - if iaction.startswith("Nudge"): - direction = iaction.split("|")[1] - insname = self.selectedInstrument.name - if direction == "Left" or direction == "Right": - param = self.Hparam - else: - param = self.Vparam - currentValue = self.scene.Params.getValue(param, insname) - newvalue = limit((currentValue - 0.03 if direction == "Left" or direction == "Down" else currentValue + 0.03), 0, 1) - self.scene.Params.setValue(param, insname, newvalue) - self.selectedInstrument.Touch = True - if newvalue == 0 or newvalue == 1: - try: - self.keyActions.remove(iaction) - except ValueError: pass - elif iaction.startswith("Instrument"): - ins = iaction.split('|')[1] - self.requestInstrument(ins) - try: - self.keyActions.remove(iaction) - except ValueError: pass - elif iaction.startswith("Parameter"): - pm = iaction.split('|')[1] - if "Modifier|Shift" in self.keyActions: - print "shift key is on" - if olpcgames.ACTIVITY: - olpcgames.ACTIVITY.J2JToolbar.set_vertical_parameter(pm) - else: - self.Vparam = pm - else: - print "shift key is off" - if olpcgames.ACTIVITY: - olpcgames.ACTIVITY.J2JToolbar.set_horizontal_parameter(pm) - else: - self.Hparam = pm - try: - self.keyActions.remove(iaction) - except ValueError: pass - else: pass - def stealInstrument(self, stealname, releasename = False, handle = False): - "attempts to deactivate an instrument, and make it unavailable for selection" - if not handle: handle = self.myself - if stealname == self.selectedInstrument.name: - log.info("ignoring request to steal %s: already active" %stealname) - return False - elif stealname in self.occupiedInstruments and not releasename: - log.info ("ignoring request to steal %s: already occupied and no release instrument provided" %stealname) - return False - else: - paneli = [pnli for pnli in self.PanelInstruments if pnli.name == stealname][0] - self.occupiedInstruments.update({stealname:str(handle)}) - self.music_player.mutelist.append(stealname) - if releasename: - relname = releasename - relpanel = [p for p in self.PanelInstruments if p.name == relname][0] - try: - del self.occupiedInstruments[relname] - relpanel.Touch = True - self.music_player.mutelist.remove(relname) - except KeyError: pass - except ValueError: pass - paneli.Touch = True - return True - def requestInstrument(self, name): - "instrument selections should go through this first. To request an instrument, you need to give one up" - if name in self.occupiedInstruments: - log.info('failed instrument selection, as instrument currently occupied') - else: - if self.connected and (self.sharer != self.myself): - releasename = self.selectedInstrument.name - iparams = getInstrumentParameters(self.scene, releasename) - requestname = name - mesh.send_to(self.sharer, 'JammerRequest|%s|%s|%s' %(releasename, requestname, iparams)) - else: - self.reselectInstruments(name) - if self.connected: mesh.broadcast('Occupied|%s' %self.occupiedInstruments) - def receiveMessage(self, instruction, handle): - if instruction.startswith("Welcome"): - messages = instruction.split("|") - self.sharer = handle - jam_scene = messages[1] - self.pending_instrument_assignment = [messages[2],messages[3]] - self.select_activity_scene(jam_scene) - if self.sharer != self.myself: - olpcgames.ACTIVITY.J2JToolbar.deactivate_scene_change() - elif instruction.startswith("Beat"): - splitvals = instruction.split('|') - receivedBeat = int(splitvals[1]) - time_now = now() - self.beatEstimator.addBeat(receivedBeat, time_now) - if abs(receivedBeat - self.beatEstimator.beat_match(time_now)) > 0.17: - pass - else: - latency = (sum(self.latency) / len(self.latency)) - tmult = self.music_player.tempoMult - latency = latency * 0.25 + 0.04 #this might be XO 1.0 specific - beatadvance = int(ceil(latency * 1/tmult)) - scheduled_time = now() + ((beatadvance * tmult) - latency) - self.music_player.Cease() - self.music_player.playLoop(scheduled_time, (receivedBeat + beatadvance) % self.music_player.beatlimit) - elif instruction.startswith("JammerRequest"): - "In theory only the sharer ever gets this message" - split = instruction.split('|') - releasename = split[1] - requestname = split[2] - iparams = eval(split[3]) - stealresult = self.stealInstrument(requestname, releasename, handle) - if stealresult: - setInstrumentParameters(self.scene, releasename, iparams) - rqparams = getInstrumentParameters(self.scene, requestname) - mesh.send_to(handle, "AuthorisedInstrument|%s|%s" %(requestname, rqparams)) - mesh.broadcast('Occupied|%s' %self.occupiedInstruments) - else: - mesh.send_to(handle, "DeniedInstrument|%s") - elif instruction.startswith("AuthorisedInstrument"): - "In theory only a 'joiner' receives this message" - msg = instruction.split('|') - ai = msg[1] - params = eval(msg[2]) - setInstrumentParameters(self.scene, ai, params) - self.reselectInstruments(ai) - elif instruction.startswith("DeniedInstrument"): - di = instruction.split('|')[1] - log.info("Instrument request for %s was denied by sharer." %di) - elif instruction.startswith("Occupied"): - insdict = eval(instruction.split('|')[1]) - self.occupiedInstruments = insdict - for pni in self.PanelInstruments: - if pni.name in insdict: - pni.deactivate() - else: - pni.activate() - elif instruction.startswith("LateReq"): - id = instruction.split('|')[1] - mesh.send_to(handle, "LateResp|%s" %id) - elif instruction.startswith("LateResp"): - id = int(instruction.split('|')[1]) - try: - t = self.latency_time_ID[id] - del self.latency_time_ID[id] - result = (now() - t) / 2 - avglat = sum(self.latency) / len(self.latency) - diffs = [(val - avglat) ** 2 for val in self.latency] - stddev = sqrt(sum(diffs) / len(diffs)) - if id == 0: - del self.latency[0] - self.latency.append(result) - elif result > (avglat + stddev): - pass - elif result < (avglat - stddev) and len(self.latency) > 6: - pass - elif len(self.latency) > 12: - del self.latency[0] - self.latency.append(result) - else: - self.latency.append(result) - except KeyError: - log.info('Unmatched time ID %s' %id) - else: - log.debug("UNKNOWN INSTRUCTION RECEIVED :%s", instruction) - def reselectInstruments(self, name): - "Swaps the instrument on screen and selects the active Panel Instruments available to this user" - oldInstrument = self.selectedInstrument - oldname = oldInstrument.name - if (self.sharer == self.myself) or not self.connected: - del self.occupiedInstruments[oldname] - self.occupiedInstruments.update({name:str(self.myself)}) - self.screen.blit(self.backgroundImage, oldInstrument.Rect, oldInstrument.Rect) - oldInstrument.Touch = False - self.setselectedInstrument([i for i in self.TemplateInstruments if i.name == name][0]) - for w in self.PanelInstruments: - if w.name == name or w.name == oldname: - w.Touch = True - if self.connected: - if self.sharer == self.myself: - self.music_player.mutelist = [j for j in self.occupiedInstruments if j != self.selectedInstrument.name] - else: - self.music_player.mutelist = [k.name for k in self.TemplateInstruments if k.name != self.selectedInstrument.name] - def load_scene(self, name, key, mode, tempo, defaults = {}): - self.music_player.freeze() - self.music_player.cs.perf.Stop() - self.music_player.cs.perf.Join() - self.music_player.cs.csound.cleanup() - sc = City.ScenePlayer(name, key, mode, tempo, defaults) - mp = City.makePlayer(sc) - global schedEvent, now - schedEvent = sc.TimeQueue.schedEvent - now = sc.cs.perfTime - self.scene = sc - self.music_player = mp - self.music_player.playLoop(now()) - self.selectedInstrument.Touch = True - self.music_player.picture_cycle = [self, True] - - def select_activity_scene(self, scene_name, key = None, mode = None, tempo = None, defaults = None): - current_scene_name = self.scene.scene_name - if scene_name == current_scene_name: - if self.pending_instrument_assignment: - self.receiveMessage("AuthorisedInstrument|%s|%s" %(self.pending_instrument_assignment[0], self.pending_instrument_assignment[1]), self.myself) - elif not olpcgames.ACTIVITY: - k = (key if key else 'G') - m = (mode if mode else 'major') - t = (int(tempo) if tempo else 164) - d = (eval(defaults) if defaults else {}) - self.load_scene(scene_name, k,m,t,d) - else: - toolbar = olpcgames.ACTIVITY.J2JToolbar - try: - ndx = [n[0] for n in toolbar.scenes].index(scene_name) - toolbar._Scene_combo.combo.set_active(ndx) - except ValueError: - log.info('request to change to unknown scene: %s', scene_name) - def latency_checker(self): - if self.sharer: - self.latency_time_ID[self.latency_counter] = now() - mesh.send_to(self.sharer, "LateReq|%s" %self.latency_counter) - self.latency_counter += 1 - if self.latency_counter < 10: - Timer(3.5, self.latency_checker, ()).start() - elif self.latency_counter < 50: - Timer(6.75, self.latency_checker, ()).start() - else: - log.info('turning off latency checking') - -#pygame main loop -def main(): - # check automatic power management - try: - sugar_pm_check = subprocess.Popen("sugar-control-panel -g automatic_pm", shell=True, stdout=subprocess.PIPE) - sugar_pm_result = sugar_pm_check.communicate()[0] - if sugar_pm_result.startswith("on"): - subprocess.Popen("sugar-control-panel -s automatic_pm off", shell=True) - _spm_off = True - else: - _spm_off = False - except OSError: - _spm_off = False - log.info("Failed to detect and set automatic power management") - screenSize_X, screenSize_Y = (olpcgames.ACTIVITY.game_size if platform=="Sugar" else (1024,640)) - toolbarheight = 45 - screen = pygame.display.set_mode((screenSize_X, screenSize_Y - toolbarheight)) - a_,b_,c_,d_ = pygame.cursors.load_xbm("arrow40b.xbm", "arrow40b-mask.xbm") - pygame.mouse.set_cursor(a_,b_,c_,d_) - jam = jamScene(screen, tempo = 120) - jam.runloop() - pygame.quit() - jam.music_player.freeze() - jam.music_player.cs.perf.Stop() - jam.music_player.cs.csound.cleanup() - if _spm_off: subprocess.Popen("sugar-control-panel -s automatic_pm on", shell=True) - -if __name__ == '__main__': - logging.basicConfig() - print "running as main" - main() - -- cgit v0.9.1