readMidiVariablelength method

int readMidiVariablelength()

Implementation

int readMidiVariablelength()
{
    var acc = 0;
    var count = 0;
    while (true)
    {
        var value = readUInt8();
        acc = (acc << 7) | (value & 127);
        if ((value & 128) == 0)
        {
            break;
        }
        count++;
        if (count == 4)
        {
            throw "The length of the value must be equal to or less than 4.";
        }
    }
    return acc;
}