Exemplo n.º 1
0
 def spank_me_play_question(self):
     t1 = utils.new_percussion_track()
     t1.note(8, 71)
     t2 = utils.new_track()
     t2.notelen_time(4)
     t2.note(4, mpd.notename_to_int(self.m_question) + self.m_octave * 12)
     soundcard.synth.play_track(t1, t2)
Exemplo n.º 2
0
 def spank_me_play_question(self):
     t1 = utils.new_percussion_track()
     t1.note(8, 71)
     t2 = utils.new_track()
     t2.notelen_time(4)
     t2.note(4, mpd.notename_to_int(self.m_question) + self.m_octave * 12)
     soundcard.synth.play_track(t1, t2)
Exemplo n.º 3
0
    def play_question(self):
        if self.q_status == self.QSTATUS_NO:
            return
        t = self.m_tonika

        m = utils.new_track()
        m.note(4, self.m_tonika.semitone_pitch())
        for i in self.m_question:
            t = t + i
            m.note(4, t.semitone_pitch())
        soundcard.synth.play_track(m)
Exemplo n.º 4
0
    def play_question(self):
        if self.q_status == self.QSTATUS_NO:
            return
        t = self.m_tonika

        m = utils.new_track()
        m.note(4, self.m_tonika.semitone_pitch())
        for i in self.m_question:
            t = t + i
            m.note(4, t.semitone_pitch())
        soundcard.synth.play_track(m)
Exemplo n.º 5
0
 def click_on_interval(self, mouse_button, interval, midi_int):
     """The key bindings are also directed here.
     """
     if mouse_button == 3 and not solfege.app.m_test_mode \
             and self.get_int('number_of_intervals') == 1:
         if not self.m_t.m_tonika:
             return
         i = mpd.Interval()
         if (not midi_int  # buttons interface does not set midi_int. And
                 # since it assumes all intervals go up, we have
                 # to check and set the direction.
                 and self.m_t.m_question[0] < 0):
             i.set_from_int(-interval)
         else:
             i.set_from_int(interval)
         n = self.m_t.m_tonika + i
         track = utils.new_track()
         track.note(4, self.m_t.m_tonika.semitone_pitch())
         track.note(4, n.semitone_pitch())
         soundcard.synth.play_track(track)
         return
     if mouse_button not in (1, self.keyboard_accel):
         return
     if solfege.app.m_test_mode and self.m_t.q_status == self.QSTATUS_NO:
         self.g_flashbar.flash(_("Click 'Start test' to begin."))
         return
     if solfege.app.m_test_mode:
         self.g_new.hide()
     if self.m_t.q_status == self.QSTATUS_NO:
         self.g_flashbar.flash(_("Click 'New interval' to begin."))
         return
     if midi_int:
         # midi_int is only set when we use some of the instrument widgets,
         # not when we use the buttons interface.
         utils.play_note(4, midi_int)
     if self.m_t.q_status == self.QSTATUS_GIVE_UP:
         return
     if self.m_t.q_status == self.QSTATUS_SOLVED:
         self.g_flashbar.flash(
             _("You have already identified this interval"))
         return
     if not (mpd.interval.min_interval < interval <=
             mpd.interval.max_interval):
         self.g_flashbar.flash(
             _("Ignoring intervals greater than double octave."))
         self.g_input.forget_last_tone()
         return
     self.m_answer.append(interval)
     d = self.m_t.m_question[len(self.m_answer) - 1]
     md = d / abs(d)
     if self.g_input.know_directions():
         md = 1
     if not self.msg:
         self.msg = utils.int_to_intervalname(interval * md, 1, 1) + "+ ..."
     else:
         self.msg = self.msg[:-4]
         self.msg = self.msg + utils.int_to_intervalname(
             interval * md, 1, 1) + "+ ..."
     self.g_flashbar.push(self.msg)
     if len(self.m_answer) == self.m_number_of_intervals_in_question:
         if self.m_t.guess_answer(self.m_answer,
                                  self.g_input.know_directions()):
             self.g_flashbar.clear()
             self.g_flashbar.flash(_("Correct"))
             self.std_buttons_answer_correct()
         else:
             self.g_flashbar.clear()
             self.g_flashbar.flash(_("Wrong"))
             if self.get_bool(
                     "config/auto_repeat_question_if_wrong_answer"):
                 self.m_t.play_question()
             self.std_buttons_answer_wrong()
         self.m_answer = []
         self.g_input.set_first_note(self.m_t.m_tonika)
         self.msg = ""
     if solfege.app.m_test_mode and self.m_t.m_P.is_test_complete():
         self.do_test_complete()
         return
Exemplo n.º 6
0
 def click_on_interval(self, mouse_button, interval, midi_int):
     """The key bindings are also directed here.
     """
     if mouse_button == 3 and not solfege.app.m_test_mode \
             and self.get_int('number_of_intervals') == 1:
         if not self.m_t.m_tonika:
             return
         i = mpd.Interval()
         if (not midi_int # buttons interface does not set midi_int. And
                          # since it assumes all intervals go up, we have
                          # to check and set the direction.
             and self.m_t.m_question[0] < 0):
             i.set_from_int(-interval)
         else:
             i.set_from_int(interval)
         n = self.m_t.m_tonika + i
         track = utils.new_track()
         track.note(4, self.m_t.m_tonika.semitone_pitch())
         track.note(4, n.semitone_pitch())
         soundcard.synth.play_track(track)
         return
     if mouse_button not in (1, self.keyboard_accel):
         return
     if solfege.app.m_test_mode and self.m_t.q_status == self.QSTATUS_NO:
         self.g_flashbar.flash(_("Click 'Start test' to begin."))
         return
     if solfege.app.m_test_mode:
         self.g_new.hide()
     if self.m_t.q_status == self.QSTATUS_NO:
         self.g_flashbar.flash(_("Click 'New interval' to begin."))
         return
     if midi_int:
         # midi_int is only set when we use some of the instrument widgets,
         # not when we use the buttons interface.
         utils.play_note(4, midi_int)
     if self.m_t.q_status == self.QSTATUS_GIVE_UP:
         return
     if self.m_t.q_status == self.QSTATUS_SOLVED:
         self.g_flashbar.flash(_("You have already identified this interval"))
         return
     if not (-17 < interval < 17):
         self.g_flashbar.flash(_("Ignoring intervals greater than major tenth."))
         self.g_input.forget_last_tone()
         return
     self.m_answer.append(interval)
     d = self.m_t.m_question[len(self.m_answer)-1]
     md = d / abs(d)
     if self.g_input.know_directions():
         md = 1
     if not self.msg:
         self.msg = utils.int_to_intervalname(interval * md, 1, 1) + "+ ..."
     else:
         self.msg = self.msg[:-4]
         self.msg = self.msg + utils.int_to_intervalname(interval * md, 1, 1) + "+ ..."
     self.g_flashbar.push(self.msg)
     if len(self.m_answer) == self.m_number_of_intervals_in_question:
         if self.m_t.guess_answer(self.m_answer,
                                  self.g_input.know_directions()):
             self.g_flashbar.clear()
             self.g_flashbar.flash(_("Correct"))
             self.std_buttons_answer_correct()
         else:
             self.g_flashbar.clear()
             self.g_flashbar.flash(_("Wrong"))
             if self.get_bool("config/auto_repeat_question_if_wrong_answer"):
                 self.m_t.play_question()
             self.std_buttons_answer_wrong()
         self.m_answer = []
         self.g_input.set_first_note(self.m_t.m_tonika)
         self.msg = ""
     if solfege.app.m_test_mode and self.m_t.m_P.is_test_complete():
         self.do_test_complete()
         return