⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ivocuse.c

📁 brew voice sound brew voice sound
💻 C
📖 第 1 页 / 共 2 页
字号:
   {
      DBGPRINTF("Error Creating IVocoder interface");
      return FALSE;
   }

   // Create ISound interface
   if (ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SOUND, (void **)&pMe->pISound) != SUCCESS)
   {
      DBGPRINTF("Error Creating ISound interface");
      return FALSE;
   }

   return TRUE;
}

/*===========================================================================

FUNCTION VocUse_FreeAppData

DESCRIPTION
   This function ireleases all resources used by the application.

PROTOTYPE:
	static void VocUse_FreeAppData(CVocApp * pMe);

PARAMETERS:
   pi: [in]: Pointer to CVocApp struct

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None
===========================================================================*/
static void VocUse_FreeAppData(CVocApp * pMe) {
   // Release all menu items
   if(pMe->pIMenu) {
      IMENUCTL_Release (pMe->pIMenu);
      pMe->pIMenu = NULL;
   }
   if(pMe->pISoft) {
      IMENUCTL_Release (pMe->pISoft);
      pMe->pISoft = NULL;
   }
   if(pMe->pIBack) {
      IMENUCTL_Release(pMe->pIBack);
      pMe->pIBack = NULL;
   }

   // Release IVocoder
   if(pMe->pIVocoder) {
      IVOCODER_Release(pMe->pIVocoder);
      pMe->pIVocoder = NULL;
   }

   // Release Sound interface
   if(pMe->pISound) {
      ISOUND_Release(pMe->pISound);
      pMe->pISound = NULL;
   }

   // Release Static box
   if(pMe->pIStatic) {
      ISTATIC_Release(pMe->pIStatic);
      pMe->pIStatic = NULL;
   }

}

/*===========================================================================

FUNCTION DisplayOutput

DESCRIPTION
   This function displays a specified message to the screen.  The uint16 on input
   correlates to the bar file needed for this app.

PROTOTYPE:
	void DisplayOutput(CVocApp * pMe, uint16 event);

PARAMETERS:
   pMe: [in]: Pointer to cVocApp structure

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None
===========================================================================*/
void DisplayOutput(CVocApp * pMe, uint16 event) {

   // Do not update screen if on main menu
   if(IMENUCTL_IsActive(pMe->pIMenu)) {
      return;
   }

   // Clear the screen
   IDISPLAY_ClearScreen(pMe->a.m_pIDisplay);

   //Load the string to memory
   if(SUCCESS != ISHELL_LoadResString(pMe->a.m_pIShell, IVOCUSE_RES_FILE, event, pMe->pNameBuffer, sizeof(pMe->pNameBuffer))) {
      ISHELL_LoadResString(pMe->a.m_pIShell, IVOCUSE_RES_FILE, event, pMe->pNameBuffer, sizeof(pMe->pNameBuffer));
   } else {
      ISHELL_LoadResString(pMe->a.m_pIShell, IVOCUSE_RES_FILE, IDS_ERROR, pMe->pNameBuffer, sizeof(pMe->pNameBuffer));
   }

   // Draw text
   IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_BOLD, pMe->pNameBuffer, -1, 0, 0, NULL,                // No clipping
                           IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
   IDISPLAY_Update(pMe->a.m_pIDisplay);

   // Redraw Menu if active
   if(IMENUCTL_IsActive(pMe->pISoft)) {
      IMENUCTL_Redraw(pMe->pISoft);
   }
}


/*===========================================================================

FUNCTION HaveCB

DESCRIPTION
	Callback function invoked when decoder has more frames. 

PROTOTYPE:
	static void HaveCB(uint16 numFrames, void * usrPtr);

PARAMETERS:
   numFrames [in]: number of rames that ivocoder can use
   pMe: [in]: Pointer to CVocApp  struct

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None
===========================================================================*/
static void HaveDataCB(uint16 numFrames, void * usrPtr)
{
   CVocApp* pMe = (CVocApp*)usrPtr;
   DataRateType rate;
   uint16 length;
   int i;
   int status;

   // Data integrity checks
   if (!pMe || !pMe->pIVocoder)
   {
      return;
   }

   // Read in each frame and send to network
   for (i = 0; i < numFrames; i++) {
      status = IVOCODER_VocInRead(pMe->pIVocoder,
                                  &rate, &length, pMe->frameData);

      // If we succesfully read in data, then write to IVocoder
      if (status == SUCCESS) {
         // Send recived data to IVocoder
         IVOCODER_VocOutWrite(pMe->pIVocoder, rate, length, pMe->frameData);
      }
   }
}


/*===========================================================================

FUNCTION NeedCB

DESCRIPTION
	Callback function invoked when decoder requires more frames. This function
   will get invoked when the IVocoder is paused (deactivated)

PROTOTYPE:
	static void NeedCB(uint16 numFrames, void * usrPtr);

PARAMETERS:
   numFrames [in]: number of rames that ivocoder can use
   pMe: [in]: Pointer to CVocApp  struct

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None
===========================================================================*/
static void NeedDataCB(uint16 numFrames, void * usrPtr) {
   CVocApp* pMe = (CVocApp*)usrPtr;

   // Display pause message if ivocoder needs data
   if(pMe->bVocOn) {
      DisplayOutput(pMe, IDS_PAUSE);
   }
}


/*===========================================================================

FUNCTION ReadyCB

DESCRIPTION
	Callback function invoked when vocoder is ready for use. Called after
   IVOCODER_VocConfigure has finished.

PROTOTYPE:
	static void ReadyCB(void * usrPtr);

PARAMETERS:
   pMe: [in]: Pointer to CVocApp  struct

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None
===========================================================================*/
static void ReadyCB(void * usrPtr) {
   CVocApp* pMe = (CVocApp*)usrPtr;

   // Start Reading in
   IVOCODER_VocInStart(pMe->pIVocoder);

   // Allow for playing
   IVOCODER_VocOutStart(pMe->pIVocoder);

   // Set Vocoder variable to on
   pMe->bVocOn = TRUE;
}


/*===========================================================================

FUNCTION DisplayMessageToScreen

DESCRIPTION
	This Clears the Screen and displays the inputed text

PROTOTYPE:
	static void DisplayMessageToScreen(CVocApp* pMe, char* message)

PARAMETERS:
   pMe: [in]: Pointer to CMaxFileTest  struct
   message: [in]: pointer to a string

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None
===========================================================================*/
static void DisplayMessageToScreen(CVocApp* pMe, AECHAR* message) {
	AEERect	rec;

   // Set All menus to inactive
   IMENUCTL_SetActive(pMe->pIMenu, FALSE);

   // Set properties of text box
	SETAEERECT(&rec, 0, 0, pMe->deviceInfo.cxScreen, pMe->deviceInfo.cyScreen);
	ISTATIC_SetRect(pMe->pIStatic, &rec);
	ISTATIC_SetProperties(pMe->pIStatic, ST_MIDDLETEXT | ST_CENTERTEXT);
	ISTATIC_SetText(pMe->pIStatic, NULL, message, AEE_FONT_NORMAL, AEE_FONT_NORMAL);

   // Prepare text box and update screen Update screen
	ISTATIC_SetActive(pMe->pIStatic, TRUE);
	ISTATIC_Redraw(pMe->pIStatic);
	IDISPLAY_Update(pMe->a.m_pIDisplay);
}

/*===========================================================================

FUNCTION BuildMainMenu

DESCRIPTION
	This function adds all menu items to the main menu. 

PROTOTYPE:
	void BuildMainMenu(CVocApp *pMe);

PARAMETERS:
   pMe: [in]: Pointer to CVocApp  struct

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None
===========================================================================*/
void BuildMainMenu(CVocApp *pMe) {

    // Set Title
   IMENUCTL_SetTitle(pMe->pIMenu, IVOCUSE_RES_FILE, IDSMAIN_TITLE, NULL); 

   // Add Streaming to IVocuse
   IMENUCTL_AddItem(pMe->pIMenu, IVOCUSE_RES_FILE, IDSMAIN_STREAM, IDSMAIN_STREAM, NULL, NULL); 

   // Add An info page
   IMENUCTL_AddItem(pMe->pIMenu, IVOCUSE_RES_FILE, IDSMAIN_INFO, IDSMAIN_INFO, NULL, NULL); 

   // Add an exit option
   IMENUCTL_AddItem(pMe->pIMenu, IVOCUSE_RES_FILE, IDSMAIN_EXIT, IDSMAIN_EXIT, NULL, NULL);    
}



/*===========================================================================

FUNCTION BuildSoftMenu

DESCRIPTION
	This function adds all menu items to the soft menu.  This menu is displayed
   when the application is streaming audio.

PROTOTYPE:
	void BuildSoftMenu(CVocApp *pMe);

PARAMETERS:
   pMe: [in]: Pointer to CVocApp  struct

DEPENDENCIES
   None

RETURN VALUE
   None

SIDE EFFECTS
   None

===========================================================================*/
void BuildSoftMenu(CVocApp *pMe) {

   // Avoid memory leak
   if(pMe->pISoft) {
      IMENUCTL_Release (pMe->pISoft);
      pMe->pISoft = NULL;
   }

   // Create interface
   if (ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SOFTKEYCTL, (void **)&pMe->pISoft) != SUCCESS)
   {
      return;
   }

   // Add Activation to IVocuse - This must change when deactivated
   IMENUCTL_AddItem(pMe->pISoft, IVOCUSE_RES_FILE, IDSSOFT_DEACTIVATE, IDSSOFT_DEACTIVATE, NULL, NULL); 

   // Add an exit option
   IMENUCTL_AddItem(pMe->pISoft, IVOCUSE_RES_FILE, IDSSOFT_EXIT, IDSSOFT_EXIT, NULL, NULL); 
}


/*===========================================================================

FUNCTION ReplaceMenuItem

DESCRIPTION
	This function will remove the second parameter from a menu and add
   the third parameter to the menu.  The parameter corresponds to the 
   resource file supplied with this application.  If either parameter
   is 0, then it's corresponding removal ar addition is ignored.

PROTOTYPE:
	ReplaceMenuItem(IMenuCtl *pIMenu, uint16 remove, uint16 add);

PARAMETERS:
   pIMenu: [in]: Pointer to working menu
   remove: [in]: remove this item from menu, if 0 remove nothing
   add: [in]: add this item to the menu, if 0 add nothing

DEPENDENCIES
   None

RETURN VALUE
   None

SIDE EFFECTS
   None

===========================================================================*/
static void ReplaceMenuItem(IMenuCtl *pIMenu, uint16 remove, uint16 add) {
   
   // Remove Item if one is given
   if(remove) {
      IMENUCTL_DeleteItem(pIMenu, remove); 
   }
   
   // Add Item if one is given
   if(add) {
      IMENUCTL_AddItem(pIMenu, IVOCUSE_RES_FILE, add, add, NULL, NULL); 
   }

   // Move item up to beginning
   IMENUCTL_MoveItem(pIMenu, add, -1);

   // Set Cursor focus to added elem
   IMENUCTL_SetFocus(pIMenu, add);

   // Redraw Menu
   IMENUCTL_Redraw(pIMenu);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -