home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / SOUND.ZIP / Soundin.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-11-21  |  2.9 KB  |  98 lines

  1. // Sound.h: interface for the CSoundIn class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. /*
  5.    
  6.         This program is Copyright  Developped by Yannick Sustrac
  7.                    yannstrc@mail.dotcom.fr
  8.                 http://www.mygale.org/~yannstrc/
  9.  
  10.  
  11. This program is free software; you can redistribute it and/or modify it under the terms
  12. of the GNU General Public License as published by the Free Software Foundation; either
  13. version 2 of the License, or (at your option) any later version.
  14.  
  15. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  16. without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. See the GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License along with this program;
  20. if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. */
  23. //////////////////////////////////////////////////////////////////////////////////////////    
  24.  
  25.  
  26. #if !defined(AFX_SOUND_H__69C928C4_1F19_11D2_8045_30460BC10000__INCLUDED_)
  27. #define AFX_SOUND_H__69C928C4_1F19_11D2_8045_30460BC10000__INCLUDED_
  28.  
  29. #if _MSC_VER >= 1000
  30. #pragma once
  31. #endif // _MSC_VER >= 1000
  32.  
  33. #include <mmsystem.h>
  34.  
  35. #define MAX_SAMPLES 8192   //>>>>>>>> must also be defined in CFft
  36. #define MAX_VOIE 2
  37. #define MAX_SIZE_SAMPLES  1  // WORD
  38. #define MAX_SIZE_INPUT_BUFFER   MAX_SAMPLES*MAX_VOIE*MAX_SIZE_SAMPLES 
  39. #define DEFAULT_CAL_OFFSET -395 // >>>>> depends of you sound card
  40. #define DEFAULT_CAL_GAIN   1.0
  41.  
  42.  
  43. class CSoundIn  
  44. {
  45. public:
  46.  
  47.     // used for int FFT
  48.     SHORT  InputBuffer[MAX_SIZE_INPUT_BUFFER];
  49.  
  50.     WAVEINCAPS        m_WaveInDevCaps;
  51.     HWAVEIN            m_WaveIn;
  52.     WAVEHDR            m_WaveHeader;
  53.     WAVEFORMATEX    m_WaveFormat;
  54.     
  55.     short m_CalOffset;
  56.     double m_CalGain;
  57.  
  58.  
  59.     HANDLE m_WaveInEvent;
  60.     CWinThread * m_WaveInThread;
  61.     BOOL m_TerminateThread;
  62.  
  63.     UINT m_WaveInSampleRate;
  64.     int m_NbMaxSamples;
  65.     UINT m_SizeRecord;
  66.     WORD     m_Toggle; /*0 or 1 according the buffer currently loaded*/
  67.  
  68. public :    
  69.     void StartMic();
  70.     void StopMic();
  71.     void CloseMic();
  72.     void AddBuffer();
  73.  
  74. public :
  75.     virtual void RazBuffers();
  76.     virtual void ComputeSamples(SHORT *);  // calibrate the samples for the basse class 
  77.                                             // this function is overloaded by the parent
  78.                                             // it need to call this function first to calibrate them
  79.  
  80.  
  81.  
  82. //////////////////////////////////////////////////////
  83. // functions members
  84.     MMRESULT OpenMic();
  85.     void WaveInitFormat(   WORD    nCh, // number of channels (mono, stereo)
  86.                             DWORD   nSampleRate, // sample rate
  87.                             WORD    BitsPerSample);
  88.     //void CALLBACK waveInProc( HWAVEIN hwi,  UINT uMsg,   DWORD dwInstance,   DWORD dwParam1, DWORD dwParam2 );
  89.     
  90.     CSoundIn();
  91.     virtual ~CSoundIn();
  92.  
  93. };
  94.  
  95. // global Thread procedure 
  96.     UINT WaveInThreadProc( LPVOID pParam);
  97.  
  98. #endif