//***************************************************************************** // // Enable the Speex encoder/decoder and allow the quality setting to be set // by a single decimal argument. // //***************************************************************************** int Cmd_speex(int argc, char *argv[]) { unsigned long ulTemp; // // Clear the pass through flag. // HWREGBITW(&g_ulFlags, FLAG_BYPASS) = 0; // // Check for an argument that is specifying a quality setting. // if(argc == 2) { // // Convert the value to a numeric value. // ulTemp = ustrtoul(argv[1], 0, 10); // // Rail the quality setting at 4. // if(ulTemp <= 4) { g_iQuality = (int)ulTemp; // // Set the quality setting. // SpeexEncodeQualitySet(g_iQuality); UARTprintf("Speex Encoder Quality set to %d\n", g_iQuality); } else { UARTprintf("Encoder Quality not changed, value must be (1-4).\n"); } } return(0); }
//***************************************************************************** // //! Initialize the encoder's state to prepare for encoding new frames. //! //! \param iSampleRate is the sample rate of the incoming audio. //! \param iComplexity is the complexity setting for the encoder. //! \param iQuality is the quality setting for the encoder. //! //! This function will initializes the encoder by setting the sample rate, //! complexity and quality settings. The \e iComplexity and \e iQuality //! settings are explained further in the Speex documentation. //! //! \return This function returns 0. // //***************************************************************************** int32_t SpeexEncodeInit(int iSampleRate, int iComplexity, int iQuality) { const SpeexMode *psMode; // // Clear out the flags for this instance. // g_sSpeexEncoder.ui32Flags = 0; // // Read out the current encoder mode. // psMode = speex_lib_get_mode(SPEEX_MODEID_NB); // // Create a new decoder state in narrow band mode. // g_sSpeexEncoder.pvState = speex_encoder_init(psMode); // // Initialize the bit stream. // speex_bits_init(&g_sSpeexEncoder.sBits); // // Set the quality. // SpeexEncodeQualitySet(iQuality); // // Set the complexity and sample rate for the encoder. // speex_encoder_ctl(g_sSpeexEncoder.pvState, SPEEX_SET_COMPLEXITY, &iComplexity); speex_encoder_ctl(g_sSpeexEncoder.pvState, SPEEX_SET_SAMPLING_RATE, &iSampleRate); return(0); }