| 54 | |
| 55 | |
| 56 | bool Audio_file_reader::open(const char *filename, Scorealign &sa, bool verbose) |
| 57 | { |
| 58 | bytes_per_frame = 0; // initialize now in case an error occurs |
| 59 | name[0] = 0; |
| 60 | bzero(&sf_info, sizeof(sf_info)); |
| 61 | sf = sf_open(filename, SFM_READ, &sf_info); |
| 62 | if (!sf) { |
| 63 | #ifdef WIN32 |
| 64 | /* windows-specific code to report error opening file */ |
| 65 | char *msg; |
| 66 | DWORD code = GetLastError(); |
| 67 | DWORD code2 = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | |
| 68 | FORMAT_MESSAGE_FROM_SYSTEM, |
| 69 | 0, code, 0, (LPSTR) &msg, 0, 0); |
| 70 | printf("Error string: %s\n", msg); |
| 71 | LocalFree(msg); |
| 72 | #endif |
| 73 | return false; |
| 74 | } |
| 75 | strncpy(name, filename, MAX_NAME_LEN); |
| 76 | name[MAX_NAME_LEN] = 0; // just in case |
| 77 | total_frames = (long) sf_seek(sf, 0, SEEK_END); |
| 78 | sf_seek(sf, 0, SEEK_SET); |
| 79 | // we're going to read floats, but they might be multi-channel... |
| 80 | bytes_per_frame = sf_info.channels * sizeof(float); |
| 81 | calculate_parameters(sa, verbose); |
| 82 | return true; |
| 83 | } |
| 84 | |
| 85 | |
| 86 | void Audio_file_reader::close() |
no outgoing calls