summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2005-02-23 11:53:20 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2005-02-23 11:53:20 (GMT)
commit230a2a50f31295c0f8aa9b04dc7f7b10d163ee2e (patch)
tree45b0a34d78bf9f64856f9666509798207178afbd
parentb93369af2cd1d2b5ac20669e83cb07feca349462 (diff)
downloadTASS-230a2a50f31295c0f8aa9b04dc7f7b10d163ee2e.zip
TASS-230a2a50f31295c0f8aa9b04dc7f7b10d163ee2e.tar.gz
TASS-230a2a50f31295c0f8aa9b04dc7f7b10d163ee2e.tar.bz2
added audio player functionality
-rw-r--r--Graphic_Equalizer/src/audio.hcc65
-rw-r--r--Graphic_Equalizer/src/display.hcc75
-rw-r--r--Graphic_Equalizer/src/eventhandler.hcc866
-rw-r--r--Graphic_Equalizer/src/smartmedia.hcc53
4 files changed, 614 insertions, 445 deletions
diff --git a/Graphic_Equalizer/src/audio.hcc b/Graphic_Equalizer/src/audio.hcc
index 8722ce7..22470cf 100644
--- a/Graphic_Equalizer/src/audio.hcc
+++ b/Graphic_Equalizer/src/audio.hcc
@@ -158,11 +158,13 @@ macro proc audio_main(audiodata, AUDIOIN, AUDIOOUT)
displayptr4 = &audiodata.ifft_info.write[192];
FFT_Sync=0;
+
+ audiodata.player_state = PLAYER_DISABLED;
par
{
run_fft(audiodata);
- sample_audio(audiodata, AUDIOOIN);
- output_audio(AUDIOOOUT);
+ sample_audio(audiodata, AUDIOIN);
+ output_audio(AUDIOOUT);
}//end par
} /* --- audio_main() --- */
#endif
@@ -230,7 +232,7 @@ macro proc run_fft(audiodata)
* /return Never Returns.
* /retval void
*/
-macro proc sample_audio(audiodata, AUDIOOIN)
+macro proc sample_audio(audiodata, AUDIOIN)
{
macro expr IW = PalAudioInGetMaxDataWidthCT();
signed IW LeftNew, RightNew;
@@ -239,12 +241,13 @@ macro proc sample_audio(audiodata, AUDIOOIN)
unsigned 8 not_saturated;
unsigned 6 sample_count;
unsigned 2 saturation;
+ unsigned 2 track_index;
unsigned 1 result;
par {
while (TRUE)
{
- if (FFT_Sync && audiodata.play) //if 64 samples are read from ...
+ /* if (FFT_Sync && audiodata.play) //if 64 samples are read from ...
{
result = load_audio_samples(audioptr_in1, blockcount, WINDOW_SIZE);
if (result) {
@@ -257,6 +260,53 @@ macro proc sample_audio(audiodata, AUDIOOIN)
{
delay;
}
+*/
+ switch (audiodata.player_state) {
+ case PLAYING:
+ if (FFT_Sync) { //if 64 samples can be processed again
+ result = load_audio_samples(audioptr_in1, blockcount, WINDOW_SIZE);
+ if (result) {
+ if(audiodata.player_mode) {
+ blockcount = 0;
+ } else {
+ audiodata.player_state = NEXT_TRACK;
+ }
+ } else {
+ blockcount++;
+ }
+ } else {
+ delay;
+ }
+ break;
+ case STOPPED:
+ blockcount = 0;
+ break;
+ case NEXT_TRACK:
+ if(track_index == NUMBER_OF_TRACKS-1) {
+ track_index = 0;
+ } else {
+ track_index++;
+ }
+ blockcount = 0;
+ change_track(track_index);
+ audiodata.player_state = PLAYING;
+ break;
+ case PREV_TRACK:
+ if(track_index == 0) {
+ track_index = NUMBER_OF_TRACKS-1;
+ } else {
+ track_index--;
+ }
+ blockcount = 0;
+ change_track(track_index);
+ audiodata.player_state = PLAYING;
+ break;
+ case PAUSED: // fall through
+ default: //PLAYER_DISABLED
+ delay;
+ break;
+ }
+
}
while (TRUE)//store the samples in the inputbuffer
{
@@ -268,7 +318,7 @@ macro proc sample_audio(audiodata, AUDIOOIN)
{
PalAudioInRead(AUDIOIN, &LeftNew, &RightNew);
- if (!audiodata.play)
+ if (audiodata.player_state == PLAYER_DISABLED)
{
#if HARDWARE_MULTIPLY
audioptr_in1[sample_count] = LeftNew;
@@ -292,6 +342,9 @@ macro proc sample_audio(audiodata, AUDIOOIN)
}
}
}
+ if ((audiodata.player_state == STOPPED) || (audiodata.player_state == PAUSED))
+ audioptr_in1[sample_count] = 0;
+
sample_count++;
if (!sample_count)
{
@@ -300,7 +353,7 @@ macro proc sample_audio(audiodata, AUDIOOIN)
}
seq
{
- Output_sample = audioptr_out2[sample_count];
+ Output_sample = audioptr_out2[sample_count];
}
}
}
diff --git a/Graphic_Equalizer/src/display.hcc b/Graphic_Equalizer/src/display.hcc
index 81d0037..798f399 100644
--- a/Graphic_Equalizer/src/display.hcc
+++ b/Graphic_Equalizer/src/display.hcc
@@ -61,10 +61,12 @@ static rom unsigned 20 images[32] = {
ADDRESS_SKIN_START,
ADDRESS_HELP_START,
ADDRESS_HELP_START,
- ADDRESS_GRAPH_START
+ ADDRESS_GRAPH_START,
+ ADDRESS_AUDIO_PLAYER_START
};
+static rom unsigned 5 image_indexes [5] = {0,IMAGE_SKIN, IMAGE_HELP, 0, IMAGE_ABOUT};
/*! \fn void display_main(skindata_t *skindata, audiodata_t *audiodata, events_t *events, mousedata_t *mousedata)
*
@@ -132,19 +134,9 @@ inline void display_main(skindata_t *skindata, audiodata_t *audiodata, events_t
* for the next cycle.
*/
PalPL2RAMRead(RAM_BANK0, &pixeldata);
- PalPL2RAMSetReadAddress(RAM_BANK0, (IMAGE_GRAPH == events->image) ? (images[events->image] +(0 @ (addresses[address_index] \\ 2))) : (images[events->image] +addresses[address_index]));
+ PalPL2RAMSetReadAddress(RAM_BANK0, (events->mode[3]) ? (images[events->image] +(0 @ (addresses[address_index] \\ 2))) : (images[events->image] +addresses[address_index]));
- /*
- * Always reset the address_index to the corresponding
- * array index containing the address counter of the
- * background image, when the default skin should be
- * displayed.
- */
- if (IMAGE_SKIN == events->image) {
- address_index = MASK_AREA_BACKGROUND;
- } else {
- delay;
- }
+ //print_hex_value(0@MASK);
/*
* When displaying the visual the pixeldata read
@@ -152,7 +144,8 @@ inline void display_main(skindata_t *skindata, audiodata_t *audiodata, events_t
* since the visual-image is not stored as a MRGB value,
* but as a MMMM-value. (M = mask)
*/
- if (IMAGE_GRAPH == events->image) {
+// if (IMAGE_GRAPH == events->image) {
+ if (events->mode[3]) {
par {
switch (addresses[MASK_AREA_BACKGROUND] <- 2) {
case 3:
@@ -281,10 +274,6 @@ inline void display_main(skindata_t *skindata, audiodata_t *audiodata, events_t
draw_button(audiodata->display_log);
break;
- case BUTTON_PLAY:
- draw_button(audiodata->play);
- break;
-
case BUTTON_DEMO:
draw_button(events->button_demo_state);
break;
@@ -300,7 +289,12 @@ inline void display_main(skindata_t *skindata, audiodata_t *audiodata, events_t
break;
case AREA_ABOUT_TOP:
+/*
+ Check wether the application is in about mode.
if (IMAGE_ABOUT == events->image) {
+*/
+ if (events->mode[2]) {
+ //draw current about top window
par {
events->image = events->image_about;
address_index = MASK_AREA_ABOUT_TOP;
@@ -317,7 +311,12 @@ inline void display_main(skindata_t *skindata, audiodata_t *audiodata, events_t
case BUTTON_URL_CELOXICA: /* fall through */
case BUTTON_URL_DETAILS: /* fall through */
case AREA_ABOUT_BOTTOM:
+/*
+ Check wether the application is in about mode.
if (IMAGE_ABOUT == events->image) {
+*/
+ if (events->mode[2]) {
+ //draw current about bottom window
par {
events->image = IMAGE_ABOUT_BOTTOM;
address_index = MASK_AREA_ABOUT_BOTTOM;
@@ -328,15 +327,43 @@ inline void display_main(skindata_t *skindata, audiodata_t *audiodata, events_t
}
break;
- case AREA_MASK_END:
- /* (IMAGE_ABOUT_TOP_FONTYS <= events->image) && (events->image <= IMAGE_ABOUT_BOTTOM)*/
- if ((events->image <= IMAGE_ABOUT_BOTTOM) || (IMAGE_ABOUT == events->image)) {
+ case BUTTON_PREV_TRACK:
+ draw_button(events->prev_track_state);
+ break;
+ case BUTTON_PLAY:
+ draw_button(audiodata->player_state== PLAYING);
+ break;
+ case BUTTON_PAUSE:
+ draw_button(audiodata->player_state == PAUSED);
+ break;
+ case BUTTON_STOP:
+ draw_button(audiodata->player_state == STOPPED);
+ break;
+ case BUTTON_NEXT_TRACK:
+ draw_button(events->next_track_state);
+ break;
+ case BUTTON_REPEAT:
+ draw_button(audiodata->player_mode);
+ break;
+ case AREA_AUDIO_PLAYER:
+/*
+ Check wether the application is in audioplayer mode.
+*/ //print_hex_value(0@MASK);
+ if (events->mode[4]) {
par {
- events->image = IMAGE_ABOUT;
- address_index = MASK_AREA_BACKGROUND;
+ events->image = IMAGE_AUDIO_PLAYER;
+ address_index = MASK_AREA_AUDIO_PLAYER;
PalVideoOutWrite(VIDEOOUT, PIXEL);
}
} else {
+ PalVideoOutWrite(VIDEOOUT, PIXEL);
+ }
+ break;
+
+ case AREA_MASK_END:
+ par {
+ events->image = image_indexes[events->mode <- 3];
+ address_index = MASK_AREA_BACKGROUND;
PalVideoOutWrite(VIDEOOUT, PIXEL);
}
break;
@@ -405,7 +432,7 @@ inline void display_main(skindata_t *skindata, audiodata_t *audiodata, events_t
addresses[address_index] = 0;
}
} else {
- delay;
+ delay;
}
/*
* We are in the blanking area of the screen.
diff --git a/Graphic_Equalizer/src/eventhandler.hcc b/Graphic_Equalizer/src/eventhandler.hcc
index baa5969..5e9fa87 100644
--- a/Graphic_Equalizer/src/eventhandler.hcc
+++ b/Graphic_Equalizer/src/eventhandler.hcc
@@ -1,191 +1,209 @@
-/*! \file eventhandler.hcc
- *
- * \section generic This modules coordinates all events. Thus for example
- * when the mousehandler registers a 'click' we coordinate
- * the actions that follow that click.
- *
- * \section project Project information.
- * Project Graphic Equalizer\n
- * \author O.M. Schinagl
- * \date 20041110
- * \version 0.1
- *
- * \section copyright Copyright
- * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved
- *
- * \section history Change history
- * 20041110: O.M. Schinagl\n Initial version
- *
- ********************************************************************/
-
-/******** System Includes *************/
-#include <stdlib.hch>
-
-#include "pal_master.hch"
-
-/******** Application Includes ********/
-#include "configuration.hch"
-#include "audio.hch"
-#include "mouse_shared.hch"
-#include "eventhandler_shared.hch"
-#include "display_shared.hch"
-#include "eventhandler.hch"
-#include "events.hch"
-#include "display.hch"
-
-#if HAVE_DEBUG
- #include "debug.hch"
-#endif
-
-
-
-/*
- */
-extern chan unsigned 1 maskupdate_notification;
-extern chan unsigned 1 event_notification;
-
-
-/*! \fn void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mousedata);
- * \brief
- *
- * \param *audiodata pointer to struct for setting equalizer levels.
- * \param *events pointer to struct with all events for display states.
- * \param *mousedata pointer to struct with mouse data for X and Y
- * coordinates.
- *
- * \return Never Returns.
- * \retval void
- */
-inline void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mousedata, skindata_t *skindata) {
- mpram {
- ram unsigned 4 write[768];
- rom unsigned 4 read[768];
- } equalizer_levels with { block = "BlockRAM"};
-
- unsigned 11 reference_point, reference_point_right;
- unsigned 10 preset_offset;
- unsigned 6 gain_counter;
- unsigned 5 old_volume;
- unsigned 5 volume;
- unsigned 4 gain;
- unsigned 4 index_offset, index_end;
- unsigned 4 equalizer_mode_local;
- unsigned 1 newmaskupdate, eventupdate;
-
- audiodata->display_log = TRUE;
- audiodata->play = FALSE;
- events->image = IMAGE_SKIN;
- events->button_demo_state = FALSE;
- events->button_reset_state = FALSE;
+/*! \file eventhandler.hcc
+ *
+ * \section generic This modules coordinates all events. Thus for example
+ * when the mousehandler registers a 'click' we coordinate
+ * the actions that follow that click.
+ *
+ * \section project Project information.
+ * Project Graphic Equalizer\n
+ * \author O.M. Schinagl
+ * \date 20041110
+ * \version 0.1
+ *
+ * \section copyright Copyright
+ * Copyright ©2004 Koninklijke Philips Electronics N.V. All rights reserved
+ *
+ * \section history Change history
+ * 20041110: O.M. Schinagl\n Initial version
+ *
+ ********************************************************************/
+
+/******** System Includes *************/
+#include <stdlib.hch>
+
+#include "pal_master.hch"
+
+/******** Application Includes ********/
+#include "configuration.hch"
+#include "audio.hch"
+#include "mouse_shared.hch"
+#include "eventhandler_shared.hch"
+#include "display_shared.hch"
+#include "eventhandler.hch"
+#include "events.hch"
+#include "display.hch"
+
+#if HAVE_DEBUG
+ #include "debug.hch"
+#endif
+
+
+
+/*
+ */
+extern chan unsigned 1 maskupdate_notification;
+extern chan unsigned 1 event_notification;
+
+
+/*! \fn void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mousedata);
+ * \brief
+ *
+ * \param *audiodata pointer to struct for setting equalizer levels.
+ * \param *events pointer to struct with all events for display states.
+ * \param *mousedata pointer to struct with mouse data for X and Y
+ * coordinates.
+ *
+ * \return Never Returns.
+ * \retval void
+ */
+inline void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedata_t *mousedata, skindata_t *skindata) {
+ mpram {
+ ram unsigned 4 write[768];
+ rom unsigned 4 read[768];
+ } equalizer_levels with { block = "BlockRAM"};
+
+ unsigned 11 reference_point, reference_point_right;
+ unsigned 10 preset_offset;
+ unsigned 6 gain_counter;
+ unsigned 5 old_volume;
+ unsigned 5 volume;
+ unsigned 4 gain;
+ unsigned 4 index_offset, index_end;
+ unsigned 4 equalizer_mode_local;
+ unsigned 1 newmaskupdate, eventupdate;
+
+ macro proc set_mode(newmode)
+ {
+// print_eol();print_string("Be: ");print_hex_value(0@ events->mode);
+ events->mode = (events->mode[4]) ? (newmode | EVENTS_MODE_AUDIO_PLAYER): newmode;
+// print_eol();print_string("af: ");print_hex_value(0@ events->mode);
+ }
+
+ audiodata->display_log = TRUE;
+ events->image = IMAGE_SKIN;
+ events->button_demo_state = FALSE;
+ events->button_reset_state = FALSE;
events->saturated = FALSE;
-
- volume = change_volume_from_coordinate(volumecontrol_table_inv[0x18], events, skindata);
- gain = change_inputgain_from_coordinate(inputgain_table_inv[0xf], events, skindata);
- load_preset(LOAD_PRESET_RESET, equalizer_levels.write);
- reload_equalizer(events, &equalizer_levels.write[preset_offset]);
-
- par {
- while (TRUE) {
- event_notification ? eventupdate;
-
- if (audiodata->saturated) {
- gain_counter--;
- if (!gain_counter) {
- gain--;
- change_inputgain_from_coordinate(inputgain_table_inv[gain], events, skindata);
- events->saturated = TRUE;
- }
- }
- }
- while (TRUE) {
-
- maskupdate_notification ? newmaskupdate;
- /*
- * First we determine what mousestate we currently have. Then
- * we check where we are to decide what to do.
- */
- switch (mousedata->state) {
- case MOUSE_STATE_ON_PRESS:
- /*
- * If we are displaying the graphic visual,
- * any press returns to the application.
- */
- if (IMAGE_GRAPH == events->image) {
- events->image = IMAGE_SKIN;
- events->mask = 0;
- } else {
- delay;
- }
-
- /*
- */
- if (BUTTON_MODE == events->mask) {
- if (IMAGE_GRAPH == events->image) {
- events->image = IMAGE_SKIN;
- } else {
- events->image = IMAGE_GRAPH;
- }
- } else {
- delay;
- }
-
- /*
- * If the current mask equals the help button
- * we set display mode to help.
- */
- if ((IMAGE_ABOUT != events->image) && (BUTTON_HELP == events->mask)) {
- /*
- * Change the mode to help if it's
- * currently not set, otherwise go back
- * to skin mode.
- */
- if (IMAGE_HELP == events->image) {
- events->image = IMAGE_SKIN;
- } else {
- events->image = IMAGE_HELP;
- }
- } else {
- delay;
- }
-
- if ((IMAGE_HELP != events->image) && (BUTTON_ABOUT == events->mask)) {
- /*
- * Change the mode to about if it's
- * currently not set, otherwise go back
- * to skin mode.
- */
- if (IMAGE_ABOUT == events->image) {
- events->image = IMAGE_SKIN;
- } else {
- events->image_about = IMAGE_ABOUT_TOP_TASS;
- events->image = IMAGE_ABOUT;
- }
- } else {
- delay;
- }
-
- if (BUTTON_EXIT_TO_SKIN == events->mask) {
- /*
- */
- events->image = IMAGE_SKIN;
- } else {
- delay;
- }
-
- /*
- */
- if ((BUTTON_URL_FONTYS <= events->mask) && (events->mask <= BUTTON_URL_DETAILS)) {
- events->image_about = (events->mask -BUTTON_URL_FONTYS) <- 5;
- } else {
- 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)) {
+ events->mode = 1;
+ events->locked_gain = FALSE;
+
+ volume = change_volume_from_coordinate(volumecontrol_table_inv[0x18], events, skindata);
+ gain = change_inputgain_from_coordinate(inputgain_table_inv[0xf], events, skindata);
+ load_preset(LOAD_PRESET_RESET, equalizer_levels.write);
+ reload_equalizer(events, &equalizer_levels.write[preset_offset]);
+
+
+
+ par {
+ while (TRUE) {
+ event_notification ? eventupdate;
+
+ if (audiodata->saturated) {
+ gain_counter--;
+ if (!gain_counter) {
+ gain--;
+ change_inputgain_from_coordinate(inputgain_table_inv[gain], events, skindata);
+ events->saturated = TRUE;
+ }
+ }
+ }
+ while (TRUE) {
+
+ maskupdate_notification ? newmaskupdate;
+ /*
+ * First we determine what mousestate we currently have. Then
+ * we check where we are to decide what to do.
+ */
+ switch (mousedata->state) {
+ case MOUSE_STATE_ON_PRESS:
+ /*
+ * If we are displaying the graphic visual,
+ * any press returns to the application.
+ */
+ if (IMAGE_GRAPH == events->image) {
+ events->image = IMAGE_SKIN;
+ events->mask = 0;
+ set_mode(EVENTS_MODE_SKIN);
+ } else {
+ delay;
+ }
+
+ /*
+ */
+ if (BUTTON_MODE == events->mask) {
+ if (IMAGE_GRAPH == events->image) {
+ events->image = IMAGE_SKIN;
+ set_mode(EVENTS_MODE_SKIN);
+ } else {
+ events->image = IMAGE_GRAPH;
+ set_mode(EVENTS_MODE_GRAPH);
+ }
+ } else {
+ delay;
+ }
+
+ /*
+ * If the current mask equals the help button
+ * we set display mode to help.
+ */
+ if ((!events->mode[2]) && (BUTTON_HELP == events->mask)) {
+ /*
+ * Change the mode to help if it's
+ * currently not set, otherwise go back
+ * to skin mode.
+ */
+ if (events->mode[1]) {
+ events->image = IMAGE_SKIN;
+ set_mode(EVENTS_MODE_SKIN);
+ } else {
+ events->image = IMAGE_HELP;
+ set_mode(EVENTS_MODE_HELP);
+ }
+ } else {
+ delay;
+ }
+
+ if ((!events->mode[1]) && (BUTTON_ABOUT == events->mask)) {
+ /*
+ * Change the mode to about if it's
+ * currently not set, otherwise go back
+ * to skin mode.
+ */
+ if (events->mode[2]) {
+ events->image = IMAGE_SKIN;
+ set_mode(EVENTS_MODE_SKIN);
+ } else {
+ events->image_about = IMAGE_ABOUT_TOP_TASS;
+ events->image = IMAGE_ABOUT;
+ set_mode(EVENTS_MODE_ABOUT);
+ }
+ } else {
+ delay;
+ }
+
+ if (BUTTON_EXIT_TO_SKIN == events->mask) {
+ /*
+ */
+ events->image = IMAGE_SKIN;
+ set_mode(EVENTS_MODE_SKIN);
+ } else {
+ delay;
+ }
+
+ /*
+ */
+ if ((BUTTON_URL_FONTYS <= events->mask) && (events->mask <= BUTTON_URL_DETAILS)) {
+ events->image_about = (events->mask -BUTTON_URL_FONTYS) <- 5;
+ } else {
+ 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
@@ -208,228 +226,260 @@ inline void eventhandler_main(audiodata_t *audiodata, events_t *events, mousedat
* we point to 0, 128, 256, 384, 512
* or 640.
*/
- audiodata->equalizer_levels_ptr = &equalizer_levels.read[preset_offset]; /*
- * Reload the equalizer bars
- * from our buffer into
- * the display memory.
- */
- reload_equalizer(events, &equalizer_levels.write[preset_offset]);
- } else {
- delay;
- }
-
- if ((BUTTON_PRECISE <= events->mask) && (events->mask <= BUTTON_CONVEX_FULL)) {
- events->equalizer_mode = (events->mask -BUTTON_PRECISE) <-4;
- } else {
- delay;
- }
-
- /*
- * If the demo button was pressed load the
- * demo preset values into the presets.
- */
- if (BUTTON_DEMO == events->mask) {
- events->button_demo_state = TRUE;
- load_preset(LOAD_PRESET_DEMO, equalizer_levels.write);
- reload_equalizer(events, &equalizer_levels.write[preset_offset]);
- }
-
- /*
- * If the reset button was pressed load the
- * reset values into the presets.
- */
- if (BUTTON_RESET == events->mask) {
- events->button_reset_state = TRUE;
- load_preset(LOAD_PRESET_RESET, equalizer_levels.write);
- reload_equalizer(events, &equalizer_levels.write[preset_offset]);
- }
-
- /*
- * 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 {
- delay;
- }
-
- if (BUTTON_PLAY == events->mask) {
- audiodata->play = !audiodata->play;
- if (audiodata->play) {
- events->locked_gain = TRUE;
- } else {
+ audiodata->equalizer_levels_ptr = &equalizer_levels.read[preset_offset]; /*
+ * Reload the equalizer bars
+ * from our buffer into
+ * the display memory.
+ */
+ reload_equalizer(events, &equalizer_levels.write[preset_offset]);
+ } else {
+ delay;
+ }
+
+ if ((BUTTON_PRECISE <= events->mask) && (events->mask <= BUTTON_CONVEX_FULL)) {
+ events->equalizer_mode = (events->mask -BUTTON_PRECISE) <-4;
+ } else {
+ delay;
+ }
+
+ /*
+ * If the demo button was pressed load the
+ * demo preset values into the presets.
+ */
+ if (BUTTON_DEMO == events->mask) {
+ events->button_demo_state = TRUE;
+ load_preset(LOAD_PRESET_DEMO, equalizer_levels.write);
+ reload_equalizer(events, &equalizer_levels.write[preset_offset]);
+ }
+
+ /*
+ * If the reset button was pressed load the
+ * reset values into the presets.
+ */
+ if (BUTTON_RESET == events->mask) {
+ events->button_reset_state = TRUE;
+ load_preset(LOAD_PRESET_RESET, equalizer_levels.write);
+ reload_equalizer(events, &equalizer_levels.write[preset_offset]);
+ }
+
+ /*
+ * 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 {
+ delay;
+ }
+
+ if (BUTTON_INPUT_SELECT == events->mask) {
+ if(events->mode[4])
+ {
+ events->mode &= (~EVENTS_MODE_AUDIO_PLAYER);
+ change_volume_from_coordinate(volumecontrol_table_inv[volume], events, skindata);
+ audiodata->player_state = PLAYER_DISABLED;
events->locked_gain = FALSE;
- }
- } else {
- delay;
- }
-
-
-/*
- if ((BUTTON_PAUSE == events->mask) && (audiodata->player != STOP_AUDIO)) {
- if (PLAY_AUDIO == audiodata->player) {
- audiodata->player = PAUSE_AUDIO;
- } else {
- audioplay->player = RESUME_AUDIO;
- }
- } else {
- delay;
- }
-
- if (BUTTON_PLAY == events->mask) {
- if (PAUSE_AUDIO == audiodata->player) {
- audioplay->player = RESUME_AUDIO;
- } else {
- old_volume = volume;
- change_volume_from_coordinate(volulmecontrol_table_inv[0x18], events, skindata);
- audiodata->player = PLAY_AUDIO;
- }
- } else {
- delay;
- }
-
- if (BUTTON_STOP == events->mask) {
- audiodata->player = STOP_AUDIO;
- volume = change_volume_from_coordinate(volulmecontrol_table_inv[old_volume], events, skindata);
- } else {
- delay;
- }
-*/
- break;
-
- case MOUSE_STATE_DOWN:
- /*
- * If we are in the volume area we update the
- * volume level for both channels.
- */
- if (AREA_VOLUME_YAXIS == events->mask) {
- /*
- * Change the volume depending
- * on the y position.
- */
- volume = change_volume_from_coordinate(mousedata->y, events, skindata);
- } else {
- delay;
- }
-
- if ((AREA_INPUTGAIN_YAXIS == events->mask) && (!events->locked_gain)) {
- /*
- * Change the inputgain
- * depending on the y position.
- * We store the 'set' gain to
- * be used with the automatic
- * input gain detection.
- */
- gain = change_inputgain_from_coordinate(mousedata->y, events, skindata);
- /*
- * We manually update the
- * inputgain so we change the
- * color of the slider.
- */
- events->saturated = FALSE;
- } else {
- delay;
- }
-
- if ((AREA_EQUALIZER_MIN <= events->mask) && (events->mask <= AREA_EQUALIZER_MAX)) {
-
- if (EQUALIZERMODE_PRECISE == events->equalizer_mode) {
- events->locked_display = TRUE;
- equalizer_levels.write[preset_offset +(0 @ events->mask) -AREA_EQUALIZER_MIN] = equalizer_table[(mousedata->y -382) <- 10];
- events->equalizer_display[(events->mask -AREA_EQUALIZER_MIN) <- 7] = 0 @ (mousedata->y);
- events->locked_display = FALSE;
- } else {
-
- equalizer_mode_local = events->equalizer_mode +1;
-
- events->locked_display = TRUE;
- index_offset = ((equalizer_mode_local << 1)); /* delay; */
-
- if (events->mask < (AREA_EQUALIZER_MIN +(0 @ equalizer_mode_local))) {
- reference_point = events->equalizer_display[AREA_EQUALIZER_MIN -AREA_EQUALIZER_MIN];
- index_offset -= (((0 @ equalizer_mode_local) -(events->mask -AREA_EQUALIZER_MIN)) <- 4);
- } else {
- reference_point = events->equalizer_display[(events->mask - (0 @ equalizer_mode_local) -AREA_EQUALIZER_MIN) <- 7];
- index_offset -= 1;
- }
-
- if (events->mask > (AREA_EQUALIZER_MAX -(0 @ equalizer_mode_local))) {
- reference_point_right = events->equalizer_display[AREA_EQUALIZER_MAX -AREA_EQUALIZER_MIN];
- index_end = (((0 @ equalizer_mode_local) -(AREA_EQUALIZER_MAX -events->mask)) <- 4) -1;
- } else {
- reference_point_right = events->equalizer_display[(events->mask + (0 @ equalizer_mode_local) -AREA_EQUALIZER_MIN) <- 7];
- index_end = 0;
- }
- events->locked_display = FALSE;
-
- for (; index_offset != index_end; index_offset--) {
- unsigned 11 average_bar;
- unsigned 7 equalizer_index;
- unsigned 4 bar_index;
-
- if (index_offset == equalizer_mode_local) {
- reference_point = reference_point_right;
- } else {
- delay;
- }
-
- if (index_offset > equalizer_mode_local)
- {
- bar_index = (index_offset -equalizer_mode_local);
- equalizer_index = ((events->mask -(0 @ bar_index) -AREA_EQUALIZER_MIN) <- 7);
- } else
- {
- bar_index = (equalizer_mode_local -index_offset);
- equalizer_index = ((events->mask +(0 @ bar_index) -AREA_EQUALIZER_MIN) <- 7);
- }
-
- if (reference_point > mousedata->y) {
- average_bar = mousedata->y +((reference_point -mousedata->y) >> (equalizer_mode_local -bar_index));
- } else {
- average_bar = mousedata->y -((mousedata->y -reference_point) >> (equalizer_mode_local -bar_index));
- }
-
- events->locked_display = TRUE;
- equalizer_levels.write[preset_offset +(0 @ equalizer_index)] = equalizer_table[(average_bar -382) <- 10];
- events->equalizer_display[equalizer_index] = average_bar;
- events->locked_display = FALSE;
- }
- }
- } else {
- delay;
- }
-
- if (BUTTON_DEMO != events->mask) {
- events->button_demo_state = FALSE;
- }
- if (BUTTON_RESET != events->mask) {
- events->button_reset_state = FALSE;
+ }
+ else
+ {
+ events->mode |= EVENTS_MODE_AUDIO_PLAYER;
+ old_volume = volume;
+ change_volume_from_coordinate(volumecontrol_table_inv[0x18], events, skindata);
+ audiodata->player_state = PLAYING;
+ events->locked_gain = TRUE;
+ }
+ } else {
+ delay;
+ }
+
+
+
+ if ((BUTTON_PAUSE == events->mask) && (audiodata->player_state != STOPPED)) {
+ if (PLAYING == audiodata->player_state) {
+ audiodata->player_state = PAUSED;
+ } else {
+ audiodata->player_state = PLAYING;
+ }
+ } else {
+ delay;
+ }
+
+ if (BUTTON_PLAY == events->mask) {
+ audiodata->player_state = PLAYING;
+ } else {
+ delay;
+ }
+
+ if (BUTTON_STOP == events->mask) {
+ audiodata->player_state = STOPPED;
+ } else {
+ delay;
+ }
+
+ if (BUTTON_NEXT_TRACK == events->mask) {
+ audiodata->player_state = NEXT_TRACK;
+ events->next_track_state = TRUE;
+ } else {
+ delay;
+ }
+
+ if (BUTTON_PREV_TRACK == events->mask) {
+ audiodata->player_state = PREV_TRACK;
+ events->prev_track_state = TRUE;
+ } else {
+ delay;
+ }
+
+ if (BUTTON_REPEAT == events->mask) {
+ audiodata->player_mode = !audiodata->player_mode;
+ } else {
+ delay;
+ }
+
+ break;
+
+ case MOUSE_STATE_DOWN:
+ /*
+ * If we are in the volume area we update the
+ * volume level for both channels.
+ */
+ if (AREA_VOLUME_YAXIS == events->mask) {
+ /*
+ * Change the volume depending
+ * on the y position.
+ */
+ volume = change_volume_from_coordinate(mousedata->y, events, skindata);
+ } else {
+ delay;
+ }
+
+ if ((AREA_INPUTGAIN_YAXIS == events->mask) && (!events->locked_gain)) {
+ /*
+ * Change the inputgain
+ * depending on the y position.
+ * We store the 'set' gain to
+ * be used with the automatic
+ * input gain detection.
+ */
+ gain = change_inputgain_from_coordinate(mousedata->y, events, skindata);
+ /*
+ * We manually update the
+ * inputgain so we change the
+ * color of the slider.
+ */
+ events->saturated = FALSE;
+ } else {
+ delay;
+ }
+
+ if ((AREA_EQUALIZER_MIN <= events->mask) && (events->mask <= AREA_EQUALIZER_MAX)) {
+
+ if (EQUALIZERMODE_PRECISE == events->equalizer_mode) {
+ events->locked_display = TRUE;
+ equalizer_levels.write[preset_offset +(0 @ events->mask) -AREA_EQUALIZER_MIN] = equalizer_table[(mousedata->y -382) <- 10];
+ events->equalizer_display[(events->mask -AREA_EQUALIZER_MIN) <- 7] = 0 @ (mousedata->y);
+ events->locked_display = FALSE;
+ } else {
+
+ equalizer_mode_local = events->equalizer_mode +1;
+
+ events->locked_display = TRUE;
+ index_offset = ((equalizer_mode_local << 1)); /* delay; */
+
+ if (events->mask < (AREA_EQUALIZER_MIN +(0 @ equalizer_mode_local))) {
+ reference_point = events->equalizer_display[AREA_EQUALIZER_MIN -AREA_EQUALIZER_MIN];
+ index_offset -= (((0 @ equalizer_mode_local) -(events->mask -AREA_EQUALIZER_MIN)) <- 4);
+ } else {
+ reference_point = events->equalizer_display[(events->mask - (0 @ equalizer_mode_local) -AREA_EQUALIZER_MIN) <- 7];
+ index_offset -= 1;
+ }
+
+ if (events->mask > (AREA_EQUALIZER_MAX -(0 @ equalizer_mode_local))) {
+ reference_point_right = events->equalizer_display[AREA_EQUALIZER_MAX -AREA_EQUALIZER_MIN];
+ index_end = (((0 @ equalizer_mode_local) -(AREA_EQUALIZER_MAX -events->mask)) <- 4) -1;
+ } else {
+ reference_point_right = events->equalizer_display[(events->mask + (0 @ equalizer_mode_local) -AREA_EQUALIZER_MIN) <- 7];
+ index_end = 0;
+ }
+ events->locked_display = FALSE;
+
+ for (; index_offset != index_end; index_offset--) {
+ unsigned 11 average_bar;
+ unsigned 7 equalizer_index;
+ unsigned 4 bar_index;
+
+ if (index_offset == equalizer_mode_local) {
+ reference_point = reference_point_right;
+ } else {
+ delay;
+ }
+
+ if (index_offset > equalizer_mode_local)
+ {
+ bar_index = (index_offset -equalizer_mode_local);
+ equalizer_index = ((events->mask -(0 @ bar_index) -AREA_EQUALIZER_MIN) <- 7);
+ } else
+ {
+ bar_index = (equalizer_mode_local -index_offset);
+ equalizer_index = ((events->mask +(0 @ bar_index) -AREA_EQUALIZER_MIN) <- 7);
+ }
+
+ if (reference_point > mousedata->y) {
+ average_bar = mousedata->y +((reference_point -mousedata->y) >> (equalizer_mode_local -bar_index));
+ } else {
+ average_bar = mousedata->y -((mousedata->y -reference_point) >> (equalizer_mode_local -bar_index));
+ }
+
+ events->locked_display = TRUE;
+ equalizer_levels.write[preset_offset +(0 @ equalizer_index)] = equalizer_table[(average_bar -382) <- 10];
+ events->equalizer_display[equalizer_index] = average_bar;
+ events->locked_display = FALSE;
+ }
+ }
+ } else {
+ delay;
+ }
+
+ if (BUTTON_DEMO != events->mask) {
+ events->button_demo_state = FALSE;
+ }
+ if (BUTTON_RESET != events->mask) {
+ events->button_reset_state = FALSE;
}
- break;
-
- case MOUSE_STATE_ON_RELEASE:
- events->button_demo_state = FALSE;
+ if (BUTTON_NEXT_TRACK != events->mask) {
+ events->next_track_state = FALSE;
+ }
+
+ if (BUTTON_PREV_TRACK != events->mask) {
+ events->prev_track_state = FALSE;
+ }
+
+ break;
+
+ case MOUSE_STATE_ON_RELEASE:
+ events->button_demo_state = FALSE;
events->button_reset_state = FALSE;
- break;
-
- default:
- break;
- }
- }
- }
-} /* --- eventhandler_main() --- */
-
-
-
-/*
- * Volume Control lookuptable.
- * TODO: This table is now hardcoded. To ensure full skinability this table
- * should be dynamically loaded.
- */
-ram 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};
-ram unsigned 11 volumecontrol_table_inv[32] = {111, 110, 108, 106, 105, 103, 102, 100, 99, 97, 96, 94, 93, 91, 90, 88, 87, 85, 84, 82, 81, 79, 78, 76, 75, 73, 72, 70, 69, 67, 66};
-
-ram unsigned 4 inputgain_table[46] = {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, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0};
-ram unsigned 11 inputgain_table_inv[16] = {111, 108, 105, 102, 99, 96, 93, 90, 87, 84, 81, 78, 75, 72, 69, 66};
+ events->next_track_state = FALSE;
+ events->prev_track_state = FALSE;
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+} /* --- eventhandler_main() --- */
+
+
+
+/*
+ * Volume Control lookuptable.
+ * TODO: This table is now hardcoded. To ensure full skinability this table
+ * should be dynamically loaded.
+ */
+ram 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};
+ram unsigned 11 volumecontrol_table_inv[32] = {111, 110, 108, 106, 105, 103, 102, 100, 99, 97, 96, 94, 93, 91, 90, 88, 87, 85, 84, 82, 81, 79, 78, 76, 75, 73, 72, 70, 69, 67, 66};
+
+ram unsigned 4 inputgain_table[46] = {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, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0};
+ram unsigned 11 inputgain_table_inv[16] = {111, 108, 105, 102, 99, 96, 93, 90, 87, 84, 81, 78, 75, 72, 69, 66};
diff --git a/Graphic_Equalizer/src/smartmedia.hcc b/Graphic_Equalizer/src/smartmedia.hcc
index f02b8bc..371d0bf 100644
--- a/Graphic_Equalizer/src/smartmedia.hcc
+++ b/Graphic_Equalizer/src/smartmedia.hcc
@@ -38,6 +38,19 @@
unsigned 1 physical_format;
+unsigned 2 current_track;
+
+static rom unsigned 27 track_start[4] = {
+ SMARTMEDIA_ADDRESS_TRACK1_START,
+ SMARTMEDIA_ADDRESS_TRACK2_START,
+ SMARTMEDIA_ADDRESS_TRACK3_START
+};
+
+static rom unsigned 27 track_end[4] = {
+ SMARTMEDIA_ADDRESS_TRACK1_END,
+ SMARTMEDIA_ADDRESS_TRACK2_END,
+ SMARTMEDIA_ADDRESS_TRACK3_END
+};
/*! \fn unsigned 1 smartmedia_init(void);
* \brief We here initialize the Smart Media card and verify wether the
@@ -68,7 +81,8 @@ inline unsigned 1 smartmedia_init(void) {
* of the SMC. This to ensure we use the correct functions later.
*/
RC200SmartMediaCheckLogicalFormat(&physical_format);
-
+
+ current_track = 0;
return retval;
} /* --- smartmedia_init() --- */
@@ -108,7 +122,7 @@ void smartmedia_loaddata(skindata_t *skindata) {
* We have several stages to go through. We stop once we pass the last
* one.
*/
- while ((STAGE_LOAD_ABOUT_BOTTOM +1) != stage) {
+ while ((STAGE_LOAD_AUDIO_PLAYER +1) != stage) {
/*
* For each iteration of the main loop we set a different
* start and end variables.
@@ -171,6 +185,12 @@ void smartmedia_loaddata(skindata_t *skindata) {
address = ADDRESS_ABOUT_BOTTOM_START;
address_end = ADDRESS_ABOUT_BOTTOM_END;
break;
+
+ case STAGE_LOAD_AUDIO_PLAYER:
+ sm_address = SMARTMEDIA_ADDRESS_AUDIO_PLAYER_START;
+ address = ADDRESS_AUDIO_PLAYER_START;
+ address_end = ADDRESS_AUDIO_PLAYER_END;
+ break;
default:
break;
}
@@ -281,7 +301,12 @@ void smartmedia_loaddata(skindata_t *skindata) {
*/
stage++;
}
-
+ if (physical_format)
+ {
+ RC200SmartMediaSetAddress(READ, 0);
+ } else {
+ RC200SmartMediaSetLogicalAddress(READ, 0);
+ }
/*
* TODO: This block needs to move up into the loop where we calculate
* these settings determind by the image data.
@@ -325,7 +350,21 @@ smartmedia_load_block() {
end();
}*/
-
+void change_track(unsigned 2 track_index)
+{
+ current_track = track_index;
+}
+
+void empty_buffers(signed 18 *buffer, unsigned 7 buffer_size)
+{
+ unsigned 7 buffer_index;
+ buffer_index = 0;
+ while(buffer_index != buffer_size)
+ {
+ buffer[buffer_index] = 0;
+ buffer_index++;
+ }
+}
unsigned 1 load_audio_samples(signed 18 *samples, unsigned 27 blockoffset, unsigned 7 sample_count) {
ram unsigned 8 data[128];
@@ -339,7 +378,7 @@ unsigned 1 load_audio_samples(signed 18 *samples, unsigned 27 blockoffset, unsig
retval = 0;
if (!blockoffset) {
- smartmedia_set_read_address(SMARTMEDIA_ADDRESS_AUDIO_START)
+ smartmedia_set_read_address(track_start[current_track]);
}
smartmedia_read_bytes(data, samplecount);
@@ -351,13 +390,13 @@ unsigned 1 load_audio_samples(signed 18 *samples, unsigned 27 blockoffset, unsig
sampleindex +=2;
}
- if (((blockoffset <<7) +(0 @ samplecount) +SMARTMEDIA_ADDRESS_AUDIO_START) >= SMARTMEDIA_ADDRESS_AUDIO_END) {
+ if (((blockoffset <<7) +(0 @ samplecount) +track_start[current_track]) >= track_end[current_track]) {
retval = 1;
}
return retval;
}
-void smartmedia_set_read_address(unsigned 20 address)
+void smartmedia_set_read_address(unsigned 27 address)
{
unsigned 8 dummy;
unsigned 1 result;