Ejemplo n.º 1
0
 def play_last_tone(self):
     if self.q_status == self.QSTATUS_NO:
         return
     assert self.m_question
     t = self.m_tonika
     for i in self.m_question:
         t = t + i
     utils.play_note(4, t.semitone_pitch())
Ejemplo n.º 2
0
 def play_last_tone(self):
     if self.q_status == self.QSTATUS_NO:
         return
     assert self.m_question
     t = self.m_tonika
     for i in self.m_question:
         t = t + i
     utils.play_note(4, t.semitone_pitch())
Ejemplo n.º 3
0
 def play_last_note(self):
     if self.q_status == self.QSTATUS_NO:
         return
     utils.play_note(4, mpd.notename_to_int(self.m_question[-1]))
Ejemplo n.º 4
0
 def play_question(self):
     if self.q_status == self.QSTATUS_NO:
         return
     utils.play_note(
         4,
         mpd.notename_to_int(self.m_question) + self.m_octave * 12)
Ejemplo n.º 5
0
 def on_button_press_event(self, event, midi_int):
     if event.button == 3:
         utils.play_note(4, midi_int)
     elif event.button == 1:
         self.m_callback(mpd.int_to_octave_notename(midi_int))
Ejemplo n.º 6
0
 def play_440hz(self):
     utils.play_note(4, mpd.notename_to_int("a'"))
Ejemplo n.º 7
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
Ejemplo n.º 8
0
 def play_first_tone(self):
     if self.q_status == self.QSTATUS_NO:
         return
     assert self.m_question
     utils.play_note(4, self.m_tonika.semitone_pitch())
Ejemplo n.º 9
0
 def on_button_press_event(self, event, midi_int):
     if event.button == 3:
         utils.play_note(4, midi_int)
     elif event.button == 1:
         self.m_callback(mpd.int_to_octave_notename(midi_int))
Ejemplo n.º 10
0
 def play_first_tone(self):
     if self.q_status == self.QSTATUS_NO:
         return
     assert self.m_question
     utils.play_note(4, self.m_tonika.semitone_pitch())
Ejemplo n.º 11
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
Ejemplo n.º 12
0
 def play_question(self):
     if self.q_status == self.QSTATUS_NO:
         return
     utils.play_note(4,
         mpd.notename_to_int(self.m_question) + self.m_octave * 12)
Ejemplo n.º 13
0
 def play_last_note(self):
     if self.q_status == self.QSTATUS_NO:
         return
     utils.play_note(4, mpd.notename_to_int(self.m_question[-1]))
Ejemplo n.º 14
0
 def play_selected_instrument(self, _o=None):
     utils.play_note(4, 60)