title: aplay read error when editing code in main
body: <p>I have a file named experiment.cpp. In the main function, I extract the mono channel and downsample it. I was able to run experiment.cpp and it performed the process as described. However, I wanted to put mono processing in a single file outside of experiment.cpp. Just by putting the mono processing part of the main function code in comments, I got this &quot;aplay: read_header:2834:read error&quot; error. I'd like to know why I got this error and how to solve it.
  <a href="https://i.stack.imgur.com/KCOmh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KCOmh.png" alt="enter image description here" /></a></p>
  <pre><code>#include &quot;dy4.h&quot;
  #include &quot;filter.h&quot;
  #include &quot;fourier.h&quot;
  #include &quot;genfunc.h&quot;
  #include &quot;iofunc.h&quot;
  #include &quot;logfunc.h&quot;
  #include &lt;cmath&gt;
  #include &lt;cstdlib&gt;
  #include &lt;list&gt;
  #include &lt;iostream&gt;
  #include &lt;chrono&gt;
  #include &lt;thread&gt;
  //int main(){
  int main(int argc, char* argv[]){
  
      int mode = 0;
      if(argc &lt; 2){
          std::cerr &lt;&lt; &quot; Operating in default mode 0&quot; &lt;&lt; std::endl;
      } else if (argc == 2){
          mode = atoi(argv[1]);
          if (mode != 1){
              std::cerr &lt;&lt; &quot;Wrong mode&quot; &lt;&lt; mode &lt;&lt; std::endl;
              exit(1);
          }
      }else{
          std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; argv[0] &lt;&lt; std::endl;
          std::cerr &lt;&lt; &quot;or&quot; &lt;&lt;std::endl;
          std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; argv[0] &lt;&lt; &quot; 1&quot; &lt;&lt; std::endl;
          exit(1);
      }
      int rf_Fs = 2.4e6;
      int rf_Fc = 100e3;
      int rf_taps = 50;
      int rf_decim = 10;
  
    int rf1_Fs = 2.5e6;
      int mode0_Fs = 240e3;
      int mode0_decim = 5;
      int mode0_Fc =16e3;
      int mode0_taps = 50;
  
      int expand_rate = 24;
      int mode1_Fs = 250e3*expand_rate;
      int mode1_Fc = mode0_Fc;
      int mode1_decim = 125;
      int mode1_taps = 1250;
  
    std::vector&lt;float&gt; rf_coeff;
      std::vector&lt;float&gt; rf1_coeff;
      std::vector&lt;float&gt; mode0_coeff;
      std::vector&lt;float&gt; mode1_coeff;
  
      impulseResponseLPF(rf_Fs, rf_Fc, rf_taps, rf_coeff);
      impulseResponseLPF(rf1_Fs, rf_Fc, rf_taps, rf1_coeff);
      impulseResponseLPF(mode0_Fs, mode0_Fc, mode0_taps,mode0_coeff);
      impulseResponseLPF(mode1_Fs, mode1_Fc, mode1_taps,mode1_coeff);
      int BLOCK_SIZE = 1024*rf_decim*mode0_decim*2;
      std::vector&lt;float&gt; state_i_lpf_100k;
      state_i_lpf_100k.resize(rf_taps-1,0.0);
      std::vector&lt;float&gt; state_q_lpf_100k;
      state_q_lpf_100k.resize(rf_taps-1,0.0);
      std::vector&lt;float&gt; state_phase;
      state_phase.resize(2,0.0);
      std::vector&lt;float&gt; mode0_lpf_16k;
      std::vector&lt;float&gt; mode1_lpf_16k;
      mode0_lpf_16k.resize(mode0_taps-1,0.0);
      mode1_lpf_16k.resize(mode1_taps-1,0.0);
      std::vector&lt;float&gt; temp_I;
      temp_I.resize(BLOCK_SIZE/2,0.0);
      std::vector&lt;float&gt; temp_Q;
      temp_Q.resize(BLOCK_SIZE/2,0.0);
      std::vector&lt;float&gt; i_filt;
    std::vector&lt;float&gt; q_filt;
      std::vector&lt;float&gt; mode0_filt;
      std::vector&lt;float&gt; mode1_filt;
      std::vector&lt;float&gt; i_ds;
    std::vector&lt;float&gt; q_ds;
      std::vector&lt;float&gt; mode0_block;
      mode0_block.resize(BLOCK_SIZE/rf_decim/mode0_decim,0.0);
      std::vector&lt;float&gt; mode1_block;
      mode1_block.resize(BLOCK_SIZE*13/rf_decim/mode1_decim,0.0);
      std::vector&lt;float&gt; fm_demod;
      std::vector&lt;float&gt; exp_fm_demod;
      int mode0_data_size;
      std::vector&lt;short int&gt; mode0_data;
      mode0_data.resize(BLOCK_SIZE,0.0);
      int mode1_data_size;
      std::vector&lt;short int&gt; mode1_data;
      mode1_data.resize(BLOCK_SIZE,0.0);
      std::vector&lt;float&gt; block_data(BLOCK_SIZE);
      //mono_processing() commented out
   return 0;
  
  }
  </code></pre>