From ffc4ac5d4189b73db7bf6ff39fc5113536e59426 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sun, 17 May 2020 19:19:21 -0400 Subject: [PATCH 01/14] Force float constants for TCC --- colorchord2/color.c | 70 ++++++++++++++++++++++----------------------- colorchord2/main.c | 3 +- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/colorchord2/color.c b/colorchord2/color.c index cd8a179..286d042 100644 --- a/colorchord2/color.c +++ b/colorchord2/color.c @@ -9,23 +9,23 @@ uint32_t CCtoHEX( float note, float sat, float value ) { float hue = 0.0; note = fmodf( note, 1.0 ); - note *= 12; - if( note < 4 ) + note *= 12.0; + if( note < 4.0 ) { //Needs to be YELLOW->RED - hue = (4 - note) / 24.0; + hue = (4.0 - note) / 24.0; } - else if( note < 8 ) + else if( note < 8.0 ) { // [4] [8] //Needs to be RED->BLUE - hue = ( 4 - note ) / 12.0; + hue = ( 4.0 - note ) / 12.0; } else { // [8] [12] //Needs to be BLUE->YELLOW - hue = ( 12 - note ) / 8.0 + 1./6.; + hue = ( 12.0 - note ) / 8.0 + 1.0/6.0; } return HSVtoHEX( hue, sat, value ); } @@ -41,44 +41,44 @@ uint32_t CCtoHEX( float note, float sat, float value ) uint32_t HSVtoHEX( float hue, float sat, float value ) { - float pr = 0; - float pg = 0; - float pb = 0; + float pr = 0.0; + float pg = 0.0; + float pb = 0.0; - short ora = 0; - short og = 0; - short ob = 0; + short ora = 0.0; + short og = 0.0; + short ob = 0.0; - float ro = fmod( hue * 6, 6. ); + float ro = fmod( hue * 6.0, 6.0 ); - float avg = 0; + float avg = 0.0; - ro = fmod( ro + 6 + 1, 6 ); //Hue was 60* off... + ro = fmod( ro + 6.0 + 1.0, 6.0 ); //Hue was 60* off... - if( ro < 1 ) //yellow->red + if( ro < 1.0 ) //yellow->red { - pr = 1; - pg = 1. - ro; - } else if( ro < 2 ) + pr = 1.0; + pg = 1.0 - ro; + } else if( ro < 2.0 ) { - pr = 1; - pb = ro - 1.; - } else if( ro < 3 ) + pr = 1.0; + pb = ro - 1.0; + } else if( ro < 3.0 ) { - pr = 3. - ro; - pb = 1; - } else if( ro < 4 ) + pr = 3.0 - ro; + pb = 1.0; + } else if( ro < 4.0 ) { - pb = 1; - pg = ro - 3; - } else if( ro < 5 ) + pb = 1.0; + pg = ro - 3.0; + } else if( ro < 5.0 ) { - pb = 5 - ro; - pg = 1; + pb = 5.0 - ro; + pg = 1.0; } else { - pg = 1; - pr = ro - 5; + pg = 1.0; + pr = ro - 5.0; } //Actually, above math is backwards, oops! @@ -90,9 +90,9 @@ uint32_t HSVtoHEX( float hue, float sat, float value ) avg += pg; avg += pb; - pr = pr * sat + avg * (1.-sat); - pg = pg * sat + avg * (1.-sat); - pb = pb * sat + avg * (1.-sat); + pr = pr * sat + avg * (1.0-sat); + pg = pg * sat + avg * (1.0-sat); + pb = pb * sat + avg * (1.0-sat); ora = pr * 255; og = pb * 255; diff --git a/colorchord2/main.c b/colorchord2/main.c index 4b96829..c1869ea 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -533,7 +533,8 @@ int main(int argc, char ** argv) { //printf( "%f %f /", note_positions[i], note_amplitudes[i] ); if( nf->note_amplitudes_out[i] < 0 ) continue; - CNFGDialogColor = CCtoHEX( (nf->note_positions[i] / freqbins), 1.0, 1.0 ); + float note = (float) nf->note_positions[i] / freqbins; + CNFGDialogColor = CCtoHEX( note, 1.0, 1.0 ); CNFGDrawBox( ((float)i / note_peaks) * screenx, 480 - nf->note_amplitudes_out[i] * 100, ((float)(i+1) / note_peaks) * screenx, 480 ); CNFGPenX = ((float)(i+.4) / note_peaks) * screenx; CNFGPenY = screeny - 30; From 9029c87c9684d67becce819eeaf7861af111b022 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sun, 17 May 2020 19:22:57 -0400 Subject: [PATCH 02/14] Make a function to manually register parameters. --- colorchord2/main.c | 62 ++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/colorchord2/main.c b/colorchord2/main.c index c1869ea..53421f4 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -143,9 +143,9 @@ int set_screenx = 640; REGISTER_PARAM( set_screenx, PAINT ); int set_screeny = 480; REGISTER_PARAM( set_screeny, PAINT ); char sound_source[16]; REGISTER_PARAM( sound_source, PABUFFER ); int cpu_autolimit = 1; REGISTER_PARAM( cpu_autolimit, PAINT ); -float cpu_autolimit_interval = 0.016; REGISTER_PARAM( cpu_autolimit_interval, PAFLOAT ); -int sample_channel = -1;REGISTER_PARAM( sample_channel, PAINT ); -int showfps = 1; REGISTER_PARAM( showfps, PAINT ); +float cpu_autolimit_interval = 0.016; REGISTER_PARAM( cpu_autolimit_interval, PAFLOAT ); +int sample_channel = -1; REGISTER_PARAM( sample_channel, PAINT ); +int showfps = 1; REGISTER_PARAM( showfps, PAINT ); #if defined(ANDROID) || defined( __android__ ) float in_amplitude = 2; @@ -308,17 +308,11 @@ void HandleResume() } #endif -int main(int argc, char ** argv) -{ - int i; -#if defined(__TINYC__) - // zero out the drivers list - for ( int ii = 0; i< MAX_OUT_DRIVERS; ++i) { - ODList[i].Name = NULL; - ODList[i].Init = NULL; - } +// function for calling initilization functions if we are using TCC +#ifdef TCC +void RegisterConstructorFunctions(){ - + // Basic Window stuff REGISTERheadless(); REGISTERset_screenx(); REGISTERset_screeny(); @@ -327,12 +321,43 @@ int main(int argc, char ** argv) REGISTERcpu_autolimit_interval(); REGISTERsample_channel(); REGISTERshowfps(); + REGISTERin_amplitude(); + + // Audio stuff + REGISTERNullCNFA(); + REGISTERWinCNFA(); + REGISTERcnfa_wasapi(); + + // Video Stuff + REGISTERnull(); + REGISTERDisplayArray(); + //REGISTERDisplayDMX(); + //REGISTERDisplayFileWrite(); + REGISTERDisplayHIDAPI(); + REGISTERDisplayNetwork(); + REGISTERDisplayOutDriver(); + REGISTERDisplayPie(); + //REGISTERDisplaySHM(); + + // Output stuff + //REGISTERDisplayUSB2812(); + REGISTEROutputCells(); + REGISTEROutputLinear(); + REGISTEROutputProminent(); + REGISTEROutputVoronoi(); + //REGISTERRecorderPlugin(); + + //void ManuallyRegisterDevices(); + //ManuallyRegisterDevices(); +} #endif +int main(int argc, char ** argv) +{ + int i; #ifdef TCC - void ManuallyRegisterDevices(); - ManuallyRegisterDevices(); + RegisterConstructorFunctions(); #endif printf( "Output Drivers:\n" ); @@ -345,10 +370,6 @@ int main(int argc, char ** argv) WSAStartup(0x202, &wsaData); - #ifdef TCC - REGISTERWinCNFA(); - REGISTERcnfa_wasapi(); - #endif strcpy( sound_source, "WASAPI" ); // Use either "sound_source=WASAPI" or "sound_source=WIN" in config file. #elif defined( ANDROID ) @@ -657,6 +678,3 @@ int main(int argc, char ** argv) } } - - - From cddec68e5b100b0860cdec6d96bcde611cd8dca4 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sun, 17 May 2020 19:23:35 -0400 Subject: [PATCH 03/14] Remove debugging printf. --- colorchord2/parameters.c | 1 - 1 file changed, 1 deletion(-) diff --git a/colorchord2/parameters.c b/colorchord2/parameters.c index 05ae639..3800694 100644 --- a/colorchord2/parameters.c +++ b/colorchord2/parameters.c @@ -137,7 +137,6 @@ static int SetParameter( struct Param * p, const char * str ) void RegisterValue( const char * name, enum ParamType t, void * ptr, int size ) { - printf("[SDE] Registering parameter %s\n", name); Init(); struct Param * p = (struct Param*)HashGetEntry( parameters, name ); From d10255bb610079ee5d727c84251c28ba025637f8 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sun, 17 May 2020 19:24:43 -0400 Subject: [PATCH 04/14] Make clang not use windows headers --- colorchord2/windows/compile-clang.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorchord2/windows/compile-clang.bat b/colorchord2/windows/compile-clang.bat index 0fcb356..648872f 100644 --- a/colorchord2/windows/compile-clang.bat +++ b/colorchord2/windows/compile-clang.bat @@ -1,5 +1,5 @@ set CC="C:\Program Files\LLVM\bin\clang.exe" -set CCFLAGS=-g -D_CRT_SECURE_NO_WARNINGS -Wno-deprecated-declarations -DICACHE_FLASH_ATTR= -Dstrdup=_strdup +set CCFLAGS=-g -D_CRT_SECURE_NO_WARNINGS -Wno-deprecated-declarations -DICACHE_FLASH_ATTR= -Dstrdup=_strdup -DNO_WIN_HEADERS set CCIFLAGS=-I../../embeddedcommon -I../cnfa -I../rawdraw -I../ -O1 set CCLFLAGS=-lwinmm -lgdi32 -lws2_32 -lsetupapi -lkernel32 -luser32 -ldbghelp -lole32 -lmmdevapi -lAvrt set SOURCES=../main.c ../dft.c ../decompose.c ../filter.c ../color.c ../notefinder.c ../util.c ../outdrivers.c ^ From af7afd6af56121ad2aec8069992c438a671bc25b Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sun, 17 May 2020 19:25:17 -0400 Subject: [PATCH 05/14] Make vscode settings file --- colorchord2/.vscode/c_cpp_properties.json | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 colorchord2/.vscode/c_cpp_properties.json diff --git a/colorchord2/.vscode/c_cpp_properties.json b/colorchord2/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..ef9161d --- /dev/null +++ b/colorchord2/.vscode/c_cpp_properties.json @@ -0,0 +1,26 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**", + "${workspaceFolder}/../embeddedcommon" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE", + "CNFA_IMPLEMENTATION", + "__TINYC__", + "TCC", + "NO_WIN_HEADERS" + ], + "windowsSdkVersion": "10.0.17763.0", + "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe", + "cStandard": "c11", + "cppStandard": "c++17", + "intelliSenseMode": "msvc-x64" + } + ], + "version": 4 +} \ No newline at end of file From 6fdbe1df893a756b281637937c0db3cfa53c79e6 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Mon, 18 May 2020 22:15:19 -0400 Subject: [PATCH 06/14] Edit the default configuration --- colorchord2/default.conf | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/colorchord2/default.conf b/colorchord2/default.conf index c8d2a9d..a568eae 100644 --- a/colorchord2/default.conf +++ b/colorchord2/default.conf @@ -22,15 +22,17 @@ wininput = -1 #Compiled version will default this. #sound_source = ALSA -#-1 indicates left and right, 0 left, 1 right. +#-1 indicates left and right, 0 left, 1 right. sample_channel = -1 -sourcename = default -#alsa_output.pci-0000_00_1f.3.analog-stereo.monitor -#default +devplay = default +devrecord = default + +# For Linux mostly use the following command to find valid devices to read from: +# pactl list | grep pci- | grep monitor +# alsa_output.pci-0000_00_1f.3.analog-stereo.monitor # alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -#alsa_output.pci-0000_00_1f.3.analog-stereo.monitor << New laptop -#use pactl list | grep pci- | grep monitor +# alsa_output.pci-0000_00_1f.3.analog-stereo.monitor << New laptop ################################## # General ColorChord properties. # @@ -41,7 +43,7 @@ amplify = 2.0 # What is the base note? I.e. the lowest note. # Note that it won't have very much impact until an octave up though! -base_hz = 55 +base_hz = 55 # This is only used when dealing with the slow decompose (now defunct) # decompose_iterations = 1000 @@ -88,8 +90,9 @@ note_out_chop = 0.05000 #Outputs -This is a vornoi thing: +# This is a vornoi thing: outdrivers = OutputVoronoi, DisplayArray +# outdrivers = DisplayPie, DisplayArray lightx = 64 lighty = 32 fromsides = 1 From 2b0bb5a78d34933a4c0ab57713371bc3aec252c1 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Tue, 19 May 2020 23:19:58 -0400 Subject: [PATCH 07/14] Redefine strdup to make Windows happy --- colorchord2/chash.c | 9 ++++++++- colorchord2/hidapi.c | 7 +++++++ colorchord2/main.c | 7 ++++++- colorchord2/outdrivers.c | 7 +++++++ colorchord2/parameters.c | 7 +++++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/colorchord2/chash.c b/colorchord2/chash.c index f4cc84f..a5e7c41 100644 --- a/colorchord2/chash.c +++ b/colorchord2/chash.c @@ -10,6 +10,13 @@ #include #include +#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) \ + || defined(_WIN32) || defined(_WIN64) +#ifndef strdup +#define strdup _strdup +#endif +#endif + #define I_AM_LITTLE (((union { unsigned x; unsigned char c; }){1}).c) static unsigned long GetStrHash( const char * c ) @@ -126,7 +133,7 @@ void ** HashTableInsert( struct chash * hash, const char * key, int dontDupKey ) } else { - thisEntry->key = strdup( key ); + thisEntry->key = _strdup( key ); } thisEntry->hash = thisHash; diff --git a/colorchord2/hidapi.c b/colorchord2/hidapi.c index 225c8a8..d1f9c2f 100644 --- a/colorchord2/hidapi.c +++ b/colorchord2/hidapi.c @@ -58,6 +58,13 @@ typedef LONG NTSTATUS; /*#define HIDAPI_USE_DDK*/ +#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) \ + || defined(_WIN32) || defined(_WIN64) +#ifndef strdup +#define strdup _strdup +#endif +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/colorchord2/main.c b/colorchord2/main.c index 53421f4..bb12d50 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -1,9 +1,14 @@ //Copyright 2015 <>< Charles Lohr under the ColorChord License. -#if defined(WIN32) || defined(USE_WINDOWS) +#if defined(WINDOWS) || defined(USE_WINDOWS)\ + || defined(WIN32) || defined(WIN64) \ + || defined(_WIN32) || defined(_WIN64) #include #include +#ifndef strdup +#define strdup _strdup #endif +#endif #include #include "color.h" diff --git a/colorchord2/outdrivers.c b/colorchord2/outdrivers.c index 6d3591b..5f604f5 100644 --- a/colorchord2/outdrivers.c +++ b/colorchord2/outdrivers.c @@ -7,6 +7,13 @@ #include #include +#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) \ + || defined(_WIN32) || defined(_WIN64) +#ifndef strdup +#define strdup _strdup +#endif +#endif + int force_white = 0; unsigned char OutLEDs[MAX_LEDS*3]; int UsedLEDs; diff --git a/colorchord2/parameters.c b/colorchord2/parameters.c index 3800694..d462b8f 100644 --- a/colorchord2/parameters.c +++ b/colorchord2/parameters.c @@ -6,6 +6,13 @@ #include #include +#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) \ + || defined(_WIN32) || defined(_WIN64) +#ifndef strdup +#define strdup _strdup +#endif +#endif + static struct chash * parameters; //XXX TODO: Make this thread safe. From a2359e1f028dba525d4a905b8279624d9931b54c Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Tue, 19 May 2020 23:39:10 -0400 Subject: [PATCH 08/14] Modify build scripts --- colorchord2/windows/compile-clang.bat | 5 +++-- colorchord2/windows/compile.bat | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/colorchord2/windows/compile-clang.bat b/colorchord2/windows/compile-clang.bat index 648872f..91a2c56 100644 --- a/colorchord2/windows/compile-clang.bat +++ b/colorchord2/windows/compile-clang.bat @@ -1,6 +1,7 @@ set CC="C:\Program Files\LLVM\bin\clang.exe" -set CCFLAGS=-g -D_CRT_SECURE_NO_WARNINGS -Wno-deprecated-declarations -DICACHE_FLASH_ATTR= -Dstrdup=_strdup -DNO_WIN_HEADERS -set CCIFLAGS=-I../../embeddedcommon -I../cnfa -I../rawdraw -I../ -O1 +rem To enable OpenGL rendering use the -DCNFGOGL option +set CCFLAGS=-g -D_CRT_SECURE_NO_WARNINGS +set CCIFLAGS=-I../../embeddedcommon -I../cnfa -I../rawdraw -I../ -O2 set CCLFLAGS=-lwinmm -lgdi32 -lws2_32 -lsetupapi -lkernel32 -luser32 -ldbghelp -lole32 -lmmdevapi -lAvrt set SOURCES=../main.c ../dft.c ../decompose.c ../filter.c ../color.c ../notefinder.c ../util.c ../outdrivers.c ^ ../parameters.c ../chash.c ../OutputVoronoi.c ../OutputProminent.c ../DisplayArray.c ^ diff --git a/colorchord2/windows/compile.bat b/colorchord2/windows/compile.bat index 9ee0d80..051b4a1 100644 --- a/colorchord2/windows/compile.bat +++ b/colorchord2/windows/compile.bat @@ -2,7 +2,7 @@ echo Unzip http://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27-win64-bin.zip to C:\tcc echo Don't worry. It includes the i386 compiler in the win64 build. -set CFLAGS= -v -DHIDAPI -DWINDOWS -DWIN32 -DTCC -DRUNTIME_SYMNUM -Os -Itccinc -DINCLUDING_EMBEDDED -rdynamic -g +set CFLAGS= -v -DHIDAPI -DWINDOWS -DWIN32 -DTCC -DRUNTIME_SYMNUM -O2 -Itccinc -DINCLUDING_EMBEDDED -rdynamic -g set INCLUDES=-I../rawdraw -I../cnfa -I.. -I. -I../../embeddedcommon set LDFLAGS=-lkernel32 -lole32 -lgdi32 -luser32 -lsetupapi -ldbghelp -lws2_32 -lAvrt @@ -11,9 +11,9 @@ set SOURCES=..\main.c ..\chash.c ..\color.c ..\configs.c ..\decompose.c ..\dft.c ..\outdrivers.c ..\hidapi.c ..\hook.c ..\parameters.c ..\util.c ..\notefinder.c ^ ..\..\embeddedcommon\DFT32.c tcc_stubs.c symbol_enumerator.c ^ ..\DisplayNetwork.c ..\DisplayArray.c ..\DisplayHIDAPI.c ..\DisplayOUTDriver.c ..\DisplayPie.c ^ -..\OutputCells.c ..\OutputLinear.c ..\OutputProminent.c ..\OutputVoronoi.c +..\OutputCells.c ..\OutputLinear.c ..\OutputProminent.c ..\OutputVoronoi.c -set ARCH_SPECIFIC=-L32 C:\windows\system32\winmm.dll -Dstrdup=_strdup -DWIN32_LEAN_AND_MEAN +set ARCH_SPECIFIC=-L32 C:\windows\system32\winmm.dll -DWIN32_LEAN_AND_MEAN set CC=C:\tcc\tcc.exe rem set CC=C:\tcc\i386-win32-tcc.exe rem set CC=C:\tcc\x86_64-win32-tcc.exe From 776a5dc5f57cd63bf8227229030929eff44a77d8 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Tue, 19 May 2020 23:55:16 -0400 Subject: [PATCH 09/14] bump submodule version --- colorchord2/cnfa | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorchord2/cnfa b/colorchord2/cnfa index 465e394..314da0d 160000 --- a/colorchord2/cnfa +++ b/colorchord2/cnfa @@ -1 +1 @@ -Subproject commit 465e394f5efa13fc8f9c9fd2c011abd2a4acf0f7 +Subproject commit 314da0d28f51cc57f13923210f7213a0fd8e8d3c From bb0c7a0dc8f401b1a2ecc5a3be07a5dbbc6e9d2c Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Tue, 19 May 2020 23:59:04 -0400 Subject: [PATCH 10/14] Add in NULL for the opaque object for CNFA. --- colorchord2/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/colorchord2/main.c b/colorchord2/main.c index bb12d50..fb3a9a1 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -456,7 +456,7 @@ int main(int argc, char ** argv) //Initialize Sound sd = CNFAInit( sound_source, "colorchord", &SoundCB, GetParameterI( "samplerate", 44100 ), GetParameterI( "channels", 2 ), GetParameterI( "channels", 2 ), GetParameterI( "buffer", 1024 ), - GetParameterS( "devrecord", 0 ), GetParameterS( "devplay", 0 ) ); + GetParameterS( "devrecord", 0 ), GetParameterS( "devplay", 0 ), NULL ); if( sd ) break; @@ -464,7 +464,7 @@ int main(int argc, char ** argv) CNFGPenX = 10; CNFGPenY = 100; CNFGHandleInput(); CNFGClearFrame(); - CNFGDrawText( "Colorchord must be used with sound. Sound not available.", 10 ); + CNFGDrawText( "Colorchord must be used with sound. Sound not available.", 10 ); CNFGSwapBuffers(); OGSleep(1); } while( 1 ); From 4cc141bff1df1b4dfb1b726dbb9619ae0655e702 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Wed, 20 May 2020 00:01:30 -0400 Subject: [PATCH 11/14] Add more comments to the default configuration --- colorchord2/default.conf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/colorchord2/default.conf b/colorchord2/default.conf index a568eae..db9363c 100644 --- a/colorchord2/default.conf +++ b/colorchord2/default.conf @@ -25,8 +25,12 @@ wininput = -1 #-1 indicates left and right, 0 left, 1 right. sample_channel = -1 +# Sets the playback device for CNFA (what speakers to go to) devplay = default +# Sets the device to get audio from, default searches for a mic devrecord = default +# If speaker loopback is desired use the following line +#devrecord = defaultRender # For Linux mostly use the following command to find valid devices to read from: # pactl list | grep pci- | grep monitor @@ -68,7 +72,7 @@ filter_iter = 2 filter_strength = .5 # How many bins per octave to use? -freqbins = 24 +freqbins = 24 # For the final note information... How much to slack everything? note_attach_amp_iir = 0.3500 From 779651da4b7f530edad4fec7e9aedb2d08043a09 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Wed, 20 May 2020 00:04:14 -0400 Subject: [PATCH 12/14] Remove VS-Code files --- colorchord2/.vscode/c_cpp_properties.json | 26 ----------------------- 1 file changed, 26 deletions(-) delete mode 100644 colorchord2/.vscode/c_cpp_properties.json diff --git a/colorchord2/.vscode/c_cpp_properties.json b/colorchord2/.vscode/c_cpp_properties.json deleted file mode 100644 index ef9161d..0000000 --- a/colorchord2/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "configurations": [ - { - "name": "Win32", - "includePath": [ - "${workspaceFolder}/**", - "${workspaceFolder}/../embeddedcommon" - ], - "defines": [ - "_DEBUG", - "UNICODE", - "_UNICODE", - "CNFA_IMPLEMENTATION", - "__TINYC__", - "TCC", - "NO_WIN_HEADERS" - ], - "windowsSdkVersion": "10.0.17763.0", - "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe", - "cStandard": "c11", - "cppStandard": "c++17", - "intelliSenseMode": "msvc-x64" - } - ], - "version": 4 -} \ No newline at end of file From 33f33ed9fd3228b36da64a59bdb3545b58ae5534 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Wed, 20 May 2020 00:10:59 -0400 Subject: [PATCH 13/14] Oops, that could have been embareassing. --- colorchord2/chash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorchord2/chash.c b/colorchord2/chash.c index a5e7c41..717ccf9 100644 --- a/colorchord2/chash.c +++ b/colorchord2/chash.c @@ -133,7 +133,7 @@ void ** HashTableInsert( struct chash * hash, const char * key, int dontDupKey ) } else { - thisEntry->key = _strdup( key ); + thisEntry->key = strdup( key ); } thisEntry->hash = thisHash; From 003a1f4f8a34d9ca872c3d2ca6868f30afe5e063 Mon Sep 17 00:00:00 2001 From: CaiB Date: Wed, 20 May 2020 14:38:56 +0900 Subject: [PATCH 14/14] Marging --- .gitignore | 7 +++++- README.md | 22 +++++++++++++++++++ colorchord2/android/AndroidManifest.xml | 7 ++++-- colorchord2/android/Makefile | 3 ++- ...rd-android.conf => colorchord-android.txt} | 0 colorchord2/configs.c | 20 +++++++++++------ colorchord2/main.c | 10 ++++----- colorchord2/windows/compile-clang.bat | 1 + 8 files changed, 54 insertions(+), 16 deletions(-) rename colorchord2/android/{colorchord-android.conf => colorchord-android.txt} (100%) mode change 100755 => 100644 diff --git a/.gitignore b/.gitignore index 3841a63..d81e4dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ colorchord2/windows/colorchord.def -colorchord2/colorchord.def \ No newline at end of file +colorchord2/colorchord.def +*.o +**/*.exp +**/*.ilk +**/*.pdb +colorchord2/colorchord.lib diff --git a/README.md b/README.md index a368eb2..30431c0 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ make Building with Windows ------------------- +There are 3 options available for building on Windows, MSYS2, clang, or TCC. +### MSYS2 With either 64bit or 32bit [MSYS2](https://msys2.github.io/) installed, run the _MSYS2 MSYS_ launcher and use `pacman` to set up a MinGW32 toolchain, if you don't have one already: ``` pacman -S mingw-w64-i686-toolchain @@ -71,6 +73,26 @@ To make colorchord, navigate to your working copy and type: mingw32-make colorchord.exe ``` +### clang +Start by [downloading](https://clang.llvm.org/) the clang compiler, and installing it. + +Edit the batch script at `colorchord2/windows/compile-clang.bat`: +- Verify that the executable location is correct, on line 1 (`CC`). + +If you have the Windows SDK installed, you should not need to do any additional work. +If you do not, you'll want to either [install it](https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk/) to get the official headers, or use the unofficial headers instead by adding `-DNO_WIN_HEADERS` to the `CCFLAGS` line in the batch file above. + +Run the batch script, and it should output to `colorchord2/colorchord.exe`. + +### TCC +Start by [downloading TCC](http://savannah.nongnu.org/projects/tinycc/), and extracting it to a location of your choice. + +Edit the batch script at `colorchord2/windows/compile.bat`: +- Edit line 17 (`CC`) to be the location where you put TCC. If there are spaces in the path, wrap the entire path in quotes. + +Note that TCC is not able to use the Windows SDK, and as such using the unofficial headers is required, and automatically enabled when compiling with TCC. If you encounter issues, try the clang method above instead. + + Using ----- diff --git a/colorchord2/android/AndroidManifest.xml b/colorchord2/android/AndroidManifest.xml index 27265e1..4acec47 100644 --- a/colorchord2/android/AndroidManifest.xml +++ b/colorchord2/android/AndroidManifest.xml @@ -1,12 +1,15 @@ + android:versionCode="8"> + + - + diff --git a/colorchord2/android/Makefile b/colorchord2/android/Makefile index 883f7e4..b9c3df1 100644 --- a/colorchord2/android/Makefile +++ b/colorchord2/android/Makefile @@ -7,7 +7,8 @@ CFLAGS:=-I. -I.. -Irawdrawandroid/rawdraw -I../cnfa -I../../embeddedcommon \ -ffunction-sections -Os -s -DPRINTF_NO_OVERRIDDE -fvisibility=hidden \ -DRDALOGFNCB=example_log_function -#ANDROIDVERSION=24 +ANDROIDVERSION=22 +ANDROIDTARGET=28 LDFLAGS:=-s -lOpenSLES diff --git a/colorchord2/android/colorchord-android.conf b/colorchord2/android/colorchord-android.txt old mode 100755 new mode 100644 similarity index 100% rename from colorchord2/android/colorchord-android.conf rename to colorchord2/android/colorchord-android.txt diff --git a/colorchord2/configs.c b/colorchord2/configs.c index 2c26c03..b6788cb 100644 --- a/colorchord2/configs.c +++ b/colorchord2/configs.c @@ -48,16 +48,19 @@ void LoadFile( const char * filename ) void SetEnvValues( int force ) { - int i; + static int ifcheck; int hits = 0; - for( i = 0; i < InitialFileCount; i++ ) + + if( InitialFileCount ) { - double ft = OGGetFileTime( InitialFile[i] ); - if( FileTimes[i] != ft ) + //Only check one location per frame. + double ft = OGGetFileTime( InitialFile[ifcheck] ); + if( FileTimes[ifcheck] != ft ) { - FileTimes[i] = ft; + FileTimes[ifcheck] = ft; hits++; } + ifcheck = ( ifcheck + 1 ) % InitialFileCount; } if( !hits && !force ) return; @@ -109,6 +112,7 @@ void SetEnvValues( int force ) printf( "On Android, looking for configuration file in: %s\n", InitialFile[0] ); #endif + int i; for( i = 0; i < InitialFileCount; i++ ) { LoadFile( InitialFile[i] ); @@ -151,8 +155,10 @@ void SetupConfigs() { #ifdef ANDROID InitialFile[0] = "/sdcard/colorchord-android.txt"; - InitialFile[1] = "/sdcard/colorchord-android-overlay.txt"; - InitialFileCount = 2; + InitialFile[1] = "/storage/emulated/0/colorchord-android.txt"; + InitialFile[2] = "/sdcard/colorchord-android-overlay.txt"; + InitialFile[3] = "/storage/emulated/0/colorchord-android-overlay.txt"; + InitialFileCount = 4; #else InitialFile[0] = "default.conf"; #endif diff --git a/colorchord2/main.c b/colorchord2/main.c index fb3a9a1..59adea9 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -232,7 +232,7 @@ void HandleMotion( int x, int y, int mask ) { } -void SoundCB( struct CNFADriver * sd, short * in, short * out, int samplesr, int samplesp ) +void SoundCB( struct CNFADriver * sd, short * in, short * out, int framesr, int framesp ) { int channelin = sd->channelsRec; int channelout = sd->channelsPlay; @@ -246,7 +246,7 @@ void SoundCB( struct CNFADriver * sd, short * in, short * out, int samplesr, int if( in ) { - for( i = 0; i < samplesr; i++ ) + for( i = 0; i < framesr; i++ ) { if( sample_channel < 0 ) { @@ -285,17 +285,17 @@ void SoundCB( struct CNFADriver * sd, short * in, short * out, int samplesr, int } } - SoundEventHappened( samplesr, in, 0, channelin ); + SoundEventHappened( framesr, in, 0, channelin ); } if( out ) { - for( j = 0; j < samplesp * channelout; j++ ) + for( j = 0; j < framesp * channelout; j++ ) { out[j] = 0; } - SoundEventHappened( samplesp, out, 1, channelout ); + SoundEventHappened( framesp, out, 1, channelout ); } diff --git a/colorchord2/windows/compile-clang.bat b/colorchord2/windows/compile-clang.bat index 91a2c56..900ea1d 100644 --- a/colorchord2/windows/compile-clang.bat +++ b/colorchord2/windows/compile-clang.bat @@ -1,3 +1,4 @@ +@echo off set CC="C:\Program Files\LLVM\bin\clang.exe" rem To enable OpenGL rendering use the -DCNFGOGL option set CCFLAGS=-g -D_CRT_SECURE_NO_WARNINGS