From b5367ea57e4d1769db5dde6245345aa2279e868f Mon Sep 17 00:00:00 2001 From: Karchnu Date: Mon, 26 Jun 2023 12:57:07 +0200 Subject: [PATCH] Slightly improved distort.c. --- c/distort.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 118 insertions(+), 13 deletions(-) diff --git a/c/distort.c b/c/distort.c index d9a386a..74d6ea3 100644 --- a/c/distort.c +++ b/c/distort.c @@ -6,18 +6,22 @@ #define BUFFER_LEN 1024 +void applyOverdriveDistortion (SNDFILE *inputFile, SNDFILE *outputFile); +void applyFuzzDistortion (SNDFILE *inputFile, SNDFILE *outputFile); +void applyDistortion (SNDFILE *inputFile, SNDFILE *outputFile); +void applyBoostDistortion (SNDFILE *inputFile, SNDFILE *outputFile, float gain); + int main(int argc, char **argv) { int distortionLevel; SNDFILE *infile, *outfile; SF_INFO sfinfo; - double buffer[BUFFER_LEN]; // Check for distortion level argument - if (argc < 2) { - printf("Usage: %s distortion_level\n", argv[0]); + if (argc < 3) { + printf("Usage: %s distortion-type distortion_level\n", argv[0]); return 1; } - distortionLevel = atoi(argv[1]); + distortionLevel = atoi(argv[2]); // Open standard input as input file if (!(infile = sf_open_fd(0, SFM_READ, &sfinfo, 0))) { @@ -31,16 +35,34 @@ int main(int argc, char **argv) { return 1; } - // Read and process data - while (sf_read_double(infile, buffer, BUFFER_LEN) > 0) { - for (int i=0; i 0) { +// for (int i=0; i