Parallel generation and coding of a terahertz pulse train