diff --git a/colorchord2/DisplayArray.c b/colorchord2/DisplayArray.c index 0924ee1..01da7d8 100644 --- a/colorchord2/DisplayArray.c +++ b/colorchord2/DisplayArray.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "outdrivers.h" #include "notefinder.h" #include diff --git a/colorchord2/DisplayDMX.c b/colorchord2/DisplayDMX.c index d802ae9..c4ccdae 100644 --- a/colorchord2/DisplayDMX.c +++ b/colorchord2/DisplayDMX.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "outdrivers.h" #include "notefinder.h" #include diff --git a/colorchord2/DisplayNetwork.c b/colorchord2/DisplayNetwork.c index 526530c..a8cd4e9 100644 --- a/colorchord2/DisplayNetwork.c +++ b/colorchord2/DisplayNetwork.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "outdrivers.h" #include "notefinder.h" #include diff --git a/colorchord2/DisplayOUTDriver.c b/colorchord2/DisplayOUTDriver.c index 13b60e9..892e41a 100644 --- a/colorchord2/DisplayOUTDriver.c +++ b/colorchord2/DisplayOUTDriver.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + //XXX This needs to be re-worked to only output LEDs so DisplayArray can take it. //XXX CONSIDER DUMPING diff --git a/colorchord2/DisplayPie.c b/colorchord2/DisplayPie.c index 8448e2b..5374842 100644 --- a/colorchord2/DisplayPie.c +++ b/colorchord2/DisplayPie.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "outdrivers.h" #include "notefinder.h" #include diff --git a/colorchord2/DisplayUSB2812.c b/colorchord2/DisplayUSB2812.c index 5605793..1c8cf3e 100644 --- a/colorchord2/DisplayUSB2812.c +++ b/colorchord2/DisplayUSB2812.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "outdrivers.h" #include "notefinder.h" #include diff --git a/colorchord2/DrawFunctions.c b/colorchord2/DrawFunctions.c index c7c994a..ceb123c 100644 --- a/colorchord2/DrawFunctions.c +++ b/colorchord2/DrawFunctions.c @@ -1,5 +1,8 @@ /* -Copyright (c) 2010, 2011 Charles Lohr +Copyright (c) 2010, 2011, 2015 <>< Charles Lohr + +This file may be licensed under the NewBSD License OR The license found +here: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/colorchord2/OutputLinear.c b/colorchord2/OutputLinear.c index 6e3fbda..43d106c 100644 --- a/colorchord2/OutputLinear.c +++ b/colorchord2/OutputLinear.c @@ -1,5 +1,8 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + //XXX TODO Figure out why it STILL fails when going around a loop + #include "outdrivers.h" #include "notefinder.h" #include diff --git a/colorchord2/OutputProminent.c b/colorchord2/OutputProminent.c index aa5adcb..a9cfb6c 100644 --- a/colorchord2/OutputProminent.c +++ b/colorchord2/OutputProminent.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + //Really basic driver, that just selects the most prominent color and washes all the LEDs with that. #include "outdrivers.h" diff --git a/colorchord2/OutputVoronoi.c b/colorchord2/OutputVoronoi.c index e8c6664..31390b3 100644 --- a/colorchord2/OutputVoronoi.c +++ b/colorchord2/OutputVoronoi.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "outdrivers.h" #include "notefinder.h" #include diff --git a/colorchord2/RecorderPlugin.c b/colorchord2/RecorderPlugin.c index 467d57b..25ff7cb 100644 --- a/colorchord2/RecorderPlugin.c +++ b/colorchord2/RecorderPlugin.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "outdrivers.h" #include #include diff --git a/colorchord2/chash.c b/colorchord2/chash.c index 34a2190..f4cc84f 100644 --- a/colorchord2/chash.c +++ b/colorchord2/chash.c @@ -1,3 +1,9 @@ +//Generic C Hash table thing. +//WARNING: There is a known bug somewhere in the remove entry thing. +//I never found it... +// +// Copyright 2015 <>< Charles Lohr, under the NewBSD or MIT/x11 License. + #include "chash.h" #include #include diff --git a/colorchord2/chash.h b/colorchord2/chash.h index 36e73d1..b6a4bf9 100644 --- a/colorchord2/chash.h +++ b/colorchord2/chash.h @@ -1,3 +1,9 @@ +//Generic C Hash table thing. +//WARNING: There is a known bug somewhere in the remove entry thing. +//I never found it... +// +// Copyright 2015 <>< Charles Lohr, under the NewBSD or MIT/x11 License. + #ifndef _CHASH_H #define _CHASH_H diff --git a/colorchord2/color.c b/colorchord2/color.c index 0724393..cd8a179 100644 --- a/colorchord2/color.c +++ b/colorchord2/color.c @@ -1,3 +1,7 @@ +//Copyright (Public Domain) 2015 <>< Charles Lohr, under the NewBSD License. +//This file may be used in whole or part in any way for any purpose by anyone +//without restriction. + #include "color.h" #include diff --git a/colorchord2/color.h b/colorchord2/color.h index b766129..3b780f1 100644 --- a/colorchord2/color.h +++ b/colorchord2/color.h @@ -1,3 +1,7 @@ +//Copyright (Public Domain) 2015 <>< Charles Lohr, under the NewBSD License. +//This file may be used in whole or part in any way for any purpose by anyone +//without restriction. + #ifndef _COLOR_H #define _COLOR_H diff --git a/colorchord2/decompose.c b/colorchord2/decompose.c index fca34cf..9b76f6e 100644 --- a/colorchord2/decompose.c +++ b/colorchord2/decompose.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "decompose.h" #include #include diff --git a/colorchord2/decompose.h b/colorchord2/decompose.h index 6c5b455..19ac4cf 100644 --- a/colorchord2/decompose.h +++ b/colorchord2/decompose.h @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #ifndef _DECOMPOSE_H #define _DECOMPOSE_H diff --git a/colorchord2/dft.c b/colorchord2/dft.c index d9e574a..2ee7174 100644 --- a/colorchord2/dft.c +++ b/colorchord2/dft.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "dft.h" #include #include diff --git a/colorchord2/dft.h b/colorchord2/dft.h index 19d845e..7a5a8d2 100644 --- a/colorchord2/dft.h +++ b/colorchord2/dft.h @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #ifndef _DFT_H #define _DFT_H diff --git a/colorchord2/filter.c b/colorchord2/filter.c index 7b522f0..8ecdba4 100644 --- a/colorchord2/filter.c +++ b/colorchord2/filter.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "filter.h" #include #include diff --git a/colorchord2/filter.h b/colorchord2/filter.h index e9d8fa3..11e8130 100644 --- a/colorchord2/filter.h +++ b/colorchord2/filter.h @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #ifndef _FILTER_H #define _FILTER_H diff --git a/colorchord2/hook.c b/colorchord2/hook.c index 299759a..dfba8d8 100644 --- a/colorchord2/hook.c +++ b/colorchord2/hook.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "hook.h" struct KeyEvent diff --git a/colorchord2/hook.h b/colorchord2/hook.h index ad5199b..81afa1c 100644 --- a/colorchord2/hook.h +++ b/colorchord2/hook.h @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #ifndef _KEYHOOK_H #define _KEYHOOK_H diff --git a/colorchord2/main.c b/colorchord2/main.c index cf8f198..21c1caa 100644 --- a/colorchord2/main.c +++ b/colorchord2/main.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include #include "color.h" #include diff --git a/colorchord2/notefinder.c b/colorchord2/notefinder.c index 8f7b8f0..5b6b4c4 100644 --- a/colorchord2/notefinder.c +++ b/colorchord2/notefinder.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "notefinder.h" #include "parameters.h" #include diff --git a/colorchord2/notefinder.h b/colorchord2/notefinder.h index 5d56462..3ab7feb 100644 --- a/colorchord2/notefinder.h +++ b/colorchord2/notefinder.h @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #ifndef _NOTEFINDER_H #define _NOTEFINDER_H diff --git a/colorchord2/os_generic.c b/colorchord2/os_generic.c index f268cd2..effe5eb 100644 --- a/colorchord2/os_generic.c +++ b/colorchord2/os_generic.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the NewBSD OR MIT/x11 License. + #include "os_generic.h" diff --git a/colorchord2/os_generic.h b/colorchord2/os_generic.h index 8ac2239..c7de7db 100644 --- a/colorchord2/os_generic.h +++ b/colorchord2/os_generic.h @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the NewBSD or MIT/x11 License. + #ifndef _OS_GENERIC_H #define _OS_GENERIC_H diff --git a/colorchord2/outdrivers.c b/colorchord2/outdrivers.c index 8bf9b77..6d3591b 100644 --- a/colorchord2/outdrivers.c +++ b/colorchord2/outdrivers.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "outdrivers.h" #include #include "parameters.h" diff --git a/colorchord2/outdrivers.h b/colorchord2/outdrivers.h index 106ea52..60f56ce 100644 --- a/colorchord2/outdrivers.h +++ b/colorchord2/outdrivers.h @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + //Output drivers, used for outputting lights, etc... However, this technique //may be used for unrelated-to-output plugins. diff --git a/colorchord2/parameters.c b/colorchord2/parameters.c index 99e8f87..3800694 100644 --- a/colorchord2/parameters.c +++ b/colorchord2/parameters.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "parameters.h" #include "chash.h" #include diff --git a/colorchord2/parameters.h b/colorchord2/parameters.h index 4287c87..7ea093f 100644 --- a/colorchord2/parameters.h +++ b/colorchord2/parameters.h @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #ifndef _PARAMETERS_H #define _PARAMETERS_H diff --git a/colorchord2/sort.c b/colorchord2/sort.c index c39844d..2787150 100644 --- a/colorchord2/sort.c +++ b/colorchord2/sort.c @@ -1,3 +1,7 @@ +//Copyright (Public Domain) 2015 <>< Charles Lohr, under the NewBSD License. +//This file may be used in whole or part in any way for any purpose by anyone +//without restriction. + #include "sort.h" #include #include diff --git a/colorchord2/sort.h b/colorchord2/sort.h index 4ebe23a..7b1a35c 100644 --- a/colorchord2/sort.h +++ b/colorchord2/sort.h @@ -1,3 +1,7 @@ +//Copyright (Public Domain) 2015 <>< Charles Lohr, under the NewBSD License. +//This file may be used in whole or part in any way for any purpose by anyone +//without restriction. + #ifndef _SORT_H #define _SORT_H diff --git a/colorchord2/sound.c b/colorchord2/sound.c index 6497bb8..df7ff1c 100644 --- a/colorchord2/sound.c +++ b/colorchord2/sound.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "sound.h" #include #include diff --git a/colorchord2/sound.h b/colorchord2/sound.h index 25ef4d4..0bfe9b9 100644 --- a/colorchord2/sound.h +++ b/colorchord2/sound.h @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #ifndef _SOUND_H #define _SOUND_H diff --git a/colorchord2/sound_alsa.c b/colorchord2/sound_alsa.c index e00ff98..64dc720 100644 --- a/colorchord2/sound_alsa.c +++ b/colorchord2/sound_alsa.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "sound.h" #include "os_generic.h" #include "parameters.h" diff --git a/colorchord2/sound_null.c b/colorchord2/sound_null.c index 51117c2..47d5415 100644 --- a/colorchord2/sound_null.c +++ b/colorchord2/sound_null.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "sound.h" #include "os_generic.h" #include diff --git a/colorchord2/sound_pulse.c b/colorchord2/sound_pulse.c index 7033db8..2cecc35 100644 --- a/colorchord2/sound_pulse.c +++ b/colorchord2/sound_pulse.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + //This file is really rough. Full duplex doesn't seem to work hardly at all. diff --git a/colorchord2/sound_win.c b/colorchord2/sound_win.c index ee731ea..684e61c 100644 --- a/colorchord2/sound_win.c +++ b/colorchord2/sound_win.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include #include "parameters.h" #include "sound.h" diff --git a/colorchord2/util.c b/colorchord2/util.c index 5177c5b..d1e2d4e 100644 --- a/colorchord2/util.c +++ b/colorchord2/util.c @@ -1,3 +1,7 @@ +//Copyright (Public Domain) 2015 <>< Charles Lohr, under the NewBSD License. +//This file may be used in whole or part in any way for any purpose by anyone +//without restriction. + #include "util.h" #include #include diff --git a/colorchord2/util.h b/colorchord2/util.h index eeb85a9..7194169 100644 --- a/colorchord2/util.h +++ b/colorchord2/util.h @@ -1,3 +1,7 @@ +//Copyright (Public Domain) 2015 <>< Charles Lohr, under the NewBSD License. +//This file may be used in whole or part in any way for any purpose by anyone +//without restriction. + #ifndef _UTIL_H #define _UTIL_H diff --git a/embeddedcommon/DFT32.c b/embeddedcommon/DFT32.c index 67b8aad..75bd1bc 100644 --- a/embeddedcommon/DFT32.c +++ b/embeddedcommon/DFT32.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "DFT32.h" #include diff --git a/embeddedcommon/DFT32.h b/embeddedcommon/DFT32.h index 99d6e30..bbbc046 100644 --- a/embeddedcommon/DFT32.h +++ b/embeddedcommon/DFT32.h @@ -1,6 +1,9 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #ifndef _DFT32_H #define _DFT32_H +#include #include //A 32-bit version of the DFT used for ColorChord. diff --git a/embeddedcommon/embeddednf.c b/embeddedcommon/embeddednf.c index 0c5349e..e07c8c2 100644 --- a/embeddedcommon/embeddednf.c +++ b/embeddedcommon/embeddednf.c @@ -1,5 +1,8 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "embeddednf.h" #include +#include uint16_t folded_bins[FIXBPERO]; uint16_t fuzzed_bins[FIXBINS]; @@ -9,6 +12,7 @@ uint16_t note_peak_amps2[MAXNOTES]; uint8_t note_jumped_to[MAXNOTES]; +#ifndef PRECOMPUTE_FREQUENCY_TABLE static const float bf_table[24] = { 1.000000, 1.029302, 1.059463, 1.090508, 1.122462, 1.155353, 1.189207, 1.224054, 1.259921, 1.296840, 1.334840, 1.373954, @@ -36,12 +40,15 @@ int main() } */ +#endif #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) void UpdateFreqs() { + +#ifndef PRECOMPUTE_FREQUENCY_TABLE uint16_t fbins[FIXBPERO]; int i; @@ -55,8 +62,18 @@ void UpdateFreqs() for( i = 0; i < FIXBPERO; i++ ) { float frq = ( bf_table[i] * BASE_FREQ ); - fbins[i] = ( 65536.0 ) / ( DFREQ ) * frq * 16; + fbins[i] = ( 65536.0 ) / ( DFREQ ) * frq * 16 + 0.5; } +#else + + #define PCOMP( f ) (uint16_t)((65536.0)/(DFREQ) * (f * BASE_FREQ) * 16 + 0.5) + + static const uint16_t fbins[FIXBPERO] = { + PCOMP( 1.000000 ), PCOMP( 1.029302 ), PCOMP( 1.059463 ), PCOMP( 1.090508 ), PCOMP( 1.122462 ), PCOMP( 1.155353 ), + PCOMP( 1.189207 ), PCOMP( 1.224054 ), PCOMP( 1.259921 ), PCOMP( 1.296840 ), PCOMP( 1.334840 ), PCOMP( 1.373954 ), + PCOMP( 1.414214 ), PCOMP( 1.455653 ), PCOMP( 1.498307 ), PCOMP( 1.542211 ), PCOMP( 1.587401 ), PCOMP( 1.633915 ), + PCOMP( 1.681793 ), PCOMP( 1.731073 ), PCOMP( 1.781797 ), PCOMP( 1.834008 ), PCOMP( 1.887749 ), PCOMP( 1.943064 ) }; +#endif #ifdef USE_32DFT UpdateBins32( fbins ); @@ -65,7 +82,7 @@ void UpdateFreqs() #endif } -void Init() +void InitColorChord() { int i; //Set up and initialize arrays. @@ -76,15 +93,8 @@ void Init() note_peak_amps2[i] = 0; } - for( i = 0; i < FIXBPERO; i++ ) - { - folded_bins[i] = 0; - } - - for( i = 0; i < FIXBINS; i++ ) - { - fuzzed_bins[i] = 0; - } + memset( folded_bins, 0, sizeof( folded_bins ) ); + memset( fuzzed_bins, 0, sizeof( fuzzed_bins ) ); //Step 1: Initialize the Integer DFT. #ifdef USE_32DFT @@ -102,10 +112,7 @@ void HandleFrameInfo() { int i, j, k; uint8_t hitnotes[MAXNOTES]; - for( i = 0; i < MAXNOTES; i++ ) - { - hitnotes[i] = 0; - } + memset( hitnotes, 0, sizeof( hitnotes ) ); #ifdef USE_32DFT uint16_t * strens; diff --git a/embeddedcommon/embeddednf.h b/embeddedcommon/embeddednf.h index c1f2f1f..5778de6 100644 --- a/embeddedcommon/embeddednf.h +++ b/embeddedcommon/embeddednf.h @@ -1,6 +1,10 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #ifndef _EMBEDDEDNF_H #define _EMBEDDEDNF_H +#include + //Use a 32-bit DFT. It won't work for AVRs, but for any 32-bit systems where //they can multiply quickly, this is the bees knees. #define USE_32DFT @@ -9,7 +13,10 @@ #define DFREQ 8000 #endif -#define BASE_FREQ 55.0 // You may make this a float. +//You may make this a float. If PRECOMPUTE_FREQUENCY_TABLE is defined, then +//it will create the table at compile time, and the float will never be used +//runtime. +#define BASE_FREQ 55.0 //The higher the number the slackier your FFT will be come. #define FUZZ_IIR_BITS 1 @@ -54,12 +61,12 @@ #define MINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR 64 +//This prevents compilation of any floating-point code, but it does come with +//an added restriction: Both DFREQ and BASE_FREQ must be #defined to be +//constants. +#define PRECOMPUTE_FREQUENCY_TABLE -#ifdef USE_32DFT #include "DFT32.h" -#else -#include "dft.h" -#endif extern uint16_t folded_bins[]; //[FIXBPERO] <- The folded fourier output. extern uint16_t fuzzed_bins[]; //[FIXBINS] <- The Full DFT after IIR, Blur and Taper @@ -72,11 +79,14 @@ extern uint16_t note_peak_amps2[]; //[MAXNOTES] (Responds quicker) extern uint8_t note_jumped_to[]; //[MAXNOTES] When a note combines into another one, //this records where it went. I.e. if your note just disappeared, check this flag. -void Init(); -void UpdateFreqs(); -void HandleFrameInfo(); +void UpdateFreqs(); //Not user-useful on most systems. +void HandleFrameInfo(); //Not user-useful on most systems +//Call this when starting. +void InitColorChord(); + + #endif diff --git a/embeddedcommon/embeddedout.c b/embeddedcommon/embeddedout.c index a20483e..ddb046f 100644 --- a/embeddedcommon/embeddedout.c +++ b/embeddedcommon/embeddedout.c @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #include "embeddedout.h" //uint8_t ledArray[NUM_LIN_LEDS]; //Points to which notes correspond to these LEDs @@ -105,14 +107,14 @@ void UpdateLinearLEDs() if( total_size_all_notes == 0 ) { - for( j = 0; j < NUM_LIN_LEDS * 3; j++ ) + for( j = 0; j < USE_NUM_LIN_LEDS * 3; j++ ) { ledOut[j] = 0; } return; } - uint32_t porportional = (uint32_t)(NUM_LIN_LEDS<<16)/((uint32_t)total_size_all_notes); + uint32_t porportional = (uint32_t)(USE_NUM_LIN_LEDS<<16)/((uint32_t)total_size_all_notes); uint16_t total_accounted_leds = 0; @@ -122,7 +124,7 @@ void UpdateLinearLEDs() total_accounted_leds += porpamps[i]; } - int16_t total_unaccounted_leds = NUM_LIN_LEDS - total_accounted_leds; + int16_t total_unaccounted_leds = USE_NUM_LIN_LEDS - total_accounted_leds; int addedlast = 1; do @@ -151,14 +153,14 @@ void UpdateLinearLEDs() #if LIN_WRAPAROUND uint16_t midx = 0; uint32_t mqty = 100000000; - for( j = 0; j < NUM_LIN_LEDS; j++ ) + for( j = 0; j < USE_NUM_LIN_LEDS; j++ ) { uint32_t dqty; uint16_t localj; dqty = 0; localj = j; - for( l = 0; l < NUM_LIN_LEDS; l++ ) + for( l = 0; l < USE_NUM_LIN_LEDS; l++ ) { int32_t d = (int32_t)ledFreqOut[localj] - (int32_t)ledFreqOutOld[l]; if( d < 0 ) d *= -1; @@ -166,7 +168,7 @@ void UpdateLinearLEDs() dqty += ( d * d ); localj++; - if( localj == NUM_LIN_LEDS ) localj = 0; + if( localj == USE_NUM_LIN_LEDS ) localj = 0; } if( dqty < mqty ) @@ -183,9 +185,9 @@ void UpdateLinearLEDs() #endif j = ledSpin; - for( l = 0; l < NUM_LIN_LEDS; l++, j++ ) + for( l = 0; l < USE_NUM_LIN_LEDS; l++, j++ ) { - if( j >= NUM_LIN_LEDS ) j = 0; + if( j >= USE_NUM_LIN_LEDS ) j = 0; ledFreqOutOld[l] = ledFreqOut[j]; uint16_t amp = ledAmpOut[j]; @@ -208,7 +210,7 @@ void UpdateLinearLEDs() ledOut[j*3+2] = ( color >>16 ) & 0xff; j++; - if( j == NUM_LIN_LEDS ) j = 0; + if( j == USE_NUM_LIN_LEDS ) j = 0; porpamps[i]--; } }*/ diff --git a/embeddedcommon/embeddedout.h b/embeddedcommon/embeddedout.h index e039b17..1328128 100644 --- a/embeddedcommon/embeddedout.h +++ b/embeddedcommon/embeddedout.h @@ -1,3 +1,5 @@ +//Copyright 2015 <>< Charles Lohr under the ColorChord License. + #ifndef _EMBEDDEDOUT_H #define _EMBEDDEDOUT_H @@ -18,12 +20,19 @@ #define NUM_LIN_LEDS 32 #endif -#ifndef LIN_WRAPAROUND -#define LIN_WRAPAROUND 0 //Whether the output lights wrap around. (Can't easily run on embedded systems) +#ifndef USE_NUM_LIN_LEDS +#define USE_NUM_LIN_LEDS NUM_LIN_LEDS #endif -#ifdef SORT_NOTES -#define SORT_NOTES 0 //Whether the notes will be sorted. + +#ifndef LIN_WRAPAROUND +//Whether the output lights wrap around. +//(Can't easily run on embedded systems) +#define LIN_WRAPAROUND 0 +#endif + +#ifndef SORT_NOTES +#define SORT_NOTES 0 //Whether the notes will be sorted. BUGGY Don't use. #endif extern uint8_t ledArray[]; diff --git a/embeddedstm32f303/Makefile b/embeddedstm32f303/Makefile index 8012b23..c471765 100644 --- a/embeddedstm32f303/Makefile +++ b/embeddedstm32f303/Makefile @@ -30,7 +30,7 @@ CFLAGS = $(MCFLAGS) $(OPTIMIZE) $(DEFS) \ -I../embeddedcommon \ -Wl,-T,lib/stm32f303.ld CFLAGS+=-DDEBUG -CFLAGS+=-DNUM_LIN_LEDS=17 -DDFREQ=12500 -DCCEMBEDDED +CFLAGS+=-I. AFLAGS = $(MCFLAGS) diff --git a/embeddedstm32f303/adc.h b/embeddedstm32f303/adc.h index 000f638..1df23ce 100644 --- a/embeddedstm32f303/adc.h +++ b/embeddedstm32f303/adc.h @@ -2,7 +2,7 @@ #define _ADC_H #include - +#include "ccconfig.h" #define ADCFS DFREQ #define ADCOVERSAMP 4 diff --git a/embeddedstm32f303/ccconfig.h b/embeddedstm32f303/ccconfig.h new file mode 100644 index 0000000..384459d --- /dev/null +++ b/embeddedstm32f303/ccconfig.h @@ -0,0 +1,10 @@ +#ifndef _CCCONFIG_H +#define _CCCONFIG_H + +#define CCEMBEDDED +#define NUM_LIN_LEDS 24 +#define USE_NUM_LIN_LEDS 24 +#define DFREQ 12500 + +#endif + diff --git a/embeddedstm32f407/Makefile b/embeddedstm32f407/Makefile index c9a6f59..6ca9978 100644 --- a/embeddedstm32f407/Makefile +++ b/embeddedstm32f407/Makefile @@ -32,7 +32,7 @@ CFLAGS = $(MCFLAGS) $(OPTIMIZE) $(DEFS) \ -Wl,-T,lib/stm32f407.ld CFLAGS+=-DDEBUG -CFLAGS+=-DNUM_LIN_LEDS=17 -DDFREQ=12000 -DCCEMBEDDED +CFLAGS+=-I. AFLAGS = $(MCFLAGS) diff --git a/embeddedstm32f407/ccconfig.h b/embeddedstm32f407/ccconfig.h new file mode 100644 index 0000000..65f2271 --- /dev/null +++ b/embeddedstm32f407/ccconfig.h @@ -0,0 +1,10 @@ +#ifndef _CCCONFIG_H +#define _CCCONFIG_H + +#define CCEMBEDDED +#define NUM_LIN_LEDS 217 +#define USE_NUM_LIN_LEDS 217 +#define DFREQ 12000 + +#endif + diff --git a/embeddedstm32f407/main.c b/embeddedstm32f407/main.c index 7ebdbd5..1572c26 100644 --- a/embeddedstm32f407/main.c +++ b/embeddedstm32f407/main.c @@ -116,7 +116,7 @@ int main(void) // it also takes up a bunch of space. No printf = no space wasted in printf. // printf( "Operating at %.3fMHz\n", fv ); - Init(); + InitColorChord(); Configure_PA0(); InitMP45DT02(); InitSPI2812(); diff --git a/embeddedstm32f407/mp45dt02.h b/embeddedstm32f407/mp45dt02.h index 715d197..9f9c0ae 100644 --- a/embeddedstm32f407/mp45dt02.h +++ b/embeddedstm32f407/mp45dt02.h @@ -3,6 +3,7 @@ #ifndef _MP45DT02 #define _MP45DT02 +#include "ccconfig.h" //sampling frequency #define FS DFREQ