diff options
author | cbdev <cb@cbcdn.com> | 2021-04-19 19:23:35 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2021-04-19 19:23:35 +0200 |
commit | d0a273724b2bb2ad775d0461fe8ee5de1e6bad2f (patch) | |
tree | 23a09977097c0ad18a8eedb352120a8bfa6d9555 | |
parent | 419ab539dd22b11279310745dbf78e5b18f50cce (diff) | |
download | cswave-d0a273724b2bb2ad775d0461fe8ee5de1e6bad2f.tar.gz cswave-d0a273724b2bb2ad775d0461fe8ee5de1e6bad2f.tar.bz2 cswave-d0a273724b2bb2ad775d0461fe8ee5de1e6bad2f.zip |
Add README & Licensev0.1
-rw-r--r-- | LICENSE.txt | 22 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 39 | ||||
-rw-r--r-- | cswave.c | 4 |
4 files changed, 64 insertions, 3 deletions
diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..5827d3c --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2021, cbdev/FJS +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -1,6 +1,6 @@ CFLAGS = -g -Wall -Wpedantic -all: cswave cswave.exe +all: cswave cswave: cswave.c diff --git a/README.md b/README.md new file mode 100644 index 0000000..caf4f3e --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# cswave + +`cswave` is a small, cross-platform utility to convert CSV sample data to WAVE files. This can be used to do further analysis or processing on the +data using audio tooling. + +Any column of the input file can be used as sample data for a resulting monophonic wave file, in one of the supported formats + +* `i8`: 8 bit unsigned integer data +* `i16`: 16bit signed little-endian data +* `i32`: 32bit signed little-endian data +* `f32`: 32bit IEEE float data + +Note that the integer output data formats only use the integer part of the input data, ie. when using the `i32` output format, the input sample +value `1.23` is truncated to the output sample value `1`. + +When using the integer output data formats, the exact sample value is preserved (as long as it fits the storage size). For the `f32` format, the +specification requires that the samples be normalized to the range `-1.0` to `1.0`, thus the sample values will not be preserved. + +Quoted text embedding the separation character `,` within CSV columns will confuse the CSV parser. Don't do that. + +## Building + +To build `cswave`, running `make` within the project directory on a machine with a working C compiler should work. + +To build the windows executable `cswave.exe`, the `mingw-w64` crosscompiler is required. Use `make cswave.exe` to build it. + +## Usage + +Call the tool using the invocation + +``` +./cswave <file.csv> <file.wav> <column> <samplerate> [<format>] +``` + +* `<file.csv>`: CSV input file +* `<file.wav>`: Output file, will be overwritten without question if it already exists +* `<column>`: Zero-based column index within the CSV (e.g., `0`) +* `<samplerate>`: Integer sample rate of the resulting output file (e.g., `44100`) +* `<format>`: Output file sample format as listed above, default `i16` @@ -13,7 +13,6 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include <windows.h> - #include <winsock2.h> #define PRIsize_t "Iu" #define htole16(x) (x) #define htole32(x) (x) @@ -122,7 +121,8 @@ typedef struct /*_chunk_data*/ { static int usage(char* fn){ fprintf(stdout, "Call as %s <file.csv> <file.wav> <column> <samplerate> [<format>]\n", fn); - fprintf(stdout, "Possible formats: i8, i16 (default), i32, f32"); + fprintf(stdout, "Supported wave formats: i8, i16 (default), i32, f32\n"); + fprintf(stdout, "Note that when using integer output formats, floating point input samples will be truncated to their integer parts\n"); return EXIT_FAILURE; } |