def _brahmic(data, scheme_map, **kw):
    """Transliterate `data` with the given `scheme_map`. This function is used
    when the source scheme is a Brahmic scheme.

    :param data: the data to transliterate
    :param scheme_map: a dict that maps between characters in the old scheme
                       and characters in the new scheme
    """
    marks = scheme_map.marks
    virama = scheme_map.virama
    consonants = scheme_map.consonants
    other = scheme_map.other
    to_roman = scheme_map.to_roman
    buf = []
    had_consonant = False
    append = buf.append
    for L in data:
        if L in marks:
            append(marks[L])
        elif L in virama:
            append(virama[L])
        else:
            if had_consonant:
                append('a')
            append(other.get(L, L))
        had_consonant = to_roman and L in consonants
    if had_consonant:
        append('a')
    return ''.join(buf)
