- commit
- cc706c0e88909a4fad2a998a4ff8843322a094e8
- parent
- 37c9da9eccca24a5daef7c15a618733f6e4fea78
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2019-12-18 17:56
output stereo
Diffstat
| M | beat.c | 11 | ++++++----- |
1 files changed, 6 insertions, 5 deletions
diff --git a/beat.c b/beat.c
@@ -7,7 +7,7 @@ 7 7 #define BUFSIZE (1 << 12) 8 8 9 9 struct ring {10 -1 float buf[BUFSIZE];-1 10 float buf[BUFSIZE * 2]; 11 11 struct ring *next; 12 12 }; 13 13 @@ -20,7 +20,7 @@ struct ring *first; 20 20 21 21 struct ring *create_ring(void) { 22 22 struct ring *c = (struct ring *)malloc(sizeof(struct ring));23 -1 memset(c->buf, 0, BUFSIZE * sizeof(float));-1 23 memset(c->buf, 0, BUFSIZE * 2 * sizeof(float)); 24 24 return c; 25 25 } 26 26 @@ -54,7 +54,8 @@ void add_file_at_beat(const char *path, int beat) { 54 54 } 55 55 cur = cur->next; 56 56 }57 -1 cur->buf[rel_pos] += fbuf[i] * factor;-1 57 cur->buf[rel_pos * 2] += fbuf[i] * factor; -1 58 cur->buf[rel_pos * 2 + 1] += fbuf[i] * factor; 58 59 } 59 60 } 60 61 @@ -86,7 +87,7 @@ int main(int argc, char **argv) { 86 87 first->next = first; 87 88 88 89 SF_INFO sfinfo;89 -1 sfinfo.channels = 1;-1 90 sfinfo.channels = 2; 90 91 sfinfo.format = SF_FORMAT_FLAC | SF_FORMAT_PCM_16; 91 92 sfinfo.frames = frames; 92 93 sfinfo.samplerate = samplerate; @@ -101,7 +102,7 @@ int main(int argc, char **argv) { 101 102 102 103 while (beat * frames_per_beat >= (buf_cur + 1) * BUFSIZE) { 103 104 _sf_writef_float(outfile, first->buf);104 -1 memset(first->buf, 0, BUFSIZE * sizeof(float));-1 105 memset(first->buf, 0, BUFSIZE * 2 * sizeof(float)); 105 106 106 107 first = first->next; 107 108 buf_cur += 1;