- commit
- 8af26cee8be29115d05c7deff1edf0aa77350281
- parent
- e1e6cc95c33b9b1e5b4200d90116f04b868b7f03
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2019-12-18 12:52
dynamic write
Diffstat
| M | beat.c | 14 | ++++++-------- |
1 files changed, 6 insertions, 8 deletions
diff --git a/beat.c b/beat.c
@@ -26,6 +26,8 @@ void add_file_at_beat(const char *path, int beat) {
26 26 SF_INFO sfinfo;
27 27 SNDFILE *infile = sf_open(path, SFM_READ, &sfinfo);
28 28
-1 29 struct context *curctx = ctx;
-1 30
29 31 // assert sfinfo.samplerate == samplerate
30 32 // assert sfinfo.channels == 1
31 33
@@ -38,15 +40,11 @@ void add_file_at_beat(const char *path, int beat) {
38 40 for (int i = 0; i < count; ++i) {
39 41 pos += 1;
40 42 rel_pos += 1;
41 -1 if (rel_pos >= 2 * BUFSIZE) {
42 -1 printf("dropping %s at %i\n", path, pos);
43 -1 sf_close(infile);
44 -1 return;
45 -1 } else if (rel_pos >= BUFSIZE) {
46 -1 ctx->next->buf[rel_pos - BUFSIZE] += fbuf[i] * factor;
47 -1 } else {
48 -1 ctx->buf[rel_pos] += fbuf[i] * factor;
-1 43 while (rel_pos >= BUFSIZE) {
-1 44 rel_pos -= BUFSIZE;
-1 45 curctx = curctx->next;
49 46 }
-1 47 curctx->buf[rel_pos] += fbuf[i] * factor;
50 48 }
51 49 }
52 50