summaryrefslogtreecommitdiff
path: root/audio/SoundWire/Samples/SdcaVad/SdcaVDsp/ToneGenerator.h
blob: c9fd08fc23b9233283d26cdcc8cee1575e73b56f (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*++

Copyright (c) Microsoft Corporation All Rights Reserved

Module Name:

    ToneGenerator.h

Abstract:

    Declaration of a generic sine wave generator.

--*/
#ifndef _SAMPLE_TONEGENERATOR_H
#define _SAMPLE_TONEGENERATOR_H

class ToneGenerator
{
public:
    DWORD           m_Frequency; 
    WORD            m_ChannelCount; 
    WORD            m_BitsPerSample;
    DWORD           m_SamplesPerSecond;
    double          m_Theta;
    double          m_SampleIncrement;  
    bool            m_Mute;
    BYTE*           m_PartialFrame;
    DWORD           m_PartialFrameBytes;
    DWORD           m_FrameSize;
    double          m_ToneAmplitude;
    double          m_ToneDCOffset;

public:
    __drv_maxIRQL(PASSIVE_LEVEL)
    __declspec(code_seg("PAGE"))
    ToneGenerator();

    __drv_maxIRQL(PASSIVE_LEVEL)
    __declspec(code_seg("PAGE"))
    ~ToneGenerator();

    __drv_maxIRQL(PASSIVE_LEVEL)
    __declspec(code_seg("PAGE"))
    NTSTATUS
    Init
    (
        _In_    DWORD                   ToneFrequency, 
        _In_    double                  ToneAmplitude,
        _In_    double                  ToneDCOffset,
        _In_    double                  ToneInitialPhase,
        _In_    PWAVEFORMATEXTENSIBLE   WfExt
    );

    __drv_maxIRQL(PASSIVE_LEVEL)
    __declspec(code_seg("PAGE"))
    NTSTATUS
    Init
    (
        _In_    DWORD                   ToneFrequency,
        _In_    PWAVEFORMATEXTENSIBLE   WfExt
    );

    __drv_maxIRQL(DISPATCH_LEVEL)
    #pragma code_seg()
    VOID
    GenerateSine
    (
        _Out_writes_bytes_(BufferLength) BYTE       *Buffer, 
        _In_                             size_t      BufferLength
    );

    __drv_maxIRQL(PASSIVE_LEVEL)
    __declspec(code_seg("PAGE"))
    VOID
    SetMute
    (
        _In_ bool Value
    )
    {
        m_Mute = Value;
    }

private:
    __drv_maxIRQL(DISPATCH_LEVEL)
    #pragma code_seg()
    VOID InitNewFrame
    (
        _Out_writes_bytes_(FrameSize)   BYTE*  Frame, 
        _In_                            DWORD  FrameSize
    );
};

#endif // _SAMPLE_TONEGENERATOR_H