Source code of Windows XP (NT5)
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.

100 lines
4.0 KiB

  1. //
  2. // Copyright (c) 1996-2000 Microsoft Corporation. All rights reserved.
  3. //
  4. // CSynth.h
  5. //
  6. #ifndef __CSYNTH_H__
  7. #define __CSYNTH_H__
  8. #include "synth.h"
  9. #define MAX_CHANNEL_GROUPS 1000
  10. #define MAX_VOICES 1000
  11. #define DEFAULT_CHANNEL_GROUPS 32
  12. #define DEFAULT_VOICES 32
  13. #ifndef IDirectMusicSynthSink
  14. #define IDirectMusicSynthSink ISynthSinkDMus
  15. #endif // IDirectMusicSynthSink
  16. struct IDirectMusicSynthSink;
  17. /*****************************************************************************
  18. * class CSynth
  19. *****************************************************************************
  20. * Class declaration for the synth object itself.
  21. * Manages the CControlLogic and CInstManager objects.
  22. */
  23. class CSynth : public CListItem
  24. {
  25. friend class CControlLogic;
  26. public:
  27. CSynth();
  28. ~CSynth();
  29. CSynth * GetNext() {return(CSynth *)CListItem::GetNext();};
  30. HRESULT SetStereoMode(DWORD dwChannels) ;
  31. HRESULT SetSampleRate(DWORD dwSampleRate) ;
  32. HRESULT Activate(DWORD dwSampleRate, DWORD dwChannels);
  33. HRESULT Deactivate();
  34. HRESULT Download(LPHANDLE phDownload, void * pdwData, LPBOOL bpFree);
  35. HRESULT Unload(HANDLE hDownload,HRESULT ( CALLBACK *lpFreeMemory)(HANDLE,HANDLE),HANDLE hUserData);
  36. HRESULT PlayBuffer(IDirectMusicSynthSink *pSynthSink,REFERENCE_TIME rt, LPBYTE lpBuffer, DWORD cbBuffer, ULONG ulCable);
  37. HRESULT SetNumChannelGroups(DWORD dwCableCount);
  38. void SetGainAdjust(VREL vrGainAdjust);
  39. HRESULT Open(DWORD dwCableCount, DWORD dwVoices);
  40. HRESULT Close();
  41. void ResetPerformanceStats();
  42. HRESULT AllNotesOff();
  43. HRESULT SetMaxVoices(short nMaxVoices,short nTempVoices);
  44. HRESULT GetMaxVoices(short * pnMaxVoices,short * pnTempVoices);
  45. HRESULT GetPerformanceStats(PerfStats *pStats);
  46. void Mix(short *pBuffer,DWORD dwLength,LONGLONG llPosition);
  47. HRESULT SetChannelPriority(DWORD dwChannelGroup,DWORD dwChannel,DWORD dwPriority);
  48. HRESULT GetChannelPriority(DWORD dwChannelGroup,DWORD dwChannel,LPDWORD pdwPriority);
  49. private:
  50. void StealNotes(STIME stTime);
  51. void FinishMix(short *pBuffer,DWORD dwlength);
  52. CVoice * OldestVoice();
  53. void QueueVoice(CVoice *pVoice);
  54. CVoice * StealVoice(DWORD dwPriority);
  55. STIME m_stLastTime; // Sample time of last mix.
  56. CVoiceList m_VoicesFree; // List of available voices.
  57. CVoiceList m_VoicesExtra; // Extra voices for temporary overload.
  58. CVoiceList m_VoicesInUse; // List of voices currently in use.
  59. short m_nMaxVoices; // Number of allowed voices.
  60. short m_nExtraVoices; // Number of voices over the limit that can be used in a pinch.
  61. STIME m_stLastStats; // Last perfstats refresh.
  62. PerfStats m_BuildStats; // Performance info accumulator.
  63. PerfStats m_CopyStats; // Performance information for display.
  64. public:
  65. // DLS-1 compatibility parameters: set these off to emulate hardware
  66. // which can't vary volume/pan during playing of a note.
  67. VREL m_vrGainAdjust; // Final output gain adjust
  68. BOOL m_fAllowPanWhilePlayingNote;
  69. BOOL m_fAllowVolumeChangeWhilePlayingNote;
  70. STIME m_stMinSpan; // Minimum time allowed for mix time span.
  71. STIME m_stMaxSpan; // Maximum time allowed for mix time span.
  72. DWORD m_dwSampleRate;
  73. DWORD m_dwStereo;
  74. CInstManager m_Instruments; // Instrument manager.
  75. CControlLogic ** m_ppControl; // Array of open ControlLogics.
  76. DWORD m_dwControlCount; // # of open CLs.
  77. CRITICAL_SECTION m_CriticalSection; // Critical section to manage access.
  78. BOOL m_fCSInitialized;
  79. };
  80. #endif// __CSYNTH_H__