summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer/src/eventhandler.hcc
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/eventhandler.hcc
parent75740fc47251c003d9d3b32efdf60fd2ca7f9e1e (diff)
downloadTASS-af87b55d03ad6f13196d27c7483837a7c4606564.zip
TASS-af87b55d03ad6f13196d27c7483837a7c4606564.tar.gz
TASS-af87b55d03ad6f13196d27c7483837a7c4606564.tar.bz2
Attempt to add Spectrum Analasys.
Diffstat (limited to 'Graphic_Equalizer/src/eventhandler.hcc')
-rw-r--r--Graphic_Equalizer/src/eventhandler.hcc57
1 files changed, 43 insertions, 14 deletions
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.