[gcompris/gcomprismusic] made it completely non hard coded
- From: Karthik Subramanian <karthiks src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris/gcomprismusic] made it completely non hard coded
- Date: Sun, 17 Jul 2011 11:28:53 +0000 (UTC)
commit df887ee97991f59e59dcf5d62a6e3a48e1944509
Author: Karthik Subramanian <itskarthik s gmail com>
Date: Sun Jul 17 16:58:09 2011 +0530
made it completely non hard coded
src/piano-activity/piano.py | 120 +++++++++----
.../resources/piano/activity.desktop | 189 +++++++++++++++++---
2 files changed, 245 insertions(+), 64 deletions(-)
---
diff --git a/src/piano-activity/piano.py b/src/piano-activity/piano.py
index 82e543b..5abb9ec 100644
--- a/src/piano-activity/piano.py
+++ b/src/piano-activity/piano.py
@@ -31,6 +31,15 @@ import time
from gcompris import gcompris_gettext as _
+class Song:
+
+ pianosize = 1
+ title = None
+ notestext = None
+ notes = []
+
+
+
class Gcompris_piano:
"""Piano gcompris python class"""
@@ -48,7 +57,6 @@ class Gcompris_piano:
# Set the default values
self.save = False
- self.noteslength = 15
self.pianosize = 1
self.filename_save = ""
@@ -267,7 +275,7 @@ class Gcompris_piano:
self.twinkle = ['c2', 'c2', 'g2', 'g2', 'a2', 'a2', 'g2', 'f2', 'f2', 'e2', 'e2','d2', 'd2', 'c2', 'g2', 'g2', 'f2', 'f2', 'e2', 'e2', 'd2', 'g2', 'g2', 'f2', 'f2', 'e2', 'e2', 'd2', 'c2', 'c2', 'g2', 'g2', 'a2', 'a2', 'g2', 'f2', 'f2', 'e2', 'e2', 'd2', 'd2', 'c2']
# For the first time, use the default.desktop file
- self.read_data('default.desktop')
+ self.read_data('activity.desktop')
self.titletext = goocanvas.Text(
parent = self.rootitem,
x = 400.0,
@@ -429,6 +437,35 @@ class Gcompris_piano:
)
self.pianobg2.translate(375, 200)
+ self.songs = []
+ count = 0
+ while(True):
+ try:
+ temp = Song()
+ print count
+ print 'song object created'
+ temp.pianosize = int(self.dataset.get(str(count),'pianosize'))
+ print 'piano size assigned'
+ temp.title = self.dataset.get(str(count),'title')
+ temp.notestext = self.dataset.get(str(count),'notes')
+ noteslength = 1
+ temp.notes=[]
+ while(True):
+ try:
+ note = self.dataset.get(str(count),'note_'+str(noteslength))
+ temp.notes.append(note)
+ noteslength += 1
+ except:
+ break
+ self.songs.append(temp)
+ count += 1
+ except:
+ print 'song not created'
+ break
+ print self.songs
+ print count
+ self.gcomprisBoard.maxlevel = count+1
+
def play_song(self, item, event, attr):
gcompris.file_selector_load( self.gcomprisBoard, self.selector_section,
@@ -586,9 +623,12 @@ class Gcompris_piano:
if self.gcomprisBoard.level >= 2:
self.noteno += 1
self.dochecknotes(notename)
- if self.noteno == self.noteslength:
+ print 'checked notes'
+ print len(self.currentsong)-1
+ if self.noteno == len(self.currentsong)-1:
gcompris.bonus.display(gcompris.bonus.WIN,gcompris.bonus.FLOWER)
self.noteno = 0
+ print 'checked length'
def key_press(self, keyval, commit_str, preedit_str):
@@ -635,43 +675,44 @@ class Gcompris_piano:
self.titletext.props.text = 'Freeplay'
self.notestext.props.text = ''
self.pianosizeicon.props.visibility = goocanvas.ITEM_VISIBLE
- elif level == 2 :
- self.setpiano(1)
- self.pianosize = 1
- self.noteslength = 11
- self.currentsong = self.mohanam
- self.titletext.props.text = ' Pentatonic Scale (Mohanam)'
- self.notestext.props.text = 'C D E G A C C A G E D C'
- self.pianosizeicon.props.visibility = goocanvas.ITEM_INVISIBLE
- elif level == 3 :
- self.setpiano(1)
- self.pianosize = 1
- self.noteslength = 15
- self.currentsong = self.cmajor
- self.titletext.props.text = ' C Major Scale '
- self.notestext.props.text = 'C D E F G A B C C B A G F E D C'
- elif level == 4 :
- self.noteslength = 15
- self.setpiano(2)
- self.pianosize = 2
- self.currentsong = self.dmajor
- self.titletext.props.text = ' D Major Scale '
- self.notestext.props.text = 'E F# G A B C# D E E D C# B A G F# E'
- elif level == 5:
- self.noteslength = 24
- self.setpiano(2)
- self.pianosize = 2
- self.currentsong = self.bday
- self.titletext.props.text = 'Happy Birthday tune'
- self.notestext.props.text = 'G G A G C3 B G G A G D3 C3 G G G3 E3 C3 B A F3 F3 E3 D3 C3'
- elif level == 6:
- self.noteslength = 41
- self.setpiano(1)
- self.pianosize = 1
- self.currentsong = self.twinkle
- self.titletext.props.text = 'Twinkle Twinkle little star tune (Pentatonic Scale)'
- self.notestext.props.text = 'C C G G A A G | F F E E D D C | G G F F E E D | G G F F E E D | C C G G A A G | F F E E D D C'
+ else:
+ self.setpiano(int(self.songs[level-2].pianosize))
+ self.pianosize = int(self.songs[level-2].pianosize)
+ print self.pianosize
+ self.currentsong = self.songs[level-2].notes
+ print len(self.currentsong)
+ self.titletext.props.text = self.songs[level-2].title
+ self.notestext.props.text = self.songs[level-2].notestext
self.pianosizeicon.props.visibility = goocanvas.ITEM_INVISIBLE
+ # elif level == 3 :
+ # self.setpiano(1)
+ # self.pianosize = 1
+ # self.noteslength = 15
+ # self.currentsong = self.cmajor
+ # self.titletext.props.text = ' C Major Scale '
+ # self.notestext.props.text = 'C D E F G A B C C B A G F E D C'
+ # elif level == 4 :
+ # self.noteslength = 15
+ # self.setpiano(2)
+ # self.pianosize = 2
+ # self.currentsong = self.dmajor
+ # self.titletext.props.text = ' D Major Scale '
+ # self.notestext.props.text = 'E F# G A B C# D E E D C# B A G F# E'
+ # elif level == 5:
+ # self.noteslength = 24
+ # self.setpiano(2)
+ # self.pianosize = 2
+ # self.currentsong = self.bday
+ # self.titletext.props.text = 'Happy Birthday tune'
+ # self.notestext.props.text = 'G G A G C3 B G G A G D3 C3 G G G3 E3 C3 B A F3 F3 E3 D3 C3'
+ # elif level == 6:
+ # self.noteslength = 41
+ # self.setpiano(1)
+ # self.pianosize = 1
+ # self.currentsong = self.twinkle
+ # self.titletext.props.text = 'Twinkle Twinkle little star tune (Pentatonic Scale)'
+ # self.notestext.props.text = 'C C G G A A G | F F E E D D C | G G F F E E D | G G F F E E D | C C G G A A G | F F E E D D C'
+ # self.pianosizeicon.props.visibility = goocanvas.ITEM_INVISIBLE """
self.noteno = 0
@@ -691,6 +732,7 @@ class Gcompris_piano:
self.allowed = self.allowed1 + self.allowed2
+
#GLOBAL
def general_save( filename, filetype, fles):
diff --git a/src/piano-activity/resources/piano/activity.desktop b/src/piano-activity/resources/piano/activity.desktop
index 34a7981..0b47267 100644
--- a/src/piano-activity/resources/piano/activity.desktop
+++ b/src/piano-activity/resources/piano/activity.desktop
@@ -1,27 +1,166 @@
[common]
-3 = dh3
-2 = ch3
-5 = fh3
-7 = ah3
-6 = gh3
-c = e2
-b = g2
-e = e3
-d = dh2
-g = fh2
-i = c4
-h = gh2
-j = ah2
-m = b2
-n = a2
-q = c3
-s = ch2
-r = f3
-u = b3
-t = g3
-w = d3
-v = f2
-y = a3
-x = d2
-z = c2
+q = c2
+2 = ch2
+w = d2
+3 = dh2
+e = e2
+r = f2
+5 = fh2
+t = g2
+6 = gh2
+y = a2
+7 = ah2
+u = b2
+i = c3
+z = c3
+s = ch3
+x = d3
+d = dh3
+c = e3
+v = f3
+g = fh3
+b = g3
+h = gh3
+n = a3
+j = ah3
+m = b3
+, = c4
+
+
+
+[0]
+pianosize = 1
+title = Pentatonic Scale (Mohanam)
+notes = C D E G A C C A G E D C
+note_1 = c2
+note_2 = d2
+note_3 = e2
+note_4 = g2
+note_5 = a2
+note_6 = c3
+note_7 = c3
+note_8 = a2
+note_9 = g2
+note_10 = e2
+note_11 = d2
+note_12 = c2
+
+[1]
+pianosize = 1
+title = C Major Scale
+notes = C D E F G A B C C B A G F E D C
+note_1 = c2
+note_2 = d2
+note_3 = e2
+note_4 = f2
+note_5 = g2
+note_6 = a2
+note_7 = b2
+note_8 = c3
+note_9 = c3
+note_10 = b2
+note_11 = a2
+note_12 = g2
+note_13 = f2
+note_14 = e2
+note_15 = d2
+note_16 = c2
+
+[2]
+
+pianosize = 2
+title = D Major Scale
+notes = E F# G A B C# D E E D C# B A G F# E
+note_1 = e2
+note_2 = fh2
+note_3 = g2
+note_4 = a2
+note_5 = b2
+note_6 = ch3
+note_7 = d3
+note_8 = e3
+note_9 = e3
+note_10 = d3
+note_11 = ch3
+note_12 = b2
+note_13 = a2
+note_14 = g2
+note_15 = fh2
+note_16 = e2
+
+[3]
+
+pianosize = 2
+title = Happy Birthday tune
+notes = G G A G C3 B G G A G D3 C3 G G G3 E3 C3 B A F3 F3 E3 D3 C3
+note_1 = g2
+note_2 = g2
+note_3 = a2
+note_4 = g2
+note_5 = c3
+note_6 = g2
+note_7 = g2
+note_8 = a2
+note_9 = g2
+note_10 = d3
+note_11 = c3
+note_12 = g2
+note_13 = g2
+note_14 = g3
+note_15 = e3
+note_16 = c3
+note_17 = b2
+note_18 = a2
+note_19 = f3
+note_20 = f3
+note_21 = e3
+note_22 = d3
+note_23 = c3
+
+[4]
+
+pianosize = 2
+title = Twinkle Twinkle little star tune
+notes = C C G G A A G | F F E E D D C | G G F F E E D | G G F F E E D | C C G G A A G | F F E E D D C
+note_1 = c2
+note_2 = c2
+note_3 = g2
+note_4 = g2
+note_5 = a2
+note_6 = a2
+note_7 = g2
+note_8 = f2
+note_9 = e2
+note_10 = e2
+note_11 = d2
+note_12 = d2
+note_13 = c2
+note_14 = g2
+note_15 = g2
+note_16 = f2
+note_17 = f2
+note_18 = e2
+note_19 = e2
+note_20 = d2
+note_21 = g2
+note_22 = g2
+note_23 = f2
+note_24 = f2
+note_25 = e2
+note_26 = e2
+note_27 = d2
+note_28 = c2
+note_29 = c2
+note_30 = g2
+note_31 = g2
+note_32 = a2
+note_33 = a2
+note_34 = g2
+note_35 = f2
+note_36 = f2
+note_37 = e2
+note_38 = e2
+note_39 = d2
+note_40 = d2
+note_41 = c2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]