What is conceptually happening in this modulation function?
My question is what is significant of this two lines

The code receives a buffer of bytes but the modulation is based on a stream of bits. The outer loop loops over all bytes in the buffer. The
 for (int j = 0; j &lt; 8; j++) {  

This loops over all 8 bits in the current byte
int bit = (buf[i] &gt;&gt; j) &amp; 0x01  

This tests whether the j'th bit in the current byte is 1 on 0, where j = 0 produces the LSb and j = 7 produces the MSb.
If your current byte is 0b11001001, then the variable &quot;bit&quot; will be 1, 0, 0, 1, 0, 0, 1, 1 in each of the 8 loop iterations. Depending whether the current bit is 1 or 0, the modulated signal is generated in phase or out of phase.