diff --git a/colorchord2/DisplayOUTDriver.c b/colorchord2/DisplayOUTDriver.c index 722f6a1..aa17c04 100644 --- a/colorchord2/DisplayOUTDriver.c +++ b/colorchord2/DisplayOUTDriver.c @@ -121,26 +121,6 @@ static void DPOUpdate(void * id, struct NoteFinder*nf) } } -/* float cw = ((float)screenx) / d->xn; - float ch = ((float)screeny) / d->yn; - - for( i = 0; i < d->note_peaks; i++ ) - { - struct LINote * l = &d->notes[i]; - int j; - float sat = nf->note_amplitudes_out[i] * d->satamp; - if( sat > 1 ) sat = 1; - CNFGDialogColor = CCtoHEX( nf->note_positions[i] / nf->freqbins, 1.0, sat ); - for( j = 0; j < l->nrleds; j++ ) - { - int id = l->ledids[j]; - float x = (id % d->xn) * cw; - float y = (id / d->xn) * ch; - - CNFGDrawBox( x, y, x+cw, y+ch ); - } - }*/ - int led = 0; for( i = 0; i < d->note_peaks; i++ ) { diff --git a/colorchord2/color.c b/colorchord2/color.c index 286d042..acacda2 100644 --- a/colorchord2/color.c +++ b/colorchord2/color.c @@ -105,5 +105,6 @@ uint32_t HSVtoHEX( float hue, float sat, float value ) if( ob < 0 ) ob = 0; if( ob > 255 ) ob = 255; - return (ob<<16) | (og<<8) | ora; + // Pack bits in RGBA format + return (ora << 24) | (og << 16) | (ob << 8) | 0xFF; } diff --git a/colorchord2/colorchord.exe b/colorchord2/colorchord.exe index 47fcdc4..aa189be 100644 Binary files a/colorchord2/colorchord.exe and b/colorchord2/colorchord.exe differ diff --git a/colorchord2/main.c b/colorchord2/main.c index ba24e41..ec7a997 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -67,6 +67,15 @@ int genloglines; int genlinelen = 0; int firstnewline = -1; + +// Define application colors RGBA format +#define BACKGROUND_COLOR 0x000080ff +#define LINE_COLOR 0xffffffff +#define TEXT_COLOR 0xffffffff +// Text colors for the debug options at the bottom of the screen +#define ENABLED_COLOR 0xffffffff +#define DISABLED_COLOR 0x800000ff + void example_log_function( int readSize, char *buf ) { static og_mutex_t *mt; @@ -118,8 +127,11 @@ void HandleDestroy() CNFAClose( sd ); } #else - #define ESCAPE_KEY 65307 +// Stub function for Linux +void HandleDestroy() +{ +} #endif @@ -349,8 +361,7 @@ int main( int argc, char **argv ) double SecToWait; double LastFPSTime = OGGetAbsoluteTime(); double LastFrameTime = OGGetAbsoluteTime(); - CNFGBGColor = 0x800000; - CNFGDialogColor = 0x444444; + CNFGBGColor = BACKGROUND_COLOR; // Generate the window title char title[ 1024 ]; @@ -362,7 +373,6 @@ int main( int argc, char **argv ) } if ( !headless ) CNFGSetup( title, set_screenx, set_screeny ); - char *OutDriverNames = strdup( GetParameterS( "outdrivers", "null" ) ); char *ThisDriver = OutDriverNames; char *TDStart; @@ -400,7 +410,7 @@ int main( int argc, char **argv ) if ( sd ) break; - CNFGColor( 0xffffff ); + CNFGColor( LINE_COLOR ); CNFGPenX = 10; CNFGPenY = 100; CNFGHandleInput(); @@ -430,7 +440,7 @@ int main( int argc, char **argv ) { CNFGHandleInput(); CNFGClearFrame(); - CNFGColor( 0xFFFFFF ); + CNFGColor( LINE_COLOR ); CNFGGetDimensions( &screenx, &screeny ); } @@ -460,6 +470,7 @@ int main( int argc, char **argv ) // Do a bunch of debugging. if ( show_debug_basic && !is_suspended ) { + CNFGColor( TEXT_COLOR ); for ( int i = 0; i < nf->dists_count; i++ ) { // Move over 0.5 for visual purposes. The means is correct. @@ -468,8 +479,8 @@ int main( int argc, char **argv ) sprintf( stt, "%f\n%f\n", nf->dists[ i ].mean, nf->dists[ i ].amp ); CNFGDrawText( stt, 2 ); } - CNFGColor( 0xffffff ); + CNFGColor( LINE_COLOR ); // Draw the folded bins for ( int bin = 0; bin < freqbins; bin++ ) { @@ -480,7 +491,6 @@ int main( int argc, char **argv ) CNFGDialogColor = CCtoHEX( note, 1.0, 1.0 ); CNFGDrawBox( x0, 400 - amp, x1, 400 ); } - CNFGDialogColor = 0xf0f000; // Draw the note peaks for ( int peak = 0; peak < note_peaks; peak++ ) @@ -492,15 +502,19 @@ int main( int argc, char **argv ) const int x2 = ( (float)( peak + 1 ) / note_peaks ) * screenx; const int y1 = 480 - nf->note_amplitudes_out[ peak ] * 100; const int y2 = 480; + CNFGColor( LINE_COLOR ); CNFGDrawBox( x1, y1, x2, y2 ); CNFGPenX = ( (float)( peak + .4 ) / note_peaks ) * screenx; CNFGPenY = screeny - 30; sprintf( stt, "%d\n%0.0f", nf->enduring_note_id[ peak ], nf->note_amplitudes2[ peak ] * 1000.0 ); + + CNFGColor( TEXT_COLOR ); CNFGDrawText( stt, 2 ); } + CNFGColor( LINE_COLOR ); // Let's draw the o-scope. int thissoundhead = soundhead; thissoundhead = ( thissoundhead - 1 + SOUNDCBSIZE ) % SOUNDCBSIZE; @@ -522,8 +536,7 @@ int main( int argc, char **argv ) { // Draw the histogram float lasthistval; - CNFGColor( 0xffffff ); - + CNFGColor( LINE_COLOR ); for ( int x_val = -1; x_val < screenx; x_val++ ) { // Calculate the value of the histogram at the current screen position @@ -537,8 +550,7 @@ int main( int argc, char **argv ) lasthistval = thishistval; } - CNFGColor( 0xffffff ); - + CNFGColor( LINE_COLOR ); // Draw the bins for ( int bin = 0; bin < freqs; bin++ ) { @@ -549,8 +561,8 @@ int main( int argc, char **argv ) CNFGDialogColor = CCtoHEX( note, 1.0, 1.0 ); CNFGDrawBox( x0, 0, x1, amp ); } - CNFGDialogColor = 0x0f0f0f; + CNFGColor( TEXT_COLOR ); char stdebug[ 1024 ]; sprintf( stdebug, "DFT:%8.2fms\nFLT:%8.2f\nDEC:%8.2f\nFNL:%8.2f\nDPY:%8.2f", ( nf->DFTTime - nf->StartTime ) * 1000, ( nf->FilterTime - nf->DFTTime ) * 1000, @@ -564,30 +576,30 @@ int main( int argc, char **argv ) if ( !is_suspended ) { - CNFGColor( show_debug ? 0xffffff : 0x000000 ); + CNFGColor( show_debug ? ENABLED_COLOR : DISABLED_COLOR ); CNFGPenX = 0; CNFGPenY = screeny - 10; CNFGDrawText( "Extra Debug (D)", 2 ); - CNFGColor( show_debug_basic ? 0xffffff : 0x000000 ); + CNFGColor( show_debug_basic ? ENABLED_COLOR : DISABLED_COLOR ); CNFGPenX = 120; CNFGPenY = screeny - 10; CNFGDrawText( "Basic Debug (E)", 2 ); - CNFGColor( show_debug_basic ? 0xffffff : 0x000000 ); + CNFGColor( show_debug_basic ? ENABLED_COLOR : DISABLED_COLOR ); CNFGPenX = 240; CNFGPenY = screeny - 10; sprintf( stt, "[9] Key: %d [0] (%3.1f) [-]", gKey, nf->base_hz ); CNFGDrawText( stt, 2 ); - CNFGColor( 0xffffff ); + CNFGColor( TEXT_COLOR ); CNFGPenX = 440; CNFGPenY = screeny - 10; sprintf( stt, "FPS: %d", lastfps ); CNFGDrawText( stt, 2 ); #ifdef ANDROID - CNFGColor( 0xffffff ); + CNFGColor( TEXT_COLOR ); CNFGPenX = 10; CNFGPenY = 600; CNFGDrawText( genlog, 3 ); diff --git a/colorchord2/rawdraw b/colorchord2/rawdraw index 407da6d..0f29047 160000 --- a/colorchord2/rawdraw +++ b/colorchord2/rawdraw @@ -1 +1 @@ -Subproject commit 407da6d1e7a11e68565c4f8cb35dfc330167e30b +Subproject commit 0f29047f6bfe287cf032e3ef845939f5d796a70e diff --git a/colorchord2/windows/compile-clang.bat b/colorchord2/windows/compile-clang.bat index ca9c46a..a669412 100644 --- a/colorchord2/windows/compile-clang.bat +++ b/colorchord2/windows/compile-clang.bat @@ -1,7 +1,7 @@ @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 +set CCFLAGS=-g -D_CRT_SECURE_NO_WARNINGS -DCNFGOGL set CCIFLAGS=-I../../embeddedcommon -I../cnfa -I../rawdraw -I../ -O2 set CCLFLAGS=-lwinmm -lgdi32 -lws2_32 -lsetupapi -lkernel32 -luser32 -ldbghelp -lole32 -lmmdevapi -lAvrt -lopengl32 set SOURCES=../main.c ../dft.c ../decompose.c ../filter.c ../color.c ../notefinder.c ../util.c ../outdrivers.c ^