Update copyright noteices, etc.
This commit is contained in:
parent
95c0c4837b
commit
bba28c688f
55 changed files with 201 additions and 41 deletions
|
@ -1,3 +1,5 @@
|
|||
//Copyright 2015 <>< Charles Lohr under the ColorChord License.
|
||||
|
||||
#include "DFT32.h"
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
//Copyright 2015 <>< Charles Lohr under the ColorChord License.
|
||||
|
||||
#ifndef _DFT32_H
|
||||
#define _DFT32_H
|
||||
|
||||
#include <ccconfig.h>
|
||||
#include <stdint.h>
|
||||
|
||||
//A 32-bit version of the DFT used for ColorChord.
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
//Copyright 2015 <>< Charles Lohr under the ColorChord License.
|
||||
|
||||
#include "embeddednf.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
//Copyright 2015 <>< Charles Lohr under the ColorChord License.
|
||||
|
||||
#ifndef _EMBEDDEDNF_H
|
||||
#define _EMBEDDEDNF_H
|
||||
|
||||
#include <ccconfig.h>
|
||||
|
||||
//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
|
||||
|
||||
|
|
|
@ -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]--;
|
||||
}
|
||||
}*/
|
||||
|
|
|
@ -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[];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue