Skip to content

Commit

Permalink
Merge pull request #123 from cnlohr/rawdraw-update
Browse files Browse the repository at this point in the history
Rawdraw update
  • Loading branch information
sellicott authored Jun 8, 2021
2 parents 65a5a33 + c800b70 commit 1ccf792
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 41 deletions.
20 changes: 0 additions & 20 deletions colorchord2/DisplayOUTDriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++ )
{
Expand Down
3 changes: 2 additions & 1 deletion colorchord2/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Binary file modified colorchord2/colorchord.exe
Binary file not shown.
48 changes: 30 additions & 18 deletions colorchord2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -118,8 +127,11 @@ void HandleDestroy()
CNFAClose( sd );
}
#else

#define ESCAPE_KEY 65307
// Stub function for Linux
void HandleDestroy()
{
}

#endif

Expand Down Expand Up @@ -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 ];
Expand All @@ -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;
Expand Down Expand Up @@ -400,7 +410,7 @@ int main( int argc, char **argv )

if ( sd ) break;

CNFGColor( 0xffffff );
CNFGColor( LINE_COLOR );
CNFGPenX = 10;
CNFGPenY = 100;
CNFGHandleInput();
Expand Down Expand Up @@ -430,7 +440,7 @@ int main( int argc, char **argv )
{
CNFGHandleInput();
CNFGClearFrame();
CNFGColor( 0xFFFFFF );
CNFGColor( LINE_COLOR );
CNFGGetDimensions( &screenx, &screeny );
}

Expand Down Expand Up @@ -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.
Expand All @@ -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++ )
{
Expand All @@ -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++ )
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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++ )
{
Expand All @@ -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,
Expand All @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion colorchord2/windows/compile-clang.bat
Original file line number Diff line number Diff line change
@@ -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 ^
Expand Down

0 comments on commit 1ccf792

Please sign in to comment.