- commit
- e85472798c43ad1786ed499adac6bb71af732610
- parent
- 305f891982da5efbafccc49bc7bd8a14dd437131
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-12-22 07:49
add error handling
Diffstat
| M | beat.c | 11 | +++++++++++ |
1 files changed, 11 insertions, 0 deletions
diff --git a/beat.c b/beat.c
@@ -29,8 +29,19 @@ void add_file_at_beat(const char *path, int beat) {
29 29 SF_INFO sfinfo;
30 30 SNDFILE *infile = sf_open(path, SFM_READ, &sfinfo);
31 31
-1 32 if (infile == NULL) {
-1 33 printf("ERROR: Could not open file: %s\n", path);
-1 34 exit(1);
-1 35 }
-1 36
32 37 int ibs = 1024;
33 38 int pos = beat * frames_per_beat;
-1 39
-1 40 if (pos < buf_cur * BUFSIZE) {
-1 41 printf("ERROR: beat is smaller than previous: %i\n", beat);
-1 42 exit(1);
-1 43 }
-1 44
34 45 int rel_pos = pos - buf_cur * BUFSIZE;
35 46 float fbuf[ibs * sfinfo.channels];
36 47