Home

AN11085 - Element14

image

Contents

1. i Enable audio output Yes All frames decoded OUT Buffer available Load a speex frame r Decode the frame gt Disable audio input Ca Fig 7 Decoding flowchart C OUTPUT Start gt Out a sample All samples delivered Free current OUT Buffer Activate next OUT Buffer for output C End D 1 Depending on the board OUTPUT can be TIMERO or 12S Interrupt Handler All information provided in this document is subject to legal disclaimers NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 10 of 15 NXP Semiconductors AN1 1 085 AN11085 Using Speex in NXP s LPC175x 6x MCU family Start decoding Start decoding Start decoding 2nd frame 3rd frame 4th frame Stop decoding Stop decoding Stop decoding 2nd frame 3rd frame 4th frame Output audio signal 20ms p4 20ms p4 20ms _ gt OUT_Buffer 0 OUT_Buffer 1 OUT _Buffer 0 available available available Start to send Start to send Start to send OUT_Buffer 0 OUT_Buffer 1 OUT_Buffer 0 Fig 8 Decoding scheme 1st frame is decoded previously 2 4 3 Audio input output for RDB1768 board The CodeRed RDB1768 board uses an external Audio Codec UDA1380 for input out
2. encoded frame is composed of 20 bytes and a buffer called output_bytes uses the Speex encoder to store the encoded frame Fig 5 shows the encoding scheme and Fig 6 the flowchart The application can record 6 seconds 300 frames of voice by using an array of 6000 bytes For IAR LPC1768 SK board the sampler is composed by the ADC and a TIMER The audio level is converted by the ADC inside the TIMERO interrupt handler which is programmed to be called every 125 us 8 kHz For the Code Red RDB1768 board samples are captured from the 12S interface The 12S frequency is adjusted to allow UDA1380 Audio Codec transfer sample data at a frequency of 8 kHz This data is saved in IN_Buffer s inside 12S interrupt handler AN11085 All information provided in this document is subject to legal disclaimers NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 8 of 15 NXP Semiconductors AN11085 AN11085 Using Speex in NXP s LPC175x 6x MCU family Start encoding Start encoding Start encoding IN_Buffer 0 IN_Buffer 1 IN_Buffer 0 Stop encoding Stop encoding IN_Buffer 0 IN_Buffer 1 Input audio signal Start recording IN_Buffer 0 IN_Buffer 1 IN_Buffer 0 f completed completed completed Start capturing to Start capturing to Start capturing to Start capturing to IN_Buffer 0 IN Buffer 1 IN_Buffer O IN Buffer 1 Fig 5 Encoding scheme ai l Init recording p
3. 5 NXP Semiconductors AN1 1 085 Using Speex in NXP s LPC175x 6x MCU family 4 References e Speex manual http speex org docs e Speex API Reference Manual http speex org docs e LPC17xx user manual UM10360 http www nxp com AN11085 All information provided in this document is subject to legal disclaimers NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 13 of 15 NXP Semiconductors AN11085 5 Legal information 5 1 Definitions Draft The document is a draft version only The content is still under internal review and subject to formal approval which may result in modifications or additions NXP Semiconductors does not give any representations or warranties as to the accuracy or completeness of information included herein and shall have no liability for the consequences of use of such information 5 2 Disclaimers Limited warranty and liability Information in this document is believed to be accurate and reliable However NXP Semiconductors does not give any representations or warranties expressed or implied as to the accuracy or completeness of such information and shall have no liability for the consequences of use of such information In no event shall NXP Semiconductors be liable for any indirect incidental punitive special or consequential damages including without limitation lost profits lost savings business interruption costs related to the remov
4. AN11085 Using Speex in NXP s LPC175x 6x MCU family Rev 1 16 June 2011 Application note Document information Info Content Keywords LPC175x 6x LPC1759FBD80 LPC1758FBD80 LPC1756FBD80 LPC1754FBD80 LPC1752FBD80 LPC1751FBD80 LPC1769FBD100 LPC1768FBD100 LPC1768FET100 LPC1767FBD100 LPC1766FBD100 LPC1765FBD100 LPC1764FBD100 LPC1763FBD100 Abstract This document describes the use of Speex s Codec in NXP s LPC175x 6x family of microcontrollers NXP Semiconductors AN1 1 085 Using Speex in NXP s LPC175x 6x MCU family Revision history Rev Date Description 1 20110616 Initial version Contact information For more information please visit http www nxp com For sales office addresses please send an email to salesaddresses nxp com AN11085 All information provided in this document is subject to legal disclaimers NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 2 of 15 NXP Semiconductors AN1 1 085 Using Speex in NXP s LPC175x 6x MCU family 1 Introduction 1 1 Overview Once designed to be a free alternative to expensive speech codecs Speex is an Open Source Free software patent free audio compression format designed for speech Speex is part of the GNU project and this application note provides information regarding the usage of this library on NXP s LPC175x 6x microcontrollers based on Cortex M3 1 1 1 Speex features The Speex library is based o
5. DA1380 Library and is also not optimized Speex application implementation Codec settings Sampling rate The LPC175x 6x port for the Speex codec works only with narrowband 8 kHz sampling rate Speex Parameters Below are some parameters required to configure the Speex codec in this application The default values are e Quality Encoder quality is set to 4 e VBR Variable Bit Rate is disabled e Complexity Encoder complexity is set to 1 e Enhancer Decoder audio enhancer feature is enabled Environment features and requirements All code examples were written using CMSIS resources including the LPC175x 6x CMSIS Compliant Standard Peripheral Firmware Driver Library Jan 28 2011 available here http ics nxp com support documents microcontrollers zip lpc1 7xx cmsis driver library Zip In IAR EWARM and Keil RVMDK the Heap Size was set to 0x2000 in order to allow Speex to allocate the necessary memory According to Speex specification for a sampling rate of 8 KHz the frame size is 20 ms corresponding to 160 samples For the application ported to RDB1768v2 without any optimization LPC 1768 running at 100 MHz takes about 17 ms to encode a single frame All information provided in this document is subject to legal disclaimers NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 6 of 15 NXP Semiconductors AN1 1 085 AN11085 2 3 3 Using Speex in NXP s LPC175x 6x MCU famil
6. SET QUALITY amp SpxCfg gt quality Speex_encoder_ctl enc_state SPEEX_SET COMPLEXITY amp SpxCfg gt complexity Speex decoding intilalization dec_state Speex_decoder_init amp Speex_nb_mode Speex_decoder_ctl dec_state SPHEX_SET_ENH amp SpxCfg gt enh Fig 4 Speex initialization 2 4 Application description Examples are provided for three LPC175x 6x evaluation boards Code Red RDB1768v2 Keil MCB1700 and IAR LPC1768 SK The Vocoder application examples provide one or two functions depending on the board used 1 Recording function Through a routine call the application obtains the audio streaming from an input I S or ADC encodes it and then stores it into the RAM This function is available only in applications for IAR LPC1768 SK and Code_Red RDB1768v2 boards 2 Playback function The application loads a voice audio stream previously stored in RAM memory decodes it and delivers the audio the audio to the appropriate output I S or DAC This function is available in all three evaluation boards 2 4 1 Record process Two buffers are used to store the input frames IN_Buffer 0 and IN_Buffer 1 At the beginning of a encoding process the sampler uses IN_Buffer 0 to store the first 160 samples As the sampler starts to store the next 160 frames in IN_Buffer 1 the encoder starts encoding IN_Buffer 0 The sampler and the encoder are always alternating the buffers accesses Each
7. al or replacement of any products or rework charges whether or not such damages are based on tort including negligence warranty breach of contract or any other legal theory Notwithstanding any damages that customer might incur for any reason whatsoever NXP Semiconductors aggregate and cumulative liability towards customer for the products described herein shall be limited in accordance with the Terms and conditions of commercial sale of NXP Semiconductors Right to make changes NXP Semiconductors reserves the right to make changes to information published in this document including without limitation specifications and product descriptions at any time and without notice This document supersedes and replaces all information supplied prior to the publication hereof Suitability for use NXP Semiconductors products are not designed authorized or warranted to be suitable for use in life support life critical or safety critical systems or equipment nor in applications where failure or malfunction of an NXP Semiconductors product can reasonably be expected to result in personal injury death or severe property or environmental damage NXP Semiconductors accepts no liability for inclusion and or use of NXP Semiconductors products in such equipment or applications and therefore such inclusion and or use is at the customer s own risk Applications Applications that are described herein for any of these products are for illust
8. arameters l Enable audio input C Sampler Start gt Capture a sample Current IN_ Buffer is full Yes All frames encoded New Frame available Enable audio input Enable audio input Toggle buffer index New frame available for encoding C gt Disable audio input CH 1 Depending on the board Sampler can be TIMERO or 12S Interrupt Handler Fig 6 Encoding flowchart All information provided in this document is subject to legal disclaimers NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 9 of 15 NXP Semiconductors AN11085 AN11085 Using Speex in NXP s LPC175x 6x MCU family 2 4 2 Playback process The playback process is similar to the encoding process Two buffers are used to deliver frame data to the output The first encoded frame 20 bytes is taken from the 6 kB array decoded and the resulting frame is stored in OUT_Buffer 0 The Decoder starts decoding the next Speex frame storing the result in OUT_Buffer 1 while OUT_Buffer 0 is delivered to the output DAC for IAR LPC1768 SK and 12S transmitter for code_red RDB1768 It continues until all Soeex frames are decoded Fig 7 and Fig 8 illustrate the decoding process tows gt l Init playing parameters
9. ard Code Red Technologies offers a development board containing an LPC1768 and several hardware options for evaluating and testing the LPC1768 features This demo uses NXP s UDA1380 I2S Stereo Codec which is integrated on the evaluation board It also contains an input for the ADC and an output for the DAC pins allowing the application to integrate various working modes merging usage of the converters and 12S codec interface All information provided in this document is subject to legal disclaimers NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 4 of 15 NXP Semiconductors AN11085 Using Speex in NXP s LPC175x 6x MCU family J2 LINE OUT SYSTCLK 7 DA ECKO Tur PES 100 EN 40K SJ4624 SMT um 2 2 4 H7 19 VWOUTLHP 3 18 VAREFHP if VOUTRHP ar LINEN 29 LINEIMA 3i MICIN ae 2 DATA z LACLKSCL LaMODE LaDATASDA SEL La IG RTCE Fig 1 Detail of I2S Codec in RBD1768 development board 2 Application AN11085 2 1 Vocoder overview The application proposed is a Vocoder using LPC1768 Vocoders are analysis and processing systems mostly used for voice applications It treats the audio signal enhancing the bandpass related to the voice spectrum frequencies encoding decoding filtering and finally amplifying it The application software processes Speex data capturing data either from ADC or I2S and to deliver it either to DAC or 12S Th
10. e application allows usage of ADC and DAC converters in case of I2S codec is not available LPC1 XX w Speex App Za 3 UDA 1380 amp LPC17XX 3 CODEC 2 reopens NAR Fig 2 Functional diagram of Speex application in LPC17XX using a NXP I2S Codec and b using ADC and DAC converters All information provided in this document is subject to legal disclaimers NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 5 of 15 NXP Semiconductors AN1 1 085 2 2 2 3 2 3 1 2 3 1 1 2 3 1 2 AN11085 2 3 2 Using Speex in NXP s LPC175x 6x MCU family Memory requirements The LPC175x 6x microcontroller has sufficient internal SRAM to meet the memory requirements for Speex One adjustment is necessary in heap size in order to enable the data to be processed correctly Because the Soeex CODEC demands a large portion of heap memory for dynamic allocation a minimum of 8 kB is necessary to allocate all necessary data Table 1 shows the amount of memory used by application using the three IDE s Keil MDK IAR EWARM LPCXpresso Based on these values a suitable member of the LPC175x 6x family can be selected For these specific examples LPC1751 and LPC1752 don t match the memory requirements Table 1 Memory usage IDE Flash usage bytes RAM usage bytes Keil RVMDK 49900 10120 IAR EWARM 36346 18196 LPCXpresso 86676 18272 1 LPCXpresso code size includes the U
11. eeeseeeeeeeeseeeeseeeeeeeeeeeas 6 Speex Parameters ccccceeeeeeeeeeeeseeeeeeeeeeeeeeees 6 Environment features and requirements 6 Using IDS POX 0 eeeecccccseseeeeceeeeeeeeeeeeeeessaeeess r Application description cccccseeeeeeeeseeeeeeeeeeees 8 Record procesS cccssececceseeeceeseecceeseesseneeesaees 8 Playback procesS cccccssseeeeeesaeeeeeeeeeeeeeeeeeas 10 Audio input output for RDB1768 board 11 User Interface ccccccccccsssececeeeeeeeeeeeeeseeeeeeas 12 CONMCIUSI ON cisesecanecesssdcivesessacasecsannsenteeacnsseavesensans 12 PCTCRCNGCCS irrisa E 13 Legal information ssssassssnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn 14 DefiMUONS sich cen sstceceeaceeidecaacdcossgetndaideaceccesinen tas 14 WISCIAIINIGN S saciscnstcepdonncatmnlendcenionssckwecedtoeadonsdetas 14 Trademarks eecccceeccccceseceeceseceeeeeeeesaaeeeesaeeees 14 COMENT Scogan E A 15 Using Speex in NXP s LPC175x 6x MCU family Please be aware that important notices concerning this document and the product s described herein have been included in the section Legal information NXP B V 2011 All rights reserved For more information please visit http www nxp com For sales office addresses please send an email to salesaddresses nxp com Date of release 16 June 2011 Document identifier AN11085
12. g Speex in NXP s LPC175x 6x MCU family 1 2 LPC175x 6x features The LPC175x 6x is an ARM Cortex M3 based microcontroller for embedded applications requiring a high level of integration and low power dissipation It operates at frequencies up to 100 MHz 120 MHz in LPC1759 and LPC1769 versions Some details of the peripherals used in this application are listed below e 12 bit Analog to Digital Converter ADC with input multiplexing among eight pins conversion rates up to 200 kHz and multiple result registers The 12 bit ADC can be used with the GPDMA controller e 10 bit Digital to Analog Converter DAC with dedicated conversion timer and DMA support e Four general purpose timers counters with a total of eight capture inputs and ten compare outputs Each timer block has an external count input Specific timer events can be selected to generate DMA requests e Three enhanced I C bus interfaces one with an open drain output supporting the full C specification and Fast mode plus with data rates of 1 Mbit s two with standard port pins Enhancements include multiple address recognition and monitor mode e S Inter IC Sound interface for digital audio input or output with fractional rate control The I S interface can be used with the GPDMA The I S interface supports 3 wire data transmit and receive or 4 wire combined transmit and receive connections as well as master clock output 1 3 About Code Red s RBD1768 development bo
13. he LPC1768 Yellow IZ2SRX_WS blue IZ2SRX_CLK and magenta I2SRX_SDA 2 4 4 User Interface The application example for the Code Red RDB1768 board uses an LCD interface to show a menu where the user can choose Record and Play functions by using the on board joystick It uses only the DOWN direction to toggle the cursor position by pressing CENTER the current option is selected For the IAR LPC1768 SK the application code is simpler Two buttons are used to start the Record and Play functions The user can use BUTTON 1 for recording a new 6 second voice stream and BUTTON 2 for playing back the recorded voice stream This software package also includes a project using Keil Real View MDK for the Keil MCB1700 board This board doesn t have a microphone input or a headphone output but it contains a speaker that is used by the application to play a sample audio that comes with the software 3 Conclusion We can see in this application note that the LPC175x 6x is suitable for Vocoder applications using Speex Codec Even using no optimization methods a microcontroller can perform encode decode satisfactorily Users also can implement some Preprocessor functions available by Speex software library such as Resampler Echo Cancellation etc AN11085 All information provided in this document is subject to legal disclaimers NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 12 of 1
14. n Code Excited Linear Prediction CELP It is designed to compress voice at bitrates ranging from 2 kB s to 44 kB s Some of Speex s features include e Narrowband 8 kHz wideband 16 kHz and ultra wideband 32 kHz compression in the same bitstream e Intensity stereo encoding e Packet loss concealment e Variable bitrate operation VBR e Voice Activity Detection VAD e Discontinuous Transmission DTX e Fixed point port e Acoustic echo canceller e Noise suppression Note that Speex has a number of features that are not present in other codecs such as intensity stereo encoding integration of multiple sampling rates in the same bitstream embedded coding and a VBR mode For more information regarding Speex visit http soeex org docs 1 1 2 Applications The Speex library can be used in various applications such as VoIP internet audio streaming data archiving e g voice mail and audio books 1 1 3 About this document The purpose of this application note is to describe the Speex library features and interface and provide the source code containing the library and a sample application to be used with a LPC175x 6x microcontroller compatible with Keil MDK IAR EWARM and LPCXpresso IDE s AN11085 All information provided in this document is subject to legal disclaimers NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 3 of 15 NXP Semiconductors AN1 1 085 AN11085 Usin
15. ot accept any liability in this respect Export control This document as well as the item s described herein may be subject to export control regulations Export might require a prior authorization from national authorities Evaluation products This product is provided on an as is and with all faults basis for evaluation purposes only NXP Semiconductors its affiliates and their suppliers expressly disclaim all warranties whether express implied or statutory including but not limited to the implied warranties of non infringement merchantability and fitness for a particular purpose The entire risk as to the quality or arising out of the use or performance of this product remains with customer In no event shall NXP Semiconductors its affiliates or their suppliers be liable to customer for any special indirect consequential punitive or incidental damages including without limitation damages for loss of business business interruption loss of use loss of data or information and the like arising out the use of or inability to use the product whether or not based on tort including negligence strict liability breach of contract breach of warranty or any other theory even if advised of the possibility of such damages Notwithstanding any damages that customer might incur for any reason whatsoever including without limitation all damages referenced above and all direct or general damages the entire liabili
16. put audio signal This external coder decoder is configured to capture audio from the MIC input which is then sent to the microcontroller using the 12S interface The LPC175x 6x 12S controller is configured as follows e Sampling frequency Fs 16 kHz The lower sampling rate for LPC1768 e Transmitter master Receiver master e 16 bit data words MONO The UDA1380 sends data according to WS and BCK signals generated by LPC1768 Because the microphone signal is MONO the same value is sent as RIGHT and LEFT data When configured for 16 bit word the RX FIFO is expected to contain two consecutive 16 bit samples after a complete WS cycle Because an 8 kHz real sampling rate is needed only one sample contained in the RX FIFO is stored into IN_Buffer as a down sampling process The RX FIFO contents and 12S bus format sent by UDA1380 is shown in Fig 9 and an oscilloscope screen of the transition is shown in Fig 10 Mono 16 bit data mode 15 N 1 ol 45 N 0 ws cert Of RIGHT 1 2 3 gt 8 1 2 3 gt 8 ek V V V AV VVV VVV ee UU TOY GHD C S ED GD GND GHD C gt O GD GD OD GD CES Fig 9 12S bus format for UDA1380 All information provided in this document is subject to legal disclaimers NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 11 of 15 NXP Semiconductors AN1 1 085 Using Speex in NXP s LPC175x 6x MCU family Fig 10 Oscilloscope screen of an I2S signal received by t
17. rative purposes only NXP Semiconductors makes no representation or warranty that such applications will be suitable for the specified use without further testing or modification Customers are responsible for the design and operation of their applications and products using NXP Semiconductors products and NXP Semiconductors accepts no liability for any assistance with applications or customer product design It is customer s sole responsibility to determine whether the NXP Semiconductors product is suitable and fit for the customer s applications and products planned as well as for the planned AN11085 All information provided in this document is subject to legal disclaimers Using Speex in NXP s LPC175x 6x MCU family application and use of customer s third party customer s Customers should provide appropriate design and operating safeguards to minimize the risks associated with their applications and products NXP Semiconductors does not accept any liability related to any default damage costs or problem which is based on any weakness or default in the customer s applications or products or the application or use by customer s third party customer s Customer is responsible for doing all necessary testing for the customer s applications and products using NXP Semiconductors products in order to avoid a default of the applications and the products or of the application or use by customer s third party customer s NXP does n
18. ty of NXP Semiconductors its affiliates and their suppliers and customer s exclusive remedy for all of the foregoing shall be limited to actual damages incurred by customer based on reasonable reliance up to the greater of the amount actually paid by customer for the product or five dollars US 5 00 The foregoing limitations exclusions and disclaimers shall apply to the maximum extent permitted by applicable law even if any remedy fails of its essential purpose 5 3 Trademarks Notice All referenced brands product names service names and trademarks are property of their respective owners NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 14 of 15 NXP Semiconductors AN11085 6 Contents alt goye Uc ol eee nent nner en nna tenis nee athe sieenn neers steers 3 VERVIEW AEE 3 Speex FEALUIES ceeeccccce ees eeeeeeeeeeeeaeeeeeeeeeeeeeeeas 9 PRODI CATIONS cca vedeccesescatdccwieesccseendenGiasenbeaacde 3 About this document ccccceeeceeeeeeeeeeeeeeeeees 3 LPC175x 6x featUreS ccccccceeceeceeeceesseeeeeeaees 4 About Code Red s RBD1768 development board PAE EE E E E T E E EEE 4 Applications 5 Vocoder OVEIVICW cccceecccceeceeeeeeeeceeecesseeeeeees 5 Memory requirements ccccseeeeeeseeeeeseeeeeeeees 6 Speex application implementation 06 6 Codet SeMS iresi se acedenetebanstderdarteaewes 6 Sampling rate cece ccccece
19. y and up to 4 5 ms for decoding This makes the LPC175x 6x suitable for real time encoding or decoding Using libSpeex In order to use libSpeex functions for encoding decoding voice a Speex bit packing struct must be declared along with a Speex encoder state SpeexBits bits void enc_state The struct bits encoder and decoder are initialized by spx_Init using a SPX_ CODEC CFG_Type for CODEC configuration as shown in Fig 3 and Fig 4 SPX_CODEC CFG Type spx_config Speex CODEC configuration spx_config quality 4 Encoder parameter spx_config complexity 1 Encoder parameter spx_config vbr SPX_VBR_DISABLED Encoder parameter spx_config enh SPX_ENHANCER_ENABLED Decoder parameter spx_Init amp spx_config Fig 3 Speex configuration struct 1 Only during encoding or decoding PO_25 is set to a high level providing a simple approach for time measurement All information provided in this document is subject to legal disclaimers NXP B V 2011 All rights reserved Application note Rev 1 16 June 2011 7 of 15 NXP Semiconductors AN1 1 085 Using Speex in NXP s LPC175x 6x MCU family void spx_Init SPX_CODEC_CFG_Type SpxCfg Speex_bits_init amp bits Speex encoding initializations enc_state Speex_encoder_init amp Speex_nb_mode Speex_encoder_ctl enc_state SPHEX_SET_VBR amp SpxCfg gt vbr Speex_encoder_ctl enc_state SPEHEEX_

Download Pdf Manuals

image

Related Search

Related Contents

準備する  [U4.63.11] Macro commande MACRO_PROJ_BASE  GangPro430 User`s Manual  Gelieve deze bijsluiter aandachtig te lezen alvorens dit  Hotpoint H151EWH User's Manual  Service Today July August 2009 Issue  Einhell TH-SM 2131 Dual  Prodigy Info- Turnout - Model Rectifier Corporation  

Copyright © All rights reserved.
Failed to retrieve file