Merging part 2

This commit is contained in:
CaiB 2020-05-20 14:40:52 +09:00
commit d291fc224a
11 changed files with 136 additions and 77 deletions

0
colorchord2/android/colorchord-android.txt Executable file → Normal file
View file

View file

@ -10,6 +10,13 @@
#include <stdio.h> #include <stdio.h>
#include <malloc.h> #include <malloc.h>
#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) #define I_AM_LITTLE (((union { unsigned x; unsigned char c; }){1}).c)
static unsigned long GetStrHash( const char * c ) static unsigned long GetStrHash( const char * c )

@ -1 +1 @@
Subproject commit c021a3d8eb2febbd6b9d6285dac884bb828c5f02 Subproject commit 314da0d28f51cc57f13923210f7213a0fd8e8d3c

View file

@ -9,23 +9,23 @@ uint32_t CCtoHEX( float note, float sat, float value )
{ {
float hue = 0.0; float hue = 0.0;
note = fmodf( note, 1.0 ); note = fmodf( note, 1.0 );
note *= 12; note *= 12.0;
if( note < 4 ) if( note < 4.0 )
{ {
//Needs to be YELLOW->RED //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] // [4] [8]
//Needs to be RED->BLUE //Needs to be RED->BLUE
hue = ( 4 - note ) / 12.0; hue = ( 4.0 - note ) / 12.0;
} }
else else
{ {
// [8] [12] // [8] [12]
//Needs to be BLUE->YELLOW //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 ); 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 ) uint32_t HSVtoHEX( float hue, float sat, float value )
{ {
float pr = 0; float pr = 0.0;
float pg = 0; float pg = 0.0;
float pb = 0; float pb = 0.0;
short ora = 0; short ora = 0.0;
short og = 0; short og = 0.0;
short ob = 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; pr = 1.0;
pg = 1. - ro; pg = 1.0 - ro;
} else if( ro < 2 ) } else if( ro < 2.0 )
{ {
pr = 1; pr = 1.0;
pb = ro - 1.; pb = ro - 1.0;
} else if( ro < 3 ) } else if( ro < 3.0 )
{ {
pr = 3. - ro; pr = 3.0 - ro;
pb = 1; pb = 1.0;
} else if( ro < 4 ) } else if( ro < 4.0 )
{ {
pb = 1; pb = 1.0;
pg = ro - 3; pg = ro - 3.0;
} else if( ro < 5 ) } else if( ro < 5.0 )
{ {
pb = 5 - ro; pb = 5.0 - ro;
pg = 1; pg = 1.0;
} else } else
{ {
pg = 1; pg = 1.0;
pr = ro - 5; pr = ro - 5.0;
} }
//Actually, above math is backwards, oops! //Actually, above math is backwards, oops!
@ -90,9 +90,9 @@ uint32_t HSVtoHEX( float hue, float sat, float value )
avg += pg; avg += pg;
avg += pb; avg += pb;
pr = pr * sat + avg * (1.-sat); pr = pr * sat + avg * (1.0-sat);
pg = pg * sat + avg * (1.-sat); pg = pg * sat + avg * (1.0-sat);
pb = pb * sat + avg * (1.-sat); pb = pb * sat + avg * (1.0-sat);
ora = pr * 255; ora = pr * 255;
og = pb * 255; og = pb * 255;

View file

@ -22,15 +22,21 @@ wininput = -1
#Compiled version will default this. #Compiled version will default this.
#sound_source = ALSA #sound_source = ALSA
#-1 indicates left and right, 0 left, 1 right.
#-1 indicates left and right, 0 left, 1 right.
sample_channel = -1 sample_channel = -1
sourcename = default # Sets the playback device for CNFA (what speakers to go to)
#alsa_output.pci-0000_00_1f.3.analog-stereo.monitor devplay = default
#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
# 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_1b.0.analog-stereo.monitor
#alsa_output.pci-0000_00_1f.3.analog-stereo.monitor << New laptop # alsa_output.pci-0000_00_1f.3.analog-stereo.monitor << New laptop
#use pactl list | grep pci- | grep monitor
################################## ##################################
# General ColorChord properties. # # General ColorChord properties. #
@ -41,7 +47,7 @@ amplify = 2.0
# What is the base note? I.e. the lowest note. # What is the base note? I.e. the lowest note.
# Note that it won't have very much impact until an octave up though! # 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) # This is only used when dealing with the slow decompose (now defunct)
# decompose_iterations = 1000 # decompose_iterations = 1000
@ -66,7 +72,7 @@ filter_iter = 2
filter_strength = .5 filter_strength = .5
# How many bins per octave to use? # How many bins per octave to use?
freqbins = 24 freqbins = 24
# For the final note information... How much to slack everything? # For the final note information... How much to slack everything?
note_attach_amp_iir = 0.3500 note_attach_amp_iir = 0.3500
@ -88,8 +94,9 @@ note_out_chop = 0.05000
#Outputs #Outputs
This is a vornoi thing: # This is a vornoi thing:
outdrivers = OutputVoronoi, DisplayArray outdrivers = OutputVoronoi, DisplayArray
# outdrivers = DisplayPie, DisplayArray
lightx = 64 lightx = 64
lighty = 32 lighty = 32
fromsides = 1 fromsides = 1

View file

@ -58,6 +58,13 @@ typedef LONG NTSTATUS;
/*#define HIDAPI_USE_DDK*/ /*#define HIDAPI_USE_DDK*/
#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) \
|| defined(_WIN32) || defined(_WIN64)
#ifndef strdup
#define strdup _strdup
#endif
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View file

@ -1,9 +1,14 @@
//Copyright 2015 <>< Charles Lohr under the ColorChord License. //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 <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>
#ifndef strdup
#define strdup _strdup
#endif #endif
#endif
#include <ctype.h> #include <ctype.h>
#include "color.h" #include "color.h"
@ -143,9 +148,9 @@ int set_screenx = 640; REGISTER_PARAM( set_screenx, PAINT );
int set_screeny = 480; REGISTER_PARAM( set_screeny, PAINT ); int set_screeny = 480; REGISTER_PARAM( set_screeny, PAINT );
char sound_source[16]; REGISTER_PARAM( sound_source, PABUFFER ); char sound_source[16]; REGISTER_PARAM( sound_source, PABUFFER );
int cpu_autolimit = 1; REGISTER_PARAM( cpu_autolimit, PAINT ); int cpu_autolimit = 1; REGISTER_PARAM( cpu_autolimit, PAINT );
float cpu_autolimit_interval = 0.016; REGISTER_PARAM( cpu_autolimit_interval, PAFLOAT ); float cpu_autolimit_interval = 0.016; REGISTER_PARAM( cpu_autolimit_interval, PAFLOAT );
int sample_channel = -1;REGISTER_PARAM( sample_channel, PAINT ); int sample_channel = -1; REGISTER_PARAM( sample_channel, PAINT );
int showfps = 1; REGISTER_PARAM( showfps, PAINT ); int showfps = 1; REGISTER_PARAM( showfps, PAINT );
#if defined(ANDROID) || defined( __android__ ) #if defined(ANDROID) || defined( __android__ )
float in_amplitude = 2; float in_amplitude = 2;
@ -308,17 +313,11 @@ void HandleResume()
} }
#endif #endif
int main(int argc, char ** argv) // function for calling initilization functions if we are using TCC
{ #ifdef TCC
int i; void RegisterConstructorFunctions(){
#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;
}
// Basic Window stuff
REGISTERheadless(); REGISTERheadless();
REGISTERset_screenx(); REGISTERset_screenx();
REGISTERset_screeny(); REGISTERset_screeny();
@ -327,12 +326,43 @@ int main(int argc, char ** argv)
REGISTERcpu_autolimit_interval(); REGISTERcpu_autolimit_interval();
REGISTERsample_channel(); REGISTERsample_channel();
REGISTERshowfps(); 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 #endif
int main(int argc, char ** argv)
{
int i;
#ifdef TCC #ifdef TCC
void ManuallyRegisterDevices(); RegisterConstructorFunctions();
ManuallyRegisterDevices();
#endif #endif
printf( "Output Drivers:\n" ); printf( "Output Drivers:\n" );
@ -345,10 +375,6 @@ int main(int argc, char ** argv)
WSAStartup(0x202, &wsaData); 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. strcpy( sound_source, "WASAPI" ); // Use either "sound_source=WASAPI" or "sound_source=WIN" in config file.
#elif defined( ANDROID ) #elif defined( ANDROID )
@ -430,7 +456,7 @@ int main(int argc, char ** argv)
//Initialize Sound //Initialize Sound
sd = CNFAInit( sound_source, "colorchord", &SoundCB, GetParameterI( "samplerate", 44100 ), sd = CNFAInit( sound_source, "colorchord", &SoundCB, GetParameterI( "samplerate", 44100 ),
GetParameterI( "channels", 2 ), GetParameterI( "channels", 2 ), GetParameterI( "buffer", 1024 ), GetParameterI( "channels", 2 ), GetParameterI( "channels", 2 ), GetParameterI( "buffer", 1024 ),
GetParameterS( "devrecord", 0 ), GetParameterS( "devplay", 0 ), 0 ); GetParameterS( "devrecord", 0 ), GetParameterS( "devplay", 0 ), NULL );
if( sd ) break; if( sd ) break;
@ -438,7 +464,7 @@ int main(int argc, char ** argv)
CNFGPenX = 10; CNFGPenY = 100; CNFGPenX = 10; CNFGPenY = 100;
CNFGHandleInput(); CNFGHandleInput();
CNFGClearFrame(); CNFGClearFrame();
CNFGDrawText( "Colorchord must be used with sound. Sound not available.", 10 ); CNFGDrawText( "Colorchord must be used with sound. Sound not available.", 10 );
CNFGSwapBuffers(); CNFGSwapBuffers();
OGSleep(1); OGSleep(1);
} while( 1 ); } while( 1 );
@ -533,7 +559,8 @@ int main(int argc, char ** argv)
{ {
//printf( "%f %f /", note_positions[i], note_amplitudes[i] ); //printf( "%f %f /", note_positions[i], note_amplitudes[i] );
if( nf->note_amplitudes_out[i] < 0 ) continue; 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 ); 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; CNFGPenX = ((float)(i+.4) / note_peaks) * screenx;
CNFGPenY = screeny - 30; CNFGPenY = screeny - 30;
@ -656,6 +683,3 @@ int main(int argc, char ** argv)
} }
} }

View file

@ -7,6 +7,13 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) \
|| defined(_WIN32) || defined(_WIN64)
#ifndef strdup
#define strdup _strdup
#endif
#endif
int force_white = 0; int force_white = 0;
unsigned char OutLEDs[MAX_LEDS*3]; unsigned char OutLEDs[MAX_LEDS*3];
int UsedLEDs; int UsedLEDs;

View file

@ -6,6 +6,13 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) \
|| defined(_WIN32) || defined(_WIN64)
#ifndef strdup
#define strdup _strdup
#endif
#endif
static struct chash * parameters; static struct chash * parameters;
//XXX TODO: Make this thread safe. //XXX TODO: Make this thread safe.
@ -137,7 +144,6 @@ static int SetParameter( struct Param * p, const char * str )
void RegisterValue( const char * name, enum ParamType t, void * ptr, int size ) void RegisterValue( const char * name, enum ParamType t, void * ptr, int size )
{ {
printf("[SDE] Registering parameter %s\n", name);
Init(); Init();
struct Param * p = (struct Param*)HashGetEntry( parameters, name ); struct Param * p = (struct Param*)HashGetEntry( parameters, name );

View file

@ -1,7 +1,8 @@
@echo off @echo off
set CC="C:\Program Files\LLVM\bin\clang.exe" 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 rem To enable OpenGL rendering use the -DCNFGOGL option
set CCIFLAGS=-I../../embeddedcommon -I../cnfa -I../rawdraw -I../ -O1 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 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 ^ 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 ^ ../parameters.c ../chash.c ../OutputVoronoi.c ../OutputProminent.c ../DisplayArray.c ^

View file

@ -2,7 +2,7 @@
echo Unzip http://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27-win64-bin.zip to C:\tcc 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. 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 INCLUDES=-I../rawdraw -I../cnfa -I.. -I. -I../../embeddedcommon
set LDFLAGS=-lkernel32 -lole32 -lgdi32 -luser32 -lsetupapi -ldbghelp -lws2_32 -lAvrt 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 ^ ..\outdrivers.c ..\hidapi.c ..\hook.c ..\parameters.c ..\util.c ..\notefinder.c ^
..\..\embeddedcommon\DFT32.c tcc_stubs.c symbol_enumerator.c ^ ..\..\embeddedcommon\DFT32.c tcc_stubs.c symbol_enumerator.c ^
..\DisplayNetwork.c ..\DisplayArray.c ..\DisplayHIDAPI.c ..\DisplayOUTDriver.c ..\DisplayPie.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 set CC=C:\tcc\tcc.exe
rem set CC=C:\tcc\i386-win32-tcc.exe rem set CC=C:\tcc\i386-win32-tcc.exe
rem set CC=C:\tcc\x86_64-win32-tcc.exe rem set CC=C:\tcc\x86_64-win32-tcc.exe