From f5c0d8de94875acf7230181271329a57e4ad2f09 Mon Sep 17 00:00:00 2001 From: Joachim Fenkes Date: Tue, 31 Jul 2012 21:43:34 +0200 Subject: [PATCH] Initial win code --- noiseplug.sln | 20 +++++++++ win/main.cpp | 50 +++++++++++++++++++++ win/noiseplug.vcxproj | 83 +++++++++++++++++++++++++++++++++++ win/noiseplug.vcxproj.filters | 22 ++++++++++ win/noiseplug.vcxproj.user | 3 ++ 5 files changed, 178 insertions(+) create mode 100644 noiseplug.sln create mode 100644 win/main.cpp create mode 100644 win/noiseplug.vcxproj create mode 100644 win/noiseplug.vcxproj.filters create mode 100644 win/noiseplug.vcxproj.user diff --git a/noiseplug.sln b/noiseplug.sln new file mode 100644 index 0000000..16c0ad9 --- /dev/null +++ b/noiseplug.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "noiseplug", "win\noiseplug.vcxproj", "{2DCCAC56-B965-4F95-9281-143691AE4C97}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2DCCAC56-B965-4F95-9281-143691AE4C97}.Debug|Win32.ActiveCfg = Debug|Win32 + {2DCCAC56-B965-4F95-9281-143691AE4C97}.Debug|Win32.Build.0 = Debug|Win32 + {2DCCAC56-B965-4F95-9281-143691AE4C97}.Release|Win32.ActiveCfg = Release|Win32 + {2DCCAC56-B965-4F95-9281-143691AE4C97}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/win/main.cpp b/win/main.cpp new file mode 100644 index 0000000..fc3d08a --- /dev/null +++ b/win/main.cpp @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include + +void fill(char *data) +{ + for (int i = 0; i < 4096; i++) + { + data[i] = (i & (i & 512 ? 7 : 3)) << 3; + } +} + +static const WAVEFORMATEX fmt = { + WAVE_FORMAT_PCM, 1, 8000, 8000, 1, 8, 0 +}; + +int main(int argc, char *argv[]) +{ + HWAVEOUT out; + HRESULT rc = waveOutOpen(&out, WAVE_MAPPER, &fmt, NULL, NULL, CALLBACK_NULL); + if (rc != MMSYSERR_NOERROR) + { + printf("error %d on open\n"); + exit(1); + } + + WAVEHDR bufs[2] = { + { (char *)malloc(4096), 4096 }, + { (char *)malloc(4096), 4096 }, + }; + int i = 0; + + fill(bufs[i].lpData); + bufs[i].dwFlags = WHDR_PREPARED; + waveOutPrepareHeader(out, bufs + i, sizeof(WAVEHDR)); + waveOutWrite(out, bufs + i, sizeof(WAVEHDR)); + i ^= 1; + + while (!(GetAsyncKeyState(VK_ESCAPE) & 1)) + { + fill(bufs[i].lpData); + bufs[i].dwFlags = WHDR_PREPARED; + waveOutPrepareHeader(out, bufs + i, sizeof(WAVEHDR)); + waveOutWrite(out, bufs + i, sizeof(WAVEHDR)); + i ^= 1; + while (waveOutUnprepareHeader(out, bufs + i, sizeof(WAVEHDR)) == WAVERR_STILLPLAYING); + } +} \ No newline at end of file diff --git a/win/noiseplug.vcxproj b/win/noiseplug.vcxproj new file mode 100644 index 0000000..7da8b1a --- /dev/null +++ b/win/noiseplug.vcxproj @@ -0,0 +1,83 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {2DCCAC56-B965-4F95-9281-143691AE4C97} + Win32Proj + noiseplug + + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);winmm.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/win/noiseplug.vcxproj.filters b/win/noiseplug.vcxproj.filters new file mode 100644 index 0000000..6e05b87 --- /dev/null +++ b/win/noiseplug.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Quelldateien + + + \ No newline at end of file diff --git a/win/noiseplug.vcxproj.user b/win/noiseplug.vcxproj.user new file mode 100644 index 0000000..ace9a86 --- /dev/null +++ b/win/noiseplug.vcxproj.user @@ -0,0 +1,3 @@ + + + \ No newline at end of file