diff --git a/colorchord2/configs.c b/colorchord2/configs.c new file mode 100644 index 0000000..61c0acf --- /dev/null +++ b/colorchord2/configs.c @@ -0,0 +1,109 @@ +#include "configs.h" +#include +#include +#include +#include +#include "parameters.h" + +int gargc; +char ** gargv; + + +const char * InitialFile[NRDEFFILES]; +double FileTimes[NRDEFFILES]; +int InitialFileCount = 1; + + +void LoadFile( const char * filename ) +{ + char * buffer; + int r; + + FILE * f = fopen( filename, "rb" ); + if( !f ) + { + fprintf( stderr, "Warning: cannot open %s.\n", filename ); + } + else + { + fseek( f, 0, SEEK_END ); + int size = ftell( f ); + fseek( f, 0, SEEK_SET ); + buffer = malloc( size + 1 ); + r = fread( buffer, size, 1, f ); + fclose( f ); + buffer[size] = 0; + if( r != 1 ) + { + fprintf( stderr, "Warning: %d bytes read. Expected: %d from file %s\n", r, size, filename ); + } + else + { + SetParametersFromString( buffer ); + } + free( buffer ); + } +} + +void SetEnvValues( int force ) +{ + int i; + int hits = 0; + for( i = 0; i < InitialFileCount; i++ ) + { + double ft = OGGetFileTime( InitialFile[i] ); + if( FileTimes[i] != ft ) + { + FileTimes[i] = ft; + hits++; + } + } + + if( !hits && !force ) return; + + //Otherwise, something changed. + + LoadFile( InitialFile[0] ); + + for( i = 1; i < gargc; i++ ) + { + if( strchr( gargv[i], '=' ) != 0 ) + { + printf( "AP: %s\n", gargv[i] ); + SetParametersFromString( gargv[i] ); + } + else + { + printf( "LF: %s\n", gargv[i] ); + LoadFile( gargv[i] ); + } + } +} + +void ProcessArgs() +{ + int i; + for( i = 1; i < gargc; i++ ) + { + if( strchr( gargv[i], '=' ) != 0 ) + { + //A value setting operation + } + else + { + InitialFile[InitialFileCount++] = gargv[i]; + } + } + + SetEnvValues( 1 ); +} + + +void SetupConfigs() +{ + + InitialFile[0] = "default.conf"; + + ProcessArgs(); + +} diff --git a/colorchord2/configs.h b/colorchord2/configs.h new file mode 100644 index 0000000..69a7e9d --- /dev/null +++ b/colorchord2/configs.h @@ -0,0 +1,16 @@ +#ifndef _CONFIGS_H +#define _CONFIGS_H + +#define NRDEFFILES 10 + +extern int gargc; +extern char ** gargv; + + +void LoadFile( const char * filename ); +void SetEnvValues( int force ); +void ProcessArgs(); +void SetupConfigs(); + +#endif + diff --git a/colorchord2/double_pie_voice.conf b/colorchord2/double_pie_voice.conf new file mode 100644 index 0000000..a8d574c --- /dev/null +++ b/colorchord2/double_pie_voice.conf @@ -0,0 +1,53 @@ +#for a two-ring WS2812 light, 24 LEDs per layer, one layer clockwise, the other counter-clockwise. + +outdrivers = DisplayPie,DisplayNetwork,OutputLinear,RecorderPlugin +leds = 48 +light_siding = 2.5 #Turn this to ~1.9 for more uniformity, ~1.0 for less. +satamp = 1.600 +is_loop=1 +led_floor = .1 #Turn to .25 for more uniformity, .1 for less. +steady_bright = 0 + + + + +# For the final note information... How much to slack everything? +note_attach_amp_iir = 0.4500 +note_attach_amp_iir2 = 0.350 +note_attach_freq_iir = 0.4000 +dft_iir = 0.3 + +skipfirst = 3 +firstval = 0 +port = 7777 +#address = 192.168.11.231 +#address = 192.168.43.128 +address = 192.168.4.1 + +slope=.10 +amplify=.1 + + +lightx = 20 +lighty = 20 + +sourcename = +# alsa_output.pci-0000_00_1f.3.analog-stereo.monitor + +#alsa_input.pci-0000_00_1f.3.analog-stereo +#alsa_output.pci-0000_00_1f.3.analog-stereo.monitor + +fliprg = 1 +skittlequantity = 24 + + +led_limit=.4 + + + + +play = 1 +buffer = 512 +player_filename = _CUT1recfile.raw +recorder_filename = recfile.raw +recorder_bypass = 44100 diff --git a/karaoke/Makefile b/karaoke/Makefile new file mode 100644 index 0000000..ee71c19 --- /dev/null +++ b/karaoke/Makefile @@ -0,0 +1,29 @@ +all : composer + +CFLAGS:=-DOCTAVES=6 -DFIXBPERO=48 + +CX := ../colorchord2 +CM := ../embeddedcommon + +OUTS := $(CX)/OutputVoronoi.o $(CX)/DisplayArray.o $(CX)/OutputLinear.o $(CX)/DisplayPie.o $(CX)/DisplayNetwork.o $(CX)/DisplayUSB2812.o $(CX)/DisplayDMX.o $(CX)/OutputProminent.o $(CX)/RecorderPlugin.o $(CX)/OutputCells.o + +COMMON := $(OUTS) $(CX)/chash.o $(CX)/color.o $(CX)/decompose.o $(CX)/dft.o $(CX)/filter.o $(CX)/DrawFunctions.o $(CX)/hook.o $(CX)/notefinder.o $(CX)/os_generic.o $(CX)/parameters.o $(CX)/sort.o $(CX)/sound_null.o $(CX)/sound.o $(CX)/sound_pulse.o $(CX)/util.o $(CM)/DFT32.o $(CX)/configs.o $(CX)/outdrivers.o + +LINUX := $(COMMON) $(CX)/XDriver.o $(CX)/sound_alsa.o +WINDOWS := $(COMMON) $(CX)/WinDriver.o $(CX)/sound_win.o + + +WINGCCFLAGS:= -g -DICACHE_FLASH_ATTR= -I../embeddedcommon -I. -O0 #-O2 -Wl,--relax -Wl,--gc-sections -ffunction-sections -fdata-sections +WINLDFLAGS:=-lwinmm -lgdi32 -lws2_32 + +CFLAGS:=$(CFLAGS) -I$(CX) -I../embeddedcommon -DICACHE_FLASH_ATTR= +#CFLAGS:=-flto -Os -ffast-math -Wl,--relax -Wl,--gc-sections -ffunction-sections -fdata-sections +CFLAGS:=$(CFLAGS) -g -O2 +LDFLAGS:=-lm -lX11 -lpulse -lasound -lpthread -lXinerama -lusb-1.0 -lXext -g + +composer : composer.o $(LINUX) + gcc -o $@ $^ $(LDFLAGS) + +clean : + rm -rf *.o *~ $(LINUX) $(WINDOWS) + diff --git a/karaoke/README.md b/karaoke/README.md new file mode 100644 index 0000000..9a5963d --- /dev/null +++ b/karaoke/README.md @@ -0,0 +1,3 @@ +This part is under construction. + +Don't mess around here. diff --git a/karaoke/composer.c b/karaoke/composer.c new file mode 100644 index 0000000..df87d2c --- /dev/null +++ b/karaoke/composer.c @@ -0,0 +1,551 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + +#include +#include "color.h" +#include +#include +#include "sound.h" +#include "os_generic.h" +#include "DrawFunctions.h" +#include "dft.h" +#include "filter.h" +#include "decompose.h" +#include +#include +#include "notefinder.h" +#include "outdrivers.h" +#include "parameters.h" +#include "hook.h" +#include "configs.h" + + +struct SoundDriver * sd; + +#ifdef WIN32 +#include +void WindowsTerm() +{ + CloseSound( sd ); +} + +#endif + +float DeltaFrameTime = 0; +double Now = 0; + +int lastfps; +short screenx, screeny; +struct DriverInstances * outdriver[MAX_OUT_DRIVERS]; + +int SoundRawLength; +int SoundRawChannels; +float * SoundRawData; //SoundRawChannels*SoundRawLength + +float SoundPictureHz; +int SoundPictureStacks; +int SoundPictureBins; +float * SoundPicture; // [SoundPictureStacks * SoundPictureBins] + +int headless = 0; REGISTER_PARAM( headless, PAINT ); +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 ); +int sample_channel = -1;REGISTER_PARAM( sample_channel, PAINT ); + +struct NoteFinder * nf; + +//Sound circular buffer +#define SOUNDCBSIZE 8096 +#define MAX_CHANNELS 2 + +double VisTimeEnd, VisTimeStart; +int soundhead = 0; +float sound[SOUNDCBSIZE]; +int show_debug = 0; +int show_debug_basic = 1; + +int gKey = 0; +extern int force_white; + +void HandleKey( int keycode, int bDown ) +{ + char c = toupper( keycode ); + if( c == 'D' && bDown ) show_debug = !show_debug; + if( c == 'W' ) force_white = bDown; + if( c == '9' && bDown ) { gKey--; nf->base_hz = 55 * pow( 2, gKey / 12.0 ); ChangeNFParameters( nf ); } + if( c == '-' && bDown ) { gKey++; nf->base_hz = 55 * pow( 2, gKey / 12.0 ); ChangeNFParameters( nf ); } + if( c == '0' && bDown ) { gKey = 0; nf->base_hz = 55 * pow( 2, gKey / 12.0 ); ChangeNFParameters( nf ); } + if( c == 'E' && bDown ) show_debug_basic = !show_debug_basic; + if( c == 'K' && bDown ) DumpParameters(); + if( keycode == 65307 ) exit( 0 ); + printf( "Key: %d -> %d\n", keycode, bDown ); + KeyHappened( keycode, bDown ); +} + +void HandleButton( int x, int y, int button, int bDown ) +{ + printf( "Button: %d,%d (%d) -> %d\n", x, y, button, bDown ); +} + +void HandleMotion( int x, int y, int mask ) +{ +} + +void SoundCB( float * out, float * in, int samplesr, int * samplesp, struct SoundDriver * sd ) +{ + int channelin = sd->channelsRec; +// int channelout = sd->channelsPlay; + //*samplesp = 0; +// int process_channels = (MAX_CHANNELS < channelin)?MAX_CHANNELS:channelin; + + //Load the samples into a ring buffer. Split the channels from interleved to one per buffer. + + int i; + int j; + + for( i = 0; i < samplesr; i++ ) + { + if( out ) + { + for( j = 0; j < channelin; j++ ) + { + out[i*channelin+j] = 0; + } + } + + if( sample_channel < 0 ) + { + float fo = 0; + for( j = 0; j < channelin; j++ ) + { + float f = in[i*channelin+j]; + if( f >= -1 && f <= 1 ) + { + fo += f; + } + else + { + fo += (f>0)?1:-1; +// printf( "Sound fault A %d/%d %d/%d %f\n", j, channelin, i, samplesr, f ); + } + } + + fo /= channelin; + sound[soundhead] = fo; + soundhead = (soundhead+1)%SOUNDCBSIZE; + } + else + { + float f = in[i*channelin+sample_channel]; + + if( f > 1 || f < -1 ) + { + f = (f>0)?1:-1; + } + + //printf( "Sound fault B %d/%d\n", i, samplesr ); + sound[soundhead] = f; + soundhead = (soundhead+1)%SOUNDCBSIZE; + + } + } + + SoundEventHappened( samplesr, in, 0, channelin ); + if( out ) + { + SoundEventHappened( samplesr, out, 1, sd->channelsPlay ); + } + *samplesp = samplesr; +} + +void LoadRaw() +{ + const char * rawfilename = GetParameterS( "rawfilename", 0 ); + if( !rawfilename ) + { + fprintf( stderr, "Error: This application requires the 'rawfilename' parameter.\n" ); + exit( -19 ); + } + FILE * f = fopen( rawfilename, "rb" ); + if( !f ) + { + fprintf( stderr, "Error: Can't open the specified rawfile.\n" ); + exit( -20 ); + } + + int SoundRawChannels = MAX_CHANNELS; + fseek( f, 0, SEEK_END ); + SoundRawLength = ftell( f ) / SoundRawChannels / 4; + fseek( f, 0, SEEK_SET ); + + SoundRawData = malloc( SoundRawChannels * 4 * SoundRawLength ); + int r = fread( SoundRawData, SoundRawChannels * 4, SoundRawLength, f ); + fclose( f ); + + int samplerate = GetParameterI( "samplerate", 44100 ); + SoundPictureHz = GetParameterF( "initmapper_width_hz", 120 ); + float fSoundMapMux = GetParameterF( "sound_map_mux", 20 ); + int iBins = GetParameterI( "freqbins", 24 ); + float SoundPictureTime = samplerate / SoundPictureHz; + + int SoundPictureStacks = (SoundRawLength / SoundPictureTime) + 1; + SoundPictureBins = nf->octaves * nf->freqbins; + SoundPicture = malloc( ( SoundPictureStacks + 1 ) * SoundPictureBins * 4); + + int i; + int place = 0; + + int sbs = (int)SoundPictureTime + 4; + int sbp = 0; + float IntSoundBuffer[sbs]; + + for( i = 0; i < SoundPictureStacks; i++ ) + { + int nplace = ((int)(SoundPictureTime * (i+1)))&0xffffffe; + int j = 0; + //float SoundLump[nplace-place]; + for( ; place < nplace; place++, j++ ) + { + float fo = 0; + int k; + if( place >= SoundRawLength ) break; + for( k = 0; k < SoundRawChannels; k++ ) + { + float f = SoundRawData[place*SoundRawChannels+k]; + fo += f; + } + place++; + fo /= SoundRawChannels; + IntSoundBuffer[sbp++] = fo; + if( sbp == sbs ) sbp = 0; + } + + //XXX WARNING: apparently we actually have to use a circular buffer or something + + float backup = nf->dft_iir; + nf->dft_iir = 0; + //printf( "%d %d -- %d %d\n", sbp, sbs, nplace, place ); + RunNoteFinder( nf, IntSoundBuffer, sbp, sbs ); + nf->dft_iir = backup; +// printf( "NF On %d\n", j ); + for( j = 0; j < SoundPictureBins; j++ ) + { + SoundPicture[i*SoundPictureBins+j] = nf->outbins[j]; + } + } + + FILE * pic = fopen( "pic.pgm", "wb" ); + fprintf( pic, "P6\n%d %d\n255\n", SoundPictureStacks, SoundPictureBins ); + int x, y; + for( y = SoundPictureBins-1; y >= 0; y-- ) + { + for( x = 0; x < SoundPictureStacks; x++ ) + { + float pf = SoundPicture[x*SoundPictureBins+y]*fSoundMapMux; + if( pf > 1 ) pf = 1; + if( pf < 0 ) pf = 0; + + //int c = (int)(pf * 255. + 0.5); + //putc( c, pic ); + + int r = CCtoHEX( y/(float)iBins, 1.0, pf ); + + putc( r, pic ); + putc( r>>8, pic ); + putc( r>>16, pic ); + } + } + fclose( pic ); + +} + +int main(int argc, char ** argv) +{ + int i; + + printf( "Output Drivers:\n" ); + for( i = 0; i < MAX_OUT_DRIVERS; i++ ) + { + if( ODList[i].Name ) printf( "\t%s\n", ODList[i].Name ); + } + +#ifdef WIN32 + WSADATA wsaData; + + WSAStartup(0x202, &wsaData); + + strcpy( sound_source, "WIN" ); +#else + strcpy( sound_source, "PULSE" ); +#endif + + gargc = argc; + gargv = argv; + + SetupConfigs(); + + //Initialize Rawdraw + int frames = 0; + double ThisTime; + double LastFPSTime = OGGetAbsoluteTime(); + double LastFrameTime = OGGetAbsoluteTime(); + double SecToWait; + CNFGBGColor = 0x800000; + CNFGDialogColor = 0x444444; + + char title[1024]; + char * tp = title; + + memcpy( tp, "ColorChord ", strlen( "ColorChord " ) ); + tp += strlen( "ColorChord " ); + + for( i = 1; i < argc; i++ ) + { + memcpy( tp, argv[i], strlen( argv[i] ) ); + tp += strlen( argv[i] ); + *tp = ' '; + tp++; + } + *tp = 0; + if( !headless ) + CNFGSetup( title, set_screenx, set_screeny ); + + + char * OutDriverNames = strdup( GetParameterS( "outdrivers", "null" ) ); + char * ThisDriver = OutDriverNames; + char * TDStart; + for( i = 0; i < MAX_OUT_DRIVERS; i++ ) + { + while( *ThisDriver == ' ' || *ThisDriver == '\t' ) ThisDriver++; + if( !*ThisDriver ) break; + + TDStart = ThisDriver; + + while( *ThisDriver != 0 && *ThisDriver != ',' ) + { + if( *ThisDriver == '\t' || *ThisDriver == ' ' ) *ThisDriver = 0; + ThisDriver++; + } + + if( *ThisDriver ) + { + *ThisDriver = 0; + ThisDriver++; + } + + printf( "Loading: %s\n", TDStart ); + outdriver[i] = SetupOutDriver( TDStart ); + } + free(OutDriverNames); + + + //Initialize Sound + sd = InitSound( sound_source, &SoundCB ); + + if( !sd ) + { + fprintf( stderr, "ERROR: Failed to initialize sound output device\n" ); + return -1; + } + + nf = CreateNoteFinder( sd->spsRec ); + + //Once everything was reinitialized, re-read the ini files. + SetEnvValues( 1 ); + + Now = OGGetAbsoluteTime(); + double Last = Now; + + LoadRaw(); + + + while(1) + { + char stt[1024]; + //Handle Rawdraw frame swappign + + Now = OGGetAbsoluteTime(); + DeltaFrameTime = Now - Last; + + if( !headless ) + { + CNFGHandleInput(); + CNFGClearFrame(); + CNFGColor( 0xFFFFFF ); + CNFGGetDimensions( &screenx, &screeny ); + } + + RunNoteFinder( nf, sound, (soundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE, SOUNDCBSIZE ); + //Done all ColorChord work. + + + VisTimeStart = OGGetAbsoluteTime(); + + for( i = 0; i < MAX_OUT_DRIVERS; i++ ) + { + + if( force_white ) + { + memset( OutLEDs, 0x7f, MAX_LEDS*3 ); + } + + if( outdriver[i] ) + outdriver[i]->Func( outdriver[i]->id, nf ); + } + + VisTimeEnd = OGGetAbsoluteTime(); + + + if( !headless ) + { + //Handle outputs. + int freqbins = nf->freqbins; + int note_peaks = freqbins/2; + int freqs = freqbins * nf->octaves; + //int maxdists = freqbins/2; + + //Do a bunch of debugging. + if( show_debug_basic ) + { + //char sttdebug[1024]; + //char * sttend = sttdebug; + + for( i = 0; i < nf->dists; i++ ) + { + CNFGPenX = (nf->dist_means[i] + 0.5) / freqbins * screenx; //Move over 0.5 for visual purposes. The means is correct. + CNFGPenY = 400-nf->dist_amps[i] * 150.0 / nf->dist_sigmas[i]; + //printf( "%f %f\n", dist_means[i], dist_amps[i] ); + sprintf( stt, "%f\n%f\n", nf->dist_means[i], nf->dist_amps[i] ); +// sttend += sprintf( sttend, "%f/%f ",nf->dist_means[i], nf->dist_amps[i] ); + CNFGDrawText( stt, 2 ); + } + CNFGColor( 0xffffff ); + + //Draw the folded bins + for( i = 0; i < freqbins; i++ ) + { + float x0 = i / (float)freqbins * (float)screenx; + float x1 = (i+1) / (float)freqbins * (float)screenx; + float amp = nf->folded_bins[i] * 250.0; + CNFGDialogColor = CCtoHEX( ((float)(i+0.5) / freqbins), 1.0, 1.0 ); + CNFGDrawBox( x0, 400-amp, x1, 400 ); + } + CNFGDialogColor = 0xf0f000; + + for( i = 0; i < note_peaks; i++ ) + { + //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 ); + 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; + sprintf( stt, "%d\n%0.0f", nf->enduring_note_id[i], nf->note_amplitudes2[i]*1000.0 ); + //sttend += sprintf( sttend, "%5d/%5.0f ", nf->enduring_note_id[i], nf->note_amplitudes2[i]*1000.0 ); + CNFGDrawText( stt, 2 ); + + } + + //Let's draw the o-scope. + int thissoundhead = soundhead; + thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE; + int lasty = sound[thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE; + int thisy = sound[thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE; + for( i = 0; i < screenx; i++ ) + { + if( thisy < 0 || thisy > 256 ) printf( "%d/%d\n", thisy,thissoundhead ); + CNFGTackSegment( i, lasty, i+1, thisy ); + lasty = thisy; + thisy = sound[thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE; + } + //puts( sttdebug ); + } + + //Extra debugging? + if( show_debug ) + { + //Draw the histogram + float lasthistval; + CNFGColor( 0xffffff ); + + for( i = -1; i < screenx; i++ ) + { + float thishistval = CalcHistAt( (float)i/(float)screenx*freqbins-0.5, nf->freqbins, nf->dist_means, nf->dist_amps, nf->dist_sigmas, nf->dists ); + if( i >= 0 ) + CNFGTackSegment( i, 400-lasthistval * 250.0, i+1, 400-thishistval * 250.0 ); + lasthistval = thishistval; + } + + CNFGColor( 0xffffff ); + + //Draw the bins + for( i = 0; i < freqs; i++ ) + { + float x0 = i / (float)freqs * (float)screenx; + float x1 = (i+1) / (float)freqs * (float)screenx; + float amp = nf->outbins[i] * 250.0; + CNFGDialogColor = CCtoHEX( ((float)i / freqbins), 1.0, 1.0 ); + CNFGDrawBox( x0, 0, x1, amp ); + } + CNFGDialogColor = 0x0f0f0f; + + 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, + (nf->DecomposeTime - nf->FilterTime)*1000, + (nf->FinalizeTime - nf->DecomposeTime)*1000, + (VisTimeEnd - VisTimeStart)*1000 ); + CNFGPenX = 50; + CNFGPenY = 50; + CNFGDrawText( stdebug, 2 ); + } + + CNFGColor( show_debug?0xffffff:0x000000 ); + CNFGPenX = 0; CNFGPenY = screeny-10; + CNFGDrawText( "Extra Debug (D)", 2 ); + + CNFGColor( show_debug_basic?0xffffff:0x000000 ); + CNFGPenX = 120; CNFGPenY = screeny-10; + CNFGDrawText( "Basic Debug (E)", 2 ); + + CNFGColor( show_debug_basic?0xffffff:0x000000 ); + CNFGPenX = 240; CNFGPenY = screeny-10; + sprintf( stt, "[9] Key: %d [0] (%3.1f) [-]", gKey, nf->base_hz ); + CNFGDrawText( stt, 2 ); + + CNFGColor( 0xffffff ); + CNFGPenX = 440; CNFGPenY = screeny-10; + sprintf( stt, "FPS: %d", lastfps ); + CNFGDrawText( stt, 2 ); + CNFGSwapBuffers(); + } + + //Finish Rawdraw with FPS counter, and a nice delay loop. + frames++; + + ThisTime = OGGetAbsoluteTime(); + if( ThisTime > LastFPSTime + 1 ) + { +// printf( "FPS: %d\n", frames ); + lastfps = frames; + frames = 0; + LastFPSTime+=1; + } + + if( cpu_autolimit ) + { + SecToWait = .016 - ( ThisTime - LastFrameTime ); + LastFrameTime += .016; + if( SecToWait < -.1 ) LastFrameTime = ThisTime - .1; + if( SecToWait > 0 ) + OGUSleep( (int)( SecToWait * 1000000 ) ); + } + + SetEnvValues( 0 ); + Last = Now; + } + +} + diff --git a/karaoke/default.conf b/karaoke/default.conf new file mode 100644 index 0000000..51557e0 --- /dev/null +++ b/karaoke/default.conf @@ -0,0 +1,118 @@ +# This is the configuration file for colorchord. +# Most values are already defaulted in the software. +# This file is constantly checked for new versions. +# \r, and ; are used as terminators, so you can put +# multiple entries on the same line. + + + +########################################################################### +# Composer-specific stuff + +rawfilename = fount.raw +initmapper_width_hz = 120 +octaves = 6 +sound_map_mux = 10 +freqbins = 48 + +# Should we use a progressive DFT? +# 0 = DFT Quick +# 1 = DFT Progressive +# 2 = DFT Progressive Integer +# 3 = DFT Progressive Integer Skippy +# 4 = Integer, 32-Bit, Progressive, Skippy. +do_progressive_dft = 4 + + + +########################################################################### +# Default stuff. + +#Whether to limit the control loop to ~60ish FPS. +cpu_autolimit = 1 + +#General GUI properties. +title = PA Test +set_screenx = 720 +set_screeny = 480 + +#Sound properties. +buffer = 384 +play = 0 +rec = 1 +channels = 2 +samplerate = 44100 +wininput = 0 + +#Compiled version will default this. +#sound_source = PULSE +#-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 +# 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- + +################################## +# General ColorChord properties. # +################################## + +# How much to amplify the incoming signal. +amplify = 2.0 + +# What is the base note? I.e. the lowest note. +# Note that it won't have very much impact until an octave up though! +base_hz = 55.0000 + +# This is only used when dealing with the slow decompose (now defunct) +# decompose_iterations = 1000 +# default_sigma = 1.4000 + +# DFT properties for the DFT up top. +dft_iir = 0.6 +dft_speedup = 1000.0000 +#octaves = 5 + + + +filter_iter = 2 +filter_strength = .5 + +# How many bins per octave to use? + +# For the final note information... How much to slack everything? +note_attach_amp_iir = 0.3500 +note_attach_amp_iir2 = 0.250 +note_attach_freq_iir = 0.3000 + +#How many bins a note can jump from frame to frame to be considered a slide. +#this is used to prevent notes from popping in and out a lot. +note_combine_distance = 0.5000 +note_jumpability = 1.8000 +note_minimum_new_distribution_value = 0.0200 +note_out_chop = 0.05000 + +#compress_coefficient = 4.0 +#compress_exponent = .5 + + +#======================================================================= +#Outputs + + +#This is a vornoi thing: +outdrivers = #OutputVoronoi, DisplayArray +lightx = 64 +lighty = 32 +fromsides = 1 +shape_cutoff = 0.03 +satamp = 5.000 +amppow = 2.510 +distpow = 1.500 + + + + diff --git a/karaoke/fount.conf b/karaoke/fount.conf new file mode 100644 index 0000000..3c1661f --- /dev/null +++ b/karaoke/fount.conf @@ -0,0 +1,5 @@ +songfile = fount.raw +channels = 2 +samplerate = 44100 +songtps = 120 +