am_custom_tune.cc
来自「Motorola synergy audio component」· CC 代码 · 共 279 行
CC
279 行
/*==================================================================================================
Module Name: aud_mute_req.c
General Description: Utility function to send mute request primitives to the Audio Manager.
====================================================================================================
Motorola Confidential Proprietary
Advanced Technology and Software Operations
(c) Copyright Motorola 1999-2001, All Rights Reserved
Revision History:
Modification Tracking
Author Date Number Description of Changes
------------------------- ------------ ---------- -------------------------------------------
Olga Fine 10/30/2002 LIBbb65108 Invalid format in stored melody (Port the fix from TALON)
Steve Hagino 08/17/2001 LIBbb02768 Merge R1.2 baseline with latest R1.1
- Added function am_custom_tune_set_meta_info
Kevin Tang 06/25/2001 CSGce90044 Creation of file
Portability: This module is portable to other compilers.
====================================================================================================
INCLUDE FILES
==================================================================================================*/
#include <SUAPI/suapi.h>
#include <audio/am_custom_tune.h>
#include <audio/AM_iMelody.H>
#include <ENGINE_AUDIO/td_aud_tone_req_type.h>
#include <ENGINE_AUDIO/td_aud_tone_req_tone_type.h>
#include <audio/aud_tone_req.h>
#include <ENGINE_AUDIO/aud_prim_ids.h>
#include <string.h>
/*==================================================================================================
LOCAL FUNCTION PROTOTYPES
==================================================================================================*/
/*==================================================================================================
LOCAL CONSTANTS
==================================================================================================*/
/*==================================================================================================
LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
==================================================================================================*/
/*==================================================================================================
LOCAL MACROS
==================================================================================================*/
/*==================================================================================================
LOCAL VARIABLES
==================================================================================================*/
/*==================================================================================================
GLOBAL VARIABLES
==================================================================================================*/
CUSTOM_TUNE_INFO custom_tune = {0};
/*==================================================================================================
LOCAL FUNCTIONS
==================================================================================================*/
/*==================================================================================================
GLOBAL FUNCTIONS
==================================================================================================*/
/*==================================================================================================
FUNCTION: am_custom_tune_iMelody_parse
DESCRIPTION:
Call for iMelody parsor object to parse the input notes, and tune character info
ARGUMENTS PASSED:
input_note_ptr, pointer to the input notes
beats, 0 to ignore
RETURN VALUE:
Duration of the whole tune
PRE-CONDITIONS:
None
POST-CONDITIONS:
None
IMPORTANT NOTES:
None
==================================================================================================*/
UINT32
am_custom_tune_iMelody_parse(UINT8* input_note_ptr, UINT16 beats, AUD_CUSTOM_TYPE action)
{
AM_iMelody parsor;
UINT32 duration;
// Perfom the translation and puts the output data into AM buffer.
// It returns the pointer to the begginning of the converted data
custom_tune.meta.tune_ptr = parsor.TuneTranslation(input_note_ptr,
custom_tune.data_buf,
AM_CUSTOM_TUNE_BUFFER_SIZE,
action);
custom_tune.meta.tempo = parsor.GetTuneCharater(TEMPO);
duration = parsor.GetTuneCharater(TUNE_DURATION);
if ( beats != 0 )
{
custom_tune.meta.tempo = custom_tune.meta.tempo * DEFAULT_BEAT / beats;
duration = duration * DEFAULT_BEAT / beats;
}
custom_tune.meta.note_numb = parsor.GetTuneCharater(NOTE_COUNT);
return (duration);
}
void
am_custom_tune_store_request(TD_AUD_TONE_REQ_TYPE_T req_type,
TD_AUD_TONE_REQ_TONE_TYPE_T tone_type,
TD_AUD_TONE_REQ_TONE_TYPE_T vibrate_type,
TD_AUD_TONE_SEQUENCE_NUMBER_T sequence_number,
TD_AUD_VOLUME_SETTING_T vol_step)
{
custom_tune.request.req_type = req_type;
custom_tune.request.tone_type = tone_type;
custom_tune.request.sequence = sequence_number;
custom_tune.request.vib_type = vibrate_type;
custom_tune.request.vol_step = vol_step;
}
void
am_custom_tune_send_request(TD_AUD_MEDIA_INFO_T media_info)
{
TD_AUD_TONE_UNION_T tone;
char *msgptr = (char*)suCreateMessage((UINT32)sizeof(AUD_TONE_REQ), (UINT32)AUD_TONE_REQ_ID,
SU_INVALID_HANDLE, NULL);
tone.type = custom_tune.request.tone_type;
/* Fill in tone info */
((AUD_TONE_REQ*)msgptr)->tone = tone;
((AUD_TONE_REQ*)msgptr)->req_type = custom_tune.request.req_type;
((AUD_TONE_REQ*)msgptr)->vibrate_type = custom_tune.request.vib_type;
((AUD_TONE_REQ*)msgptr)->sequence_number = custom_tune.request.sequence;
((AUD_TONE_REQ*)msgptr)->uplink = FALSE;
((AUD_TONE_REQ*)msgptr)->vol_step = custom_tune.request.vol_step;
((AUD_TONE_REQ*)msgptr)->media_info = media_info;
((AUD_TONE_REQ*)msgptr)->sampling_rate = AM_SAMPLING_RATE_08_00; /* Send Message to the Audio Manager */
AM_SendMessage(msgptr);
}
UINT8*
am_custom_tune_buffer()
{
return (custom_tune.data_buf);
}
void
am_custom_tune_invalidate()
{
custom_tune.request.req_type = AUD_TONE_STOP;
}
BOOL
am_custom_tune_identify(TD_AUD_TONE_REQ_TONE_TYPE_T tone_type,
TD_AUD_TONE_SEQUENCE_NUMBER_T sequence_number)
{
return (tone_type == custom_tune.request.tone_type &&
sequence_number == custom_tune.request.sequence);
}
void
am_custom_tune_set_meta_info(TUNE_META meta)
{
custom_tune.meta = meta;
}
TUNE_META
am_custom_tune_get_meta_info()
{
return (custom_tune.meta);
}
TUNE_REQUEST
am_custom_tune_get_request_info()
{
return (custom_tune.request);
}
/*==================================================================================================
FUNCTION: aud_custom_tune_imelody_unpack
DESCRIPTION:
This function takes the passed in imelody string and return the content of the "MELODY:" and
"BEAT:". If the string doesn't have the field, will return the whole string to notes_buffer,
and return the DEFAULT_BEAT.
This function can be called at anytime since it changes nothing in the cache of custom_tune.
ARGUMENTS PASSED:
imelody_string - imelody string passed in
notes_buffer - output notes buffer
notes_buffer_size - output notes buffer size
beats - output beats
RETURN VALUE:
PRE-CONDITIONS:
None
POST-CONDITIONS:
None
==================================================================================================*/
void aud_custom_tune_imelody_unpack( UINT8 * imelody_string,
UINT8 * notes_buffer,
UINT16 notes_buffer_size,
UINT16 * beats)
{
AM_iMelody parsor;
parsor.TuneUnpack( imelody_string,
notes_buffer,
notes_buffer_size,
beats );
}
/*==================================================================================================
FUNCTION: aud_custom_tune_imelody_pack
DESCRIPTION:
If imelody_buffer is empty, this function will pack notes_string, beats and use
default value for other fields.
If imelody_buffer is not empty, this function will pack notes_string, beats and
keep the oringinal value for other fields.
If beats is 0 and the "BEAT:" field in imelody_buffer is empty or 0, this function
will pack DEFAULT_BEAT.
This function can be called at anytime since it changes nothing in the cache of custom_tune.
ARGUMENTS PASSED:
imelody_buffer - imelody string passed in and packed to
imelody_buffer_size - imelody buffer size
notes_string - input notes string
beats - input beats, 0 means putting the default beat which is 120
RETURN VALUE:
PRE-CONDITIONS:
None
POST-CONDITIONS:
None
==================================================================================================*/
void aud_custom_tune_imelody_pack( UINT8 * imelody_buffer,
UINT16 imelody_buffer_size,
UINT8 * notes_string,
UINT16 beats)
{
AM_iMelody parsor;
parsor.TunePack( imelody_buffer, imelody_buffer_size, notes_string, beats);
}
/*================================================================================================*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?