RingToneComposeEngine.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:222k
源码类别:
MTK
开发平台:
C/C++
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * RingToneComposeEngine.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * This file implements the tone editor screen related functionalities of Ring Tone Composer.
- *
- * Author:
- * -------
- * -------
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- /**
- * Copyright Notice
- * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
- * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
- * (It is illegal to remove this copyright notice from this software or any
- * portion of it)
- **/
- /**************************************************************
- FILENAME : RingToneComposerEngine.c
- PURPOSE :
- REMARKS : nil
- AUTHOR : Vikram
- DATE :
- **************************************************************/
- #include "MMI_features.h"
- #if defined(__MMI_RING_COMPOSER__) && defined(__MMI_IMELODY_SUPPORT__)
- #include "GlobalConstants.h"
- #include "GlobalDefs.h"
- #include "gui.h"
- #include "HistoryGprot.h"
- #include "Unicodexdcl.h"
- #include "ComposeRingToneEngineProts.h"
- #include "FileSystemDef.h"
- #include "wgui_categories.h"
- #include "gui_data_types.h"
- #include "Asciiprot.h"
- #include "ComposeRingToneDefs.h"
- #include "TimerEvents.h"
- #include "SettingProfile.h"
- #include "DownloadDefs.h"
- #include "FileSystemGProt.h"
- #include "CustDataProts.h"
- #include "ComposeRingToneProts.h"
- #include "gpioInc.h"
- #include "ProfileGprots.h"
- #include "mdi_datatype.h"
- #include "mdi_audio.h"
- #include "FileManagerDef.h"
- #include "CommonScreens.h"
- #include "KeyBrd.h"
- #include "fs_type.h"
- #include "FS_Func.h"
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- #include "PixtelDataTypes.h"
- #include "TouchScreenGprot.h"
- #include "gui_buttons.h"
- #include "wgui_softkeys.h"
- #include "ScrMemMgrGprot.h" /* screen memeory manager */
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- #if defined(__MMI_TOUCH_RING_COMPOSER__) || defined(__MMI_MAINLCD_240X320__)
- #include "DebugInitDef.h"
- #endif
- #ifdef MMI_ON_HARDWARE_P
- #ifdef __DRM_SUPPORT__
- #include "drm_gprot.h"
- #endif
- #endif /* MMI_ON_HARDWARE_P */
- /*
- * Define
- */
- #define MULTITAP_TIME 1000
- /* iMelody header/tailer */
- #define MELODY_HEADER "BEGIN:IMELODYrnVERSION:1.2rnFORMAT:CLASS1.0rn"
- #define MELODY_END "rnEND:IMELODYrn"
- /* mask for musical note */
- #define NOTE_MASK 0x0000000F /* symbol of musical note */
- #define CLEAR_NOTE_MASK 0xFFFFFFF0
- #define DURATION_MASK 0x00001E00 /* beat length */
- #define CLEAR_DURATION_MASK 0xFFFFE1FF
- #define CLEAR_NOTETYPE_MASK 0xFFFFFFCF
- #define NOTETYPE_MASK 0x00000030 /* sharp, normal, flat */
- #define OCTAVE_MASK 0x000001C0 /* octave */
- /* UI related */
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- #define RNGC_X_POS_BASED 25
- #define RNGC_X_POS_OFFSET 20
- #else /* __MMI_TOUCH_RING_COMPOSER__ */
- #define RNGC_X_POS_BASED 25
- #define RNGC_X_POS_OFFSET 20
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- #if defined ( __MMI_MAINLCD_128X128__)
- #define BKG_IMG_Y1 27 /* y-coordinate based of musical notes */
- #define NOTE_BAR_HEIGHT 9 /* the height to display remaining number of notes */
- #define RNGC_NOTE_OFFSET BKG_IMG_Y1
- #define RNGC_EFFECT_NOTE_OFFSET (BKG_IMG_Y1+14)
- #elif defined (__MMI_MAINLCD_128X160__)
- #define BKG_IMG_Y1 29 /* y-coordinate based of musical notes */
- #define NOTE_BAR_HEIGHT 10 /* the height to display remaining number of notes */
- #define RNGC_NOTE_OFFSET (BKG_IMG_Y1+8)
- #define RNGC_EFFECT_NOTE_OFFSET (BKG_IMG_Y1+14+8)
- #elif defined( __MMI_MAINLCD_176X220__) /* || defined(__MMI_MAINLCD_240X320__)//041205 Calvin modified */
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- #define BKG_IMG_Y1 52
- #define NOTE_BAR_HEIGHT 11 /* the height to display remaining number of notes */
- #define RNGC_NOTE_OFFSET (BKG_IMG_Y1+6)
- #define RNGC_EFFECT_NOTE_OFFSET (BKG_IMG_Y1+4+6)
- #else /* __MMI_TOUCH_RING_COMPOSER__ */
- #define BKG_IMG_Y1 52
- #define NOTE_BAR_HEIGHT 11 /* the height to display remaining number of notes */
- #define RNGC_NOTE_OFFSET (BKG_IMG_Y1+8)
- #define RNGC_EFFECT_NOTE_OFFSET (BKG_IMG_Y1+14+8)
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- /* [~PMT MANISH 20050614 */
- #elif defined(__MMI_MAINLCD_240X320__)
- #define BKG_IMG_Y1 (108)
- #define NOTE_BAR_HEIGHT (18) /* the height to display remaining number of notes */
- #define RNGC_NOTE_OFFSET (BKG_IMG_Y1+13)
- #define RNGC_EFFECT_NOTE_OFFSET (BKG_IMG_Y1+8+13)
- #define MMI_RNGC_INSTRUMENT_SELECT_HEIGHT (39)
- /* ~] */
- #else
- #define BKG_IMG_Y1 27 /* y-coordinate based of musical notes */
- #define NOTE_BAR_HEIGHT 9 /* the height to display remaining number of notes */
- #define RNGC_NOTE_OFFSET (BKG_IMG_Y1+21)
- #define RNGC_EFFECT_NOTE_OFFSET (BKG_IMG_Y1+14+21)
- #endif
- #define RNGC_MAX_FILE_LEN 2048
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- #define RNGC_NOTE_SELECTION_FINAL 0x0001
- #define RNGC_SHOW_SELECTION_AREA 0x0002
- #define RNGC_SELECTION_AREA_REDRAW 0x0004
- #define RNGC_PEN_EVENT_UP 0x0008
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- /*
- * Typedef
- */
- /*
- * Local Variable
- */
- MMI_BOOL CurrentNodePlaying = MMI_FALSE;
- /*
- * Local Function
- */
- /*
- * Global Variable
- */
- rngc_engine_context_struct *g_rngc_eng_cntx;
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- touch_rngc_struct touch_rngc_context;
- rngc_selection_area_layout_struct const *selection_area_context;
- S32 rngc_pen_event_on_object = RNGC_PEN_NONE;
- const UI_filled_area touch_rngc_color_key_filler = {UI_FILLED_AREA_TYPE_COLOR | UI_FILLED_AREA_SHADOW,
- UI_NULL_IMAGE,
- NULL,
- {128, 255, 255, 100},
- {0, 0, 0, 0},
- {0, 0, 0, 100},
- {50, 50, 50, 100},
- 0
- };
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- /* MTK Elvis for R2L characters */
- extern BOOL r2lMMIFlag;
- /* MTk end */
- /*
- * Global Function
- */
- const UI_filled_area lightblue_color_dialog_background = {UI_FILLED_AREA_TYPE_COLOR,
- UI_NULL_IMAGE,
- NULL,
- {108, 182, 255, 100},
- {0, 0, 0, 0},
- {0, 0, 0, 100},
- {50, 50, 50, 100},
- 0
- };
- /* [~PMT MANISH 20050617 */
- #ifdef __MMI_MAINLCD_240X320__
- const UI_filled_area rngc_instrument_select_background = {UI_FILLED_AREA_TYPE_COLOR,
- UI_NULL_IMAGE,
- NULL,
- {215, 215, 215, 100},
- {0, 0, 0, 0},
- {0, 0, 0, 100},
- {0, 0, 0, 0},
- 0
- };
- #endif /* __MMI_MAINLCD_240X320__ */
- /* ~] */
- #define SetVibrationOff() {g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&=CLEAR_NOTE_MASK;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=NOTE_VIBRATION_OFF;}
- #define SetVibrationOn() {g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&=CLEAR_NOTE_MASK;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=NOTE_VIBRATION_ON;}
- #define SetLEDOff() {g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&=CLEAR_NOTE_MASK;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=NOTE_LED_OFF;}
- #define SetLEDOn() {g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&=CLEAR_NOTE_MASK;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=NOTE_LED_ON;}
- #define SetBackLightOff() {g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&=CLEAR_NOTE_MASK;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=NOTE_BACKLIGHT_OFF;}
- #define SetBackLightOn() {g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&=CLEAR_NOTE_MASK;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=NOTE_BACKLIGHT_ON;}
- #define SetNoteType(nType) {g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&=CLEAR_NOTETYPE_MASK;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=nType;}
- #define SetOctave(nType) {g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&=~OCTAVE_MASK;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=nType;}
- #define IncrementNoteBeat() {
- S32 nTempVal;
- nTempVal=g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&DURATION_MASK;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&=CLEAR_DURATION_MASK;
- if(nTempVal >= DURATION_1BY16)
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=DURATION_3BY2;
- else
- {
- nTempVal=nTempVal>>9;
- ++nTempVal;
- nTempVal=nTempVal<<9;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=nTempVal;
- }
- }
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- #define TouchRngcDecrementNoteBeat() {
- S32 nTempVal;
- nTempVal=g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&DURATION_MASK;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&=CLEAR_DURATION_MASK;
- if(nTempVal <= DURATION_3BY2)
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=DURATION_1BY16;
- else
- {
- nTempVal=nTempVal>>9;
- --nTempVal;
- nTempVal=nTempVal<<9;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=nTempVal;
- }
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- #define IncrementRestBeat() {
- S32 nTempVal;
- nTempVal=g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&DURATION_MASK;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]&=CLEAR_DURATION_MASK;
- if(nTempVal >= DURATION_1BY16)
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=DURATION_3BY8;
- else
- {
- nTempVal=nTempVal>>9;
- ++nTempVal;
- nTempVal=nTempVal<<9;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]|=nTempVal;
- }
- }
- /* vandana UI code */
- // declare this struct in the function calling the entry for Composer engine
- // Also allocate the memory there only.
- /* [~PMT MANISH 20050614 */
- #if defined(__MMI_MAINLCD_176X220__) && defined(__MMI_TOUCH_RING_COMPOSER__)
- const U8 gnYCoords[] =
- {
- 45 + RNGC_NOTE_OFFSET,
- 54 + RNGC_NOTE_OFFSET,
- 51 + RNGC_NOTE_OFFSET,
- 48 + RNGC_NOTE_OFFSET,
- 45 + RNGC_NOTE_OFFSET,
- 42 + RNGC_NOTE_OFFSET,
- 39 + RNGC_NOTE_OFFSET,
- 24 + RNGC_NOTE_OFFSET,
- 21 + RNGC_NOTE_OFFSET,
- 18 + RNGC_NOTE_OFFSET,
- 15 + RNGC_NOTE_OFFSET,
- 12 + RNGC_NOTE_OFFSET,
- 9 + RNGC_NOTE_OFFSET,
- 6 + RNGC_NOTE_OFFSET,
- 15 + RNGC_NOTE_OFFSET,
- 12 + RNGC_NOTE_OFFSET,
- 9 + RNGC_NOTE_OFFSET,
- 6 + RNGC_NOTE_OFFSET,
- 3 + RNGC_NOTE_OFFSET,
- 0 + RNGC_NOTE_OFFSET,
- RNGC_NOTE_OFFSET - 3,
- 21 + RNGC_NOTE_OFFSET,
- 22 + RNGC_NOTE_OFFSET,
- 22 + RNGC_NOTE_OFFSET,
- 8 + RNGC_NOTE_OFFSET
- };
- #elif defined( __MMI_MAINLCD_176X220__) /* || defined(__MMI_MAINLCD_240X320__)//041205 Calvin modified */
- const U8 gnYCoords[] =
- {
- 59 + RNGC_NOTE_OFFSET,
- 68 + RNGC_NOTE_OFFSET,
- 65 + RNGC_NOTE_OFFSET,
- 62 + RNGC_NOTE_OFFSET,
- 59 + RNGC_NOTE_OFFSET,
- 56 + RNGC_NOTE_OFFSET,
- 53 + RNGC_NOTE_OFFSET,
- 38 + RNGC_NOTE_OFFSET,
- 35 + RNGC_NOTE_OFFSET,
- 32 + RNGC_NOTE_OFFSET,
- 29 + RNGC_NOTE_OFFSET,
- 26 + RNGC_NOTE_OFFSET,
- 23 + RNGC_NOTE_OFFSET,
- 20 + RNGC_NOTE_OFFSET,
- 29 + RNGC_NOTE_OFFSET,
- 26 + RNGC_NOTE_OFFSET,
- 23 + RNGC_NOTE_OFFSET,
- 20 + RNGC_NOTE_OFFSET,
- 17 + RNGC_NOTE_OFFSET,
- 14 + RNGC_NOTE_OFFSET,
- 11 + RNGC_NOTE_OFFSET,
- 21 + RNGC_NOTE_OFFSET,
- 22 + RNGC_NOTE_OFFSET,
- 22 + RNGC_NOTE_OFFSET,
- 8 + RNGC_NOTE_OFFSET
- };
- #elif defined(__MMI_MAINLCD_240X320__)
- const U8 gnYCoords[] =
- {
- 49 + RNGC_NOTE_OFFSET,
- 59 + RNGC_NOTE_OFFSET,
- 56 + RNGC_NOTE_OFFSET,
- 53 + RNGC_NOTE_OFFSET,
- 50 + RNGC_NOTE_OFFSET,
- 47 + RNGC_NOTE_OFFSET,
- 44 + RNGC_NOTE_OFFSET,
- 29 + RNGC_NOTE_OFFSET,
- 26 + RNGC_NOTE_OFFSET,
- 23 + RNGC_NOTE_OFFSET,
- 20 + RNGC_NOTE_OFFSET,
- 17 + RNGC_NOTE_OFFSET,
- 14 + RNGC_NOTE_OFFSET,
- 11 + RNGC_NOTE_OFFSET,
- 20 + RNGC_NOTE_OFFSET,
- 17 + RNGC_NOTE_OFFSET,
- 14 + RNGC_NOTE_OFFSET,
- 11 + RNGC_NOTE_OFFSET,
- 8 + RNGC_NOTE_OFFSET,
- 5 + RNGC_NOTE_OFFSET,
- 2 + RNGC_NOTE_OFFSET,
- 21 + RNGC_NOTE_OFFSET,
- 22 + RNGC_NOTE_OFFSET,
- 22 + RNGC_NOTE_OFFSET,
- 8 + RNGC_NOTE_OFFSET
- };
- /* ~] */
- #else
- const U8 gnYCoords[] =
- {
- 54 + RNGC_NOTE_OFFSET,
- 51 + RNGC_NOTE_OFFSET,
- 48 + RNGC_NOTE_OFFSET,
- 45 + RNGC_NOTE_OFFSET,
- 42 + RNGC_NOTE_OFFSET,
- 39 + RNGC_NOTE_OFFSET,
- 36 + RNGC_NOTE_OFFSET,
- 33 + RNGC_NOTE_OFFSET,
- 30 + RNGC_NOTE_OFFSET,
- 27 + RNGC_NOTE_OFFSET,
- 24 + RNGC_NOTE_OFFSET,
- 21 + RNGC_NOTE_OFFSET,
- 18 + RNGC_NOTE_OFFSET,
- 15 + RNGC_NOTE_OFFSET,
- 24 + RNGC_NOTE_OFFSET,
- 21 + RNGC_NOTE_OFFSET,
- 18 + RNGC_NOTE_OFFSET,
- 14 + RNGC_NOTE_OFFSET,
- 12 + RNGC_NOTE_OFFSET,
- 9 + RNGC_NOTE_OFFSET,
- 6 + RNGC_NOTE_OFFSET,
- 21 + RNGC_NOTE_OFFSET,
- 22 + RNGC_NOTE_OFFSET,
- 22 + RNGC_NOTE_OFFSET,
- 8 + RNGC_NOTE_OFFSET
- };
- #endif
- const NoteInfo gNotesList[] =
- {
- {DURATION_3BY2 | OCTAVE_3 | NORMAL, IMG_3BY2_OCT_L_M_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY2 | OCTAVE_3 | FLAT, IMG_3BY2_OCT_L_M_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY2 | OCTAVE_3 | SHARP, IMG_3BY2_OCT_L_M_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY2 | OCTAVE_5 | NORMAL, IMG_3BY2_OCT_U_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY2 | OCTAVE_5 | FLAT, IMG_3BY2_OCT_U_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY2 | OCTAVE_5 | SHARP, IMG_3BY2_OCT_U_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1 | OCTAVE_3 | NORMAL, IMG_1_OCT_L_M_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1 | OCTAVE_3 | FLAT, IMG_1_OCT_L_M_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1 | OCTAVE_3 | SHARP, IMG_1_OCT_L_M_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1 | OCTAVE_5 | NORMAL, IMG_1_OCT_U_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1 | OCTAVE_5 | FLAT, IMG_1_OCT_U_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1 | OCTAVE_5 | SHARP, IMG_1_OCT_U_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY4 | OCTAVE_3 | NORMAL, IMG_3BY4_OCT_L_M_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY4 | OCTAVE_3 | FLAT, IMG_3BY4_OCT_L_M_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY4 | OCTAVE_3 | SHARP, IMG_3BY4_OCT_L_M_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY4 | OCTAVE_5 | NORMAL, IMG_3BY4_OCT_U_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY4 | OCTAVE_5 | FLAT, IMG_3BY4_OCT_U_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY4 | OCTAVE_5 | SHARP, IMG_3BY4_OCT_U_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY2 | OCTAVE_3 | NORMAL, IMG_1BY2_OCT_L_M_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY2 | OCTAVE_3 | FLAT, IMG_1BY2_OCT_L_M_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY2 | OCTAVE_3 | SHARP, IMG_1BY2_OCT_L_M_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY2 | OCTAVE_5 | NORMAL, IMG_1BY2_OCT_U_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY2 | OCTAVE_5 | FLAT, IMG_1BY2_OCT_U_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY2 | OCTAVE_5 | SHARP, IMG_1BY2_OCT_U_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY8 | OCTAVE_3 | NORMAL, IMG_3BY8_OCT_L_M_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY8 | OCTAVE_3 | FLAT, IMG_3BY8_OCT_L_M_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY8 | OCTAVE_3 | SHARP, IMG_3BY8_OCT_L_M_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY8 | OCTAVE_5 | NORMAL, IMG_3BY8_OCT_U_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY8 | OCTAVE_5 | FLAT, IMG_3BY8_OCT_U_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY8 | OCTAVE_5 | SHARP, IMG_3BY8_OCT_U_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY4 | OCTAVE_3 | NORMAL, IMG_1BY4_OCT_L_M_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY4 | OCTAVE_3 | FLAT, IMG_1BY4_OCT_L_M_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY4 | OCTAVE_3 | SHARP, IMG_1BY4_OCT_L_M_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY4 | OCTAVE_5 | NORMAL, IMG_1BY4_OCT_U_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY4 | OCTAVE_5 | FLAT, IMG_1BY4_OCT_U_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY4 | OCTAVE_5 | SHARP, IMG_1BY4_OCT_U_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY16 | OCTAVE_3 | NORMAL, IMG_3BY16_OCT_L_M_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY16 | OCTAVE_3 | FLAT, IMG_3BY16_OCT_L_M_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY16 | OCTAVE_3 | SHARP, IMG_3BY16_OCT_L_M_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY16 | OCTAVE_5 | NORMAL, IMG_3BY16_OCT_U_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY16 | OCTAVE_5 | FLAT, IMG_3BY16_OCT_U_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY16 | OCTAVE_5 | SHARP, IMG_3BY16_OCT_U_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY8 | OCTAVE_3 | NORMAL, IMG_1BY8_OCT_L_M_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY8 | OCTAVE_3 | FLAT, IMG_1BY8_OCT_L_M_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY8 | OCTAVE_3 | SHARP, IMG_1BY8_OCT_L_M_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY8 | OCTAVE_5 | NORMAL, IMG_1BY8_OCT_U_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY8 | OCTAVE_5 | FLAT, IMG_1BY8_OCT_U_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY8 | OCTAVE_5 | SHARP, IMG_1BY8_OCT_U_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY32 | OCTAVE_3 | NORMAL, IMG_3BY32_OCT_L_M_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY32 | OCTAVE_3 | FLAT, IMG_3BY32_OCT_L_M_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY32 | OCTAVE_3 | SHARP, IMG_3BY32_OCT_L_M_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY32 | OCTAVE_5 | NORMAL, IMG_3BY32_OCT_U_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY32 | OCTAVE_5 | FLAT, IMG_3BY32_OCT_U_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY32 | OCTAVE_5 | SHARP, IMG_3BY32_OCT_U_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY16 | OCTAVE_3 | NORMAL, IMG_1BY16_OCT_L_M_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY16 | OCTAVE_3 | FLAT, IMG_1BY16_OCT_L_M_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY16 | OCTAVE_3 | SHARP, IMG_1BY16_OCT_L_M_S - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY16 | OCTAVE_5 | NORMAL, IMG_1BY16_OCT_U_N - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY16 | OCTAVE_5 | FLAT, IMG_1BY16_OCT_U_F - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY16 | OCTAVE_5 | SHARP, IMG_1BY16_OCT_U_S - COMPOSE_RING_TONE_ENGINE_BASE},
- /********************Rest Notes********/
- {DURATION_3BY8 | OCTAVE_3, IMG_3BY8_OCT_L_M - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY4 | OCTAVE_3, IMG_1BY4_OCT_L_M - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY16 | OCTAVE_3, IMG_3BY16_OCT_L_M - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY8 | OCTAVE_3, IMG_1BY8_OCT_L_M - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_3BY32 | OCTAVE_3, IMG_3BY32_OCT_L_M - COMPOSE_RING_TONE_ENGINE_BASE},
- {DURATION_1BY16 | OCTAVE_3, IMG_1BY16_OCT_L_M - COMPOSE_RING_TONE_ENGINE_BASE},
- /*********************************Rest Notes End***************/
- };
- const PS8 gRngcMusicalNote[] =
- {
- "c", "d", "e", "f", "g", "a", "b", "r", "vibeon", "vibeoff", "ledon", "ledoff", "backon", "backoff"
- };
- const PS8 gRngcDuration[] =
- {
- "0.", "0", "1.", "1", "2.", "2", "3.", "3", "4.", "4"
- };
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- static const rngc_matrix_key_layout_struct normal_toolbar_matrix_layout =
- {
- 1, 1,
- 2, 7,
- RNGC_NOTE_SELECT_MATRIX_WIDTH, RNGC_NOTE_SELECT_MATRIX_HEIGHT,
- RNGC_MATRIX_KEY_WIDTH, RNGC_MATRIX_KEY_HEIGHT,
- {
- {IMG_TOUCH_RING_UP, TOUCH_IMG_1_OCT_L_M_N, TOUCH_IMG_1BY2_OCT_L_M_N, TOUCH_IMG_1BY4_OCT_L_M_N,
- TOUCH_IMG_1BY8_OCT_L_M_N, TOUCH_IMG_1BY16_OCT_L_M_N, IMG_RING_EVENTVIB_ON},
- {IMG_TOUCH_RING_DOWN, TOUCH_IMG_1BY4_OCT_L_M, TOUCH_IMG_1BY8_OCT_L_M, TOUCH_IMG_1BY16_OCT_L_M, IMG_TOUCH_RNGC_HASH,
- IMG_TOUCH_RING_P, IMG_TOUCH_RING_DOT},
- },
- {
- {GUI_RNGC_OCTAVE_UP, GUI_RNGC_KEY_NOTE1, GUI_RNGC_KEY_NOTE2, GUI_RNGC_KEY_NOTE3, GUI_RNGC_KEY_NOTE4,
- GUI_RNGC_KEY_NOTE5, NOTE_VIBRATION_ON},
- {GUI_RNGC_OCTAVE_DOWN, GUI_RNGC_KEY_NOTE6, GUI_RNGC_KEY_NOTE7, GUI_RNGC_KEY_NOTE8, GUI_RNGC_KEY_SHARP,
- GUI_RNGC_KEY_FLAT, GUI_RNGC_KEY_DOT},
- }
- };
- #if defined(__MMI_MAINLCD_176X220__) /* PMT MANISH 20050614 */
- static const rngc_custom_key_layout_struct normal_toolbar_custom_layout[] =
- {
- {1, 185, 34, 14, IMG_TOUCH_RING_EDIT, GUI_RNGC_KEY_EDIT},
- {36, 185, 45, 14, IMG_TOUCH_RING_INSERT, GUI_RNGC_KEY_INSERT},
- {82, 185, 45, 14, IMG_TOUCH_RING_PLAY, GUI_RNGC_KEY_PLAY},
- {128, 185, 23, 14, IMG_TOUCH_RING_PREV, GUI_RNGC_KEY_NEXT},
- {152, 185, 23, 14, IMG_TOUCH_RING_NEXT, GUI_RNGC_KEY_PREV}
- };
- /* [~PMT MANISH 20050614 */
- #elif defined(__MMI_MAINLCD_240X320__) /* 072505 Calvin modified */
- static const rngc_custom_key_layout_struct normal_toolbar_custom_layout[] =
- {
- {1, NORMAL_TOOLBAR_IMAGE_Y + 1, 57, NORMAL_TOOLBAR_HEIGHT - 2, IMG_TOUCH_RING_EDIT, GUI_RNGC_KEY_EDIT},
- {59, NORMAL_TOOLBAR_IMAGE_Y + 1, 52, NORMAL_TOOLBAR_HEIGHT - 2, IMG_TOUCH_RING_INSERT, GUI_RNGC_KEY_INSERT},
- {112, NORMAL_TOOLBAR_IMAGE_Y + 1, 59, NORMAL_TOOLBAR_HEIGHT - 2, IMG_TOUCH_RING_PLAY, GUI_RNGC_KEY_PLAY},
- {172, NORMAL_TOOLBAR_IMAGE_Y + 1, 33, NORMAL_TOOLBAR_HEIGHT - 2, IMG_TOUCH_RING_PREV, GUI_RNGC_KEY_NEXT},
- {206, NORMAL_TOOLBAR_IMAGE_Y + 1, 33, NORMAL_TOOLBAR_HEIGHT - 2, IMG_TOUCH_RING_NEXT, GUI_RNGC_KEY_PREV}
- };
- #else
- static const rngc_custom_key_layout_struct normal_toolbar_custom_layout[] =
- {
- {1, 185, 34, 14, IMG_TOUCH_RING_EDIT, GUI_RNGC_KEY_EDIT},
- {36, 185, 45, 14, IMG_TOUCH_RING_INSERT, GUI_RNGC_KEY_INSERT},
- {82, 185, 45, 14, IMG_TOUCH_RING_PLAY, GUI_RNGC_KEY_PLAY},
- {128, 185, 23, 14, IMG_TOUCH_RING_PREV, GUI_RNGC_KEY_NEXT},
- {152, 185, 23, 14, IMG_TOUCH_RING_NEXT, GUI_RNGC_KEY_PREV}
- };
- #endif
- /* ~] */
- const static rngc_selection_area_layout_struct normal_toolbar_layout =
- {
- 0,
- 5,
- NORMAL_TOOLBAR_IMAGE_X,
- NORMAL_TOOLBAR_IMAGE_Y,
- (rngc_matrix_key_layout_struct *) & normal_toolbar_matrix_layout,
- (rngc_custom_key_layout_struct *) normal_toolbar_custom_layout,
- 1,
- 0,
- IMG_TOUCH_RING_NORMAL
- };
- const static rngc_matrix_key_layout_struct note_selection_matrix_layout =
- {
- 1, 1,
- 2, 7,
- RNGC_NOTE_SELECT_MATRIX_WIDTH, RNGC_NOTE_SELECT_MATRIX_HEIGHT,
- RNGC_MATRIX_KEY_WIDTH, RNGC_MATRIX_KEY_HEIGHT,
- {
- {IMG_TOUCH_RING_UP, TOUCH_IMG_1_OCT_L_M_N, TOUCH_IMG_1BY2_OCT_L_M_N, TOUCH_IMG_1BY4_OCT_L_M_N,
- TOUCH_IMG_1BY8_OCT_L_M_N, TOUCH_IMG_1BY16_OCT_L_M_N, IMG_RING_EVENTVIB_ON},
- {IMG_TOUCH_RING_DOWN, TOUCH_IMG_1BY4_OCT_L_M, TOUCH_IMG_1BY8_OCT_L_M, TOUCH_IMG_1BY16_OCT_L_M, IMG_TOUCH_RNGC_HASH,
- IMG_TOUCH_RING_P, IMG_TOUCH_RING_DOT},
- },
- {
- {GUI_RNGC_OCTAVE_UP, GUI_RNGC_KEY_NOTE1, GUI_RNGC_KEY_NOTE2, GUI_RNGC_KEY_NOTE3, GUI_RNGC_KEY_NOTE4,
- GUI_RNGC_KEY_NOTE5, NOTE_VIBRATION_ON},
- {GUI_RNGC_OCTAVE_DOWN, GUI_RNGC_KEY_NOTE6, GUI_RNGC_KEY_NOTE7, GUI_RNGC_KEY_NOTE8, GUI_RNGC_KEY_SHARP,
- GUI_RNGC_KEY_FLAT, GUI_RNGC_KEY_DOT},
- }
- };
- /* Notice: If you want to change the button size, please remember to modify the memory size defined in ScrMemMgr.h */
- #if defined(__MMI_MAINLCD_176X220__) /* PMT MANISH 20050614 */
- static rngc_custom_key_layout_struct note_selection_custom_layout[] =
- {
- {134, 151, 18, 23, IMG_RING_EVENTBL_ON, NOTE_BACKLIGHT_ON},
- #ifdef __MMI_RING_COMPOSER_NO_LED__
- {153, 151, 22, 23, 0, NOTE_LED_ON},
- #else
- {153, 151, 22, 23, IMG_RING_EVENTLED_ON, NOTE_LED_ON},
- #endif
- {134, 175, 41, 23, IMG_TOUCH_RING_DOWN, GUI_RNGC_KEY_OK},
- };
- /* [~PMT MANISH 20050614 */
- #elif defined(__MMI_MAINLCD_240X320__)
- static rngc_custom_key_layout_struct note_selection_custom_layout[] =
- {
- {176, NOTE_SELECTION_IMAGE_Y + 1, 24, 31, IMG_RING_EVENTLED_ON, NOTE_LED_ON},
- {201, NOTE_SELECTION_IMAGE_Y + 1, 38, 31, IMG_RING_EVENTBL_ON, NOTE_BACKLIGHT_ON},
- {176, NOTE_SELECTION_IMAGE_Y + 34, 63, 31, IMG_TOUCH_RING_DOWN, GUI_RNGC_KEY_OK},
- };
- #else
- static rngc_custom_key_layout_struct note_selection_custom_layout[] =
- {
- {134, 152, 18, 23, IMG_RING_EVENTLED_ON, NOTE_LED_ON},
- {153, 152, 22, 23, IMG_RING_EVENTBL_ON, NOTE_BACKLIGHT_ON},
- {134, 176, 41, 23, IMG_TOUCH_RING_DOWN, GUI_RNGC_KEY_OK},
- };
- #endif
- /* ~] */
- static const rngc_selection_area_layout_struct note_selection_layout =
- {
- 14,
- 3,
- NOTE_SELECTION_IMAGE_X,
- NOTE_SELECTION_IMAGE_Y,
- (rngc_matrix_key_layout_struct *) & note_selection_matrix_layout,
- (rngc_custom_key_layout_struct *) note_selection_custom_layout,
- 1,
- #ifdef __MMI_MAINLCD_240X320__ /* 072505 Calvin modified */
- 2,
- #else
- 1,
- #endif
- IMG_TOUCH_RING_SELECTION
- };
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- /* 110805 ringtonecomposer Calvin Start */
- // #if defined(__MMI_TOUCH_RING_COMPOSER__) || defined(__MMI_MAINLCD_240X320__)
- /* static const U8 CurrentInstrument[]= */
- const U8 CurrentInstrument[] =
- {
- INSTR_PIANO,
- INSTR_GUITAR,
- INSTR_VIOLIN,
- INSTR_SPHONE,
- INSTR_SDRUMS,
- INSTR_FLUTE,
- INSTR_HARMONICA,
- INSTR_TRUMPET,
- INSTR_MUSICBOX,
- INSTR_XYLOPHONE
- };
- // #endif /* __MMI_TOUCH_RING_COMPOSER__) || defined(__MMI_MAINLCD_240X320__ */
- /* 110805 ringtonecomposer Calvin Start */
- #if defined(__MMI_TOUCH_RING_COMPOSER__)
- extern void mmi_rngc_finish_insert_editing(void);
- #endif
- /*****************************************************************************
- * FUNCTION
- * EntryRngcComposerEngine
- * DESCRIPTION
- * Entry function of editor screen in ring tone composer
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void EntryRngcComposerEngine(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *guiBuffer = NULL;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_DISABLED);
- /* first time of entering */
- if (g_rngc_eng_cntx == NULL)
- {
- g_rngc_eng_cntx = OslMalloc(sizeof(rngc_engine_context_struct));
- if (g_rngc_eng_cntx == NULL)
- {
- return;
- }
- EntryNewScreen(SCR_COMPOSER_ENGINE, ExitRngcComposerEngine, NULL, NULL);
- InitializeComposer();
- SetRingComposer(
- STR_RING_COMPOSE_TITLE,
- STR_GLOBAL_OPTIONS,
- IMG_GLOBAL_OPTIONS,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- g_rngc_cntx.CurrInstr,
- MAX_NOTES,
- guiBuffer);
- g_rngc_eng_cntx->CurrUIPos = 0;
- redraw_ringcomposer();
- }
- else
- {
- EntryNewScreen(SCR_COMPOSER_ENGINE, ExitRngcComposerEngine, NULL, NULL);
- SetRingComposer(
- STR_RING_COMPOSE_TITLE,
- STR_GLOBAL_OPTIONS,
- IMG_GLOBAL_OPTIONS,
- STR_GLOBAL_BACK,
- IMG_GLOBAL_BACK,
- g_rngc_cntx.CurrInstr,
- (MAX_NOTES - g_rngc_eng_cntx->TotalNotes),
- guiBuffer);
- if (g_rngc_eng_cntx->TotalNotes)
- {
- RedrawNotes();
- ChangeRightSoftkey(STR_GLOBAL_CLEAR, IMG_GLOBAL_CLEAR);
- }
- else
- {
- g_rngc_eng_cntx->CurrUIPos = 0;
- redraw_ringcomposer();
- }
- }
- mdi_audio_suspend_background_play();
- SetKeyHandler(HandleKey_0, KEY_0, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_1, KEY_1, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_2, KEY_2, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_3, KEY_3, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_4, KEY_4, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_5, KEY_5, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_6, KEY_6, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_7, KEY_7, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_8, KEY_8, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_9, KEY_9, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_STAR, KEY_STAR, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_POUND, KEY_POUND, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_UP, KEY_UP_ARROW, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_DOWN, KEY_DOWN_ARROW, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_LEFT, KEY_LEFT_ARROW, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_RIGHT, KEY_RIGHT_ARROW, KEY_EVENT_UP);
- SetKeyHandler(HandleKey_END, KEY_END, KEY_EVENT_DOWN);
- SetKeyHandler(HandleKey_CLEARLONG, KEY_RSK, KEY_LONG_PRESS);
- SetRightSoftkeyFunction(RngcComposerRSKUpHandler, KEY_EVENT_UP);
- SetRightSoftkeyFunction(RngcComposerRSKDownHandler, KEY_EVENT_DOWN);
- SetLeftSoftkeyFunction(EntryRngcCompToneOptList, KEY_EVENT_UP);
- }
- /*****************************************************************************
- * FUNCTION
- * ExitRngcComposerEngine
- * DESCRIPTION
- * Exit function of editor screen in ring tone composer
- * 1. Stop playing tone
- * 2. Reset IsKeyPadAudioDisable;
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void ExitRngcComposerEngine(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- history ScrComposer;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* 072505 Calvin Start */
- #ifdef __MMI_MAINLCD_240X320__
- #ifdef __MMI_UI_LIST_HIGHLIGHT_EFFECTS__
- gui_unblock_list_effect();
- #endif
- #endif /* __MMI_MAINLCD_240X320__ */
- /* 072505 Calvin End */
- StopTimer(NOTE_MULTITAP_TIMER);
- mdi_audio_stop_string();
- mdi_audio_resume_background_play();
- mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_ENABLED);
- ScrComposer.scrnID = SCR_COMPOSER_ENGINE;
- ScrComposer.entryFuncPtr = EntryRngcComposerEngine;
- pfnUnicodeStrcpy((S8*) ScrComposer.inputBuffer, (S8*) L"");
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- if (selection_area_context == ¬e_selection_layout)
- {
- selection_area_context->custom_keys[2].key_image = IMG_TOUCH_RING_DOWN;
- }
- selection_area_context = &normal_toolbar_layout;
- touch_rngc_context.area_type = GUI_RNGC_NORMAL_TOOLBAR;
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- AddHistory(ScrComposer);
- RedrawCategoryFunction = MMI_dummy_function;
- }
- /*****************************************************************************
- * FUNCTION
- * RngcClearStave
- * DESCRIPTION
- * Clear all notes in stave
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void RngcClearStave(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_rngc_eng_cntx->TotalNotes = 0;
- g_rngc_eng_cntx->CurrNoteIndex = 0;
- g_rngc_eng_cntx->CurrUIPos = 0;
- g_rngc_eng_cntx->IsRskLP = 0;
- memset(g_rngc_eng_cntx->NotesList, 0xFF, sizeof(g_rngc_eng_cntx->NotesList));
- }
- /*****************************************************************************
- * FUNCTION
- * RngcInitCursor
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void RngcInitCursor(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 i;
- S32 width, height;
- PU8 img;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* get the maximum size of cursor */
- g_rngc_eng_cntx->CursorWidth = 0;
- for (i = IMG_3BY2_OCT_L_M_N; i <= IMG_RING_EVENTVIB_OFF; i++)
- {
- img = (PU8) GetImage(i);
- gui_measure_image(img, &width, &height);
- if (g_rngc_eng_cntx->CursorWidth < width)
- {
- g_rngc_eng_cntx->CursorWidth = (U8) width;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * InitializeComposer
- * DESCRIPTION
- * This function is to reset state and global variables used in composed engine.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void InitializeComposer(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- RngcInitCursor();
- RngcClearStave();
- g_rngc_cntx.CurrSpeed = NORMAL_SPEED;
- g_rngc_cntx.CurrInstr = INSTR_PIANO;
- }
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- /*****************************************************************************
- * FUNCTION
- * mmi_touch_rngc_setup
- * DESCRIPTION
- *
- * PARAMETERS
- * touch_rngc_context [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_touch_rngc_setup(touch_rngc_struct *touch_rngc_context)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- touch_rngc_context->flag = 0;
- touch_rngc_context->flag |= RNGC_SELECTION_AREA_REDRAW;
- touch_rngc_context->mode = GUI_RNGC_VIEW;
- if (touch_rngc_context->play_mode != RNGC_PAUSE)
- {
- selection_area_context = &normal_toolbar_layout;
- touch_rngc_context->area_type = GUI_RNGC_NORMAL_TOOLBAR;
- }
- touch_rngc_context->play_mode = RNGC_PLAY;
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- /*****************************************************************************
- * FUNCTION
- * HandleKey_CLEARLONG
- * DESCRIPTION
- * Handler of long-pressed RSK.
- * 1. clear all notes and reset all state varilables.
- * 2. redraw screen and set RSK to Back
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_CLEARLONG(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_rngc_eng_cntx->TotalNotes != 0) /* not cleared yet */
- {
- RngcClearStave();
- g_rngc_eng_cntx->CurrUIPos = 0;
- RedrawNotes();
- ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
- g_rngc_eng_cntx->IsRskLP = 1;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * FreeMemory
- * DESCRIPTION
- * Free allocated memory to stored composed information
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void FreeMemory(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_rngc_eng_cntx)
- {
- OslMfree(g_rngc_eng_cntx);
- g_rngc_eng_cntx = NULL;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * RngcComposerRSKUpHandler
- * DESCRIPTION
- * Event handler of RSK up when composing ring tone
- * If there is no musical note and RSK is not long pressed, go back to previous screen
- * otherwise, reset state flag.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void RngcComposerRSKUpHandler(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_rngc_eng_cntx->TotalNotes == 0 && g_rngc_eng_cntx->IsRskLP == 0)
- {
- FreeMemory();
- StopTimer(NOTE_MULTITAP_TIMER);
- if (g_rngc_cntx.CurrEditState == ENUM_COMP_ADD)
- {
- GoBackToHistory(SCR_FMGR_EXPLORER);
- }
- else
- {
- GoBackHistory();
- }
- }
- else if (g_rngc_eng_cntx->IsRskLP == 1)
- {
- g_rngc_eng_cntx->IsRskLP = 0;
- }
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- if (touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT)
- {
- touch_rngc_context.mode = GUI_RNGC_INSERT;
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- }
- /*****************************************************************************
- * FUNCTION
- * RngcComposerRSKDownHandler
- * DESCRIPTION
- * Event handler of RSK down when composing ring tone
- * Delete one musical note.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void RngcComposerRSKDownHandler(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_rngc_eng_cntx->TotalNotes)
- {
- DeleteCurNote();
- /* change RSK to "Back" if there is no note */
- if (!g_rngc_eng_cntx->TotalNotes)
- {
- ChangeRightSoftkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);
- g_rngc_eng_cntx->IsRskLP = 1;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * DeleteCurNote
- * DESCRIPTION
- * Event handler of RSK down when composing ring tone
- * Delete one musical note.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void DeleteCurNote(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_rngc_eng_cntx->CurrNoteIndex < g_rngc_eng_cntx->TotalNotes)
- {
- /* highlight on the last one */
- if (g_rngc_eng_cntx->CurrNoteIndex == g_rngc_eng_cntx->TotalNotes - 1)
- {
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] = 0xFFFF;
- }
- else /* internal note */
- {
- memcpy(
- (g_rngc_eng_cntx->NotesList + g_rngc_eng_cntx->CurrNoteIndex),
- (g_rngc_eng_cntx->NotesList + (g_rngc_eng_cntx->CurrNoteIndex + 1)),
- (g_rngc_eng_cntx->TotalNotes - g_rngc_eng_cntx->CurrNoteIndex) * sizeof(U16));
- }
- --g_rngc_eng_cntx->TotalNotes;
- }
- else if (g_rngc_eng_cntx->CurrNoteIndex == g_rngc_eng_cntx->TotalNotes)
- {
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- g_rngc_eng_cntx->NotesList[--g_rngc_eng_cntx->CurrNoteIndex] = 0;
- #else
- g_rngc_eng_cntx->NotesList[--g_rngc_eng_cntx->CurrNoteIndex] = 0xFFFF;
- #endif
- --g_rngc_eng_cntx->TotalNotes;
- if (g_rngc_eng_cntx->TotalNotes < g_rngc_eng_cntx->CurrUIPos)
- {
- --g_rngc_eng_cntx->CurrUIPos;
- }
- }
- GDI_LOCK;
- RedrawNotes();
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- if (touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT || touch_rngc_context.mode == GUI_RNGC_INSERT)
- {
- mmi_rngc_finish_insert_editing();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- GDI_UNLOCK;
- }
- /*****************************************************************************
- * FUNCTION
- * RngcPlayCurrentNodeCallBack
- * DESCRIPTION
- *
- * PARAMETERS
- * result [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void RngcPlayCurrentNodeCallBack(mdi_result result)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- CurrentNodePlaying = MMI_FALSE;
- }
- /*****************************************************************************
- * FUNCTION
- * PlayCurrentNode
- * DESCRIPTION
- * Play iMelody stream of current input note
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void PlayCurrentNode(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- static U8 pCurrentNode[512]; /* because audio interface does not make a copy, we have to prepare a buffer */
- U8 pNoteString[10];
- U8 *temp;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifdef __MMI_SILENT_MEETING_PROFILE__
- if (IsMeetingModeActivated() || IsSilentModeActivated())
- if ((g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] & NOTE_MASK) < NOTE_REST)
- {
- return;
- }
- #endif /* __MMI_SILENT_MEETING_PROFILE__ */
- memset(pNoteString, 0, 10);
- temp = GetStringForNode(pNoteString, g_rngc_eng_cntx->CurrNoteIndex);
- *temp = 0;
- /* generate iMelody string */
- sprintf(
- (S8*) pCurrentNode,
- "%sCOMPOSER:MTK(%d)rnBEAT:%drnMELODY:",
- MELODY_HEADER,
- g_rngc_cntx.CurrInstr,
- g_rngc_cntx.CurrSpeed);
- strcat((S8*) & pCurrentNode, (S8*) pNoteString);
- strcat((S8*) pCurrentNode, (S8*) MELODY_END);
- if (mdi_audio_play_string
- ((void*)pCurrentNode, strlen((S8*) pCurrentNode), MDI_FORMAT_IMELODY, DEVICE_AUDIO_PLAY_ONCE, NULL,
- RngcPlayCurrentNodeCallBack) == MDI_AUDIO_SUCCESS)
- {
- CurrentNodePlaying = MMI_TRUE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * InsertNote
- * DESCRIPTION
- * Insert a note to screen accroding to current position
- * PARAMETERS
- * nNote [IN] Musical note symbol
- * RETURNS
- * void
- *****************************************************************************/
- void InsertNote(U16 nNote)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 nCount;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- StopTimer(NOTE_MULTITAP_TIMER);
- if (g_rngc_eng_cntx->TotalNotes >= MAX_NOTES)
- {
- return;
- }
- /* internal note */
- if (g_rngc_eng_cntx->CurrNoteIndex < g_rngc_eng_cntx->TotalNotes)
- {
- /* shift one note right */
- for (nCount = g_rngc_eng_cntx->TotalNotes; nCount > g_rngc_eng_cntx->CurrNoteIndex; --nCount)
- {
- g_rngc_eng_cntx->NotesList[nCount] = g_rngc_eng_cntx->NotesList[nCount - 1];
- }
- /* insert note */
- ++g_rngc_eng_cntx->CurrNoteIndex;
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] = nNote;
- /* increase total number of notes */
- ++g_rngc_eng_cntx->TotalNotes;
- if (g_rngc_eng_cntx->CurrUIPos < NUM_NOTES_IN_STAVE - 1)
- {
- ++g_rngc_eng_cntx->CurrUIPos;
- }
- PlayCurrentNode();
- RedrawNotes();
- }
- else /* last note */
- {
- /* insert note */
- g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] = nNote;
- /* increase total number of notes */
- ++g_rngc_eng_cntx->TotalNotes;
- if (g_rngc_eng_cntx->TotalNotes == 1)
- {
- change_right_softkey(STR_GLOBAL_CLEAR, IMG_GLOBAL_CLEAR);
- }
- PlayCurrentNode();
- ShowNote(g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]);
- }
- #if !defined (__MMI_TOUCH_RING_COMPOSER__)
- /* auto shift cursor if a note is insert at the end */
- if (g_rngc_eng_cntx->CurrNoteIndex == g_rngc_eng_cntx->TotalNotes - 1 ||
- g_rngc_eng_cntx->CurrNoteIndex == g_rngc_eng_cntx->TotalNotes)
- {
- StartTimer(NOTE_MULTITAP_TIMER, MULTITAP_TIME, (FuncPtr) HandleKey_RIGHT);
- }
- #endif /* !defined (__MMI_TOUCH_RING_COMPOSER__) */
- }
- /*****************************************************************************
- * FUNCTION
- * RedrawNotes
- * DESCRIPTION
- * This function is to redraw the stave
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void RedrawNotes(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 nFirstNoteIndex;
- S16 nEndNote;
- U16 nTemp;
- U16 nImageId = 0;
- U16 nCount = 0;
- U8 nYVal = 0;
- DisplayInfo sDisplayInfo[NUM_NOTES_IN_STAVE];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* get the first note to be drawed */
- nFirstNoteIndex = g_rngc_eng_cntx->CurrNoteIndex - g_rngc_eng_cntx->CurrUIPos;
- if (nFirstNoteIndex < 0)
- {
- nFirstNoteIndex = 0;
- }
- /* get the last note to be drawed */
- if (nFirstNoteIndex + NUM_NOTES_IN_STAVE >= g_rngc_eng_cntx->TotalNotes) /* tail */
- {
- nEndNote = g_rngc_eng_cntx->TotalNotes - 1;
- }
- else
- {
- nEndNote = (nFirstNoteIndex + NUM_NOTES_IN_STAVE) - 1;
- }
- for (nTemp = nFirstNoteIndex; nTemp <= nEndNote; ++nTemp)
- {
- GetIndexInList(g_rngc_eng_cntx->NotesList[nTemp], &nImageId, &nYVal);
- sDisplayInfo[nCount].nImageId = nImageId;
- sDisplayInfo[nCount].nXPos = (U8) nTemp;
- sDisplayInfo[nCount].nYPos = nYVal;
- ++nCount;
- }
- RefreshNotesList(nCount, (DisplayInfo*) sDisplayInfo);
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_0
- * DESCRIPTION
- * Key event handler of number keys
- * Insert corresponding musical note to stave
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_0(void)
- {
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT)
- {
- mmi_rngc_finish_insert_editing();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- InsertNote(NOTE_REST | DURATION_1BY4 | OCTAVE_4);
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_1
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_1(void)
- {
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT)
- {
- mmi_rngc_finish_insert_editing();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- InsertNote(NOTE_C | DURATION_1BY4 | OCTAVE_4 | NORMAL);
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_2
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_2(void)
- {
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT)
- {
- mmi_rngc_finish_insert_editing();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- InsertNote(NOTE_D | DURATION_1BY4 | OCTAVE_4 | NORMAL);
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_3
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_3(void)
- {
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT)
- {
- mmi_rngc_finish_insert_editing();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- InsertNote(NOTE_E | DURATION_1BY4 | OCTAVE_4 | NORMAL);
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_4
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_4(void)
- {
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT)
- {
- mmi_rngc_finish_insert_editing();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- InsertNote(NOTE_F | DURATION_1BY4 | OCTAVE_4 | NORMAL);
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_5
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_5(void)
- {
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT)
- {
- mmi_rngc_finish_insert_editing();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- InsertNote(NOTE_G | DURATION_1BY4 | OCTAVE_4 | NORMAL);
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_6
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_6(void)
- {
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT)
- {
- mmi_rngc_finish_insert_editing();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- InsertNote(NOTE_A | DURATION_1BY4 | OCTAVE_4 | NORMAL);
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_7
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_7(void)
- {
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT)
- {
- mmi_rngc_finish_insert_editing();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- InsertNote(NOTE_B | DURATION_1BY4 | OCTAVE_4 | NORMAL);
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_8
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_8(void)
- {
- #ifndef __MMI_RING_COMPOSER_NO_VIB__
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- if (touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT)
- {
- mmi_rngc_finish_insert_editing();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- InsertNote(NOTE_VIBRATION_ON);
- #endif /* __MMI_RING_COMPOSER_NO_VIB__ */
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_9
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_9(void)
- {
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT)
- {
- mmi_rngc_finish_insert_editing();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- #ifdef __MMI_RING_COMPOSER_NO_LED__
- InsertNote(NOTE_BACKLIGHT_ON);
- #else
- InsertNote(NOTE_LED_ON);
- #endif
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_END
- * DESCRIPTION
- *
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_END(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- FreeMemory();
- StopTimer(NOTE_MULTITAP_TIMER);
- DisplayIdleScreen();
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_STAR
- * DESCRIPTION
- * Start key handler
- * Change note duration/type according to highlighted note.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_STAR(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 nValue;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_rngc_eng_cntx->TotalNotes > MAX_NOTES)
- {
- return;
- }
- /* highlighted on empty position */
- if (g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] == 0xFFFF)
- {
- return;
- }
- StopTimer(NOTE_MULTITAP_TIMER);
- nValue = g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] & NOTE_MASK;
- switch (nValue)
- {
- #ifndef __MMI_RING_COMPOSER_NO_LED__
- case NOTE_LED_ON:
- SetBackLightOn()break;
- case NOTE_LED_OFF:
- SetBackLightOff()break;
- case NOTE_BACKLIGHT_ON:
- SetLEDOn()break;
- case NOTE_BACKLIGHT_OFF:
- SetLEDOff()break;
- #endif /* __MMI_RING_COMPOSER_NO_LED__ */
- case NOTE_C:
- case NOTE_D:
- case NOTE_E:
- case NOTE_F:
- case NOTE_G:
- case NOTE_A:
- case NOTE_B:
- IncrementNoteBeat()break;
- case NOTE_REST:
- IncrementRestBeat()break;
- default:
- #if 0
- /* under construction !*/
- #else
- return; /* vib/led/backlight, return. */
- #endif
- }
- PlayCurrentNode();
- ShowNote(g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]);
- if (g_rngc_eng_cntx->CurrNoteIndex == g_rngc_eng_cntx->TotalNotes - 1)
- {
- StartTimer(NOTE_MULTITAP_TIMER, MULTITAP_TIME, (FuncPtr) HandleKey_RIGHT);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_POUND
- * DESCRIPTION
- * Pound key handler
- * change flag/sharp/normal state of a musical note
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_POUND(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 nValue;
- U32 nNoteType;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_rngc_eng_cntx->TotalNotes > MAX_NOTES)
- {
- return;
- }
- if (g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] == 0xFFFF)
- {
- return;
- }
- StopTimer(NOTE_MULTITAP_TIMER);
- nValue = g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] & NOTE_MASK;
- nNoteType = g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] & NOTETYPE_MASK;
- switch (nValue)
- {
- case NOTE_C:
- case NOTE_F:
- if (nNoteType == NORMAL)
- SetNoteType(SHARP)
- else
- SetNoteType(NORMAL) break;
- case NOTE_D:
- case NOTE_G:
- case NOTE_A:
- if (nNoteType == NORMAL)
- SetNoteType(FLAT)
- else
- if (nNoteType == FLAT)
- SetNoteType(SHARP)
- else
- SetNoteType(NORMAL) break;
- case NOTE_B:
- case NOTE_E:
- if (nNoteType == NORMAL)
- SetNoteType(FLAT)
- else
- SetNoteType(NORMAL) break;
- default: /* other notes, pound key does not effect */
- #if 0
- /* under construction !*/
- #else
- return; /* vib/led/backlight, return. */
- #endif
- }
- PlayCurrentNode();
- ShowNote(g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]);
- if (g_rngc_eng_cntx->CurrNoteIndex == g_rngc_eng_cntx->TotalNotes - 1)
- {
- StartTimer(NOTE_MULTITAP_TIMER, MULTITAP_TIME, (FuncPtr) HandleKey_RIGHT);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_UP
- * DESCRIPTION
- * Up key handler
- * Change on/off for vibration/backlight/led notes
- * Change octave for musical notes
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_UP(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 nNoteOctave;
- U32 nValue;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_rngc_eng_cntx->TotalNotes > MAX_NOTES)
- {
- return;
- }
- if (g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] == 0xFFFF)
- {
- return;
- }
- StopTimer(NOTE_MULTITAP_TIMER);
- nValue = g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] & NOTE_MASK;
- nNoteOctave = g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] & OCTAVE_MASK;
- switch (nValue)
- {
- case NOTE_LED_OFF:
- SetLEDOn();
- break;
- case NOTE_BACKLIGHT_OFF:
- SetBackLightOn();
- break;
- case NOTE_VIBRATION_OFF:
- SetVibrationOn();
- break;
- case NOTE_REST:
- break;
- case NOTE_C:
- case NOTE_D:
- case NOTE_E:
- case NOTE_F:
- case NOTE_G:
- case NOTE_A:
- case NOTE_B:
- if (nNoteOctave == OCTAVE_3)
- SetOctave(OCTAVE_4)
- else
- if (nNoteOctave == OCTAVE_4)
- SetOctave(OCTAVE_5)
- else
- if (nNoteOctave == OCTAVE_5)
- SetOctave(OCTAVE_3) break;
- }
- PlayCurrentNode();
- ShowNote(g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]);
- /* after pressing up key should not move the cursor */
- #ifndef __MMI_TOUCH_RING_COMPOSER__
- if (g_rngc_eng_cntx->CurrNoteIndex == g_rngc_eng_cntx->TotalNotes - 1)
- {
- StartTimer(NOTE_MULTITAP_TIMER, MULTITAP_TIME, (FuncPtr) HandleKey_RIGHT);
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_DOWN
- * DESCRIPTION
- * Up key handler
- * Change on/off for vibration/backlight/led notes
- * Change octave for musical notes
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_DOWN(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 nNoteOctave;
- U32 nValue;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (g_rngc_eng_cntx->TotalNotes > MAX_NOTES)
- {
- return;
- }
- if (g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] == 0xFFFF)
- {
- return;
- }
- StopTimer(NOTE_MULTITAP_TIMER);
- nValue = g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] & NOTE_MASK;
- nNoteOctave = g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] & OCTAVE_MASK;
- switch (nValue)
- {
- case NOTE_LED_ON:
- SetLEDOff();
- break;
- case NOTE_BACKLIGHT_ON:
- SetBackLightOff();
- break;
- case NOTE_VIBRATION_ON:
- SetVibrationOff();
- break;
- case NOTE_REST:
- break;
- case NOTE_C:
- case NOTE_D:
- case NOTE_E:
- case NOTE_F:
- case NOTE_G:
- case NOTE_A:
- case NOTE_B:
- {
- if (nNoteOctave == OCTAVE_3)
- SetOctave(OCTAVE_5)
- else
- if (nNoteOctave == OCTAVE_4)
- SetOctave(OCTAVE_3)
- else
- if (nNoteOctave == OCTAVE_5)
- SetOctave(OCTAVE_4) break;
- }
- default:
- break;
- }
- PlayCurrentNode();
- ShowNote(g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex]);
- /* after pressing down key should not move the cursor */
- #ifndef __MMI_TOUCH_RING_COMPOSER__
- if (g_rngc_eng_cntx->CurrNoteIndex == g_rngc_eng_cntx->TotalNotes - 1)
- {
- StartTimer(NOTE_MULTITAP_TIMER, MULTITAP_TIME, (FuncPtr) HandleKey_RIGHT);
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_LEFT
- * DESCRIPTION
- * Left key handler
- * Move cursor left
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_LEFT(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- DisplayInfo sDisplayInfo[NUM_NOTES_IN_STAVE];
- U16 nTemp;
- U16 nEnd;
- U16 nImageId = 0;
- U8 nYVal = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- StopTimer(NOTE_MULTITAP_TIMER);
- if (g_rngc_eng_cntx->CurrNoteIndex > 0)
- {
- --g_rngc_eng_cntx->CurrNoteIndex;
- if (g_rngc_eng_cntx->CurrUIPos == 0)
- {
- nTemp = g_rngc_eng_cntx->TotalNotes - g_rngc_eng_cntx->CurrNoteIndex;
- if (nTemp >= NUM_NOTES_IN_STAVE)
- {
- nEnd = NUM_NOTES_IN_STAVE;
- }
- else
- {
- nEnd = nTemp;
- }
- for (nTemp = 0; nTemp < nEnd; ++nTemp)
- {
- GetIndexInList(g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex + nTemp], &nImageId, &nYVal);
- sDisplayInfo[nTemp].nImageId = nImageId;
- sDisplayInfo[nTemp].nXPos = (U8) nTemp;
- sDisplayInfo[nTemp].nYPos = nYVal;
- }
- RefreshNotesList(nEnd, (DisplayInfo*) & sDisplayInfo);
- }
- else
- {
- --g_rngc_eng_cntx->CurrUIPos;
- redraw_ringcomposer();
- }
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- if ( /* touch_rngc_context.mode == GUI_RNGC_EDIT || */ touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT ||
- touch_rngc_context.mode == GUI_RNGC_INSERT)
- {
- mmi_rngc_finish_insert_editing();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- }
- }
- /*****************************************************************************
- * FUNCTION
- * HandleKey_RIGHT
- * DESCRIPTION
- * Right key handler
- * Move cursor right
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void HandleKey_RIGHT(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* already in right boundary */
- if (g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] == 0xFFFF)
- {
- return;
- }
- StopTimer(NOTE_MULTITAP_TIMER);
- if (g_rngc_eng_cntx->CurrNoteIndex < (g_rngc_eng_cntx->TotalNotes))
- {
- ++g_rngc_eng_cntx->CurrNoteIndex;
- if (g_rngc_eng_cntx->CurrUIPos == NUM_NOTES_IN_STAVE - 1)
- {
- /* handle the right movement */
- RedrawNotes();
- }
- else
- {
- ++g_rngc_eng_cntx->CurrUIPos;
- redraw_ringcomposer();
- }
- }
- #ifdef __MMI_TOUCH_RING_COMPOSER__
- if ( /* touch_rngc_context.mode == GUI_RNGC_EDIT || */ touch_rngc_context.mode == GUI_RNGC_INSERT_EDIT ||
- touch_rngc_context.mode == GUI_RNGC_INSERT)
- {
- mmi_rngc_finish_insert_editing();
- }
- if ((touch_rngc_context.mode == GUI_RNGC_EDIT)
- && (g_rngc_eng_cntx->CurrNoteIndex >= g_rngc_eng_cntx->TotalNotes))
- {
- touch_rngc_context.area_type = GUI_RNGC_NORMAL_TOOLBAR;
- selection_area_context = &normal_toolbar_layout;
- touch_rngc_context.mode = GUI_RNGC_VIEW;
- touch_rngc_context.play_mode = RNGC_PLAY;
- touch_rngc_context.flag |= RNGC_SELECTION_AREA_REDRAW;
- redraw_ringcomposer();
- }
- #endif /* __MMI_TOUCH_RING_COMPOSER__ */
- }
- /*****************************************************************************
- * FUNCTION
- * GenerateMelodyFile
- * DESCRIPTION
- * Generate and write iMelody file to file system
- * PARAMETERS
- * pFileName [IN] Filename
- * RETURNS
- * enum value of result
- *****************************************************************************/
- S32 GenerateMelodyFile(PS8 pFileName)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 *pMelody = NULL;
- S32 err = 0;
- U16 nSize = 0;
- U32 wByte = 0;
- S8 tmpBuff[100];
- S8 FileNameBuff[FMGR_MAX_PATH_LEN * ENCODING_LENGTH];
- FILE_HANDLE fileHandle;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* generate filename */
- GenerateCompleteComposeFileName((PS8) pFileName, (PS8) FileNameBuff);
- #ifdef MMI_ON_HARDWARE_P
- if ((err = RngcCreateDir()) != FS_NO_ERROR)
- {
- return err;
- }
- #else /* MMI_ON_HARDWARE_P */
- if ((err = RngcCreateDir()) != 0)
- {
- return err;
- }
- #endif /* MMI_ON_HARDWARE_P */
- fileHandle = FS_Open((U16*) FileNameBuff, FS_READ_WRITE | FS_CREATE_ALWAYS);
- if (!pfOpenError(fileHandle))
- {
- /* write header */
- err = FS_Write(fileHandle, MELODY_HEADER, AsciiStrlen((const S8*)MELODY_HEADER), &wByte);
- if (err == 0)
- {
- sprintf(
- (PS8) tmpBuff,
- "COMPOSER:MTK(%d)rnBEAT:%drnMELODY:",
- g_rngc_cntx.CurrInstr,
- g_rngc_cntx.CurrSpeed);
- FS_Write(fileHandle, tmpBuff, AsciiStrlen((const S8*)tmpBuff), &wByte);
- }
- /* generate iMelody string */
- if (err == 0)
- {
- pMelody = OslMalloc(g_rngc_eng_cntx->TotalNotes * 7);
- nSize = GetMelodyFromStruct((PU8) pMelody, (U16) (g_rngc_eng_cntx->TotalNotes * 7));
- err = FS_Write(fileHandle, pMelody, nSize, &wByte);
- OslMfree(pMelody);
- }
- /* write tail */
- if (err == 0)
- {
- err = FS_Write(fileHandle, MELODY_END, AsciiStrlen((const S8*)MELODY_END), &wByte);
- }
- FS_Close(fileHandle);
- if (err < 0)
- {
- FS_Delete((U16*) FileNameBuff);
- }
- }
- else
- {
- err = (S32) fileHandle;
- }
- return err;
- }
- /*****************************************************************************
- * FUNCTION
- * GenerateCompleteComposeFileName
- * DESCRIPTION
- * Generate complete file path+name
- * PARAMETERS
- * pFileName [IN] Filename
- * pCompletePath [IN/OUT] Comple filename+path
- * RETURNS
- * void
- *****************************************************************************/
- void GenerateCompleteComposeFileName(PS8 pFileName, PS8 pCompletePath)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pfnUnicodeStrcpy((S8*) pCompletePath, (S8*) RINGCOMPOSER_PATH);
- pfnUnicodeStrcat((S8*) pCompletePath, (S8*) pFileName);
- }
- /*****************************************************************************
- * FUNCTION
- * EditMelody
- * DESCRIPTION
- * Read an iMelody file and convert to the structure used in program
- * Display ring tone composer stave
- * PARAMETERS
- * pFileName [IN] Filename
- * RETURNS
- * void
- *****************************************************************************/
- void EditMelody(U8 *pFileName)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 *pMelody = NULL;
- FILE_HANDLE fileHandle;
- S32 nFileSize;
- U32 nEror = 0;
- S8 FilleNameBuff[MAX_IMAGE_NAME_PATH_WIDTH + RNGC_FILE_LEN]; /* padding for filepath */
- #ifdef MMI_ON_HARDWARE_P
- #ifdef __DRM_SUPPORT__
- DRM_RIGHTS_STRUCT *rights;
- #endif
- #endif /* MMI_ON_HARDWARE_P */
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- GenerateCompleteComposeFileName((PS8) pFileName, (PS8) FilleNameBuff);
- #ifdef MMI_ON_HARDWARE_P
- #ifdef __DRM_SUPPORT__
- fileHandle = DRM_open_file((PU16) FilleNameBuff, FS_READ_ONLY, DRM_PERMISSION_NONE);
- if (fileHandle > FS_NO_ERROR)
- {
- rights = DRM_get_rights(fileHandle);
- DRM_close_file(fileHandle);
- if (rights != NULL)
- {
- DisplayPopup(
- (U8*) GetString(STR_GLOBAL_DRM_PROHIBITED),
- IMG_GLOBAL_UNFINISHED,
- 0,
- UI_POPUP_NOTIFYDURATION_TIME,
- ERROR_TONE);
- return;
- }
- }
- #endif /* __DRM_SUPPORT__ */
- #endif /* MMI_ON_HARDWARE_P */
- fileHandle = FS_Open((U16*) FilleNameBuff, FS_READ_ONLY);
- if (!pfOpenError(fileHandle))
- {
- nFileSize = GetFSFileSize(fileHandle);
- if (nFileSize > RNGC_MAX_FILE_LEN)
- {
- DisplayPopup(
- (U8*) GetString(STR_GLOBAL_UNSUPPORTED_FORMAT),
- IMG_GLOBAL_WARNING,
- 0,
- UI_POPUP_NOTIFYDURATION_TIME,
- ERROR_TONE);
- FS_Close(fileHandle);
- return;
- }
- pMelody = OslMalloc(nFileSize + 1);
- if (g_rngc_eng_cntx == NULL)
- {
- g_rngc_eng_cntx = OslMalloc(sizeof(rngc_engine_context_struct));
- }
- pfread(pMelody, 1, nFileSize, fileHandle, &nEror);
- pMelody[nFileSize] = 0;
- FS_Close(fileHandle);
- g_rngc_eng_cntx->TotalNotes = 0;
- g_rngc_eng_cntx->CurrNoteIndex = 0;
- g_rngc_eng_cntx->CurrUIPos = 0;
- g_rngc_eng_cntx->IsRskLP = 0;
- RngcInitCursor();
- memset(g_rngc_eng_cntx->NotesList, 0, sizeof(g_rngc_eng_cntx->NotesList));
- g_rngc_cntx.CurrInstr = INSTR_FLUTE; /* to sync with media task */
- if (GetComposerStructFromMelody((PU8) pMelody))
- {
- memset(
- (void*)(g_rngc_eng_cntx->NotesList + g_rngc_eng_cntx->TotalNotes),
- 0xFF,
- sizeof(g_rngc_eng_cntx->NotesList) - (sizeof(U16) * (g_rngc_eng_cntx->TotalNotes)));
- if (g_rngc_eng_cntx->CurrNoteIndex >= NUM_NOTES_IN_STAVE)
- {
- g_rngc_eng_cntx->CurrUIPos = NUM_NOTES_IN_STAVE - 1;
- }
- else
- {
- g_rngc_eng_cntx->CurrUIPos = g_rngc_eng_cntx->CurrNoteIndex;
- }
- EntryRngcComposerEngine();
- }
- else
- {
- OslMfree(g_rngc_eng_cntx);
- g_rngc_eng_cntx = NULL;
- DisplayPopup(
- (U8*) GetString(STR_GLOBAL_UNSUPPORTED_FORMAT),
- IMG_GLOBAL_WARNING,
- 0,
- UI_POPUP_NOTIFYDURATION_TIME,
- ERROR_TONE);
- }
- OslMfree(pMelody);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * GetIndexInList
- * DESCRIPTION
- * This function is to retreive duration/note symbol/octave/type of a musical node
- * PARAMETERS
- * nNote [IN] The value of the musical note
- * pImageId [IN/OUT] Image id to be display for the musical note
- * pYVal [IN/OUT] The y-coordinate of the musical note
- * RETURNS
- * void
- *****************************************************************************/
- void GetIndexInList(U16 nNote, U16 *pImageId, U8 *pYVal)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 nListCount = 0;
- U32 nNoteOctave;
- U32 nValue;
- U32 nDuration;
- U32 nNoteType;
- U32 nIndex;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- nDuration = nNote & DURATION_MASK;
- nValue = nNote & NOTE_MASK;
- nNoteOctave = nNote & OCTAVE_MASK;
- nNoteType = nNote & NOTETYPE_MASK;
- /* vibe, backlight, led */
- if (nValue >= NOTE_VIBRATION_ON)
- {
- switch (nValue)
- {
- case NOTE_VIBRATION_ON:
- *pImageId = IMG_RING_EVENTVIB_ON;
- break;
- case NOTE_VIBRATION_OFF:
- *pImageId = IMG_RING_EVENTVIB_OFF;
- break;
- case NOTE_LED_ON:
- *pImageId = IMG_RING_EVENTLED_ON;
- break;
- case NOTE_LED_OFF:
- *pImageId = IMG_RING_EVENTLED_OFF;
- break;
- case NOTE_BACKLIGHT_ON:
- *pImageId = IMG_RING_EVENTBL_ON;
- break;
- case NOTE_BACKLIGHT_OFF:
- *pImageId = IMG_RING_EVENTBL_OFF;
- break;
- default:
- break;
- }
- *pYVal = RNGC_EFFECT_NOTE_OFFSET;
- return;
- }
- /* OCTAVE_4 and OCTAVE_3 use the same symbol */
- #if defined(__MMI_MAINLCD_176X220__) || defined(__MMI_MAINLCD_240X320__) /* 041205 Calvin modified */
- if (nNoteOctave == OCTAVE_4) /* only octave 4 use the normal musical note */
- {
- nIndex = nNoteType | OCTAVE_3 | nDuration;
- }
- else if (nValue == 1 && nNoteOctave == OCTAVE_3)
- {
- nIndex = nNoteType | OCTAVE_3 | nDuration;
- }
- else
- {
- nIndex = nNoteType | OCTAVE_5 | nDuration;
- }
- #else /* defined(__MMI_MAINLCD_176X220__) || defined(__MMI_MAINLCD_240X320__) */
- if (nNoteOctave == OCTAVE_4)
- {
- nIndex = nNoteType | OCTAVE_3 | nDuration;
- }
- else
- {
- nIndex = nNoteType | nNoteOctave | nDuration;
- }
- #endif /* defined(__MMI_MAINLCD_176X220__) || defined(__MMI_MAINLCD_240X320__) */
- for (nListCount = 0; nListCount < sizeof(gNotesList); nListCount++)
- {
- if (gNotesList[nListCount].nNote == nIndex)
- {
- nNoteOctave = nNoteOctave >> 6;
- if (nValue == NOTE_REST)
- {
- if (nDuration == DURATION_3BY8 || nDuration == DURATION_1BY4)
- {
- *pYVal = gnYCoords[21];
- }
- else if (nDuration == DURATION_3BY16 || nDuration == DURATION_1BY8)
- {
- *pYVal = gnYCoords[22];
- }
- else
- {
- *pYVal = gnYCoords[23];
- }
- }
- else
- {
- *pYVal = gnYCoords[((nNoteOctave - 1) * 7 + nValue) - 1];
- }
- *pImageId = gNotesList[nListCount].nImageId + COMPOSE_RING_TONE_ENGINE_BASE;
- return;
- }
- }
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * GetMelodyFromStruct
- * DESCRIPTION
- * This function is to generate iMelody string for a given node
- * PARAMETERS
- * pList [IN/OUT] Strating address to write the iMelody string
- * nListSize [IN] Musical note
- * RETURNS
- * address of current write cursor
- *****************************************************************************/
- U16 GetMelodyFromStruct(U8 *pList, U16 nListSize)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 nCount = 0;
- U8 *pNoteString = pList;
- U8 *pTemp;
- U16 nCurrentNode = g_rngc_eng_cntx->CurrNoteIndex;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_rngc_eng_cntx->CurrNoteIndex = 0;
- while (nCount < g_rngc_eng_cntx->TotalNotes)
- {
- /* insert string of musical note to pNoteString */
- pTemp = GetStringForNode(pNoteString, g_rngc_eng_cntx->NotesList[nCount]);
- /* adjust location of string pointer */
- pNoteString += (pTemp - pNoteString);
- ++g_rngc_eng_cntx->CurrNoteIndex;
- ++nCount;
- }
- *pNoteString = 0;
- g_rngc_eng_cntx->CurrNoteIndex = nCurrentNode;
- return pNoteString - pList;
- }
- /*****************************************************************************
- * FUNCTION
- * GetStringForNode
- * DESCRIPTION
- * This function is to generate iMelody string for a given node
- * PARAMETERS
- * pStr [IN/OUT] Strating address to write the iMelody string
- * nNote [IN] Musical note
- * RETURNS
- * address of current write cursor
- *****************************************************************************/
- U8 *GetStringForNode(U8 *pStr, U32 nNote)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 nNoteOctave;
- U32 nValue;
- U32 nDuration;
- U32 nNoteType;
- U8 *pNote = pStr;
- U16 len, index;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- nValue = g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] & NOTE_MASK;
- nDuration = g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] & DURATION_MASK;
- nNoteOctave = g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] & OCTAVE_MASK;
- nNoteType = g_rngc_eng_cntx->NotesList[g_rngc_eng_cntx->CurrNoteIndex] & NOTETYPE_MASK;
- /* octave */
- if (nNoteOctave == OCTAVE_3)
- {
- memcpy(pNote, "*3", 2);
- pNote += 2;
- }
- else if (nNoteOctave == OCTAVE_5)
- {
- memcpy(pNote, "*5", 2);
- pNote += 2;
- }
- /* note type */
- if (nNoteType == SHARP)
- {
- memcpy(pNote, "#", 1);
- pNote += 1;
- }
- else if (nNoteType == FLAT)
- {
- memcpy(pNote, "&", 1);
- pNote += 1;
- }
- index = (U16) (nValue - 1);
- len = strlen((PS8) gRngcMusicalNote[index]);
- memcpy(pNote, gRngcMusicalNote[index], len);
- pNote += len;
- if (nDuration > 0)
- {
- index = (U16) (nDuration / DURATION_3BY2 - 1);
- len = strlen((PS8) gRngcDuration[index]);
- memcpy(pNote, gRngcDuration[index], len);
- pNote += len;
- }
- return pNote;
- }
- /*****************************************************************************
- * FUNCTION
- * GetComposerStructFromMelody
- * DESCRIPTION
- * Parsing header of iMelody string, and convert to the structure used in this application
- * PARAMETERS
- * pMelody [IN] IMelody string, including header
- * RETURNS
- * success or failed
- *****************************************************************************/
- U8 GetComposerStructFromMelody(U8 *pMelody)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 *ptr = pMelody;
- U8 instrument;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (!CompareMelody(&ptr, "BEGIN:"))
- {
- return FALSE;
- }
- if (!CompareMelody(&ptr, "IMELODY"))
- {
- return FALSE;
- }
- if (!CompareMelody(&ptr, "VERSION:"))
- {
- return FALSE;
- }
- if (!CompareMelody(&ptr, "1.0") && !CompareMelody(&ptr, "1.1") && !CompareMelody(&ptr, "1.2"))
- {
- return FALSE;
- }
- if (!CompareMelody(&ptr, "FORMAT:"))
- {
- return FALSE;
- }
- if (!CompareMelody(&ptr, "CLASS1.0") && !CompareMelody(&ptr, "CLASS2.0"))
- {
- return FALSE;
- }
- while (*ptr != 0)
- {
- if (CompareMelody(&ptr, "NAME:")) /* ignore song name */
- {
- ClearToEnd(&ptr);
- }
- else if (CompareMelody(&ptr, "COMPOSER:"))
- { /* ignore composer name */
- g_rngc_cntx.CurrInstr = GetInstrument(&ptr);
- /* check instrument */
- for (instrument = 0; instrument < ENUM_TOTAL_INSTR; instrument++)
- {
- if ((U8) g_rngc_cntx.CurrInstr == CurrentInstrument[instrument])
- {
- break;
- }
- }
- if( instrument == ENUM_TOTAL_INSTR)
- {
- return FALSE;
- }
- ClearToEnd(&ptr);
- }
- else if (CompareMelody(&ptr, "BEAT:"))
- {
- g_rngc_cntx.CurrSpeed = (U8) GetBeat(&ptr);
- ClearToEnd(&ptr);
- }
- else if (CompareMelody(&ptr, "STYLE:"))
- {
- ClearToEnd(&ptr);
- }
- else if (CompareMelody(&ptr, "VOLUME:"))
- {
- ClearToEnd(&ptr);
- }
- else if (CompareMelody(&ptr, "MELODY:"))
- {
- if (GetMelody(&ptr) == FALSE)
- {
- return FALSE;
- }
- if (!CompareMelody(&ptr, "END:IMELODY"))
- {
- return FALSE;
- }
- break;
- }
- else
- {
- return FALSE;
- }
- }
- return TRUE;
- }
- /*****************************************************************************
- * FUNCTION
- * GetMelody
- * DESCRIPTION
- * Retrieve musical note according to the melody string
- * PARAMETERS
- * pptr [IN] Pointer of an iMelody string
- * RETURNS
- * success or failed
- *****************************************************************************/
- U8 GetMelody(U8 **pptr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 **ptr = pptr;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- while (**ptr)
- {
- if (g_rngc_eng_cntx->TotalNotes == MAX_NOTES)
- {
- if (**ptr == 10 || **ptr == 13)
- {
- return TRUE;
- }
- else
- {