示例#1
0
def __mk_kendang():
    def mk_re(pitches):
        def mk_pitch2samples(pitch):
            basic_path = "samples/kendang/new/"
            normalized_pitch = pitch.normalize(2)

            if normalized_pitch == ji.r(8, 7):
                basic_path += "0_"
            elif normalized_pitch == ji.r(5, 4):
                basic_path += "1_"
            elif normalized_pitch == ji.r(8, 5):
                basic_path += "2_"
            elif normalized_pitch == ji.r(7, 4):
                basic_path += "3_"
            else:
                basic_path += "4_"

            octave = pitch.octave

            if octave == 0:
                basic_path += "hand"
            elif octave == 1:
                basic_path += "tak"
            elif octave == -1:
                basic_path += "stick"
            else:
                msg = "Unknonw octave {0} of pitch {1}".format(octave, pitch)
                raise ValueError(msg)

            return itertools.cycle(
                ("{0}{1}.wav".format(basic_path, idx), 1) for idx in range(2))

        pitch2sample = {pitch: mk_pitch2samples(pitch) for pitch in pitches}

        return sound.SampleEngine(pitch2sample)

    pitches = (
        sw.translate(".7- .7+ .5- .5+ .1", False),
        sw.translate("7- 7+ 5- 5+ 1", False),
        sw.translate("7-. 7+. 5-. 5+. 1.", False),
    )

    pitch2notation = tuple(
        instruments.mk_p2n(p, idx, False) for idx, p in enumerate(pitches))
    pitch2notation = instruments.combine_p2n(*pitch2notation)

    notation_styles = tuple(
        notation.MelodicLineStyle("Large", "", True, True, True)
        for i in range(1))
    vertical_line = notation.VerticalLine(0.5, "", 1)
    vertical_line_style = notation.VerticalLineStyle(vertical_line,
                                                     vertical_line,
                                                     vertical_line)

    re0 = mk_re(functools.reduce(operator.add, pitches))
    render_engines = (re0, )

    return instruments.Instrument("Kendang", pitch2notation, notation_styles,
                                  render_engines, vertical_line_style)
def __mk_siter_gong_simplified():
    def mk_combination_pitches(comb: int, octave: ji.JIPitch):
        pitches = (tuple(
            ji.r(functools.reduce(operator.mul, com), 1)
            for com in itertools.combinations((3, 5, 7, 9), comb)
            if tuple(sorted(com)) != (3, 9)), )
        pitches += (tuple(p.inverse().normalize(2) + octave
                          for p in pitches[0]), )
        return tuple(p.normalize(2) + octave for p in pitches[0]), pitches[1]

    def mk_re():
        return sound.PyteqEngine(preset='"Cimbalom hard"')

    pitch_gong_plus = ji.r(3 * 5 * 7, 1).normalize(2) + ji.r(1, 4)
    pitch_gong_minus = pitch_gong_plus.inverse().normalize(2) + ji.r(1, 4)
    pitches_tong = mk_combination_pitches(2, ji.r(1, 2))
    pitches = (
        pitches_tong[0] + (pitch_gong_plus, ),
        pitches_tong[1] + (pitch_gong_minus, ),
    )

    pitch2notation = tuple(
        instruments.mk_p2n(p, idx) for idx, p in enumerate(pitches))
    pitch2notation = instruments.combine_p2n(*pitch2notation)

    notation_styles = tuple(
        notation.MelodicLineStyle("Large", label, False, True, False)
        for label in ("+", "-"))
    vertical_line_metrical = notation.VerticalLine(1.6, "", 1)
    vertical_line_compound = notation.VerticalLine(0.9, "", 1)
    vertical_line_unit = notation.VerticalLine(0.15, "", 1)
    vertical_line_style = notation.VerticalLineStyle(vertical_line_metrical,
                                                     vertical_line_compound,
                                                     vertical_line_unit)

    re = mk_re()
    render_engines = (re, re)

    return instruments.Instrument(
        "Siter_gong",
        pitch2notation,
        notation_styles,
        render_engines,
        vertical_line_style,
    )
示例#3
0
 def adapt_vertical_line(
         self,
         vertical_line: notation.VerticalLine) -> notation.VerticalLine:
     if self.thickness:
         thickness = self.thickness
     else:
         thickness = vertical_line.thickness
     if self.color:
         color = self.color
     else:
         color = vertical_line.color
     if self.amount_lines:
         amount_lines = self.amount_lines
     else:
         amount_lines = vertical_line.amount
     return notation.VerticalLine(thickness, color, amount_lines)
示例#4
0
def __mk_tak():
    def mk_re():
        def mk_tak_cycle():
            names = tuple("samples/klapper/{0}.wav".format(idx) for idx in range(5))
            return itertools.cycle(tuple((n, 1, 0.59) for n in names))

        def mk_schlitz_kurz_cycle():
            names = tuple(
                "samples/schlitztrommel/kurz/{0}.wav".format(idx) for idx in range(6)
            )
            return itertools.cycle(tuple((n, 1, 1.1) for n in names))

        def mk_schlitz_lang_cycle():
            names = tuple(
                "samples/schlitztrommel/lang/{0}.wav".format(idx) for idx in range(5)
            )
            return itertools.cycle(tuple((n, 1, 1.1) for n in names))

        short_pitch = ji.r(1, 1)
        long_pitch = ji.r(1, 2)
        tak_pitch = ji.r(3, 2)
        pitch2sample = {
            tak_pitch: mk_tak_cycle(),
            short_pitch: mk_schlitz_kurz_cycle(),
            long_pitch: mk_schlitz_lang_cycle(),
        }

        return sound.SampleEngine(pitch2sample)

    pitches = sw.translate("1 .1 3", False)

    pitch2notation = instruments.mk_p2n(pitches, 0)

    notation_styles = tuple(
        notation.MelodicLineStyle("Large", "", True, True, True) for i in range(1)
    )
    vertical_line = notation.VerticalLine(0.5, "", 1)
    vertical_line_style = notation.VerticalLineStyle(
        vertical_line, vertical_line, vertical_line
    )

    re = mk_re()
    render_engines = (re,)

    return instruments.Instrument(
        "Tak", pitch2notation, notation_styles, render_engines, vertical_line_style
    )
示例#5
0
def __mk_kecapi(inverse: bool, is_positive: bool):
    def mk_pitches(main, side, inverse=False):
        if main == 9:
            primes = (5, 7)
        else:
            primes = (3, 5, 7)
        special = functools.reduce(operator.mul,
                                   tuple(p for p in primes if p != main))
        if is_positive and not inverse:
            p0 = ji.r(main, 1)
            p1 = ji.r(main, special)
        elif not is_positive and not inverse:
            p0 = ji.r(main, special)
            p1 = ji.r(main, 1)
        elif is_positive and inverse:
            p0 = ji.r(special, main)
            p1 = ji.r(1, main)
        elif not is_positive and inverse:
            p0 = ji.r(1, main)
            p1 = ji.r(special, main)
        else:
            raise ValueError()

        p0 = p0.normalize(2)
        p1 = p1.normalize(2) + ji.r(4, 1)

        p_between = (ji.r(main, s) for s in side)
        if inverse:
            p_between = (p.inverse() for p in p_between)
        p_inbetween = tuple(p.normalize(2) + ji.r(2, 1) for p in p_between)
        return (p0, ) + p_inbetween + (p1, )

    def mk_re():
        harp_range = tuple(range(20, 110))
        se = sound.PyteqEngine(preset='"Concert Harp Recording"',
                               available_midi_notes=harp_range)
        return se

    primes = (9, 7, 5, 3)
    pitches = tuple(
        mk_pitches(p, tuple(s for s in primes if s != p), inverse)
        for p in primes)

    pitch2notation = tuple(
        instruments.mk_p2n(p, idx) for idx, p in enumerate(pitches))
    pitch2notation = instruments.combine_p2n(*pitch2notation)

    notation_styles = tuple(
        notation.MelodicLineStyle("Large", "", True, False, True)
        for i in range(4))
    vertical_line = notation.VerticalLine(0.5, "", 1)
    vertical_line_style = notation.VerticalLineStyle(vertical_line,
                                                     vertical_line,
                                                     vertical_line)
    re = mk_re()
    render_engines = (re, re, re, re)

    if inverse:
        name = "Kecapi_minus"
    else:
        name = "Kecapi_plus"

    return instruments.Instrument(name, pitch2notation, notation_styles,
                                  render_engines, vertical_line_style)
def __mk_siter_barung():
    def mk_pitches(inverse=False):
        pitches0 = tuple(ji.r(p**2, 1) for p in (3, 5, 7))
        pitches0 += (ji.r(3**3, 1), )
        pitches1 = tuple(ji.r(p, 1) for p in (9, 19, 5, 11, 3, 13, 7))
        pitches2 = tuple(ji.r(1, 1) for p in (1, ))
        octaves = (ji.r(1, 2), ji.r(1, 1), ji.r(2, 1))
        pitches = (pitches0, pitches1, pitches2)
        if inverse:
            pitches = tuple(tuple(p.inverse() for p in pi) for pi in pitches)
        return functools.reduce(
            operator.add,
            tuple(
                tuple(p.normalize(2) + o for p in pi)
                for pi, o in zip(pitches, octaves)),
        )

    def mk_re():
        return sound.PyteqEngine(preset='"Cimbalom hard"')

    pitches0 = mk_pitches(False)
    pitches1 = mk_pitches(True)
    pitches = (pitches0, pitches1)
    pitch2notation = tuple(
        instruments.mk_p2n(p, idx) for idx, p in enumerate(pitches))

    pitch2notation_plus, pitch2notation_minus = pitch2notation
    pitch2notation = instruments.combine_p2n(*tuple(pitch2notation))

    notation_styles = tuple(
        notation.MelodicLineStyle("Large", label, False, True, True)
        for label in ("+", "-"))
    vertical_line = notation.VerticalLine(0.5, "", 1)
    vertical_line_style = notation.VerticalLineStyle(vertical_line,
                                                     vertical_line,
                                                     vertical_line)

    re = mk_re()
    render_engines = (re, re)

    full = instruments.Instrument(
        "Siter_barung",
        pitch2notation,
        notation_styles,
        render_engines,
        vertical_line_style,
    )

    plus = instruments.Instrument(
        "Siter_barung",
        pitch2notation_plus,
        notation_styles[:1],
        render_engines[:1],
        vertical_line_style,
    )

    minus = instruments.Instrument(
        "Siter_barung",
        pitch2notation_plus,
        notation_styles[1:],
        render_engines[1:],
        vertical_line_style,
    )

    return full, plus, minus