def METHOD_NAME(output, base_indent_depth, num_channels):
    def write(data, depth=0):
        output.append(
            " " * (BASIC_INDENT * (depth + base_indent_depth)) + data
        )
    header = "static inline void %s(" % copy_with_ramping_gain_method_name(
        num_channels
    )
    arg_groups = (
        ["CSAMPLE* M_RESTRICT pDest"]
        + [
            (
                "const CSAMPLE* M_RESTRICT pSrc%(i)d, "
                "CSAMPLE_GAIN gain%(i)din, CSAMPLE_GAIN gain%(i)dout"
            )
            % {"i": i}
            for i in range(num_channels)
        ]
        + ["int iNumSamples"]
    )
    output.extend(
        hanging_indent(header, arg_groups, ",", ") {", depth=base_indent_depth)
    )
    for i in range(num_channels):
        write(
            (
                "if (gain%(i)din == CSAMPLE_GAIN_ZERO && "
                "gain%(i)dout == CSAMPLE_GAIN_ZERO) {"
            )
            % {"i": i},
            depth=1,
        )
        if num_channels > 1:
            args = (
                ["pDest"]
                + [
                    "pSrc%(i)d, gain%(i)din, gain%(i)dout" % {"i": j}
                    for j in range(num_channels)
                    if i != j
                ]
                + ["iNumSamples"]
            )
            write(
                "%s;"
                % method_call(
                    copy_with_ramping_gain_method_name(num_channels - 1), args
                ),
                depth=2,
            )
        else:
            write("clear(pDest, iNumSamples);", depth=2)
        write("return;", depth=2)
        write("}", depth=1)
    for i in range(num_channels):
        write(
            (
                "const CSAMPLE_GAIN gain_delta%(i)d = "
                "(gain%(i)dout - gain%(i)din) / (iNumSamples / 2);"
            )
            % {"i": i},
            depth=1,
        )
        write(
            (
                "const CSAMPLE_GAIN start_gain%(i)d = "
                "gain%(i)din + gain_delta%(i)d;"
            )
            % {"i": i},
            depth=1,
        )
    write("// note: LOOP VECTORIZED.", depth=1)
    write("for (int i = 0; i < iNumSamples / 2; ++i) {", depth=1)
    for i in range(num_channels):
        write(
            (
                "const CSAMPLE_GAIN gain%(i)d = "
                "start_gain%(i)d + gain_delta%(i)d * i;"
            )
            % {"i": i},
            depth=2,
        )
    terms1 = []
    terms2 = []
    for i in range(num_channels):
        terms1.append("pSrc%(i)d[i * 2] * gain%(i)d" % {"i": i})
        terms2.append("pSrc%(i)d[i * 2 + 1] * gain%(i)d" % {"i": i})
    assign1 = "pDest[i * 2] = "
    assign2 = "pDest[i * 2 + 1] = "
    output.extend(hanging_indent(assign1, terms1, " +", ";", depth=2))
    output.extend(hanging_indent(assign2, terms2, " +", ";", depth=2))
    write("}", depth=1)
    write("}")