Fix ColorChord on Windows10 32-bit TinyCC Compilation.

This commit is contained in:
CNLohr 2018-12-16 01:21:05 -05:00
parent 0b2e686d55
commit 9c3e841771
11 changed files with 74 additions and 21 deletions

View file

@ -17,6 +17,7 @@
#endif
#define MSG_NOSIGNAL 0
#else
#define closesocket( x ) close( x )
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@ -191,7 +192,7 @@ static void DPOUpdate(void * id, struct NoteFinder*nf)
if( r < 0 )
{
fprintf( stderr, "Send fault.\n" );
close( d->socket );
closesocket( d->socket );
d->socket = -1;
}
}

View file

@ -88,7 +88,7 @@ static void DPOUpdate(void * id, struct NoteFinder*nf)
for( i = 0; i < d->note_peaks; i++ )
{
struct LINote * l = &d->notes[i];
l->ledexp = pow( nf->note_amplitudes2[i], d->pow ) - d->cutoff;
l->ledexp = powf( nf->note_amplitudes2[i], d->pow ) - d->cutoff;
if( l->ledexp < 0 ) l->ledexp = 0;
totalexp += l->ledexp;
}

View file

@ -56,7 +56,7 @@ static void DPOUpdate(void * id, struct NoteFinder*nf)
for( i = 0; i < d->note_peaks; i++ )
{
struct LINote * l = &d->notes[i];
l->ledexp = pow( nf->note_amplitudes2[i], d->amppow ) - d->cutoff;
l->ledexp = powf( nf->note_amplitudes2[i], d->amppow ) - d->cutoff;
if( l->ledexp < 0 ) l->ledexp = 0;
totalexp += l->ledexp;
if( d->from_sides )

BIN
colorchord2/colorchord.exe Normal file

Binary file not shown.

View file

@ -97,6 +97,39 @@ extern "C" {
};
#define CTL_CODE(t,f,m,a) (((t)<<16)|((a)<<14)|((f)<<2)|(m))
#define WINSETUPAPI __declspec(dllimport) //XXX Should these be CDECL?
WINSETUPAPI BOOL SetupDiEnumDeviceInterfaces(
HDEVINFO DeviceInfoSet,
PSP_DEVINFO_DATA DeviceInfoData,
const GUID *InterfaceClassGuid,
DWORD MemberIndex,
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData
);
WINSETUPAPI BOOL SetupDiGetDeviceInterfaceDetailA(
HDEVINFO DeviceInfoSet,
PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
PSP_DEVICE_INTERFACE_DETAIL_DATA_A DeviceInterfaceDetailData,
DWORD DeviceInterfaceDetailDataSize,
PDWORD RequiredSize,
PSP_DEVINFO_DATA DeviceInfoData
);
WINSETUPAPI BOOL SetupDiEnumDeviceInfo(
HDEVINFO DeviceInfoSet,
DWORD MemberIndex,
PSP_DEVINFO_DATA DeviceInfoData
);
WINSETUPAPI BOOL SetupDiGetDeviceRegistryPropertyA(
HDEVINFO DeviceInfoSet,
PSP_DEVINFO_DATA DeviceInfoData,
DWORD Property,
PDWORD PropertyRegDataType,
PBYTE PropertyBuffer,
DWORD PropertyBufferSize,
PDWORD RequiredSize
);
WINSETUPAPI BOOL SetupDiDestroyDeviceInfoList(
HDEVINFO DeviceInfoSet
);
#else
#include <setupapi.h>
#include <winioctl.h>

View file

@ -166,6 +166,7 @@ int main(int argc, char ** argv)
{
int i;
#ifdef TCC
void ManuallyRegisterDevices();
ManuallyRegisterDevices();
#endif

View file

@ -288,7 +288,6 @@ void RunNoteFinder( struct NoteFinder * nf, const float * audio_stream, int head
nf->note_founds[i] = 1;
nf->note_positions[i] = avgloop( nf->note_positions[i], (1.-nf->note_attach_freq_iir), nf->dists[j].mean, nf->note_attach_freq_iir, nf->freqbins);
//I guess you can't IIR this like normal.
////note_positions[i] * (1.-note_attach_freq_iir) + dists[j].mean * note_attach_freq_iir;

View file

@ -7,8 +7,9 @@
#include <stdio.h>
#include <stdint.h>
#include <mmsystem.h>
#include <stdlib.h>
#if defined(WIN32)
#if defined(WIN32) && !defined( TCC )
#pragma comment(lib,"winmm.lib")
#endif
@ -133,11 +134,14 @@ static struct SoundDriverWin * InitWinSound( struct SoundDriverWin * r )
printf( "Wave Devs: %d; WAVE_MAPPER: %d; Selected Input: %d\n", waveInGetNumDevs(), WAVE_MAPPER, dwdevice );
printf( "waveInOpen: %p, %p\n", &r->hMyWave, &wfmt );
printf( "waveInOpen: %p, %p\n", r->hMyWave, &wfmt );
int p = waveInOpen(&r->hMyWave, dwdevice, &wfmt,(DWORD)(void*)(&HANDLEMIC) , 0, CALLBACK_FUNCTION);
printf( "WIO: %d\n", p );
int p = waveInOpen(&r->hMyWave, dwdevice, &wfmt, (void*)(&HANDLEMIC) , 0, CALLBACK_FUNCTION);
if( p )
{
fprintf( stderr, "Error performing waveInOpen. Received code: %d\n", p );
}
for ( i=0;i<BUFFS;i++)
{
@ -145,13 +149,17 @@ static struct SoundDriverWin * InitWinSound( struct SoundDriverWin * r )
(r->WavBuff[i]).dwBufferLength = r->buffer*2*r->channelsRec;
(r->WavBuff[i]).dwLoops = 1;
(r->WavBuff[i]).lpData=(char*) malloc(r->buffer*r->channelsRec*2);
waveInPrepareHeader(r->hMyWave,&(r->WavBuff[i]),sizeof(WAVEHDR));
p = waveInPrepareHeader(r->hMyWave,&(r->WavBuff[i]),sizeof(WAVEHDR));
printf( "WIP: %d\n", p );
waveInAddBuffer(r->hMyWave,&(r->WavBuff[i]),sizeof(WAVEHDR));
printf( "WIA: %d\n", p );
}
\
p = waveInStart(r->hMyWave);
printf( "WIS: %d\n", p );
if( p )
{
fprintf( stderr, "Error performing waveInStart. Received code %d\n", p );
}
return r;
}

View file

@ -1,8 +1,11 @@
@echo off
echo Unzip https://download.savannah.gnu.org/releases/tinycc/tcc-0.9.26-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.
set CFLAGS=-v -DHIDAPI -DWINDOWS -DWIN32 -DTCC -DRUNTIME_SYMNUM -Os -Itccinc -DINCLUDING_EMBEDDED -I.. -I. -I../../embeddedcommon -rdynamic -g
set LDFLAGS=-lkernel32 -lgdi32 -luser32 -lsetupapi -ldbghelp -ltcc1 -lwinmm -lws2_32
set LDFLAGS=-lkernel32 -lgdi32 -luser32 -lsetupapi -ldbghelp -lws2_32
set SOURCES=..\chash.c ..\color.c ..\configs.c ..\decompose.c ..\dft.c ..\DisplayNetwork.c ..\DisplayArray.c ..\DisplayHIDAPI.c ..\DisplayOUTDriver.c ..\DisplayPie.c ..\DrawFunctions.c ..\filter.c ..\hidapi.c ..\hook.c ..\main.c ..\os_generic.c ..\outdrivers.c ..\OutputCells.c ..\OutputLinear.c ..\OutputProminent.c ..\OutputVoronoi.c ..\parameters.c ..\sound.c ..\sound_win.c ..\sound_null.c ..\util.c ..\WinDriver.c ..\notefinder.c ..\..\embeddedcommon\DFT32.c tcc_stubs.c symbol_enumerator.c
set ARCH_SPECIFIC=-L32
set ARCH_SPECIFIC=-L32 C:\windows\system32\winmm.dll
set CC=C:\tcc\i386-win32-tcc.exe
rem set CC=C:\tcc\x86_64-win32-tcc.exe
@echo on
C:\tcc\tcc %CFLAGS% %ARCH_SPECIFIC% %SOURCES% %LDFLAGS% -o ..\colorchord.exe
%CC% %CFLAGS% %ARCH_SPECIFIC% %SOURCES% %LDFLAGS% -o ..\colorchord.exe

View file

@ -0,0 +1,3 @@
cd ..
colorchord
cd windows

View file

@ -1,7 +1,12 @@
#include <string.h>
#include <_mingw.h>
#include <tcclib.h>
#include "symbol_enumerator.h"
#define REMATH(x) double __cdecl x( double f ); float x##f(float v) { return x(v); }
_CRTIMP int __cdecl _vscprintf(const char *_Format,va_list _ArgList);
#define REMATH(x) double __cdecl x( double f ); float x##f(float v) { return x(v); }
#define REMATH2(x) double __cdecl x( double f, double g ); float x##f(float v, float w) { return x(v,w); }
int SymnumCheck( const char * path, const char * name, void * location, long size )
{
@ -27,8 +32,8 @@ REMATH( sin );
REMATH( sqrt );
REMATH( asin );
REMATH( exp );
REMATH( fmod );
REMATH( pow );
REMATH2( fmod );
REMATH2( pow );
double __cdecl strtod (const char* str, char** endptr);
float strtof( const char* str, char** endptr)