med

C Basic Music Studio
git clone git://git.kocotian.pl/cbms.git
Log | Files | Refs

commit ad5e14ce032bc64398d2c5df4b5439aa7e6b50f2
parent e66179cc17ffdb9e547615c104eb1686919cb775
Author: kocotian <kocotian@kocotian.pl>
Date:   Wed,  2 Dec 2020 15:04:36 +0100

wave reversing

Diffstat:
Mcbms | 0
Mcbms.c | 18+++++++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/cbms b/cbms Binary files differ. diff --git a/cbms.c b/cbms.c @@ -9,6 +9,7 @@ static void dumpwave(float *wave, size_t wsize); static size_t readf32le(char *filename, float **wave); static void savef32le(char *filename, float *wave, size_t wsize); +static void wavereverse(float **wave, size_t beginning, size_t ending); static void usage(void); char *argv0; @@ -79,6 +80,21 @@ savef32le(char *filename, float *wave, size_t wsize) } static void +wavereverse(float **wave, size_t beginning, size_t ending) +{ + size_t bufsiz = ending - beginning; + float *wavebuf = malloc(sizeof(float) * bufsiz); + size_t iter = -1; + while (++iter < bufsiz) + wavebuf[iter] = (*wave)[beginning + iter]; + iter = -1; ++ending; + while (ending-- > beginning) { + (*wave)[(iter + beginning) - 1] = wavebuf[bufsiz - ++iter]; + } + free(wavebuf); +} + +static void usage(void) { die("usage: %s [-v] [-f waveformat] wave", argv0); @@ -111,7 +127,7 @@ main(int argc, char *argv[]) else die("unknown wave format [check -f parameter]"); - dumpwave(wave, wsize); + wavereverse(&wave, 0, wsize); savef32le(argv[0], wave, wsize); free(wave); }