diff --git a/colorchord2/DisplayArray.c b/colorchord2/DisplayArray.c index 01da7d8..2eed784 100644 --- a/colorchord2/DisplayArray.c +++ b/colorchord2/DisplayArray.c @@ -8,7 +8,7 @@ #include #include #include "color.h" -#include "DrawFunctions.h" +#include "CNFG.h" //Uses: note_amplitudes2[note] for how many lights to use. //Uses: note_amplitudes_out[note] for how bright it should be. diff --git a/colorchord2/DisplayNetwork.c b/colorchord2/DisplayNetwork.c index 9f8cc62..54a128b 100644 --- a/colorchord2/DisplayNetwork.c +++ b/colorchord2/DisplayNetwork.c @@ -8,7 +8,6 @@ #include #include #include "color.h" -#include "DrawFunctions.h" #if defined(WIN32) || defined(WINDOWS) #include diff --git a/colorchord2/DisplayOUTDriver.c b/colorchord2/DisplayOUTDriver.c index f848bdd..722f6a1 100644 --- a/colorchord2/DisplayOUTDriver.c +++ b/colorchord2/DisplayOUTDriver.c @@ -11,7 +11,7 @@ #include #include #include "color.h" -#include "DrawFunctions.h" +#include "CNFG.h" //Uses: note_amplitudes2[note] for how many lights to use. //Uses: note_amplitudes_out[note] for how bright it should be. diff --git a/colorchord2/DisplayPie.c b/colorchord2/DisplayPie.c index 0c38c50..08d377a 100644 --- a/colorchord2/DisplayPie.c +++ b/colorchord2/DisplayPie.c @@ -8,7 +8,7 @@ #include #include #include "color.h" -#include "DrawFunctions.h" +#include "CNFG.h" //Uses: note_amplitudes2[note] for how many lights to use. //Uses: note_amplitudes_out[note] for how bright it should be. diff --git a/colorchord2/WinDriver.c b/colorchord2/WinDriver.c deleted file mode 100644 index b0f41d7..0000000 --- a/colorchord2/WinDriver.c +++ /dev/null @@ -1,236 +0,0 @@ -//Copyright (c) 2011 <>< Charles Lohr - Under the MIT/x11 or NewBSD License you choose. -//Portion from: http://en.wikibooks.org/wiki/Windows_Programming/Window_Creation - - -#include "DrawFunctions.h" -#include -#include -#include -#include //for alloca - -static HINSTANCE lhInstance; -static HWND lsHWND; -static HDC lsHDC; -static HBITMAP lsBackBitmap; -static HDC lsWindowHDC; -static HBRUSH lsHBR; -static HPEN lsHPEN; -static HBRUSH lsClearBrush; -static unsigned int lsLastWidth; -static unsigned int lsLastHeight; - -static void InternalHandleResize() -{ - DeleteObject( lsBackBitmap ); - lsBackBitmap = CreateCompatibleBitmap( lsHDC, lsLastWidth, lsLastHeight ); - SelectObject( lsHDC, lsBackBitmap ); - -} - -uint32_t CNFGColor( uint32_t RGB ) -{ - CNFGLastColor = RGB; - - DeleteObject( lsHBR ); - lsHBR = CreateSolidBrush( RGB ); - SelectObject( lsHDC, lsHBR ); - - DeleteObject( lsHPEN ); - lsHPEN = CreatePen( PS_SOLID, 0, RGB ); - SelectObject( lsHDC, lsHPEN ); - - return RGB; -} - -void CNFGTackSegment( short x1, short y1, short x2, short y2 ) -{ - POINT pt[2] = { {x1, y1}, {x2, y2} }; - Polyline( lsHDC, pt, 2 ); - SetPixel( lsHDC, x1, y1, CNFGLastColor ); - SetPixel( lsHDC, x2, y2, CNFGLastColor ); -} - -void CNFGTackRectangle( short x1, short y1, short x2, short y2 ) -{ - RECT r; - if( x1 < x2 ) { r.left = x1; r.right = x2; } - else { r.left = x2; r.right = x1; } - if( y1 < y2 ) { r.top = y1; r.bottom = y2; } - else { r.top = y2; r.bottom = y1; } - FillRect( lsHDC, &r, lsHBR ); -} - -void CNFGClearFrame() -{ - RECT r = { 0, 0, lsLastWidth, lsLastHeight }; - DeleteObject( lsClearBrush ); - lsClearBrush = CreateSolidBrush( CNFGBGColor ); - SelectObject( lsHDC, lsClearBrush ); - - FillRect( lsHDC, &r, lsClearBrush ); -} - -void CNFGSwapBuffers() -{ - int thisw, thish; - RECT r; - BitBlt( lsWindowHDC, 0, 0, lsLastWidth, lsLastHeight, lsHDC, 0, 0, SRCCOPY ); - UpdateWindow( lsHWND ); - - //Check to see if the window is closed. - if( !IsWindow( lsHWND ) ) - { - exit( 0 ); - } - - GetClientRect( lsHWND, &r ); - thisw = r.right - r.left; - thish = r.bottom - r.top; - if( thisw != lsLastWidth || thish != lsLastHeight ) - { - lsLastWidth = thisw; - lsLastHeight = thish; - InternalHandleResize(); - } -} - -void CNFGTackPoly( RDPoint * points, int verts ) -{ - int i; - POINT * t = (POINT*)alloca( sizeof( POINT ) * verts ); - for( i = 0; i < verts; i++ ) - { - t[i].x = points[i].x; - t[i].y = points[i].y; - } - Polygon( lsHDC, t, verts ); -} - - -void CNFGTackPixel( short x1, short y1 ) -{ - SetPixel( lsHDC, x1, y1, CNFGLastColor ); -} - -void CNFGGetDimensions( short * x, short * y ) -{ - *x = lsLastWidth; - *y = lsLastHeight; -} - -//This was from the article -LRESULT CALLBACK MyWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_DESTROY: - PostQuitMessage(0); - return 0; - } - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -//This was from the article, too... well, mostly. -void CNFGSetup( const char * name_of_window, int width, int height ) -{ - static LPSTR szClassName = "MyClass"; - RECT client, window; - WNDCLASS wnd; - int w, h, wd, hd; - HINSTANCE hInstance = GetModuleHandle(NULL); - - lsLastWidth = width; - lsLastHeight = height; - - wnd.style = CS_HREDRAW | CS_VREDRAW; //we will explain this later - wnd.lpfnWndProc = MyWndProc; - wnd.cbClsExtra = 0; - wnd.cbWndExtra = 0; - wnd.hInstance = hInstance; - wnd.hIcon = LoadIcon(NULL, IDI_APPLICATION); //default icon - wnd.hCursor = LoadCursor(NULL, IDC_ARROW); //default arrow mouse cursor - wnd.hbrBackground = (HBRUSH)(COLOR_BACKGROUND); - wnd.lpszMenuName = NULL; //no menu - wnd.lpszClassName = szClassName; - - if(!RegisterClass(&wnd)) //register the WNDCLASS - { - MessageBox(NULL, "This Program Requires Windows NT", "Error", MB_OK); - } - - lsHWND = CreateWindow(szClassName, - name_of_window, //name_of_window, - WS_OVERLAPPEDWINDOW, //basic window style - CW_USEDEFAULT, - CW_USEDEFAULT, //set starting point to default value - lsLastWidth, - lsLastHeight, //set all the dimensions to default value - NULL, //no parent window - NULL, //no menu - hInstance, - NULL); //no parameters to pass - - - lsWindowHDC = GetDC( lsHWND ); - lsHDC = CreateCompatibleDC( lsWindowHDC ); - lsBackBitmap = CreateCompatibleBitmap( lsWindowHDC, lsLastWidth, lsLastHeight ); - SelectObject( lsHDC, lsBackBitmap ); - - lsClearBrush = CreateSolidBrush( CNFGBGColor ); - lsHBR = CreateSolidBrush( 0xFFFFFF ); - lsHPEN = CreatePen( PS_SOLID, 0, 0xFFFFFF ); - - ShowWindow(lsHWND, 1); //display the window on the screen - - //Once set up... we have to change the window's borders so we get the client size right. - GetClientRect( lsHWND, &client ); - GetWindowRect( lsHWND, &window ); - w = ( window.right - window.left); - h = ( window.bottom - window.top); - wd = w - client.right; - hd = h - client.bottom; - MoveWindow( lsHWND, window.left, window.top, lsLastWidth + wd, lsLastHeight + hd, 1 ); - - InternalHandleResize(); -} - -void WindowsTerm(); - -void CNFGHandleInput() -{ - int ldown = 0; - - MSG msg; - while( PeekMessage( &msg, lsHWND, 0, 0xFFFF, 1 ) ) - { - TranslateMessage(&msg); - - switch( msg.message ) - { - case WM_QUIT: - case WM_DESTROY: - case WM_CLOSE: - printf( "Close\n" ); - WindowsTerm(); - TerminateProcess( 0, 0 ); - break; - case WM_MOUSEMOVE: - HandleMotion( (msg.lParam & 0xFFFF), (msg.lParam>>16) & 0xFFFF, ( (msg.wParam & 0x01)?1:0) | ((msg.wParam & 0x02)?2:0) | ((msg.wParam & 0x10)?4:0) ); - break; - case WM_LBUTTONDOWN: HandleButton( (msg.lParam & 0xFFFF), (msg.lParam>>16) & 0xFFFF, 1, 1 ); break; - case WM_RBUTTONDOWN: HandleButton( (msg.lParam & 0xFFFF), (msg.lParam>>16) & 0xFFFF, 2, 1 ); break; - case WM_MBUTTONDOWN: HandleButton( (msg.lParam & 0xFFFF), (msg.lParam>>16) & 0xFFFF, 3, 1 ); break; - case WM_LBUTTONUP: HandleButton( (msg.lParam & 0xFFFF), (msg.lParam>>16) & 0xFFFF, 1, 0 ); break; - case WM_RBUTTONUP: HandleButton( (msg.lParam & 0xFFFF), (msg.lParam>>16) & 0xFFFF, 2, 0 ); break; - case WM_MBUTTONUP: HandleButton( (msg.lParam & 0xFFFF), (msg.lParam>>16) & 0xFFFF, 3, 0 ); break; - case WM_KEYDOWN: - case WM_KEYUP: - HandleKey( tolower( msg.wParam ), (msg.message==WM_KEYDOWN) ); - break; - default: - DispatchMessage(&msg); - break; - } - } -} - diff --git a/colorchord2/XDriver.c b/colorchord2/XDriver.c deleted file mode 100644 index 21fe435..0000000 --- a/colorchord2/XDriver.c +++ /dev/null @@ -1,258 +0,0 @@ -//Copyright (c) 2011 <>< Charles Lohr - Under the MIT/x11 or NewBSD License you choose. -//portions from -//http://www.xmission.com/~georgeps/documentation/tutorials/Xlib_Beginner.html - -#define HAS_XINERAMA - -#include "DrawFunctions.h" - -#include -#include -#include -#include -#include -#ifdef HAS_XINERAMA -#include -#include -#endif -#include -#include - -XWindowAttributes CNFGWinAtt; -Display *CNFGDisplay; -Window CNFGWindow; -Pixmap CNFGPixmap; -GC CNFGGC; -GC CNFGWindowGC; -int FullScreen = 0; - -void CNFGGetDimensions( short * x, short * y ) -{ - *x = CNFGWinAtt.width; - *y = CNFGWinAtt.height; -} - -static void InternalLinkScreenAndGo( const char * WindowName ) -{ - XGetWindowAttributes( CNFGDisplay, CNFGWindow, &CNFGWinAtt ); - - XSelectInput (CNFGDisplay, CNFGWindow, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask ); - XSetStandardProperties( CNFGDisplay, CNFGWindow, WindowName, WindowName, None, NULL, 0, NULL ); - - CNFGWindowGC = XCreateGC(CNFGDisplay, CNFGWindow, 0, 0); - - CNFGPixmap = XCreatePixmap( CNFGDisplay, CNFGWindow, CNFGWinAtt.width, CNFGWinAtt.height, CNFGWinAtt.depth ); - CNFGGC = XCreateGC(CNFGDisplay, CNFGPixmap, 0, 0); -} - -void CNFGSetupFullscreen( const char * WindowName, int screen_no ) -{ -#ifdef HAS_XINERAMA - XineramaScreenInfo *screeninfo = NULL; - int screens; - int event_basep, error_basep, a, b; - CNFGDisplay = XOpenDisplay(NULL); - int screen = XDefaultScreen(CNFGDisplay); - int xpos, ypos; - - if (!XShapeQueryExtension(CNFGDisplay, &event_basep, &error_basep)) - { - fprintf( stderr, "X-Server does not support shape extension" ); - exit( 1 ); - } - - Visual * visual = DefaultVisual(CNFGDisplay, screen); - CNFGWinAtt.depth = DefaultDepth(CNFGDisplay, screen); - - if (XineramaQueryExtension(CNFGDisplay, &a, &b ) && - (screeninfo = XineramaQueryScreens(CNFGDisplay, &screens)) && - XineramaIsActive(CNFGDisplay) && screen_no >= 0 && - screen_no < screens ) { - - CNFGWinAtt.width = screeninfo[screen_no].width; - CNFGWinAtt.height = screeninfo[screen_no].height; - xpos = screeninfo[screen_no].x_org; - ypos = screeninfo[screen_no].y_org; - } else - { - CNFGWinAtt.width = XDisplayWidth(CNFGDisplay, screen); - CNFGWinAtt.height = XDisplayHeight(CNFGDisplay, screen); - xpos = 0; - ypos = 0; - } - if (screeninfo) - XFree(screeninfo); - - - XSetWindowAttributes setwinattr; - setwinattr.override_redirect = 1; - setwinattr.save_under = 1; - setwinattr.event_mask = StructureNotifyMask | SubstructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonPressMask | PointerMotionMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask |KeyPressMask |KeyReleaseMask | SubstructureNotifyMask | FocusChangeMask; - setwinattr.border_pixel = 0; - - CNFGWindow = XCreateWindow(CNFGDisplay, XRootWindow(CNFGDisplay, screen), - xpos, ypos, CNFGWinAtt.width, CNFGWinAtt.height, - 0, CNFGWinAtt.depth, InputOutput, visual, CWBorderPixel | CWEventMask | CWOverrideRedirect | CWSaveUnder, &setwinattr); - - XMapWindow(CNFGDisplay, CNFGWindow); - XSetInputFocus( CNFGDisplay, CNFGWindow, RevertToParent, CurrentTime ); - XFlush(CNFGDisplay); - FullScreen = 1; -//printf( "%d %d %d %d\n", xpos, ypos, CNFGWinAtt.width, CNFGWinAtt.height ); - InternalLinkScreenAndGo( WindowName ); -/* - setwinattr.override_redirect = 1; - XChangeWindowAttributes( - CNFGDisplay, CNFGWindow, - CWBorderPixel | CWEventMask | CWOverrideRedirect, &setwinattr); -*/ -#else - CNFGSetup( WindowName, 640, 480 ); -#endif -} - - -void CNFGSetup( const char * WindowName, int w, int h ) -{ - CNFGDisplay = XOpenDisplay(NULL); - XGetWindowAttributes( CNFGDisplay, RootWindow(CNFGDisplay, 0), &CNFGWinAtt ); - - int depth = CNFGWinAtt.depth; - CNFGWindow = XCreateWindow(CNFGDisplay, RootWindow(CNFGDisplay, 0), 1, 1, w, h, 0, depth, InputOutput, CopyFromParent, 0, 0 ); - XMapWindow(CNFGDisplay, CNFGWindow); - XFlush(CNFGDisplay); - - InternalLinkScreenAndGo( WindowName ); -} - -void CNFGHandleInput() -{ - static int ButtonsDown; - XEvent report; - - int bKeyDirection = 1; - int r; - while( (r=XCheckMaskEvent( CNFGDisplay, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | PointerMotionMask , &report )) ) - { -// XEvent nev; -// XPeekEvent(CNFGDisplay, &nev); - - //printf( "EVENT %d\n", report.type ); - //XMaskEvent(CNFGDisplay, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | ExposureMask, &report); - - bKeyDirection = 1; - switch (report.type) - { - case NoExpose: - break; - case Expose: - XGetWindowAttributes( CNFGDisplay, CNFGWindow, &CNFGWinAtt ); - if( CNFGPixmap ) XFreePixmap( CNFGDisplay, CNFGPixmap ); - CNFGPixmap = XCreatePixmap( CNFGDisplay, CNFGWindow, CNFGWinAtt.width, CNFGWinAtt.height, CNFGWinAtt.depth ); - if( CNFGGC ) XFreeGC( CNFGDisplay, CNFGGC ); - CNFGGC = XCreateGC(CNFGDisplay, CNFGPixmap, 0, 0); - break; - case KeyRelease: - bKeyDirection = 0; - case KeyPress: - HandleKey( XLookupKeysym(&report.xkey, 0), bKeyDirection ); - break; - case ButtonRelease: - bKeyDirection = 0; - case ButtonPress: - HandleButton( report.xbutton.x, report.xbutton.y, report.xbutton.button, bKeyDirection ); - ButtonsDown = (ButtonsDown & (~(1<>1 ); - break; - default: - printf( "Event: %d\n", report.type ); - } - } -} - - -void CNFGUpdateScreenWithBitmap( unsigned long * data, int w, int h ) -{ - static XImage *xi; - static int depth; - static int lw, lh; - - if( !xi ) - { - int screen = DefaultScreen(CNFGDisplay); -// Visual * visual = DefaultVisual(CNFGDisplay, screen); - depth = DefaultDepth(CNFGDisplay, screen)/8; -// xi = XCreateImage(CNFGDisplay, DefaultVisual( CNFGDisplay, DefaultScreen(CNFGDisplay) ), depth*8, ZPixmap, 0, (char*)data, w, h, 32, w*4 ); -// lw = w; -// lh = h; - } - - if( lw != w || lh != h ) - { - if( xi ) free( xi ); - xi = XCreateImage(CNFGDisplay, DefaultVisual( CNFGDisplay, DefaultScreen(CNFGDisplay) ), depth*8, ZPixmap, 0, (char*)data, w, h, 32, w*4 ); - lw = w; - lh = h; - } - -// ls = lw * lh; - - XPutImage(CNFGDisplay, CNFGWindow, CNFGWindowGC, xi, 0, 0, 0, 0, w, h ); -} - - -#ifndef RASTERIZER - - -uint32_t CNFGColor( uint32_t RGB ) -{ - unsigned char red = RGB & 0xFF; - unsigned char grn = ( RGB >> 8 ) & 0xFF; - unsigned char blu = ( RGB >> 16 ) & 0xFF; - CNFGLastColor = RGB; - unsigned long color = (red<<16)|(grn<<8)|(blu); - XSetForeground(CNFGDisplay, CNFGGC, color); - return color; -} - -void CNFGClearFrame() -{ - XGetWindowAttributes( CNFGDisplay, CNFGWindow, &CNFGWinAtt ); - XSetForeground(CNFGDisplay, CNFGGC, CNFGColor(CNFGBGColor) ); - XFillRectangle(CNFGDisplay, CNFGPixmap, CNFGGC, 0, 0, CNFGWinAtt.width, CNFGWinAtt.height ); -} - -void CNFGSwapBuffers() -{ - XCopyArea(CNFGDisplay, CNFGPixmap, CNFGWindow, CNFGWindowGC, 0,0,CNFGWinAtt.width,CNFGWinAtt.height,0,0); - XFlush(CNFGDisplay); - if( FullScreen ) - XSetInputFocus( CNFGDisplay, CNFGWindow, RevertToParent, CurrentTime ); -} - -void CNFGTackSegment( short x1, short y1, short x2, short y2 ) -{ - XDrawLine( CNFGDisplay, CNFGPixmap, CNFGGC, x1, y1, x2, y2 ); - XDrawPoint( CNFGDisplay, CNFGPixmap, CNFGGC, x2, y2 ); -} - -void CNFGTackPixel( short x1, short y1 ) -{ - XDrawPoint( CNFGDisplay, CNFGPixmap, CNFGGC, x1, y1 ); -} - -void CNFGTackRectangle( short x1, short y1, short x2, short y2 ) -{ - XFillRectangle(CNFGDisplay, CNFGPixmap, CNFGGC, x1, y1, x2-x1, y2-y1 ); -} - -void CNFGTackPoly( RDPoint * points, int verts ) -{ - XFillPolygon(CNFGDisplay, CNFGPixmap, CNFGGC, (XPoint *)points, verts, Convex, CoordModeOrigin ); -} - -#endif - diff --git a/colorchord2/cnfa b/colorchord2/cnfa index 818f782..7964b7d 160000 --- a/colorchord2/cnfa +++ b/colorchord2/cnfa @@ -1 +1 @@ -Subproject commit 818f7826f05d5ef1fb5c3e275d44359bd0dc01a0 +Subproject commit 7964b7ddd8ec4b36369b82ce1688ca641adde0ed diff --git a/colorchord2/colorchord.exe b/colorchord2/colorchord.exe new file mode 100644 index 0000000..47fcdc4 Binary files /dev/null and b/colorchord2/colorchord.exe differ diff --git a/colorchord2/default.conf b/colorchord2/default.conf index b11d29f..db18565 100644 --- a/colorchord2/default.conf +++ b/colorchord2/default.conf @@ -22,6 +22,7 @@ wininput = -1 #Compiled version will default to PULSE on Linux, WIN (winmm) on Windows and ANDROID on Android # sound_source = ALSA +sound_source = WASAPI #-1 indicates left and right, 0 left, 1 right. sample_channel = -1 diff --git a/colorchord2/rawdraw b/colorchord2/rawdraw index 407da6d..7681c76 160000 --- a/colorchord2/rawdraw +++ b/colorchord2/rawdraw @@ -1 +1 @@ -Subproject commit 407da6d1e7a11e68565c4f8cb35dfc330167e30b +Subproject commit 7681c766e68cbdd5640e0e342d6529e972902f46 diff --git a/colorchord2/windows/compile.bat b/colorchord2/windows/compile.bat index 051b4a1..616c2fc 100644 --- a/colorchord2/windows/compile.bat +++ b/colorchord2/windows/compile.bat @@ -2,9 +2,9 @@ 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 -O2 -Itccinc -DINCLUDING_EMBEDDED -rdynamic -g +set CFLAGS= -v -DHIDAPI -DWINDOWS -DWIN32 -DTCC -DRUNTIME_SYMNUM -O2 -Itccinc -DINCLUDING_EMBEDDED -rdynamic -g -DCNFGOGL 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 -lopengl32 rem lots of source files set SOURCES=..\main.c ..\chash.c ..\color.c ..\configs.c ..\decompose.c ..\dft.c ..\filter.c ^