forked from microsoft/Xbox-ATG-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToneSampleGenerator.h
37 lines (28 loc) · 1.2 KB
/
ToneSampleGenerator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//--------------------------------------------------------------------------------------
// ToneSampleGenerator.h
//
// Advanced Technology Group (ATG)
// Copyright (C) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once
#define _USE_MATH_DEFINES
#include <math.h>
#include <limits.h>
template<typename T> T Convert(double Value);
class ToneSampleGenerator
{
public:
ToneSampleGenerator();
~ToneSampleGenerator();
bool IsEOF(){ return (m_SampleQueue == nullptr); };
unsigned int GetBufferLength(){ return ( m_SampleQueue != nullptr ? m_SampleQueue->BufferSize : 0 ); };
void Flush();
HRESULT GenerateSampleBuffer( unsigned long Frequency, unsigned int FramesPerPeriod, WAVEFORMATEX *wfx );
HRESULT FillSampleBuffer( unsigned int BytesToRead, unsigned char *Data );
private:
template <typename T>
void GenerateSineSamples(unsigned char *Buffer, size_t BufferLength, unsigned long Frequency, unsigned short ChannelCount, unsigned long SamplesPerSecond, double Amplitude, double *InitialTheta);
private:
RenderBuffer *m_SampleQueue;
RenderBuffer **m_SampleQueueTail;
};