ghy
Alejandro Acuña
2025-03-12 26319e4c5bfbee722c15b8e7ccca9b6127bb1cb8
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
#include "WaveFormats.h"
#include "../../Tracer/Tracer.h"
 
WaveFormat::WaveFormat()
{
}
 
WaveFormat::~WaveFormat()
{
}
 
WAVEFORMATEX
WaveFormat::GetWaveFormat(int nWaveFormat)
{
    WAVEFORMATEX wfx;
    switch(nWaveFormat)
    {
    case WaveFormat_ULaw:
        wfx.wFormatTag = WAVE_FORMAT_MULAW;
        wfx.cbSize = 0;
        wfx.nAvgBytesPerSec = 8000;
        wfx.nBlockAlign = 1;
        wfx.nChannels = 1;
        wfx.nSamplesPerSec = 8000;
        wfx.wBitsPerSample = 8;
        break;
    case WaveFormat_ALaw:
        wfx.wFormatTag = WAVE_FORMAT_ALAW;
        wfx.cbSize = 0;
        wfx.nAvgBytesPerSec = 8000;
        wfx.nBlockAlign = 1;
        wfx.nChannels = 1;
        wfx.nSamplesPerSec = 8000;
        wfx.wBitsPerSample = 8;
        break;
    case WaveFormat_G729:
        wfx.wFormatTag = WAVE_FORMAT_CISCO_G729;
        wfx.cbSize = 0;
        wfx.nAvgBytesPerSec = 1000;
        wfx.nBlockAlign = 1;
        wfx.nChannels = 1;
        wfx.nSamplesPerSec = 8000;
        wfx.wBitsPerSample = 8;
        break;
    case WaveFormat_G723_53:
        wfx.wFormatTag = WAVE_FORMAT_CISCO_G723_53;
        wfx.cbSize = 0;
        wfx.nAvgBytesPerSec = 667;
        wfx.nBlockAlign = 1;
        wfx.nChannels = 1;
        wfx.nSamplesPerSec = 8000;
        wfx.wBitsPerSample = 8;
    case WaveFormat_G723_63:
        wfx.wFormatTag = WAVE_FORMAT_CISCO_G723_63;
        wfx.cbSize = 0;
        wfx.nAvgBytesPerSec = 800;
        wfx.nBlockAlign = 1;
        wfx.nChannels = 1;
        wfx.nSamplesPerSec = 8000;
        wfx.wBitsPerSample = 8;
        break;
    case WaveFormat_PCM_16_8_1:
        wfx.wFormatTag = WAVE_FORMAT_PCM;
        wfx.cbSize = 0;
        wfx.nAvgBytesPerSec = 16000;
        wfx.nBlockAlign = 2;
        wfx.nChannels = 1;
        wfx.nSamplesPerSec = 8000;
        wfx.wBitsPerSample = 16;
        break;
    default:
        break;
    }
    return wfx;
}
 
void
WaveFormat::TraceFormat(Tracer *tracer, unsigned long traceLevel, WAVEFORMATEX &wfx)
{
    tracer->tracef(traceLevel, "WAVEFORMATEX wFormatTag=%u, nAvgBytesPerSec=%u, nSamplesPerSec=%u, wBitsPerSample=%u, nChannels=%u, nBlockAlign=%u, cbSize=%u\n", wfx.wFormatTag, wfx.nAvgBytesPerSec, wfx.nSamplesPerSec, wfx.wBitsPerSample, wfx.nChannels, wfx.nBlockAlign, wfx.cbSize);
}