summaryrefslogtreecommitdiffstats
path: root/Graphic_Equalizer_v1.0/src/events.hcc
diff options
context:
space:
mode:
Diffstat (limited to 'Graphic_Equalizer_v1.0/src/events.hcc')
-rw-r--r--Graphic_Equalizer_v1.0/src/events.hcc179
1 files changed, 179 insertions, 0 deletions
diff --git a/Graphic_Equalizer_v1.0/src/events.hcc b/Graphic_Equalizer_v1.0/src/events.hcc
new file mode 100644
index 0000000..275bc25
--- /dev/null
+++ b/Graphic_Equalizer_v1.0/src/events.hcc
@@ -0,0 +1,179 @@
+/*! \file events.hcc
+ *
+ * \section generic This module contains the various actions and events
+ * that need to be performed.
+ *
+ * \section project Project information.
+ * Project Graphic Equalizer\n
+ * \author O.M. Schinagl
+ * \date 20041710
+ * \version 0.1
+ *
+ * \section copyright Copyright
+ * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved
+ *
+ * \section history Change history
+ * 20041710: O.M. Schinagl\n Initial version
+ *
+ *****************************************************************************/
+
+
+
+/******** System Includes *************/
+#include <stdlib.hch>
+
+#include "pal_master.hch"
+
+/******** Application Includes ********/
+#include "configuration.hch"
+#include "display_shared.hch"
+#include "eventhandler_shared.hch"
+#include "events.hch"
+
+#if HAVE_DEBUG
+ #include "debug.hch"
+#endif
+
+
+ram unsigned 8 presets_default_values[768] = {
+#include "presets_hardcoded.txt"
+};
+
+
+
+/*! \fn void set_preset(unsigned 10 *active_preset,
+ * unsigned 10 *preset_offset, unsigned 8 new_preset,
+ * unsigned 4 *equalizer_levels_ptr,
+ * unsigned 4 *equalizer_levels)
+ * \brief This function changes the active preset to the new_preset
+ * received from the userinterface and updates internal pointers.
+ *
+ * \param *active_preset Local store that holds the current
+ * active preset.
+ * \param *preset_offset Local store that holds the index to the
+ * current active preset in the presets
+ * array.
+ * \param new_preset The new preset.
+ * \param *equalizer_levels_ptr Pointer pointing to the current
+ * equalizer settings.
+ * \param *equalizer_levels Local store with all presets.
+ */
+inline void set_preset(unsigned 10 *active_preset, unsigned 10 *preset_offset, unsigned 8 new_preset, unsigned 4 *equalizer_levels_ptr, unsigned 4 *equalizer_levels) {
+ /*
+ * The active preset is determined by the mask minus an offset. Hence
+ * ranging our active preset from 0 to 6.
+ */
+ *active_preset = 0 @ new_preset;
+ /*
+ * 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 = *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.
+ */
+ equalizer_levels_ptr = &equalizer_levels[*preset_offset];
+}
+
+
+
+/*
+ */
+inline unsigned 5 change_volume_from_coordinate(unsigned 11 coordinate, events_t *events, skindata_t *skindata) {
+ unsigned 5 retval;
+ unsigned 5 volumeleft;
+
+ /*
+ * Copy the current Y cursor position to the events struct. This we
+ * need for drawing purposes.
+ */
+ events->volume_position = coordinate;
+ /*
+ * Look the relative y-coordinate up in the volumecontrol lookup table.
+ * We make a local copy here because the RC200 call doesn't behave
+ * nicely when passing anything else.
+ */
+ volumeleft = volumecontrol_table[(coordinate -skindata->volume.top) <- 6];
+ /*
+ * We feel that volume gets softer the closer it gets to the 0, and
+ * louder as it approaches 0x1f. The SetVolume RC200 call does this in
+ * an unnatural reverse way. Therefor we 'fix' it.
+ */
+ RC200AudioOutSetVolume(!volumeleft, (0x1f -volumeleft), (0x1f -volumeleft));
+ /*
+ * Now that we have set the gain, we return it incase someone needs it.
+ */
+ retval = volumeleft;
+
+ return retval;
+}
+
+
+
+/*
+ */
+inline unsigned 4 change_inputgain_from_coordinate(unsigned 11 coordinate, events_t *events, skindata_t *skindata) {
+ unsigned 4 retval;
+ unsigned 4 gainleft;
+
+ /*
+ * Copy the current Y cursor position to the events struct. This we
+ * then later use for drawing purposes.
+ */
+ events->inputgain_position = coordinate;
+ /*
+ * Look the relative y-coordinate up in the inputgain lookup table. We
+ * make a local copy here because the RC200 call doesn't behave nicely
+ * when passing anything else.
+ */
+ gainleft = inputgain_table[(coordinate -skindata->inputgain.top) <- 6];
+ /*
+ * Finally we set the gain as calculated.
+ */
+ RC200AudioInSetGain(!gainleft, gainleft, gainleft);
+ /*
+ * Now that we have set the gain, we return it incase someone needs it.
+ */
+ retval = gainleft;
+
+ return retval;
+}
+
+
+
+/*! \fn void load_preset(unsigned 10 preset, unsigned 4 *equalizer_levels_ptr);
+ * \brief This function loads 768 4bits presets into the equalizer_levels
+ * array pointed to by equalizer_levels.
+ *
+ * \param *equalizer_levels Location where to store presets loaded
+ * from blockram.
+ *
+ * \return void
+ * \retval void
+ */
+void load_preset(unsigned 10 preset, unsigned 4 *equalizer_levels_ptr) {
+ unsigned 10 equalizer_index;
+ unsigned 4 temp;
+
+ equalizer_index = 0;
+ while (equalizer_index != 768) {
+ temp = presets_default_values[preset +(0 @ (equalizer_index \\ 1))][7:4];
+ equalizer_levels_ptr[equalizer_index] = temp;
+ temp = presets_default_values[preset +(0 @ (equalizer_index \\ 1))][3:0];
+ equalizer_levels_ptr[equalizer_index +1] = temp;
+
+ equalizer_index += 2;
+ }
+} /* --- load_preset() --- */
+
+
+
+/*
+ * Equalizer lookuptabes.
+ * TODO: This table is now hardcoded. To ensure full skinability this table
+ * should be dynamically loaded.
+ */
+ram unsigned 4 equalizer_table[640] = {15, 15, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0};
+ram unsigned 11 equalizer_table_inv[16] = {446, 444, 440, 436, 432, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 384};