This puzzle doesn’t need gears. Whenever the blue leaver is triggered, exactly 4 blue balls must be released. This can be achieved using a 2 bit register (A in the solution) on the blue input.
The red input must trigger the pattern “b-r-r-b-r-r-r”. Bit B splits the input into two sequences. The left branch must generate the first, third, fifth and seventh balls as “b-r-r-r” and the right must generate the second, fourth and sixth as “r-b-r”.
The left branch feeds into 2 bit register C that sends one blue followed by three reds and the right into the bit D that alternated between red and blue.
The area between all the bits is filled with crossovers – any leftward central motion generates a blue and rightward a red.