C++ reading 16bit Wav file

前端 未结 5 1030
感情败类
感情败类 2021-01-07 05:11

I\'m having trouble reading in a 16bit .wav file. I have read in the header information, however, the conversion does not seem to work.

For example, in Matlab if I r

5条回答
  •  轮回少年
    2021-01-07 05:38

    My working code is

    int8_t* buffer = new int8_t[size];
    /*
      HERE buffer IS FILLED
    */
    for (int i = 0; i < size; i += 2)
    {
        int16_t c = ((unsigned char)buffer[i + 1] << 8) | (unsigned char)buffer[i];
        double t = c/32768.0;
        rawSignal.push_back(t);
    }
    

提交回复
热议问题