Hi,

2010/12/9 Gabriele Lanaro <[email protected]>:
> I've implemented some basic functionalities for the functional pitch
> recognition, now I've a little bit problem with the statistics.
>
> The exercise is that one:
>
> - the Teacher plays a cadence I, IV, V, I  or just I or the root note to
> estabilish the tonality.
> - the Teacher plays a note in the tonality (this can be set in the
> lessonfile)
> - the student have to find the note
>
> -
> I'd like to make statistics (in the major mode which grades the student was
> able to find out? In the minor mode?) but I haven't understood the
> statistics classes.

Patch attached that shows how it can  be done.

> Should I add the answer simply with the methods
> add_correct add_wrong? I have to subclass AbstractStatistics? Which method I
> have to implement?

* set Teacher.m_statistics
* call add_correct and add_wrong
* call Gui.__init__ with no_notebook=False not set, since the
statistics is displayed in a gtk.Notebook page.
* call self.setup_statisticsviewer in Gui.__init__
* implement Gui.on_start_practise and call m_statistics.reset_session

These steps are done in the attached patch.

The patch also has some changes to statistics.py because I found a bug
because the keys you use are integers. Nothing wrong with that, just
that it triggered a bug. The change to statistics.py in the attached
patch might be what I will commit, but I'll just have to think a
little about it. Busy times with concert preparations. My childrens
choir will perform a small christmas musical called «Gabrielle» on
sunday :-)

>
> I've found that the program automatically adds "lesson_id" field in the
> lessonfiles. Is it normal?

It should not do it any more. Was it 3.19.1 that did it?

>
> Extending solfege is a nice experience, I'm having a good time :). The
> branch is hosted here:
> https://code.launchpad.net/~gabriele-lanaro/+junk/solfege but it's in an
> "exploring" stage, I'm try to make it consistent with other modules.
>
> Best regards,
>
> - Gabriele
>


-- 
Tom Cato Amundsen <[email protected]>                 http://www.solfege.org/
GNU Solfege - free ear training    http://www.gnu.org/software/solfege/
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: [email protected]
# target_branch: http://bazaar.launchpad.net/~gabriele-\
#   lanaro/%2Bjunk/solfege/
# testament_sha1: 301fd251a4f0c70773cd204d4cf1bf70fe48c5bf
# timestamp: 2010-12-11 01:19:27 +0100
# base_revision_id: mati...@renoir-20101209135506-uylsqyr4y6qgf1er
# 
# Begin patch
=== modified file 'solfege/abstract.py'
--- solfege/abstract.py	2010-11-08 10:42:43 +0000
+++ solfege/abstract.py	2010-12-11 00:16:47 +0000
@@ -53,6 +53,7 @@
         # The file name, not a file object
         self.m_lessonfile = None
         self.m_question = None
+        self.m_custom_mode = False
     def maybe_auto_new_question(self):
         if self.get_bool('new_question_automatically'):
             if self.m_timeout_handle is None:

=== modified file 'solfege/exercises/functionaltone.py'
--- solfege/exercises/functionaltone.py	2010-12-09 13:55:06 +0000
+++ solfege/exercises/functionaltone.py	2010-12-11 00:16:47 +0000
@@ -50,6 +50,9 @@
 from solfege import mpd
 from solfege import utils
 from solfege import cfg
+from solfege import statistics
+from solfege import statisticsviewer
+
 import random
 import gobject
 import itertools
@@ -104,6 +107,7 @@
     def __init__(self, exname):
         abstract.Teacher.__init__(self, exname)
         self.lessonfileclass = lessonfile.HeaderLessonfile
+        self.m_statistics = statistics.LessonStatistics(self)
 
     def new_question(self, L, H):
         '''
@@ -139,13 +143,17 @@
         play(*self.music)
         
     def check_answer(self, nr):
+        if self.answer == nr:
+            self.m_statistics.add_correct(nr)
+        else:
+            self.m_statistics.add_wrong(self.answer, nr)
         return self.answer == nr
 
 
 
 class Gui(abstract.Gui):
     def __init__(self, teacher):
-        abstract.Gui.__init__(self, teacher, no_notebook=True) # what is no notebook?
+        abstract.Gui.__init__(self, teacher) # what is no notebook?
         # practise_box is the main area for practicing (display notes, interact etc..)
         # action_area is the button area
 
@@ -168,7 +176,8 @@
         self.practise_box.pack_start(self.input)
         self.practise_box.pack_start(self.g_flashbar)
         self.practise_box.show_all()
-    
+        self.setup_statisticsviewer(statisticsviewer.StatisticsViewer,
+                                   _("some statistics"))
     def new_question(self, widget=None):
         self.input.activate_grades(self.m_t.m_P.header["grades"])
         self.m_t.new_question(self.get_string('user/lowest_pitch'),
@@ -192,6 +201,9 @@
         l = self.input.labels[ans-1]
         self.g_flashbar.flash("The Pitch is: " + l)
 
+    def on_start_practise(self):
+         self.m_t.m_statistics.reset_session()
+
 # TODO: Maybe this sort of tables can be abstracted
 class GradeButtonWidget(gtk.Table):
     '''

=== modified file 'solfege/statistics.py'
--- solfege/statistics.py	2010-11-02 21:03:52 +0000
+++ solfege/statistics.py	2010-12-11 00:16:47 +0000
@@ -567,7 +567,7 @@
             c = [x[0] for x in list(c)]
         v = [self.int_if_int(x) for x in c]
         v.sort()
-        return [unicode(x) for x in v]
+        return v
     def get_statistics(self, seconds):
         """
         return a dict with statistics more recent than 'seconds' seconds.
@@ -743,6 +743,8 @@
 class LessonStatistics(AbstractStatistics):
     def key_to_pretty_name(self, key):
         def ff(x):
+            if isinstance(x, int):
+                return unicode(x)
             try:
                 t = eval(x)
                 if type(t) == tuple:

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWcnncLwAAzd/gEZUAADb5///
+6QNAL////BgBq+8t3HNS0EhXXQHRpow0RTyKeJNqY0aZGkfpT0ANA0EYahkASiKYjaAE0aZQ9CA
GmgAAAAcwJiaDCZMmTIwmCaaZGJgCGASJNTQTSZMp6TajTZTRtTQyAAZDTQNBzAmJoMJkyZMjCYJ
ppkYmAIYBJITCAJoJtTIamTBT1MT0mJoAYJpAIR4AE/8Q1LzFCVBIqijummRhkx15K/RBPymZSJA
WbcpdReJFz4l8/l/np14zbJrMnUc6UasNoJDhLG/iv0W5NA222ZvqB+prEZssE4txnsgzssdxmup
Qd0UoZ3a4a33Ezjp09/X2c/VZ2nVdqYdk30K29ezLbf19t3EmwqtphPGaToSIyvvakLqpUFDylbR
pnlTZx524Ga3uYMrd2J6wAoyKcyAY3EVJcjrq8nLKmo0h2NMt5Fk41OpUbG49AtykkYwgBghUWF+
SqL3sEIXgjqiYZX6TFK/4oNBewsf9QEkjlkDnWtBnzVVJEsXjSEUZzFN6kSMRoS32IILBoBiHyho
Jp3JiwMvGYk22hGGEkbJbvUiuNxkKoql+TRkkqYmFtLaWe7gNkBZkOLWjUohgMrOMXCLhB+Do4Vf
s0Pod3YHRVMRWGEZPFMYR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UnXGR21GUYhE+yGL4OoSW/xcEQYgIZGxSNQrhNEih08czZaDDjdKjk
G02joQEJiOe04sacpDw18MfcTDKgfeoYJvkXCc2DIgj2yrYeLegMFQ81BXK79/NY7cNGTIeEWKVa
BzxvEUOsMjWG03tiMtoMjkD7wzGyFSM2W0b1A9BJ+8U+5kByAYqmJWXiE1prfogCXEwLiutjFwKK
yB5+g6w5qu3CboB1rJtZ6j/ndiN1M7d+6oILzI3MJ6xRS8Je2WIW0Bl01zZgYYl+bPe2qSQZ2C6h
6lga9eWLtpNatvI+ZZ1ci6quv6BaAPs0Da+6vNZrBk7zJbNW65nixZY1WpBhWahVJI+DSTBGaGFW
mGn5ORmZpyAcb9x9/SLHyRfquYwyz6Ajh24rERWoC4s5hmjx7I9JMRwXCfiMlfr7jRg2jAwiBtEs
4aAh6CugG7P+LuSKcKEhk87heA==
------------------------------------------------------------------------------
Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL,
new data types, scalar functions, improved concurrency, built-in packages, 
OCI, SQL*Plus, data movement tools, best practices and more.
http://p.sf.net/sfu/oracle-sfdev2dev 
_______________________________________________
Solfege-devel mailing list
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe", or visit
https://lists.sourceforge.net/lists/listinfo/solfege-devel

Reply via email to