From ee621d9e7570532215feb116d8a6484146a73e14 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Thu, 14 May 2020 01:35:57 -0400 Subject: [PATCH 01/50] Added makefile to compile on Windows with clang --- colorchord2/windows/Makefile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 colorchord2/windows/Makefile diff --git a/colorchord2/windows/Makefile b/colorchord2/windows/Makefile new file mode 100644 index 0000000..23983f7 --- /dev/null +++ b/colorchord2/windows/Makefile @@ -0,0 +1,33 @@ +all : colorchord + +OUTS := OutputVoronoi.o DisplayArray.o OutputLinear.o DisplayPie.o DisplayNetwork.o DisplayUSB2812.o DisplayDMX.o OutputProminent.o RecorderPlugin.o DisplayHIDAPI.o hidapi.o OutputCells.o DisplaySHM.o DisplayFileWrite.o + +SRCS := ../main.c ../dft.c ../decompose.c ../filter.c ../color.c ../notefinder.c ../util.c ../outdrivers.c +SRCS += ../parameters.c ../chash.c ../OutputVoronoi.c ../OutputProminent.c ../DisplayArray.c +SRCS += ../OutputLinear.c ../DisplayPie.c ../DisplayNetwork.c ../hook.c ../RecorderPlugin.c +SRCS += ../../embeddedcommon/DFT32.c ../OutputCells.c ../configs.c ../hidapi.c ../DisplayHIDAPI.c + +WINGCC:= clang -fcolor-diagnostics + +WINGCCFLAGS:= -g -D_CRT_SECURE_NO_WARNINGS -Wno-deprecated-declarations -DICACHE_FLASH_ATTR= -I../../embeddedcommon -I../cnfa -I../rawdraw -I../ -O1 #-O2 -Wl,--relax -Wl,--gc-sections -ffunction-sections -fdata-sections +WINLDFLAGS:=-lwinmm -lgdi32 -lws2_32 -lsetupapi + +RAWDRAWLIBS:=-lX11 -lm -lpthread -lXinerama -lXext +LDLIBS:=-lpthread -lasound -lm -lpulse-simple -lpulse -ludev -lrt + + +CFLAGS:=-g -O1 -flto -Wall -ffast-math -I../embeddedcommon -I. -Icnfa -Irawdraw -DICACHE_FLASH_ATTR= +EXTRALIBS:=-lusb-1.0 + +OBJS:=../main.o ../dft.o ../decompose.o ../filter.o ../color.o ../notefinder.o ../util.o ../outdrivers.o $(OUTS) ../parameters.o ../chash.o ../hook.o ../../embeddedcommon/DFT32.o ../configs.o + +colorchord : $(OBJS) + gcc -o $@ $^ $(CFLAGS) $(LDLIBS) $(EXTRALIBS) $(RAWDRAWLIBS) + + +colorchord.exe : $(SRCS) + $(WINGCC) $(WINGCCFLAGS) -o $@ $^ $(WINLDFLAGS) + + +clean : + rm -rf *.o *~ colorchord colorchord.exe embeddedcc $(OBJS) From 7c6f7c6aaf1e4a6373322074091b81aa0fb2e105 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Thu, 14 May 2020 01:48:19 -0400 Subject: [PATCH 02/50] Update main.c so that it matches latest code --- colorchord2/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorchord2/main.c b/colorchord2/main.c index 62110e1..2fd9402 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -429,7 +429,7 @@ int main(int argc, char ** argv) Now = OGGetAbsoluteTime(); double Last = Now; - while( !bQuitColorChord ) + while( !headless ) { char stt[1024]; //Handle Rawdraw frame swappign From 3030d2a8735d4d7616f3a68d2042067f0cd259e5 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Thu, 14 May 2020 01:49:01 -0400 Subject: [PATCH 03/50] Update Makefile to compile with clang --- colorchord2/windows/Makefile | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/colorchord2/windows/Makefile b/colorchord2/windows/Makefile index 23983f7..0701174 100644 --- a/colorchord2/windows/Makefile +++ b/colorchord2/windows/Makefile @@ -1,4 +1,4 @@ -all : colorchord +all : colorchord.exe OUTS := OutputVoronoi.o DisplayArray.o OutputLinear.o DisplayPie.o DisplayNetwork.o DisplayUSB2812.o DisplayDMX.o OutputProminent.o RecorderPlugin.o DisplayHIDAPI.o hidapi.o OutputCells.o DisplaySHM.o DisplayFileWrite.o @@ -15,19 +15,10 @@ WINLDFLAGS:=-lwinmm -lgdi32 -lws2_32 -lsetupapi RAWDRAWLIBS:=-lX11 -lm -lpthread -lXinerama -lXext LDLIBS:=-lpthread -lasound -lm -lpulse-simple -lpulse -ludev -lrt - -CFLAGS:=-g -O1 -flto -Wall -ffast-math -I../embeddedcommon -I. -Icnfa -Irawdraw -DICACHE_FLASH_ATTR= -EXTRALIBS:=-lusb-1.0 - OBJS:=../main.o ../dft.o ../decompose.o ../filter.o ../color.o ../notefinder.o ../util.o ../outdrivers.o $(OUTS) ../parameters.o ../chash.o ../hook.o ../../embeddedcommon/DFT32.o ../configs.o -colorchord : $(OBJS) - gcc -o $@ $^ $(CFLAGS) $(LDLIBS) $(EXTRALIBS) $(RAWDRAWLIBS) - - colorchord.exe : $(SRCS) $(WINGCC) $(WINGCCFLAGS) -o $@ $^ $(WINLDFLAGS) - clean : rm -rf *.o *~ colorchord colorchord.exe embeddedcc $(OBJS) From 72d8e1dce9cb62208f35af2649082309194ff323 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Thu, 14 May 2020 01:50:50 -0400 Subject: [PATCH 04/50] Make CNFA module point to CaiB's repo --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index ae541d5..0803dc3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/cntools/rawdraw [submodule "colorchord2/cnfa"] path = colorchord2/cnfa - url = https://github.com/cnlohr/cnfa + url = https://github.com/CaiB/cnfa [submodule "colorchord2/android/rawdrawandroid"] path = colorchord2/android/rawdrawandroid url = https://github.com/cnlohr/rawdrawandroid From d4e19a6a12e9c265d08c22a49cfec07a91898f21 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Thu, 14 May 2020 01:35:57 -0400 Subject: [PATCH 05/50] Added makefile to compile on Windows with clang --- colorchord2/windows/Makefile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 colorchord2/windows/Makefile diff --git a/colorchord2/windows/Makefile b/colorchord2/windows/Makefile new file mode 100644 index 0000000..23983f7 --- /dev/null +++ b/colorchord2/windows/Makefile @@ -0,0 +1,33 @@ +all : colorchord + +OUTS := OutputVoronoi.o DisplayArray.o OutputLinear.o DisplayPie.o DisplayNetwork.o DisplayUSB2812.o DisplayDMX.o OutputProminent.o RecorderPlugin.o DisplayHIDAPI.o hidapi.o OutputCells.o DisplaySHM.o DisplayFileWrite.o + +SRCS := ../main.c ../dft.c ../decompose.c ../filter.c ../color.c ../notefinder.c ../util.c ../outdrivers.c +SRCS += ../parameters.c ../chash.c ../OutputVoronoi.c ../OutputProminent.c ../DisplayArray.c +SRCS += ../OutputLinear.c ../DisplayPie.c ../DisplayNetwork.c ../hook.c ../RecorderPlugin.c +SRCS += ../../embeddedcommon/DFT32.c ../OutputCells.c ../configs.c ../hidapi.c ../DisplayHIDAPI.c + +WINGCC:= clang -fcolor-diagnostics + +WINGCCFLAGS:= -g -D_CRT_SECURE_NO_WARNINGS -Wno-deprecated-declarations -DICACHE_FLASH_ATTR= -I../../embeddedcommon -I../cnfa -I../rawdraw -I../ -O1 #-O2 -Wl,--relax -Wl,--gc-sections -ffunction-sections -fdata-sections +WINLDFLAGS:=-lwinmm -lgdi32 -lws2_32 -lsetupapi + +RAWDRAWLIBS:=-lX11 -lm -lpthread -lXinerama -lXext +LDLIBS:=-lpthread -lasound -lm -lpulse-simple -lpulse -ludev -lrt + + +CFLAGS:=-g -O1 -flto -Wall -ffast-math -I../embeddedcommon -I. -Icnfa -Irawdraw -DICACHE_FLASH_ATTR= +EXTRALIBS:=-lusb-1.0 + +OBJS:=../main.o ../dft.o ../decompose.o ../filter.o ../color.o ../notefinder.o ../util.o ../outdrivers.o $(OUTS) ../parameters.o ../chash.o ../hook.o ../../embeddedcommon/DFT32.o ../configs.o + +colorchord : $(OBJS) + gcc -o $@ $^ $(CFLAGS) $(LDLIBS) $(EXTRALIBS) $(RAWDRAWLIBS) + + +colorchord.exe : $(SRCS) + $(WINGCC) $(WINGCCFLAGS) -o $@ $^ $(WINLDFLAGS) + + +clean : + rm -rf *.o *~ colorchord colorchord.exe embeddedcc $(OBJS) From 4a3d06397b810a2d51e50079992948ab2c5dd0c4 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Thu, 14 May 2020 01:48:19 -0400 Subject: [PATCH 06/50] Update main.c so that it matches latest code --- colorchord2/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorchord2/main.c b/colorchord2/main.c index b80d5e9..81a5de1 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -429,7 +429,7 @@ int main(int argc, char ** argv) Now = OGGetAbsoluteTime(); double Last = Now; - while( !bQuitColorChord ) + while( !headless ) { char stt[1024]; //Handle Rawdraw frame swappign From 84ccaf60e02f43d9c1ce4597682089ded6f289a8 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Thu, 14 May 2020 01:49:01 -0400 Subject: [PATCH 07/50] Update Makefile to compile with clang --- colorchord2/windows/Makefile | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/colorchord2/windows/Makefile b/colorchord2/windows/Makefile index 23983f7..0701174 100644 --- a/colorchord2/windows/Makefile +++ b/colorchord2/windows/Makefile @@ -1,4 +1,4 @@ -all : colorchord +all : colorchord.exe OUTS := OutputVoronoi.o DisplayArray.o OutputLinear.o DisplayPie.o DisplayNetwork.o DisplayUSB2812.o DisplayDMX.o OutputProminent.o RecorderPlugin.o DisplayHIDAPI.o hidapi.o OutputCells.o DisplaySHM.o DisplayFileWrite.o @@ -15,19 +15,10 @@ WINLDFLAGS:=-lwinmm -lgdi32 -lws2_32 -lsetupapi RAWDRAWLIBS:=-lX11 -lm -lpthread -lXinerama -lXext LDLIBS:=-lpthread -lasound -lm -lpulse-simple -lpulse -ludev -lrt - -CFLAGS:=-g -O1 -flto -Wall -ffast-math -I../embeddedcommon -I. -Icnfa -Irawdraw -DICACHE_FLASH_ATTR= -EXTRALIBS:=-lusb-1.0 - OBJS:=../main.o ../dft.o ../decompose.o ../filter.o ../color.o ../notefinder.o ../util.o ../outdrivers.o $(OUTS) ../parameters.o ../chash.o ../hook.o ../../embeddedcommon/DFT32.o ../configs.o -colorchord : $(OBJS) - gcc -o $@ $^ $(CFLAGS) $(LDLIBS) $(EXTRALIBS) $(RAWDRAWLIBS) - - colorchord.exe : $(SRCS) $(WINGCC) $(WINGCCFLAGS) -o $@ $^ $(WINLDFLAGS) - clean : rm -rf *.o *~ colorchord colorchord.exe embeddedcc $(OBJS) From ce1c86fa1b3f110f32d8843d4e0bab091c01074d Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Thu, 14 May 2020 01:50:50 -0400 Subject: [PATCH 08/50] Make CNFA module point to CaiB's repo --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index ae541d5..0803dc3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/cntools/rawdraw [submodule "colorchord2/cnfa"] path = colorchord2/cnfa - url = https://github.com/cnlohr/cnfa + url = https://github.com/CaiB/cnfa [submodule "colorchord2/android/rawdrawandroid"] path = colorchord2/android/rawdrawandroid url = https://github.com/cnlohr/rawdrawandroid From d77eced8c59ff967e08ccfe1b0c5243d648b2c2d Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Thu, 14 May 2020 22:47:20 -0400 Subject: [PATCH 09/50] Change sleep function --- colorchord2/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/colorchord2/main.c b/colorchord2/main.c index 81a5de1..7a16b2d 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -1,6 +1,6 @@ //Copyright 2015 <>< Charles Lohr under the ColorChord License. -#if defined(WIN32) || defined(USE_WINDOWS) +#if defined(WIN32) || defined(USE_WINDOWS) #include #include #endif @@ -417,7 +417,7 @@ int main(int argc, char ** argv) CNFGClearFrame(); CNFGDrawText( "Colorchord must be used with sound. Sound not available.", 10 ); CNFGSwapBuffers(); - sleep(1); + OGSleep(1); } while( 1 ); nf = CreateNoteFinder( sd->sps ); From 5fcc4b0881296e39ec6e7ccacbeaa8bb5ae9d33a Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Thu, 14 May 2020 22:47:59 -0400 Subject: [PATCH 10/50] Added script to compile with clang on Windows --- colorchord2/windows/compile-clang.bat | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 colorchord2/windows/compile-clang.bat diff --git a/colorchord2/windows/compile-clang.bat b/colorchord2/windows/compile-clang.bat new file mode 100644 index 0000000..6e66b9f --- /dev/null +++ b/colorchord2/windows/compile-clang.bat @@ -0,0 +1,11 @@ +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 CCIFLAGS=-I../../embeddedcommon -I../cnfa -I../rawdraw -I../ -O1 +set CCLFLAGS=-lwinmm -lgdi32 -lws2_32 -lsetupapi -lkernel32 -luser32 -ldbghelp -lole32 -lmmdevapi +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 ^ +../OutputLinear.c ../DisplayPie.c ../DisplayNetwork.c ../hook.c ../RecorderPlugin.c ^ +../../embeddedcommon/DFT32.c ../OutputCells.c ../configs.c ../hidapi.c ../DisplayHIDAPI.c + +@echo on +%CC% %CCFLAGS% %CCIFLAGS% -o colorchord.exe %SOURCES% %CCLFLAGS% From c27b90a1f2c0390e1c4cd23fff74ad4bdfda0963 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Fri, 15 May 2020 02:14:39 -0400 Subject: [PATCH 11/50] updated tcc build script --- colorchord2/windows/compile.bat | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/colorchord2/windows/compile.bat b/colorchord2/windows/compile.bat index 79c0915..a492683 100644 --- a/colorchord2/windows/compile.bat +++ b/colorchord2/windows/compile.bat @@ -1,12 +1,22 @@ @echo off 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 -I../rawdraw -I../cnfa -I.. -I. -I../../embeddedcommon -rdynamic -g + +set CFLAGS= -v -DHIDAPI -DWINDOWS -DWIN32 -DTCC -DRUNTIME_SYMNUM -Os -Itccinc -DINCLUDING_EMBEDDED -rdynamic -g +set INCLUDES=-I../rawdraw -I../cnfa -I.. -I. -I../../embeddedcommon set LDFLAGS=-lkernel32 -lgdi32 -luser32 -lsetupapi -ldbghelp -lws2_32 -set SOURCES=..\chash.c ..\color.c ..\configs.c ..\decompose.c ..\dft.c ..\DisplayNetwork.c ..\DisplayArray.c ..\DisplayHIDAPI.c ..\DisplayOUTDriver.c ..\DisplayPie.c ..\filter.c ..\hidapi.c ..\hook.c ..\main.c ..\outdrivers.c ..\OutputCells.c ..\OutputLinear.c ..\OutputProminent.c ..\OutputVoronoi.c ..\parameters.c ..\util.c ..\notefinder.c ..\..\embeddedcommon\DFT32.c tcc_stubs.c symbol_enumerator.c -set ARCH_SPECIFIC=-L32 C:\windows\system32\winmm.dll -set CC=C:\tcc\i386-win32-tcc.exe + +rem lots of source files +set SOURCES=..\main.c ..\chash.c ..\color.c ..\configs.c ..\decompose.c ..\dft.c ..\filter.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 + +set ARCH_SPECIFIC=-L32 C:\windows\system32\winmm.dll -Dstrdup=_strdup -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 @echo on -%CC% %CFLAGS% %ARCH_SPECIFIC% %SOURCES% %LDFLAGS% -o ..\colorchord.exe +%CC% %CFLAGS% %INCLUDES% %ARCH_SPECIFIC% %SOURCES% %LDFLAGS% -o ..\colorchord.exe pause From 457f9797231e2a5fd8386c2d0d84f704d63f4a1e Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Fri, 15 May 2020 02:15:21 -0400 Subject: [PATCH 12/50] cnfa points to my repo --- .gitmodules | 2 +- colorchord2/cnfa | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 0803dc3..7008f08 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/cntools/rawdraw [submodule "colorchord2/cnfa"] path = colorchord2/cnfa - url = https://github.com/CaiB/cnfa + url = git@github.com:sellicott/cnfa.git [submodule "colorchord2/android/rawdrawandroid"] path = colorchord2/android/rawdrawandroid url = https://github.com/cnlohr/rawdrawandroid diff --git a/colorchord2/cnfa b/colorchord2/cnfa index 6c9dd09..d3f16d2 160000 --- a/colorchord2/cnfa +++ b/colorchord2/cnfa @@ -1 +1 @@ -Subproject commit 6c9dd0901ba034577dea72f86756f3ac2f748862 +Subproject commit d3f16d2edbdca273a5bc8fab7df781ed37827f4b From 184dd91a679476e03ad5bd48d2c8055d55445e61 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Fri, 15 May 2020 02:15:38 -0400 Subject: [PATCH 13/50] this still needs some cleanup --- colorchord2/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/colorchord2/main.c b/colorchord2/main.c index 7a16b2d..be0f841 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -3,6 +3,7 @@ #if defined(WIN32) || defined(USE_WINDOWS) #include #include +#define strdup _strdup #endif #include From c51221b4fd70a327a1ab7b711d231eaec44d00b9 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Fri, 15 May 2020 18:52:57 -0400 Subject: [PATCH 14/50] Added necessary library to build --- colorchord2/windows/compile.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorchord2/windows/compile.bat b/colorchord2/windows/compile.bat index a492683..c5b3364 100644 --- a/colorchord2/windows/compile.bat +++ b/colorchord2/windows/compile.bat @@ -4,7 +4,7 @@ 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 INCLUDES=-I../rawdraw -I../cnfa -I.. -I. -I../../embeddedcommon -set LDFLAGS=-lkernel32 -lgdi32 -luser32 -lsetupapi -ldbghelp -lws2_32 +set LDFLAGS=-lkernel32 -lOle32 -lgdi32 -luser32 -lsetupapi -ldbghelp -lws2_32 rem lots of source files set SOURCES=..\main.c ..\chash.c ..\color.c ..\configs.c ..\decompose.c ..\dft.c ..\filter.c ^ From 328852d9e94cd15280f606052ede5096d4956b3e Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sat, 16 May 2020 02:35:49 -0400 Subject: [PATCH 15/50] fix reversal in fread input arguments --- colorchord2/configs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/colorchord2/configs.c b/colorchord2/configs.c index dadb57f..2c26c03 100644 --- a/colorchord2/configs.c +++ b/colorchord2/configs.c @@ -31,12 +31,12 @@ void LoadFile( const char * filename ) int size = ftell( f ); fseek( f, 0, SEEK_SET ); buffer = malloc( size + 1 ); - r = fread( buffer, size, 1, f ); + r = fread( buffer, 1, size, f); fclose( f ); buffer[size] = 0; - if( r != 1 ) + if( r != size ) { - fprintf( stderr, "Warning: %d bytes read. Expected: %d from file %s\n", r, size, filename ); + fprintf( stderr, "Warning: %d bytes read. Expected: %d from file %s\n", r, size, filename ); } else { From 4c3b7b294a972b731e84244c96386b6d879a420e Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sat, 16 May 2020 02:39:22 -0400 Subject: [PATCH 16/50] Call necessary registration functions --- colorchord2/main.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/colorchord2/main.c b/colorchord2/main.c index be0f841..177a9fa 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -312,6 +312,24 @@ void HandleResume() 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; + } + + + REGISTERheadless(); + REGISTERset_screenx(); + REGISTERset_screeny(); + REGISTERsound_source(); + REGISTERcpu_autolimit(); + REGISTERcpu_autolimit_interval(); + REGISTERsample_channel(); + REGISTERshowfps(); +#endif + #ifdef TCC void ManuallyRegisterDevices(); @@ -328,7 +346,8 @@ int main(int argc, char ** argv) WSAStartup(0x202, &wsaData); - strcpy( sound_source, "WIN" ); + REGISTERcnfa_wasapi(); + strcpy( sound_source, "WASAPI" ); #elif defined( ANDROID ) strcpy( sound_source, "ANDROID" ); From 1eb42353bd4adf3af949b4ce4697acae0c2435e1 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sat, 16 May 2020 02:40:17 -0400 Subject: [PATCH 17/50] Added logging output --- colorchord2/parameters.c | 1 + 1 file changed, 1 insertion(+) diff --git a/colorchord2/parameters.c b/colorchord2/parameters.c index 3800694..05ae639 100644 --- a/colorchord2/parameters.c +++ b/colorchord2/parameters.c @@ -137,6 +137,7 @@ 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 f9ed8625087b6198442e9e2ddce06c664f21d109 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sat, 16 May 2020 02:40:45 -0400 Subject: [PATCH 18/50] Make function prototype match implemented function --- colorchord2/outdrivers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorchord2/outdrivers.h b/colorchord2/outdrivers.h index 44db767..0a39d4d 100644 --- a/colorchord2/outdrivers.h +++ b/colorchord2/outdrivers.h @@ -37,7 +37,7 @@ extern struct OutDriverListElem ODList[MAX_OUT_DRIVERS]; extern const char OutDriverParameters[MAX_OUT_DRIVER_STRING]; //Pass setup "name=[driver]" -struct DriverInstances * SetupOutDriver( ); +struct DriverInstances * SetupOutDriver( const char * drivername ); void RegOutDriver( const char * ron, struct DriverInstances * (*Init)( ) ); #define REGISTER_OUT_DRIVER( name ) \ From 3402711e6f485d001b193687405cddc253da8889 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sat, 16 May 2020 02:41:20 -0400 Subject: [PATCH 19/50] Slightly change build scripts --- colorchord2/windows/compile-clang.bat | 2 +- colorchord2/windows/compile.bat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/colorchord2/windows/compile-clang.bat b/colorchord2/windows/compile-clang.bat index 6e66b9f..fb87658 100644 --- a/colorchord2/windows/compile-clang.bat +++ b/colorchord2/windows/compile-clang.bat @@ -8,4 +8,4 @@ set SOURCES=../main.c ../dft.c ../decompose.c ../filter.c ../color.c ../notefin ../../embeddedcommon/DFT32.c ../OutputCells.c ../configs.c ../hidapi.c ../DisplayHIDAPI.c @echo on -%CC% %CCFLAGS% %CCIFLAGS% -o colorchord.exe %SOURCES% %CCLFLAGS% +%CC% %CCFLAGS% %CCIFLAGS% -o ../colorchord.exe %SOURCES% %CCLFLAGS% diff --git a/colorchord2/windows/compile.bat b/colorchord2/windows/compile.bat index c5b3364..f8f48cc 100644 --- a/colorchord2/windows/compile.bat +++ b/colorchord2/windows/compile.bat @@ -4,7 +4,7 @@ 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 INCLUDES=-I../rawdraw -I../cnfa -I.. -I. -I../../embeddedcommon -set LDFLAGS=-lkernel32 -lOle32 -lgdi32 -luser32 -lsetupapi -ldbghelp -lws2_32 +set LDFLAGS=-lkernel32 -lole32 -lgdi32 -luser32 -lsetupapi -ldbghelp -lws2_32 rem lots of source files set SOURCES=..\main.c ..\chash.c ..\color.c ..\configs.c ..\decompose.c ..\dft.c ..\filter.c ^ From 0288cec7130c126dd57bce31d7e02a90c17a3d60 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sat, 16 May 2020 02:42:46 -0400 Subject: [PATCH 20/50] bump submodule --- colorchord2/cnfa | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorchord2/cnfa b/colorchord2/cnfa index d3f16d2..38a0235 160000 --- a/colorchord2/cnfa +++ b/colorchord2/cnfa @@ -1 +1 @@ -Subproject commit d3f16d2edbdca273a5bc8fab7df781ed37827f4b +Subproject commit 38a023556310f0377c6b3d6c2f7a3106ff7e14ef From 4c229fbe279a008703424684e8d67b60f1ebc375 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sat, 16 May 2020 02:50:20 -0400 Subject: [PATCH 21/50] switch submodule to https --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 7008f08..0bc1620 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/cntools/rawdraw [submodule "colorchord2/cnfa"] path = colorchord2/cnfa - url = git@github.com:sellicott/cnfa.git + url = https://github.com:sellicott/cnfa [submodule "colorchord2/android/rawdrawandroid"] path = colorchord2/android/rawdrawandroid url = https://github.com/cnlohr/rawdrawandroid From 2bbeb2d7df328f3a2adca94f3ae0f0e553681689 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sat, 16 May 2020 02:55:01 -0400 Subject: [PATCH 22/50] fixed bad URL --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 0bc1620..ed613bb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/cntools/rawdraw [submodule "colorchord2/cnfa"] path = colorchord2/cnfa - url = https://github.com:sellicott/cnfa + url = https://github.com/sellicott/cnfa [submodule "colorchord2/android/rawdrawandroid"] path = colorchord2/android/rawdrawandroid url = https://github.com/cnlohr/rawdrawandroid From c7f058b72b70367ee789a2973c5197a54a0ce14c Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sat, 16 May 2020 03:21:25 -0400 Subject: [PATCH 23/50] bump submodule version --- colorchord2/cnfa | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorchord2/cnfa b/colorchord2/cnfa index 38a0235..cdffc38 160000 --- a/colorchord2/cnfa +++ b/colorchord2/cnfa @@ -1 +1 @@ -Subproject commit 38a023556310f0377c6b3d6c2f7a3106ff7e14ef +Subproject commit cdffc38b0193174f6c416c32189da380b9c84701 From b6e95238952b4c2ea47a6513137140e01f4a6224 Mon Sep 17 00:00:00 2001 From: CaiB Date: Sun, 17 May 2020 15:14:03 +0900 Subject: [PATCH 24/50] Small tweaks to platform-dependent behaviour --- colorchord2/main.c | 13 ++++++++++--- colorchord2/windows/compile.bat | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/colorchord2/main.c b/colorchord2/main.c index 177a9fa..4b96829 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -3,7 +3,6 @@ #if defined(WIN32) || defined(USE_WINDOWS) #include #include -#define strdup _strdup #endif #include @@ -346,8 +345,12 @@ int main(int argc, char ** argv) WSAStartup(0x202, &wsaData); + #ifdef TCC + REGISTERWinCNFA(); REGISTERcnfa_wasapi(); - strcpy( sound_source, "WASAPI" ); + #endif + + strcpy( sound_source, "WASAPI" ); // Use either "sound_source=WASAPI" or "sound_source=WIN" in config file. #elif defined( ANDROID ) strcpy( sound_source, "ANDROID" ); @@ -449,7 +452,11 @@ int main(int argc, char ** argv) Now = OGGetAbsoluteTime(); double Last = Now; - while( !headless ) + #ifdef ANDROID + while(!bQuitColorChord) + #else + while(!headless) + #endif { char stt[1024]; //Handle Rawdraw frame swappign diff --git a/colorchord2/windows/compile.bat b/colorchord2/windows/compile.bat index f8f48cc..9ab2847 100644 --- a/colorchord2/windows/compile.bat +++ b/colorchord2/windows/compile.bat @@ -19,4 +19,5 @@ rem set CC=C:\tcc\i386-win32-tcc.exe rem set CC=C:\tcc\x86_64-win32-tcc.exe @echo on %CC% %CFLAGS% %INCLUDES% %ARCH_SPECIFIC% %SOURCES% %LDFLAGS% -o ..\colorchord.exe -pause +@echo off +pause \ No newline at end of file From e1896cf8d91a85da6ff3a0dbd898d09c7d24fd0c Mon Sep 17 00:00:00 2001 From: CaiB Date: Sun, 17 May 2020 15:46:51 +0900 Subject: [PATCH 25/50] Updating CNFA --- .gitmodules | 2 +- colorchord2/cnfa | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index ed613bb..0803dc3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/cntools/rawdraw [submodule "colorchord2/cnfa"] path = colorchord2/cnfa - url = https://github.com/sellicott/cnfa + url = https://github.com/CaiB/cnfa [submodule "colorchord2/android/rawdrawandroid"] path = colorchord2/android/rawdrawandroid url = https://github.com/cnlohr/rawdrawandroid diff --git a/colorchord2/cnfa b/colorchord2/cnfa index cdffc38..22ace63 160000 --- a/colorchord2/cnfa +++ b/colorchord2/cnfa @@ -1 +1 @@ -Subproject commit cdffc38b0193174f6c416c32189da380b9c84701 +Subproject commit 22ace63aab14507daada024767ad0fa10a67894c From 92f765817c7ed93605d6bb9c59f948d21d501a7c Mon Sep 17 00:00:00 2001 From: CaiB Date: Sun, 17 May 2020 17:28:16 +0900 Subject: [PATCH 26/50] Adding new required DLL reference, and updating CNFA --- colorchord2/cnfa | 2 +- colorchord2/windows/compile-clang.bat | 2 +- colorchord2/windows/compile.bat | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/colorchord2/cnfa b/colorchord2/cnfa index 22ace63..465e394 160000 --- a/colorchord2/cnfa +++ b/colorchord2/cnfa @@ -1 +1 @@ -Subproject commit 22ace63aab14507daada024767ad0fa10a67894c +Subproject commit 465e394f5efa13fc8f9c9fd2c011abd2a4acf0f7 diff --git a/colorchord2/windows/compile-clang.bat b/colorchord2/windows/compile-clang.bat index fb87658..0fcb356 100644 --- a/colorchord2/windows/compile-clang.bat +++ b/colorchord2/windows/compile-clang.bat @@ -1,7 +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 set CCIFLAGS=-I../../embeddedcommon -I../cnfa -I../rawdraw -I../ -O1 -set CCLFLAGS=-lwinmm -lgdi32 -lws2_32 -lsetupapi -lkernel32 -luser32 -ldbghelp -lole32 -lmmdevapi +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 ^ ../OutputLinear.c ../DisplayPie.c ../DisplayNetwork.c ../hook.c ../RecorderPlugin.c ^ diff --git a/colorchord2/windows/compile.bat b/colorchord2/windows/compile.bat index 9ab2847..9ee0d80 100644 --- a/colorchord2/windows/compile.bat +++ b/colorchord2/windows/compile.bat @@ -4,7 +4,7 @@ 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 INCLUDES=-I../rawdraw -I../cnfa -I.. -I. -I../../embeddedcommon -set LDFLAGS=-lkernel32 -lole32 -lgdi32 -luser32 -lsetupapi -ldbghelp -lws2_32 +set LDFLAGS=-lkernel32 -lole32 -lgdi32 -luser32 -lsetupapi -ldbghelp -lws2_32 -lAvrt rem lots of source files set SOURCES=..\main.c ..\chash.c ..\color.c ..\configs.c ..\decompose.c ..\dft.c ..\filter.c ^ From ffc4ac5d4189b73db7bf6ff39fc5113536e59426 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Sun, 17 May 2020 19:19:21 -0400 Subject: [PATCH 27/50] 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 28/50] 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 29/50] 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 30/50] 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 31/50] 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 32/50] 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 80944b289faece2a086f15dfa39335dd535ee44a Mon Sep 17 00:00:00 2001 From: CaiB Date: Tue, 19 May 2020 17:58:24 +0900 Subject: [PATCH 33/50] Update Windows build info in readme --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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 ----- From 64c6c508b0ccada25a0ee6d803e4ad250d7f50cb Mon Sep 17 00:00:00 2001 From: CaiB Date: Tue, 19 May 2020 20:41:20 +0900 Subject: [PATCH 34/50] Updating CNFA and removing excessive console output on compile. --- colorchord2/cnfa | 2 +- colorchord2/windows/compile-clang.bat | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/colorchord2/cnfa b/colorchord2/cnfa index 465e394..c021a3d 160000 --- a/colorchord2/cnfa +++ b/colorchord2/cnfa @@ -1 +1 @@ -Subproject commit 465e394f5efa13fc8f9c9fd2c011abd2a4acf0f7 +Subproject commit c021a3d8eb2febbd6b9d6285dac884bb828c5f02 diff --git a/colorchord2/windows/compile-clang.bat b/colorchord2/windows/compile-clang.bat index 0fcb356..047c319 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" set CCFLAGS=-g -D_CRT_SECURE_NO_WARNINGS -Wno-deprecated-declarations -DICACHE_FLASH_ATTR= -Dstrdup=_strdup set CCIFLAGS=-I../../embeddedcommon -I../cnfa -I../rawdraw -I../ -O1 From cbc15a30c02bf3bd95d661fed91138e18e220666 Mon Sep 17 00:00:00 2001 From: CaiB Date: Tue, 19 May 2020 20:45:55 +0900 Subject: [PATCH 35/50] Ignoring clang output --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 6f6ec79..d81e4dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ colorchord2/windows/colorchord.def colorchord2/colorchord.def *.o +**/*.exp +**/*.ilk +**/*.pdb +colorchord2/colorchord.lib From 2b0bb5a78d34933a4c0ab57713371bc3aec252c1 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Tue, 19 May 2020 23:19:58 -0400 Subject: [PATCH 36/50] 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 37/50] 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 38/50] 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 39/50] 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 40/50] 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 41/50] 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 42/50] 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 43/50] 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 From bf95be1226f866f949abf7f5766efd06dea9b179 Mon Sep 17 00:00:00 2001 From: CaiB Date: Wed, 20 May 2020 14:42:39 +0900 Subject: [PATCH 44/50] Clarifying config comments --- colorchord2/default.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/colorchord2/default.conf b/colorchord2/default.conf index db9363c..26f39d3 100644 --- a/colorchord2/default.conf +++ b/colorchord2/default.conf @@ -27,9 +27,9 @@ wininput = -1 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 +# Sets the device to get audio from, for WASAPI, "default" searches for a mic devrecord = default -# If speaker loopback is desired use the following line +# For WASAPI, 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: From 556338cfcbe7c45b79bee7ec515797b333bf8db2 Mon Sep 17 00:00:00 2001 From: nikky Date: Wed, 20 May 2020 21:34:57 +0200 Subject: [PATCH 45/50] add DisplayNetwork support to android --- colorchord2/android/AndroidManifest.xml | 1 + colorchord2/main.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/colorchord2/android/AndroidManifest.xml b/colorchord2/android/AndroidManifest.xml index 4acec47..7337d6f 100644 --- a/colorchord2/android/AndroidManifest.xml +++ b/colorchord2/android/AndroidManifest.xml @@ -8,6 +8,7 @@ + diff --git a/colorchord2/main.c b/colorchord2/main.c index 59adea9..d142ca5 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -385,6 +385,11 @@ int main(int argc, char ** argv) { AndroidRequestAppPermissions( "READ_EXTERNAL_STORAGE" ); } + int haspermInternet = AndroidHasPermissions( "INTERNET" ); + if( !haspermInternet ) + { + AndroidRequestAppPermissions( "INTERNET" ); + } #else From d8578fe6d9853f6ccab359331c8494d515ebac0d Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Wed, 20 May 2020 20:34:37 -0400 Subject: [PATCH 46/50] Fix TCC being dumb --- colorchord2/OutputVoronoi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/colorchord2/OutputVoronoi.c b/colorchord2/OutputVoronoi.c index c43c1af..714b429 100644 --- a/colorchord2/OutputVoronoi.c +++ b/colorchord2/OutputVoronoi.c @@ -126,7 +126,8 @@ static void DPOUpdate(void * id, struct NoteFinder*nf) { float sat = nf->note_amplitudes_out[bestmatch] * d->satamp; if( sat > 1.0 ) sat = 1.0; - color = CCtoHEX( nf->note_positions[bestmatch] / nf->freqbins, 1.0, sat ); + float note_color = nf->note_positions[bestmatch] / nf->freqbins; + color = CCtoHEX( note_color, 1.0, sat ); } OutLEDs[led*3+0] = color & 0xff; From 3274984ebff57353f038684d355a55ffd9b7ce1d Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Wed, 20 May 2020 22:39:50 -0400 Subject: [PATCH 47/50] bump submodule version --- colorchord2/cnfa | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorchord2/cnfa b/colorchord2/cnfa index 314da0d..9153df2 160000 --- a/colorchord2/cnfa +++ b/colorchord2/cnfa @@ -1 +1 @@ -Subproject commit 314da0d28f51cc57f13923210f7213a0fd8e8d3c +Subproject commit 9153df275e6fadfa0e2de9cdc5b49a1d858c950b From 98623aa29946da8932d4fe7fdba9c10e10c6ae9b Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Wed, 20 May 2020 22:40:53 -0400 Subject: [PATCH 48/50] Fix CNFA initilization call. --- colorchord2/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/colorchord2/main.c b/colorchord2/main.c index d142ca5..4bdaa4d 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -459,8 +459,10 @@ int main(int argc, char ** argv) do { //Initialize Sound - sd = CNFAInit( sound_source, "colorchord", &SoundCB, GetParameterI( "samplerate", 44100 ), - GetParameterI( "channels", 2 ), GetParameterI( "channels", 2 ), GetParameterI( "buffer", 1024 ), + sd = CNFAInit( sound_source, "colorchord", &SoundCB, + GetParameterI( "samplerate", 44100 ), GetParameterI( "samplerate", 44100 ), + GetParameterI( "channels", 2 ), GetParameterI( "channels", 2 ), + GetParameterI( "buffer", 1024 ), GetParameterS( "devrecord", 0 ), GetParameterS( "devplay", 0 ), NULL ); if( sd ) break; @@ -474,7 +476,7 @@ int main(int argc, char ** argv) OGSleep(1); } while( 1 ); - nf = CreateNoteFinder( sd->sps ); + nf = CreateNoteFinder( sd->spsRec ); //Once everything was reinitialized, re-read the ini files. SetEnvValues( 1 ); From 4eb0eb8d4a819585acfed05bbc403ff04d187475 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Wed, 20 May 2020 23:59:59 -0400 Subject: [PATCH 49/50] Misc fixes: -Make the submodule match upstream. -Update Windows makefile to work. --- .gitmodules | 2 +- colorchord2/windows/Makefile | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitmodules b/.gitmodules index 0803dc3..ae541d5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/cntools/rawdraw [submodule "colorchord2/cnfa"] path = colorchord2/cnfa - url = https://github.com/CaiB/cnfa + url = https://github.com/cnlohr/cnfa [submodule "colorchord2/android/rawdrawandroid"] path = colorchord2/android/rawdrawandroid url = https://github.com/cnlohr/rawdrawandroid diff --git a/colorchord2/windows/Makefile b/colorchord2/windows/Makefile index 0701174..bba0cb0 100644 --- a/colorchord2/windows/Makefile +++ b/colorchord2/windows/Makefile @@ -1,4 +1,4 @@ -all : colorchord.exe +all : ../colorchord.exe OUTS := OutputVoronoi.o DisplayArray.o OutputLinear.o DisplayPie.o DisplayNetwork.o DisplayUSB2812.o DisplayDMX.o OutputProminent.o RecorderPlugin.o DisplayHIDAPI.o hidapi.o OutputCells.o DisplaySHM.o DisplayFileWrite.o @@ -10,15 +10,15 @@ SRCS += ../../embeddedcommon/DFT32.c ../OutputCells.c ../configs.c ../hidapi.c . WINGCC:= clang -fcolor-diagnostics WINGCCFLAGS:= -g -D_CRT_SECURE_NO_WARNINGS -Wno-deprecated-declarations -DICACHE_FLASH_ATTR= -I../../embeddedcommon -I../cnfa -I../rawdraw -I../ -O1 #-O2 -Wl,--relax -Wl,--gc-sections -ffunction-sections -fdata-sections -WINLDFLAGS:=-lwinmm -lgdi32 -lws2_32 -lsetupapi +WINLDFLAGS:=-lwinmm -lgdi32 -lws2_32 -lsetupapi -lkernel32 -luser32 -ldbghelp -lole32 -lmmdevapi -lAvrt RAWDRAWLIBS:=-lX11 -lm -lpthread -lXinerama -lXext LDLIBS:=-lpthread -lasound -lm -lpulse-simple -lpulse -ludev -lrt OBJS:=../main.o ../dft.o ../decompose.o ../filter.o ../color.o ../notefinder.o ../util.o ../outdrivers.o $(OUTS) ../parameters.o ../chash.o ../hook.o ../../embeddedcommon/DFT32.o ../configs.o -colorchord.exe : $(SRCS) +../colorchord.exe : $(SRCS) $(WINGCC) $(WINGCCFLAGS) -o $@ $^ $(WINLDFLAGS) clean : - rm -rf *.o *~ colorchord colorchord.exe embeddedcc $(OBJS) + rm -rf *.o *~ ../colorchord ../colorchord.exe ../embeddedcc $(OBJS) From 69dcc03f391d76e4908824489436e0cf6fa38025 Mon Sep 17 00:00:00 2001 From: Sam Ellicott Date: Thu, 21 May 2020 00:03:53 -0400 Subject: [PATCH 50/50] Slightly change default config --- colorchord2/default.conf | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/colorchord2/default.conf b/colorchord2/default.conf index 26f39d3..7acb2a3 100644 --- a/colorchord2/default.conf +++ b/colorchord2/default.conf @@ -28,9 +28,9 @@ sample_channel = -1 # Sets the playback device for CNFA (what speakers to go to) devplay = default # Sets the device to get audio from, for WASAPI, "default" searches for a mic -devrecord = default +# devrecord = default # For WASAPI, if speaker loopback is desired use the following line -#devrecord = defaultRender +devrecord = defaultRender # For Linux mostly use the following command to find valid devices to read from: # pactl list | grep pci- | grep monitor @@ -95,8 +95,7 @@ note_out_chop = 0.05000 # This is a vornoi thing: -outdrivers = OutputVoronoi, DisplayArray -# outdrivers = DisplayPie, DisplayArray +# outdrivers = OutputVoronoi, DisplayArray lightx = 64 lighty = 32 fromsides = 1 @@ -105,5 +104,12 @@ satamp = 5.000 amppow = 2.510 distpow = 1.500 +outdrivers = DisplayArray, OutputLinear +# outdrivers = DisplayPie, OutputLinear +leds = 64 +pie_min = 0.18 +pie_max = 0.3 + +