From 696ff6e9b573802a697a182f00b962f645e89f5e Mon Sep 17 00:00:00 2001 From: Charlie McConnell Date: Fri, 2 Aug 2013 18:13:57 -0400 Subject: [PATCH 1/3] Allow use of float instead of short when desired --- src/wav2json.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wav2json.cpp b/src/wav2json.cpp index cd6d889..5ee7e80 100644 --- a/src/wav2json.cpp +++ b/src/wav2json.cpp @@ -97,7 +97,11 @@ void compute_waveform( using std::endl; // you can change it to float or short, short was much faster for me. +#ifdef USE_FLOAT + typedef float sample_type; +#else typedef short sample_type; +#endif samples = std::min(wav.frames(), (sf_count_t)samples); From d8e36b781ac4a905cfe8356541bfcf44caaf9d03 Mon Sep 17 00:00:00 2001 From: Charlie McConnell Date: Fri, 2 Aug 2013 18:14:55 -0400 Subject: [PATCH 2/3] Define USE_FLOAT if provided at build time This allows users to compile wav2json with `USE_FLOAT=1 make all` so that the program will be able to analyze 32-bit floating point wav files, as well as the supported bit rates. --- build/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/Makefile b/build/Makefile index d8957b8..00b073e 100644 --- a/build/Makefile +++ b/build/Makefile @@ -18,6 +18,10 @@ INCLUDES=\ -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/include/ endif +ifdef USE_FLOAT + LD_PLATFORM_FLAGS+=-DUSE_FLOAT +endif + all: $(BINARY) $(SRC)/version.hpp: Makefile version.txt From dfc870c0d8a42f973bfe631a100bd17b0a7a64db Mon Sep 17 00:00:00 2001 From: Charlie McConnell Date: Tue, 6 Aug 2013 17:31:11 -0400 Subject: [PATCH 3/3] Allow output to stdout A previous closed issue mentioned using '-' to have wav2json output the json results to stdout, but it does not seem to have been implemented. This implements that feature. --- src/main.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 52901c2..a6847a8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,7 +24,16 @@ int main(int argc, char* argv[]) using std::cout; using std::cerr; - std::ofstream ofs(options.output_file_name.c_str()); + std::ofstream output; + std::ostream ofs(std::cout.rdbuf()); + + // If the output file name provided is "-", use stdout. Otherwise open the filename provided. + if (strncmp(options.output_file_name.c_str(), "-", 1)) + { + output.open(options.output_file_name.c_str()); + ofs.rdbuf(output.rdbuf()); + } + //it appears, that javascript is fine with scientific notation //ofs << std::fixed; //explicitly use fixed notation