Leaked source code of windows server 2003
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.

108 lines
5.7 KiB

  1. // Copyright (c) 1996-1999 Microsoft Corporation
  2. //
  3. // CSynth.h
  4. //
  5. #ifndef __CSYNTH_H__
  6. #define __CSYNTH_H__
  7. #include "synth.h"
  8. #define MAX_CHANNEL_GROUPS 1000
  9. #define MAX_VOICES 1000
  10. // Forward declarations
  11. struct IDirectSoundSynthSink;
  12. class CSynth : public CListItem
  13. {
  14. friend class CControlLogic;
  15. public:
  16. CSynth();
  17. ~CSynth();
  18. CSynth * GetNext() {return(CSynth *)CListItem::GetNext();};
  19. HRESULT SetStereoMode(DWORD dwBufferFlags);
  20. HRESULT SetSampleRate(DWORD dwSampleRate);
  21. HRESULT Activate(DWORD dwSampleRate, DWORD dwBufferFlags);
  22. HRESULT Deactivate();
  23. HRESULT Download(LPHANDLE phDownload, void *pdwData, LPBOOL bpFree);
  24. HRESULT Unload(HANDLE hDownload,HRESULT ( CALLBACK *lpFreeMemory)(HANDLE,HANDLE),HANDLE hUserData);
  25. HRESULT PlayBuffer(IDirectMusicSynthSink *pSynthSink, REFERENCE_TIME rt, LPBYTE lpBuffer, DWORD cbBuffer, ULONG ulCable);
  26. HRESULT SetNumChannelGroups(DWORD dwCableCount);
  27. void SetGainAdjust(VREL vrGainAdjust);
  28. HRESULT Open(DWORD dwCableCount, DWORD dwVoices, BOOL fReverb);
  29. HRESULT Close();
  30. void ResetPerformanceStats();
  31. HRESULT AllNotesOff();
  32. HRESULT SetMaxVoices(short nMaxVoices,short nTempVoices);
  33. HRESULT GetMaxVoices(short *pnMaxVoices,short *pnTempVoices);
  34. HRESULT GetPerformanceStats(PerfStats *pStats);
  35. void Mix(short **ppvBuffer, DWORD *pdwIDs, DWORD *pdwFuncIDs, long *plPitchBends, DWORD dwBufferCount, DWORD dwBufferFlags, DWORD dwLength, LONGLONG llPosition);
  36. HRESULT SetChannelPriority(DWORD dwChannelGroup,DWORD dwChannel,DWORD dwPriority);
  37. HRESULT GetChannelPriority(DWORD dwChannelGroup,DWORD dwChannel,LPDWORD pdwPriority);
  38. HRESULT SetReverb(DMUS_WAVES_REVERB_PARAMS *pParams);
  39. void GetReverb(DMUS_WAVES_REVERB_PARAMS *pParams);
  40. void SetReverbActive(BOOL fReverb);
  41. BOOL IsReverbActive();
  42. /* DirectX8 methods */
  43. HRESULT PlayBuffer(STIME stTime, REFERENCE_TIME rt, LPBYTE lpBuffer, DWORD cbBuffer, ULONG ulCable);
  44. HRESULT PlayBuffer(IDirectSoundSynthSink *pSynthSink, REFERENCE_TIME rt, LPBYTE lpBuffer, DWORD cbBuffer, ULONG ulCable);
  45. HRESULT PlayVoice(IDirectSoundSynthSink *pSynthSink, REFERENCE_TIME rt, DWORD dwVoiceId, DWORD dwChannelGroup, DWORD dwChannel, DWORD dwDLId, VREL vrVolume, PREL prPitch, SAMPLE_TIME stVoiceStart, SAMPLE_TIME stLoopStart, SAMPLE_TIME stLoopEnd);
  46. HRESULT StopVoice(IDirectSoundSynthSink *pSynthSink, REFERENCE_TIME rt, DWORD dwVoiceId);
  47. HRESULT GetVoiceState(DWORD dwVoice[], DWORD cbVoice, DMUS_VOICE_STATE VoiceState[]);
  48. HRESULT Refresh(DWORD dwDownloadID, DWORD dwFlags);
  49. HRESULT AssignChannelToBuses(DWORD dwChannelGroup, DWORD dwChannel, LPDWORD pdwBusses, DWORD cBusses);
  50. public:
  51. bool BusIDToFunctionID(DWORD dwBusID, DWORD *pdwFunctionID, long *plPitchBends, DWORD *pdwIndex); // Converts the passed bus id into the equivalent function id and position in buffer array.
  52. private:
  53. void StealNotes(STIME stTime);
  54. void StartMix(short *pBuffer,DWORD dwlength,BOOL bInterleaved);
  55. void FinishMix(short *pBuffer,DWORD dwlength,BOOL bInterleaved);
  56. short ChangeVoiceCount(CVoiceList *pList,short nOld,short nCount);
  57. private:
  58. DWORD * m_pdwBusIDs; // Temp pointer to array of bus ids. This is valid only during a mix.
  59. DWORD * m_pdwFuncIDs; // Temp pointer to array of corresponding functional ids. This is also only valid during a mix.
  60. long * m_plPitchBends; // Temp pointer to array of corresponding pitch offsets.
  61. DWORD m_dwBufferCount; // Size of two preceding arrays.
  62. CVoice * OldestVoice();
  63. void QueueVoice(CVoice *pVoice);
  64. CVoice * StealVoice(DWORD dwPriority);
  65. STIME m_stLastTime; // Sample time of last mix.
  66. CVoiceList m_VoicesFree; // List of available voices.
  67. CVoiceList m_VoicesExtra; // Extra voices for temporary overload.
  68. CVoiceList m_VoicesInUse; // List of voices currently in use.
  69. short m_nMaxVoices; // Number of allowed voices.
  70. short m_nExtraVoices; // Number of voices over the limit that can be used in a pinch.
  71. STIME m_stLastStats; // Last perfstats refresh.
  72. PerfStats m_BuildStats; // Performance info accumulator.
  73. PerfStats m_CopyStats; // Performance information for display.
  74. BOOL m_fReverbActive; // Whether reverb is currently on or off.
  75. long * m_pStates; // State storage for reverb.
  76. void * m_pCoefs; // Coeeficient storage for reverb.
  77. DMUS_WAVES_REVERB_PARAMS m_ReverbParams; // Reverb settings.
  78. public:
  79. VREL m_vrGainAdjust; // Final output gain adjust
  80. // DLS-1 compatibility parameters: set these off to emulate hardware
  81. // which can't vary volume/pan during playing of a note.
  82. BOOL m_fAllowPanWhilePlayingNote;
  83. BOOL m_fAllowVolumeChangeWhilePlayingNote;
  84. STIME m_stMinSpan; // Minimum time allowed for mix time span.
  85. STIME m_stMaxSpan; // Maximum time allowed for mix time span.
  86. DWORD m_dwSampleRate; // Sample rate
  87. DWORD m_dwStereo; // Is the output stereo
  88. CInstManager m_Instruments; // Instrument manager.
  89. CControlLogic **m_ppControl; // Array of open ControlLogics.
  90. DWORD m_dwControlCount; // # of open CLs.
  91. CRITICAL_SECTION m_CriticalSection; // Critical section to manage access.
  92. BOOL m_fCSInitialized;
  93. BOOL m_sfMMXEnabled; // Is MMX enabled
  94. };
  95. #endif// __CSYNTH_H__