62 lines
1.3 KiB
C++
62 lines
1.3 KiB
C++
#include "AudioSample.h"
|
|
#include "AudioSynth.h"
|
|
#include "AudioWriter.h"
|
|
#include "WasapiInterface.h"
|
|
|
|
#include "TestCase.h"
|
|
#include "TestCaseRunner.h"
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#ifdef _WIN32
|
|
#include <windows.h>
|
|
#endif
|
|
#include <iostream>
|
|
|
|
class TestWriteWav : public TestCase
|
|
{
|
|
public:
|
|
bool Run() override
|
|
{
|
|
AudioWriter writer;
|
|
writer.SetPath("test.wav");
|
|
|
|
AudioSynth synth;
|
|
auto sample = synth.GetSineWave(240, 5);
|
|
|
|
writer.Write(sample);
|
|
return true;
|
|
}
|
|
};
|
|
|
|
class TestAudioRender : public TestCase
|
|
{
|
|
public:
|
|
bool Run() override
|
|
{
|
|
#ifdef _WIN32
|
|
WasapiInterface audio_interface;
|
|
auto device = AudioDevice::Create();
|
|
audio_interface.Play(device);
|
|
#endif
|
|
return true;
|
|
}
|
|
};
|
|
|
|
//int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
|
|
int main()
|
|
{
|
|
#ifdef _WIN32
|
|
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
|
#endif
|
|
std::cout << "into entry point" << std::endl;
|
|
TestCaseRunner runner;
|
|
runner.AddTestCase("TestWriteNav", std::make_unique<TestWriteWav>());
|
|
runner.AddTestCase("TestAudioRender", std::make_unique<TestAudioRender>());
|
|
|
|
const auto testsPassed = runner.Run();
|
|
return testsPassed ? 0 : -1;
|
|
#ifdef _WIN32
|
|
CoUninitialize();
|
|
#endif
|
|
}
|