def test_CSound(self): self.p = QuestionsLessonfile() self.p.parse_string(''' header { lesson_id = "csound-intonation-M3-5cent" module = idbyname help = "idbyname-intonation" title = "Test " } question { name = "III temperature" set=0 csound_sco = """ f1 0 4096 10 1 ; use GEN10 to compute a sine wave ; p1 p2 p3 p4 p5 p6 p7 ;ins strt dur amp freq attack release i1 0 1 10000 440 0.2 0.08 i1 + 1 10000 660 0.08 0.08 e """ music = csound(load("exercises/standard/lesson-files/share/sinus-ad.orc"), csound_sco) }''') question = self.p.m_questions[0] if cfg.get_bool('testing/may_play_sound'): question['music'].play(self.p, question)
def start_gui(datadir): if not options.profile: if cfg.get_bool("app/noprofilemanager"): options.profile = cfg.get_string("app/last_profile") elif do_profiles(): if solfege.splash_win: solfege.splash_win.hide() p = ProfileManager(cfg.get_string("app/last_profile")) ret = p.run() if ret == Gtk.ResponseType.ACCEPT: options.profile = p.get_profile() cfg.set_string("app/last_profile", "" if not options.profile else options.profile) elif ret in (Gtk.ResponseType.CLOSE, Gtk.ResponseType.DELETE_EVENT): Gtk.main_quit() return p.destroy() if solfege.splash_win: solfege.splash_win.show() cfg.set_bool('config/no_random', bool(options.no_random)) lessonfile.infocache = lessonfile.InfoCache() def f(s): if solfege.splash_win: solfege.splash_win.show_progress(s) if solfege.splash_win: solfege.splash_win.show_progress(_("Opening statistics database")) try: solfege.db = statistics.DB(f, profile=options.profile) except sqlite3.OperationalError, e: solfege.splash_win.hide() gu.dialog_ok(_(u"Failed to open the statistics database:\n«%s»") % str(e).decode(sys.getfilesystemencoding(), 'replace'), secondary_text=_("Click OK to exit the program. Then try to quit all other instances of the program, or reboot the computer. You can only run one instance of GNU Solfege at once.")) sys.exit()
def test_2arg(self): s = """ question { music = mma("ballad", "1 Cmaj7") } """ p = QuestionsLessonfile() p.parse_string(s) q = p.m_questions[0] if cfg.get_bool('testing/may_play_sound'): q['music'].play(p, q)
def new_2_tracks(): if cfg.get_bool('config/override_default_instrument'): instr_low = cfg.get_int('config/lowest_instrument') instr_low_volume = cfg.get_int('config/lowest_instrument_volume') instr_high = cfg.get_int('config/highest_instrument') instr_high_volume = cfg.get_int('config/highest_instrument_volume') else: instr_low = instr_high = cfg.get_int('config/preferred_instrument') instr_low_volume = instr_high_volume = cfg.get_int('config/preferred_instrument_volume') t1 = mpd.Track() t1.set_bpm(cfg.get_int('config/default_bpm')) t1.set_patch(instr_low) t1.set_volume(instr_low_volume) t2 = mpd.Track() t2.set_patch(instr_high) t2.set_volume(instr_high_volume) return t1, t2
def start_gui(datadir): if not options.profile: if cfg.get_bool("app/noprofilemanager"): options.profile = cfg.get_string("app/last_profile") elif do_profiles(): if solfege.splash_win: solfege.splash_win.hide() p = ProfileManager(cfg.get_string("app/last_profile")) ret = p.run() if ret == Gtk.ResponseType.ACCEPT: options.profile = p.get_profile() cfg.set_string("app/last_profile", "" if not options.profile else options.profile) elif ret in (Gtk.ResponseType.CLOSE, Gtk.ResponseType.DELETE_EVENT): Gtk.main_quit() return p.destroy() if solfege.splash_win: solfege.splash_win.show() cfg.set_bool('config/no_random', bool(options.no_random)) lessonfile.infocache = lessonfile.InfoCache() def f(s): if solfege.splash_win: solfege.splash_win.show_progress(s) if solfege.splash_win: solfege.splash_win.show_progress(_("Opening statistics database")) try: solfege.db = statistics.DB(f, profile=options.profile) except sqlite3.OperationalError, e: solfege.splash_win.hide() gu.dialog_ok( _(u"Failed to open the statistics database:\n«%s»") % str(e).decode(sys.getfilesystemencoding(), 'replace'), secondary_text= _("Click OK to exit the program. Then try to quit all other instances of the program, or reboot the computer. You can only run one instance of GNU Solfege at once." )) sys.exit()
def test_play(self): question = self.p.m_questions[0] if cfg.get_bool('testing/may_play_sound'): question['music'].play(self.p, question) time.sleep(3)
def start_gui(datadir): cfg.set_bool('config/no_random', bool(options.no_random)) lessonfile.infocache = lessonfile.InfoCache() def f(s): if solfege.splash_win: solfege.splash_win.show_progress(s) if solfege.splash_win: solfege.splash_win.show_progress(_("Creating application window")) solfege.app = application.SolfegeApp(options) solfege.win = w = MainWin(options, datadir) solfege.app.setup_sound() w.post_constructor() solfege.win.load_frontpage() w.show() if solfege.splash_win: solfege.splash_win.destroy() solfege.splash_win = None if not options.profile: if cfg.get_bool("app/noprofilemanager"): options.profile = cfg.get_string("app/last_profile") elif do_profiles(): if solfege.splash_win: solfege.splash_win.hide() options.profile = solfege.win.run_startup_profile_manager() if solfege.splash_win: solfege.splash_win.show() if solfege.splash_win: solfege.splash_win.show_progress(_("Opening statistics database")) try: solfege.db = statistics.DB(f, profile=options.profile) except sqlite3.OperationalError as e: if solfege.splash_win: solfege.splash_win.hide() gu.dialog_ok( _("Failed to open the statistics database:\n«%s»") % str(e).decode(sys.getfilesystemencoding(), 'replace'), solfege.win, secondary_text=_("Click OK to exit the program. Then try to quit all other instances of the program, or reboot the computer. You can only run one instance of GNU Solfege at once.")) sys.exit() def ef(t, value, traceback): if options.debug: msg = "ehooked:" + str(value) else: msg = str(value) if issubclass(t, lessonfile.LessonfileException): w.display_error_message(msg, str(t)) elif issubclass(t, osutils.ExecutableDoesNotExist): if len(value.args) > 1: w.display_error_message2(value.args[0], "\n".join(value.args[1:])) else: w.display_error_message(msg, str(t)) else: sys.__excepthook__(t, value, traceback) if not options.disable_exception_handler: sys.excepthook = ef print(time.time() - start_time) # We parse all lesson files when we are idle to save a half a # second the first time the user searches all lesson files using # Ctrl-F. lessonfile.infocache.parse_all_files(True) if options.screenshots: make_screenshots.make_screenshots() if options.lessonfile: solfege.app.practise_lessonfile(options.lessonfile)