Ejemplo n.º 1
0
def csound_intonation2(harmonic, interval_name, cent):
    i = Interval(interval_name)
    if harmonic:
        hs = "harmonic-"
    else:
        hs = ""
    filename = os.path.join(
        "exercises", "standard", "lesson-files",
        "csound-intonation-%s%s-%icent" %
        (hs, iname_to_fn(interval_name), cent))
    f = codecs.open(filename, 'w', 'utf-8')
    print >> f, "# Solfege - free ear training software"
    print >> f, "# Copyright (C) 2004, 2005, 2011 Tom Cato Amundsen"
    print >> f, "# License is GPL, see file COPYING"
    print >> f
    print >> f, "header {"
    print >> f, '    lesson_id = "csound-intonation-%s%s-%icent"' % (
        hs, iname_to_fn(interval_name), cent)
    print >> f, '        module = idbyname'
    print >> f, '        help = "idbyname-intonation"'
    print >> f, '        title = _("Is the interval flat, in tune or sharp? %%s cent wrong") %% %i' % cent
    print >> f, '        lesson_heading = _("Just interval: %%s") %% _("%s") + " (%s)"' % (
        i.get_cname(), ratio_dict[i.get_cname_short()][1])
    print >> f, '        filldir = vertic'
    print >> f, '}'
    for c in range(12):
        hz = 220 * 2**(c / 12)
        hz2 = hz * ratio_dict[i.get_cname_short()][0]
        for label, mult in (("intonation|flat", -cent),
                            ("intonation|in tune", 0), ("intonation|sharp",
                                                        cent)):
            print >> f
            print >> f, 'question {'
            print >> f, ' name = _i("%s")' % label
            print >> f, ' set=%i' % c
            print >> f, ' csound(load("share/sinus.orc"), """'
            print >> f, '   f1 0 4096 10 1 1.25 0.95 0.8 0.6 0.4 0.2 '
            if harmonic:
                print >> f, '   i1 0 1 %f' % hz
                print >> f, '   i1 0 1 %f' % (hz2 * 2**(mult / 1200))
            else:
                print >> f, '   i1 0 1 %f' % hz
                print >> f, '   i1 + 1 %f' % (hz2 * 2**(mult / 1200))
            print >> f, ' """)'
            print >> f, "}"
    f.close()
Ejemplo n.º 2
0
def csound_intonation2(harmonic, interval_name, cent):
    i = Interval(interval_name)
    if harmonic:
        hs = "harmonic-"
    else:
        hs = ""
    filename = saveto / ("csound-intonation-%s%s-%icent" % (hs, iname_to_fn(interval_name), cent))
    f = filename.open("w")
    f.write("""# Solfege - free ear training software
# Copyright (C) 2004, 2005, 2011, 2016 Tom Cato Amundsen
# License is GPL, see file COPYING

header {{
    lesson_id = "csound-intonation-{0}{1}-{2}cent"
        module = idbyname
        help = "idbyname-intonation"
        title = _("Is the interval flat, in tune or sharp? %s cent wrong") % {3}
        lesson_heading = _("Just interval: %s") % _("{4}") + " ({5})"
        filldir = vertic
}}
""".format(hs, iname_to_fn(interval_name), cent, cent,  # 0-3
           i.get_cname(), ratio_dict[i.get_cname_short()][1]))  # 4-5
    for c in range(12):
        hz = 220 * 2 ** (c / 12)
        hz2 = hz * ratio_dict[i.get_cname_short()][0]
        for label, mult in (("intonation|flat", -cent),
                            ("intonation|in tune", 0),
                            ("intonation|sharp", cent)):
            f.write("""
question {{
 name = _i("{0}")
 set={1}
 csound(load("share/sinus.orc"), \"\"\"
   f1 0 4096 10 1 1.25 0.95 0.8 0.6 0.4 0.2 
""".format(label, c))
            if harmonic:
                f.write('   i1 0 1 %f\n' % hz)
                f.write('   i1 0 1 %f\n' % (hz2 * 2**(mult / 1200)))
            else:
                f.write('   i1 0 1 %f\n' % hz)
                f.write('   i1 + 1 %f\n' % (hz2 * 2**(mult / 1200)))
            f.write(' """)\n')
            f.write("}\n")
    f.close()
Ejemplo n.º 3
0
def csound_intonation2(harmonic, interval_name, cent):
    i = Interval(interval_name)
    if harmonic:
        hs = "harmonic-"
    else:
        hs = ""
    filename = os.path.join("exercises", "standard", "lesson-files", "csound-intonation-%s%s-%icent" % (hs, iname_to_fn(interval_name), cent))
    f = codecs.open(filename, 'w', 'utf-8')
    print >> f, "# Solfege - ear training for GNOME"
    print >> f, "# Copyright (C) 2004, 2005 Tom Cato Amundsen"
    print >> f, "# License is GPL, see file COPYING"
    print >> f
    print >> f, "header {"
    print >> f, '    lesson_id = "csound-intonation-%s%s-%icent"' % (hs, iname_to_fn(interval_name), cent)
    print >> f, '        module = idbyname'
    print >> f, '        help = "idbyname-intonation"'
    print >> f, '        title = _("Is the interval flat, in tune or sharp? %%s cent wrong") %% %i' % cent
    print >> f, '        lesson_heading = _("Just interval: %%s") %% _("%s") + " (%s)"' % (i.get_cname(), ratio_dict[i.get_cname_short()][1])
    print >> f, '        filldir = vertic'
    print >> f, '}'
    for c in range(12):
        hz = 220 * 2 ** (c/12)
        hz2 = hz * ratio_dict[i.get_cname_short()][0]
        for label, mult in (("intonation|flat", -cent),
                            ("intonation|in tune", 0),
                            ("intonation|sharp", cent)):
            print >> f
            print >> f, 'question {'
            print >> f, ' name = _i("%s")' % label
            print >> f, ' set=%i' % c
            print >> f, ' csound(load("share/sinus.orc"), """'
            print >> f, '   f1 0 4096 10 1 1.25 0.95 0.8 0.6 0.4 0.2 '
            if harmonic:
                print >> f, '   i1 0 1 %f' % hz
                print >> f, '   i1 0 1 %f' % (hz2 * 2**(mult / 1200))
            else:
                print >> f, '   i1 0 1 %f' % hz
                print >> f, '   i1 + 1 %f' % (hz2 * 2**(mult / 1200))
            print >> f, ' """)'
            print >> f, "}"
    f.close()