Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.3 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 26/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: LgVoiceModem.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LgVoiceModem.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "LgVoiceModem.h"
  16. CLgVoiceModem::CLgVoiceModem()
  17. {
  18. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgVoiceModem::CLgVoiceModem" );
  19. }
  20. CLgVoiceModem::~CLgVoiceModem()
  21. {
  22. Destroy();
  23. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgVoiceModem::~CLgVoiceModem" );
  24. }
  25. BOOL CLgVoiceModem::Drop()
  26. {
  27. // stop wave
  28. CLgWavePlayer::ResetWave();
  29. // stop speech
  30. CLgSpeechPlayer::ResetSpeech();
  31. // drop line
  32. return CLgModem::Drop();
  33. }
  34. BOOL CLgVoiceModem::Play( LPCTSTR pWaveFile )
  35. {
  36. if( !m_WaveFile.Load( pWaveFile ) )
  37. {
  38. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CLgVoiceModem::Play", "m_WaveFile.Load( \"%s\" ) failed", pWaveFile );
  39. return FALSE;
  40. }
  41. if( !m_WaveFile.ConvertToPCM() )
  42. {
  43. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CLgVoiceModem::Play", "m_WaveFile.ConvertToPCM() failed" );
  44. return FALSE;
  45. }
  46. LPCTSTR pTapiDeviceName = "wave/out";
  47. DWORD dwWaveDeviceID;
  48. if( !CLgModem::GetDeviceID( &dwWaveDeviceID, pTapiDeviceName ) )
  49. {
  50. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CLgVoiceModem::Play", "Can't get wave device for %s", pTapiDeviceName );
  51. return FALSE;
  52. }
  53. if( !CLgWavePlayer::PlayWave( &m_WaveFile, dwWaveDeviceID ) )
  54. {
  55. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CLgVoiceModem::Play", "CLgWavePlayer::Play( %p, %d ) failed", &m_WaveFile, dwWaveDeviceID );
  56. return FALSE;
  57. }
  58. return TRUE;
  59. }
  60. BOOL CLgVoiceModem::Speak( LPCTSTR pSpeech, INT nVolume, INT nRate, LPWSTR pVoiceTokenId )
  61. {
  62. LPCTSTR pTapiDeviceName = "wave/out";
  63. DWORD dwWaveDeviceID;
  64. if( !CLgModem::GetDeviceID( &dwWaveDeviceID, pTapiDeviceName ) )
  65. {
  66. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, "CLgVoiceModem::Speak", "Can't get wave device for %s", pTapiDeviceName );
  67. return FALSE;
  68. }
  69. return CLgSpeechPlayer::PlaySpeech( pSpeech, dwWaveDeviceID );
  70. }