OSDN Git Service

qq
[shooting3/shootinggame.git] / ShootingGame / SoundDriver.h
1 #pragma once
2 #include "WaveTableSynth.h"
3 #include "Sequencer.h"
4 #include "TestSong.h"
5
6 typedef Microsoft::WRL::ComPtr<IAudioClient2> IAudioClient2Ptr;
7 //typedef Microsoft::WRL::ComPtr<IAudioClock2> IAudioClock2Ptr;
8 typedef Microsoft::WRL::ComPtr<IAudioRenderClient> IAudioRenderClientPtr;
9 //typedef Microsoft::WRL::ComPtr<IAudioCaptureClient> IAudioCaptureClientPtr;
10 //typedef Microsoft::WRL::ComPtr<IAudioClockAdjustment> IAudioClockAdjustmentPtr;
11
12 namespace sf {
13
14   DefineException(AudioClientNull);
15   DefineException(AudioFormatNotSupported);
16
17   struct SoundDriver
18   {
19     typedef std::function<void (boost::shared_array<float> arr,int bufferSize)> ProcessBufferType;
20
21     SoundDriver();
22     ~SoundDriver();
23
24     void Render();
25     void Start();
26     void Stop();
27     void DefaultProcessBuffer(boost::shared_array<float> arr,int bufferSize);
28     void SetProcessBufferFunc(ProcessBufferType&& v);
29     void ResetProcessBufferFunc();
30     WAVEFORMATEXTENSIBLE& Format();
31   private:
32     ProcessBufferType processBuffer_;
33     IAudioClient2Ptr audioClient_;
34     uint32_t bufferSize_;
35     REFERENCE_TIME latency_;
36     //  IAudioClockAdjustmentPtr audioClockAdjustment_;
37     IAudioRenderClientPtr audioRenderClient_;
38     WAVEFORMATEXTENSIBLE format_;
39     sf::handle_holder eventHolder_;
40     boost::shared_array<float> buffer_[2];
41     int bufferIndex_;
42     int bufferByteCount_;
43     bool isStart_;
44   };
45 }
46