title: Recasting an array in C
body: <p>I have an embedded application that is reading 16-bit signed audio data off an SD card via 8-bit reads with SPI, so a buffer of <code>uint8_t</code> that is 2x as long as the audio sample, and then forwarding it on via I2S, which wants that same data as 16-bit values, so a buffer of <code>int16_t</code>.  Since the data in the array is already the 16-bit values, but split into 8-bit boxes, I would want to now deal with the array as an array of <code>int16_t</code>.  Is this possible without having to copy the contents?  Here's an example:</p>
  <pre><code>uint8_t i2s_buffer[4096];
  
  /* spi_read performs 8-bit reads, so it reads the first half (MSB)
   * of the 16-bit signed audio sample first, then reads the second
   * half (LSB)
   */
  spi_read(i2s_buffer, sizeof(12s_buffer), address);
  
  /* Now i2s register is 32-bit wide, so takes
   * 4 8-bit samples, 2 16-bit samples, etc
   * but the width is set to 16-bit signed since the audio sample
   * is 16-bit signed, so we want the system to think of the
   * values as 16-bit, thus forcing the LRCLK to tick every half-buffer.
   */
  i2s_start( &lt;&lt;i2s_buffer but 16 bits at a time as int16_t&gt;&gt; , sizeof((int16_t*)i2s_buffer) / sizeof(int32_t));
  </code></pre>