learnAudio.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef _LEARN_AUDIO_H_
  2. #define _LEARN_AUDIO_H_
  3. #ifdef ENABLE_ENABLE_AMRNB
  4. #include "wamr.h"
  5. #endif
  6. #ifdef ENABLE_ENABLE_SPEEX
  7. #include "speex.h"
  8. #endif
  9. #define MAX_FRAMES_TOTAL (1*60*50) //1分钟最多存的帧数
  10. #ifdef ENABLE_ENABLE_AMRNB
  11. #define FRAME_PER_SIZE 32 //压缩后每帧大小
  12. #define FRAME_ENCODE_TYPE 0x3c
  13. #endif
  14. #ifdef ENABLE_ENABLE_SPEEX
  15. /*
  16. 编码等级 : 0 | 1 | 2 | 3/4| 5/6 | 7/8 | 9 | 10
  17. 编码后字节数: 6 | 10 | 15 | 20 | 28 | 38 | 46 | 62
  18. 压缩率% :1.875|3.125|4.6875|6.25|8.75 |11.875|14.375|19.375
  19. 比特率bps :2400 |4000 | 6000 |8000|11200|15200 |18400 |24800
  20. */
  21. #define FRAME_QULITY 5
  22. #define FRAME_PER_SIZE 28
  23. #endif
  24. typedef enum{
  25. LEARN_PLY_IDLE,
  26. LEARN_PLY_BUSY,
  27. LEARN_PLY_PRE_ERR,
  28. LEARN_PLY_FAILED,
  29. LEARN_PLY_DONE
  30. }LEARN_PLY_ENUM;
  31. typedef struct{
  32. unsigned char *pcm;
  33. unsigned int frameNum;
  34. unsigned short frameSize;
  35. unsigned int plyNum;
  36. #ifdef ENABLE_ENABLE_SPEEX
  37. void *speexCt;
  38. SpeexBits bits;
  39. #endif
  40. unsigned char playType;//播放类型:0 播放临时录音 1 播放本地录音
  41. bool stopPlay;//用于停止正在播放的操作
  42. int fd;//用于播放本地录音文件使用
  43. }LEARN_REC_DEF;
  44. bool learnStartRecord(unsigned char charaNum);
  45. void learnStopRecord(void);
  46. void learnRecordFree(void);
  47. void learnRecordBufRelease(void);
  48. void learnPlayAudio(unsigned char type, const char *fname);
  49. LEARN_PLY_ENUM learnPlyGetResult(void);
  50. unsigned char learnGetAudioType(void);
  51. void learnStopPlaying(void);
  52. void recordSaveTmpToLocal(char *fileName);
  53. unsigned char *learnGetTmpAudioBuf(void);
  54. unsigned int learnGetTmpAudioLength(void);
  55. unsigned short learnGetRecordMaxVolume(void);
  56. float learnGetRecordRecSpeed(void);
  57. //#define SAVE_PCM_SD
  58. #ifdef SAVE_PCM_SD
  59. void pcmFileOpen(void);
  60. void pcmFileClose(void);
  61. #endif
  62. #endif