| 31 | |
| 32 | |
| 33 | long Audio_file_reader::read(float *data, long n) |
| 34 | { |
| 35 | // note that "samples_per_frame" is really "frames_per_window" in this |
| 36 | // context, so we're computing bytes per window |
| 37 | float *input_data = (float *) alloca(bytes_per_frame * samples_per_frame); |
| 38 | assert(input_data != NULL) ; |
| 39 | |
| 40 | long frames_read = (long) sf_readf_float(sf, input_data, n); |
| 41 | long chans = sf_info.channels; |
| 42 | // now convert to mono and move to data |
| 43 | for (int frame = 0; frame < frames_read; frame++) { |
| 44 | float sum = 0; |
| 45 | for (int chan = 0; chan < sf_info.channels; chan++) { |
| 46 | // sum over channels within a frame |
| 47 | sum += input_data[frame * chans + chan]; |
| 48 | } |
| 49 | // write the frame sum to result array |
| 50 | data[frame] = sum; |
| 51 | } |
| 52 | return frames_read; |
| 53 | } |
| 54 | |
| 55 | |
| 56 | bool Audio_file_reader::open(const char *filename, Scorealign &sa, bool verbose) |
no outgoing calls
no test coverage detected