コード例 #1
0
 def setUp(self):
     cfg.set_bool('config/override_default_instrument', False)
     self.p = QuestionsLessonfile()
     self.p.parse_string("""
     question { music = percussion("e16 f g4") }
     """)
     self.p._idx = 0
コード例 #2
0
ファイル: startup.py プロジェクト: PauloJava2016/Solfege
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()
コード例 #3
0
 def test_1_3patches(self):
     """
     Test with 3 different patches, just in case implementation details
     make error handling different with config/override_default_instrument
     set and unset.
     """
     cfg.set_bool('config/override_default_instrument', True)
     self._test_1()
コード例 #4
0
 def setUp(self):
     cfg.set_bool('config/override_default_instrument', False)
     self.p = QuestionsLessonfile()
     self.p.parse_string("""
     question { music = rhythm("d c8") }
     question { music = rhythm("c \time 3\4 c d") }
     """)
     self.p._idx = 0
コード例 #5
0
 def setUp(self):
     cfg.set_bool('config/override_default_instrument', False)
     self.p = QuestionsLessonfile()
     self.p.parse_string("""
     header { random_transpose = no }
     question { music = chord("c e g") }
     """)
     self.p.m_transpose = mpd.MusicalPitch.new_from_notename("d'")
     self.p._idx = 0
コード例 #6
0
 def setUp(self):
     cfg.set_bool('config/override_default_instrument', False)
     self.p = QuestionsLessonfile()
     self.p.parse_string("""
     header { random_transpose = no }
     question { music = satb("c''| e'| g | c") }
     question { key = "aes \\major" music = satb("c''|as'|es'|as") }
     question { music = satb("c''| g' e'| g | c") }
     """)
     self.p.m_transpose = mpd.MusicalPitch.new_from_notename("d'")
     self.p._idx = 0
コード例 #7
0
 def test_play_slowly(self):
     question = self.p.m_questions[0]
     #test.py TestMusic viser at det ikke blir generert riktig instrument
     #for ovelser som progressions-2 (harmonicprogressiondictation)
     question['music'].play_slowly(self.p, question)
     self.assertEquals(soundcard.synth.flush_testdata(1),
         "t30/4 p0:0 v0:100 n0:72 n0:64 n0:48 d1/4 o72 o64 o48")
     cfg.set_bool('config/override_default_instrument', True)
     question['music'].play_slowly(self.p, question)
     self.assertEquals(soundcard.synth.flush_testdata(1),
         "t30/4 p0:0 v0:100 n0:72 n0:64 n0:48 d1/4 o72 o64 o48")
コード例 #8
0
 def setUp(self):
     cfg.set_bool('config/override_default_instrument', False)
     self.p = QuestionsLessonfile()
     self.p.parse_string("""
     header { random_transpose = no }
     question { music = music3("\staff{c''}\staff{e'}\staff{c}") }
     question {
         instrument = 33, 34, 35, 36, 37, 38
         music = music3("\staff{c''}\staff{g'}\staff{e'}\staff{c}")
     }
     """)
     self.p.m_transpose = mpd.MusicalPitch.new_from_notename("d'")
     self.p._idx = 0
コード例 #9
0
 def test_play_arpeggio(self):
     question = self.p.m_questions[0]
     question['music'].play_arpeggio(self.p, question)
     self.assertEquals(soundcard.synth.flush_testdata(),
         "t180/4 p0:0 v0:100 n48 d1/4 o48 n52 d1/4 o52 n55 d1/4 o55")
     self.p.header.random_transpose = (True,)
     question['music'].play_arpeggio(self.p, question)
     self.assertEquals(soundcard.synth.flush_testdata(),
         "t180/4 p0:0 v0:100 n50 d1/4 o50 n54 d1/4 o54 n57 d1/4 o57")
     cfg.set_bool('config/override_default_instrument', True)
     question['music'].play_arpeggio(self.p, question)
     self.assertEquals(soundcard.synth.flush_testdata(),
         "t180/4 p0:1 v0:121 n50 d1/4 o50 p0:2 v0:122 n54 d1/4 o54 p0:3 v0:123 n57 d1/4 o57")
コード例 #10
0
 def setUp(self):
     cfg.set_bool('config/override_default_instrument', False)
     self.p = QuestionsLessonfile()
     self.p.parse_string("""
     header { random_transpose = no }
     question { music = rvoice("c' d b c") }
     question { music = rvoice("[c'8 d] e16") }
     question { music = rvoice("c,, d' b c") }
     question { music = rvoice("b,, d' b c") }
     question { music = rvoice("< e") }
     question { music = rvoice("ERR") }
     question { music = rvoice("c d e f\ng ERR a") }
     """)
     self.p.m_transpose = mpd.MusicalPitch.new_from_notename("d'")
     self.p._idx = 0
コード例 #11
0
 def test_play(self):
     question = self.p.m_questions[0]
     question['music'].play(self.p, question)
     self.assertEquals(soundcard.synth.flush_testdata(1),
         "t60/4 p0:0 v0:100 n0:72 n0:64 n0:48 d1/4 o72 o64 o48")
     #
     cfg.set_bool('config/override_default_instrument', True)
     question['music'].play(self.p, question)
     self.assertEquals(soundcard.synth.flush_testdata(1),
         "t60/4 p0:3 v0:123 n0:72 p1:2 v1:122 n1:64 p2:1 v2:121 n2:48 d1/4 o72 o64 o48")
     #
     question = self.p.m_questions[1]
     question['music'].play(self.p, question)
     self.assertEquals(soundcard.synth.flush_testdata(1),
         "t60/4 p0:37 v0:38 n0:72 p1:35 v1:36 n1:67 n1:64 p2:33 v2:34 n2:48 d1/4 o72 o67 o64 o48")
コード例 #12
0
 def test_play(self):
     question = self.p.m_questions[0]
     question['music'].play(self.p, question)
     self.assertEquals(soundcard.synth.flush_testdata(1),
         "t60/4 p0:0 v0:100 n0:72 n0:64 n0:48 d1/4 o72 o64 o48")
     # Music objects should ignore config/override_default_instrument
     cfg.set_bool('config/override_default_instrument', True)
     question['music'].play(self.p, question)
     self.assertEquals(soundcard.synth.flush_testdata(1),
         "t60/4 p0:0 v0:100 n0:72 n0:64 n0:48 d1/4 o72 o64 o48")
     #
     question = self.p.m_questions[1]
     # If the instrument variable it set, and it has more than one
     # instrument, as it as in questions[1], then even Music will
     # play with more than one instrument.:w
     question['music'].play(self.p, question)
     self.assertEquals(soundcard.synth.flush_testdata(1),
         "t60/4 p0:37 v0:38 n0:72 p1:35 v1:36 n1:64 p2:33 v2:34 n2:48 d1/4 o72 o64 o48")
コード例 #13
0
ファイル: startup.py プロジェクト: yuanyelele/solfege
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()
コード例 #14
0
ファイル: test.py プロジェクト: gitGNU/gnu_solfege
import solfege.statistics
solfege.db = solfege.statistics.DB(None)

import tempfile
lessonfile.MusicBaseClass.temp_dir = tempfile.mkdtemp(prefix="solfege-")

from solfege import cfg
cfg.initialise("default.config", None, "")
cfg.set_int('config/preferred_instrument', 0)
cfg.set_int('config/lowest_instrument', 1)
cfg.set_int('config/middle_instrument', 2)
cfg.set_int('config/highest_instrument', 3)
cfg.set_int('config/lowest_instrument_volume', 121)
cfg.set_int('config/middle_instrument_volume', 122)
cfg.set_int('config/highest_instrument_volume', 123)
cfg.set_bool('config/override_default_instrument', False)
cfg.set_bool('testing/may_play_sound', False)

if os.path.exists(testlib.outdir):
    shutil.rmtree(testlib.outdir)
os.mkdir(testlib.outdir)

from solfege import soundcard
from solfege.osutils import *
soundcard.initialise_external_midiplayer()

soundcard.synth.start_testmode()


import solfege.mpd.tests
import solfege.soundcard.tests
コード例 #15
0
 def test_3patch_play(self):
     cfg.set_bool('config/override_default_instrument', True)
     question = self.p.m_questions[0]
     question['music'].play(self.p, question)
     self.assertEquals(soundcard.synth.flush_testdata(1),
         "t60/4 p0:1 v0:121 n0:48 p1:2 v1:122 n1:52 p2:3 v2:123 n2:55 d1/4 o48 o52 o55")
コード例 #16
0
 def setUp(self):
     TmpFile.setUp(self)
     cfg.set_bool('config/override_default_instrument', True)
コード例 #17
0
ファイル: test_track.py プロジェクト: gabrielelanaro/solfege
 def setUp(self):
     cfg.set_bool('config/override_default_instrument', True)
コード例 #18
0
 def test_1(self):
     cfg.set_bool('config/override_default_instrument', False)
     self._test_1()
コード例 #19
0
 def test_satb_3patches(self):
     cfg.set_bool('config/override_default_instrument', True)
     self._test_satb()
コード例 #20
0
ファイル: startup.py プロジェクト: tcamundsen/solfege
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)