summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer/src
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2004-11-16 16:07:12 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2004-11-16 16:07:12 (GMT)
commitaf87b55d03ad6f13196d27c7483837a7c4606564 (patch)
tree09d2df7d043fc72d54114d61c10c518f726bfe2e /Graphic_Equalizer/src
parent75740fc47251c003d9d3b32efdf60fd2ca7f9e1e (diff)
downloadTASS-af87b55d03ad6f13196d27c7483837a7c4606564.zip
TASS-af87b55d03ad6f13196d27c7483837a7c4606564.tar.gz
TASS-af87b55d03ad6f13196d27c7483837a7c4606564.tar.bz2
Attempt to add Spectrum Analasys.
Diffstat (limited to 'Graphic_Equalizer/src')
-rw-r--r--Graphic_Equalizer/src/display.hcc94
-rw-r--r--Graphic_Equalizer/src/eventhandler.hcc57
-rw-r--r--Graphic_Equalizer/src/fft.hcc2
-rw-r--r--Graphic_Equalizer/src/runfft.hcc12
4 files changed, 128 insertions, 37 deletions
diff --git a/Graphic_Equalizer/src/display.hcc b/Graphic_Equalizer/src/display.hcc
index 2238c1d..dbc7fc5 100644
--- a/Graphic_Equalizer/src/display.hcc
+++ b/Graphic_Equalizer/src/display.hcc
@@ -82,10 +82,12 @@ macro proc display_main(audiodata, events, mousedata, CLOCKRATE, VIDEOOUT, RAM_B
#endif
/*
- *
+ * If the passed button_state tells us the button is active, then we
+ * the button is 'on' and we draw it inverted. Otherwise we draw the
+ * area of the button normally.
*/
- macro proc draw_button(button) {
- if (button == pixeldata[31:24]) {
+ macro proc draw_button(button_state) {
+ if (button_state == pixeldata[31:24]) {
PalVideoOutWrite(VIDEOOUT, ~PIXEL);
} else {
PalVideoOutWrite(VIDEOOUT, PIXEL);
@@ -112,40 +114,102 @@ macro proc display_main(audiodata, events, mousedata, CLOCKRATE, VIDEOOUT, RAM_B
PalPL2RAMSetReadAddress(RAM_BANK0, address);
/*
- * Determin what to draw where here.
+ * Determin what to draw where here. Every case has an
+ * if else statement comparing wether to draw something
+ * special or the background. Every specific drawing
+ * obviously only happens in the masked area.
*/
switch (pixeldata[31:24]) {
+ /*
+ * Volume control over the Y-axis.
+ */
case AREA_VOLUME_YAXIS:
+ /*
+ * The volume_position stores the
+ * highest point of our bar. Every
+ * pixel after this point is drawn.
+ */
if (SCANY >= 0 @ events.volume_position) {
PalVideoOutWrite(VIDEOOUT, PIXEL_VOLUME_YAXIS);
} else {
PalVideoOutWrite(VIDEOOUT, PIXEL);
}
break;
+
+ /*
+ * Spectrum Analyzer
+ */
+ case AREA_SPECTRUM_ANALYZER:
+ /*
+ * fft_info tells us the highest point
+ * the spectrum. We draw every pixel
+ * higher then this point. The data
+ * received ranges from 0 to 2^7
+ * maximally, therefor we need to add
+ * the offset for to correct this.
+ */
+ if ((SCANY -200) >= 0 @ audiodata.fft_info.read[SCANX <- 8]) {
+ PalVideoOutWrite(VIDEOOUT, PIXEL_SPECTRUM);
+ } else {
+ PalVideoOutWrite(VIDEOOUT, PIXEL);
+ }
+ break;
- case BUTTON_PRESET_1:
- case BUTTON_PRESET_2:
- case BUTTON_PRESET_3:
- case BUTTON_PRESET_4:
- case BUTTON_PRESET_5:
+ /*
+ * Since all buttons are drawn equally, either
+ * we draw them normally or we inverse them, we
+ * can handle them almost equally.
+ */
+ case BUTTON_PRESET_1: /* fall through */
+ case BUTTON_PRESET_2: /* fall through */
+ case BUTTON_PRESET_3: /* fall through */
+ case BUTTON_PRESET_4: /* fall through */
+ case BUTTON_PRESET_5: /* fall through */
case BUTTON_PRESET_6:
- draw_button((audiodata.active_preset +BUTTON_PRESET_1) <- 8);
+ /*
+ * The active preset tells us what
+ * button is currently enabled. We must
+ * however not forget to add the preset
+ * button offset to possibly match it
+ * with the current mask.
+ */
+ draw_button((events.active_preset +BUTTON_PRESET_1) <- 8);
break;
- case BUTTON_1:
- case BUTTON_2:
- case BUTTON_3:
- case BUTTON_4:
+ case BUTTON_1: /* fall through */
+ case BUTTON_2: /* fall through */
+ case BUTTON_3: /* fall through */
+ case BUTTON_4: /* fall through */
case BUTTON_5:
+ /*
+ * equalizer mode tells us what button
+ * is currently enabled. By adding the
+ * equalizer mode button offset we can
+ * safley check wether it matches our
+ * mask.
+ */
draw_button((0 @ events.equalizer_mode) +BUTTON_1);
break;
case BUTTON_LOG:
+ /*
+ *
+ */
draw_button((0 @ audiodata.display_log) +BUTTON_LOG);
break;
+ /*
+ * The default case is split up into two parts
+ * actually. This is because we have 128 bands
+ * for the equalizer and thus as many mask
+ * entries. Since we don't want 128 identical
+ * cases we check wether the equalizer mask is
+ * currently active and if so draw it. If this
+ * is not the case we simply draw the
+ * background.
+ */
default:
- if ((AREA_EQUALIZER_MIN <= pixeldata[31:24]) && (pixeldata[31:24] <= AREA_EQUALIZER_MAX) && (SCANY == 0 @ events.equalizer_position[(pixeldata[31:24] -0x80) <- 7])) {
+ if ((AREA_EQUALIZER_MIN <= pixeldata[31:24]) && (pixeldata[31:24] <= AREA_EQUALIZER_MAX) && (SCANY == 0 @ events.equalizer_position[(pixeldata[31:24] -AREA_EQUALIZER_MIN) <- 7])) {
PalVideoOutWrite(VIDEOOUT, PIXEL_EQUALIZER);
} else {
PalVideoOutWrite(VIDEOOUT, PIXEL);
diff --git a/Graphic_Equalizer/src/eventhandler.hcc b/Graphic_Equalizer/src/eventhandler.hcc
index c19077a..2502518 100644
--- a/Graphic_Equalizer/src/eventhandler.hcc
+++ b/Graphic_Equalizer/src/eventhandler.hcc
@@ -48,12 +48,12 @@ extern chan unsigned 1 maskupdate_notification;
*/
void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mousedata) {
mpram {
- ram unsigned 4 write[128];
- rom unsigned 4 read[128];
+ ram unsigned 4 write[768];
+ rom unsigned 4 read[768];
} equalizer_levels with { block = "BlockRAM"};
unsigned 10 preset_offset;
- unsigned 8 equalizer_bands;
+ unsigned 7 equalizer_bands;
unsigned 5 volume_left;
unsigned 1 newmaskupdate;
@@ -76,20 +76,44 @@ void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mo
delay;
}
+ /*
+ * The Preset buttons span from 1 to 6 so if
+ * the mask one of those, we'll change the
+ * pointer to point to the current preset.
+ */
if ((BUTTON_PRESET_1 <= events->mask) && (events->mask <= BUTTON_PRESET_6)) {
/*
+ * The active preset is determined by
+ * the mask minus an offset. Hence
+ * ranging our active preset from 0 to
+ * 6.
*/
- preset_offset = 0 @ ((events->mask -AREA_EQUALIZER_MIN) +(events->active_preset << 7));
events->active_preset = 0 @ (events->mask -BUTTON_PRESET_1);
- audiodata->equalizer_levels_ptr = equalizer_levels[0];
-#if HAVE_DEBUG
-print_string("active preset: ");print_hex_value(0 @ events->active_preset);print_eol();
-print_string("preset offset: ");print_hex_value(0 @ preset_offset);print_eol();
-#endif
+ /*
+ * Each equalizer is 128 bands wide,
+ * thus we need to add 128 * the preset
+ * for each different preset. This
+ * offset is calculated here.
+ */
+ preset_offset = events->active_preset << 7;
+ /*
+ * We set the pointer to the active
+ * part of the array by using the
+ * preset offset as our index. Hence
+ * depending on the selected preset
+ * we point to 0, 128, 256, 384, 512
+ * or 640.
+ */
+ audiodata->equalizer_levels_ptr = &equalizer_levels.write[preset_offset];
- for (equalizer_bands = 0; equalizer_bands != 128; equalizer_bands++) {
-
- }
+ /*
+ * Reverse fill
+ */
+ equalizer_bands = 0;
+ do {
+ events->equalizer_position[equalizer_bands] = equalizer_table_inv[audiodata->equalizer_levels_ptr[equalizer_bands]];
+ equalizer_bands++;
+ } while (equalizer_bands);
} else {
delay;
}
@@ -100,6 +124,10 @@ print_string("preset offset: ");print_hex_value(0 @ preset_offset);print_eol();
delay;
}
+ /*
+ * If the current mask equals the log button,
+ * we flip the display_log bit.
+ */
if (BUTTON_LOG == events->mask) {
audiodata->display_log = !audiodata->display_log;
} else {
@@ -148,6 +176,7 @@ print_string("preset offset: ");print_hex_value(0 @ preset_offset);print_eol();
* minus the maskoffset.
*/
events->equalizer_position[((events->mask -AREA_EQUALIZER_MIN) <- 7)] = mousedata->y;
+print_string("Eventsmask: ");print_hex_value(0 @ ((events->mask -AREA_EQUALIZER_MIN) <- 7));print_eol();
/*
* We look our current possition up in
* the lookup table. We determin our
@@ -162,7 +191,7 @@ print_string("preset offset: ");print_hex_value(0 @ preset_offset);print_eol();
* TODO: lock equalizer store with a
* semaphore!
*/
- audiodata->equalizer_levels.write[((events->mask -AREA_EQUALIZER_MIN) <- 7)] = equalizer_table[((mousedata->y) -382) <- 7];
+ audiodata->equalizer_levels_ptr[(events->mask -AREA_EQUALIZER_MIN) <- 7] = equalizer_table[(mousedata->y -382) <- 7];
} else {
delay;
}
@@ -178,7 +207,7 @@ print_string("preset offset: ");print_hex_value(0 @ preset_offset);print_eol();
* TODO: This table is now hardcoded. To ensure full skinability this table
* should be dynamically loaded.
*/
-rom unsigned 5 volumecontrol_table[46] = {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0};
+rom unsigned 5 volumecontrol_table[46] = {31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0};
/*
* Equalizer lookuptabes.
diff --git a/Graphic_Equalizer/src/fft.hcc b/Graphic_Equalizer/src/fft.hcc
index 92468a8..04d072f 100644
--- a/Graphic_Equalizer/src/fft.hcc
+++ b/Graphic_Equalizer/src/fft.hcc
@@ -364,7 +364,7 @@ void equalize_audio(audiodata_t *audiodata)
for(i=0;i!=NUMBER_OF_FREQUENCIES;i++)
{
// set multiplication factor (0..64) for current frequency bar, The first frequency band must be equalized at 100% (63) since there is no DC-component taken into account.
- a = (i==0) ? 63 : adjs(eq_settings[audiodata->equalizer_levels.write[0 @ (i <- 7)]],18);
+ a = (i==0) ? 63 : adjs(eq_settings[audiodata->equalizer_levels_ptr[i <- 7]],18);
// multiply frequency with this factor and divide by 64 (drop 6 LSB's)
diff --git a/Graphic_Equalizer/src/runfft.hcc b/Graphic_Equalizer/src/runfft.hcc
index 02642cc..b847475 100644
--- a/Graphic_Equalizer/src/runfft.hcc
+++ b/Graphic_Equalizer/src/runfft.hcc
@@ -78,10 +78,10 @@ void LoadPresets(audiodata_t * audiodata)
temp = presets[index];
index++;
}
- par { audiodata->equalizer_levels.write[count] = temp[7:4]; count++; }
- par { audiodata->equalizer_levels.write[count] = temp[3:0]; count++; }
- par { audiodata->equalizer_levels.write[count] = temp[15:12]; count++; }
- par { audiodata->equalizer_levels.write[count] = temp[11:8]; count++; }
+ par { audiodata->equalizer_levels_ptr[count] = temp[7:4]; count++; }
+ par { audiodata->equalizer_levels_ptr[count] = temp[3:0]; count++; }
+ par { audiodata->equalizer_levels_ptr[count] = temp[15:12]; count++; }
+ par { audiodata->equalizer_levels_ptr[count] = temp[11:8]; count++; }
} while (count<768);
}
@@ -104,8 +104,6 @@ macro proc audio_main(audiodata, AUDIOIN, AUDIOOUT)
ram unsigned 6 input[64];
- shared expr preset_address = (audiodata.active_preset << 7);
-
//pointers for double and quadruple buffering:
audioptr_in1 = &audio_buffer_in[0];
audioptr_in2 = &audio_buffer_in[64];
@@ -122,7 +120,7 @@ macro proc audio_main(audiodata, AUDIOIN, AUDIOOUT)
FFT_Sync=0;
- LoadPresets(&audiodata);
+ //LoadPresets(&audiodata);
first = 1;
par
{