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 <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)
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;
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;

View file

@ -22,15 +22,21 @@ 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
# 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
# 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. #
@ -88,8 +94,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

View file

@ -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

View file

@ -1,8 +1,13 @@
//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 <windows.h>
#ifndef strdup
#define strdup _strdup
#endif
#endif
#include <ctype.h>
@ -143,9 +148,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 +313,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 +326,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 +375,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 )
@ -430,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 ), 0 );
GetParameterS( "devrecord", 0 ), GetParameterS( "devplay", 0 ), NULL );
if( sd ) break;
@ -438,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 );
@ -533,7 +559,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;
@ -656,6 +683,3 @@ int main(int argc, char ** argv)
}
}

View file

@ -7,6 +7,13 @@
#include <stdio.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;
unsigned char OutLEDs[MAX_LEDS*3];
int UsedLEDs;

View file

@ -6,6 +6,13 @@
#include <stdio.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;
//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 )
{
printf("[SDE] Registering parameter %s\n", name);
Init();
struct Param * p = (struct Param*)HashGetEntry( parameters, name );

View file

@ -1,7 +1,8 @@
@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
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 ^

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 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
@ -13,7 +13,7 @@ set SOURCES=..\main.c ..\chash.c ..\color.c ..\configs.c ..\decompose.c ..\dft.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 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