Skip to content

Instantly share code, notes, and snippets.

@kbjorklu
Created August 23, 2013 09:27
Show Gist options
  • Select an option

  • Save kbjorklu/6317308 to your computer and use it in GitHub Desktop.

Select an option

Save kbjorklu/6317308 to your computer and use it in GitHub Desktop.
Sample code for the waveOutWrite function.
#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
int main()
{
HWAVEOUT hWaveOut = 0;
WAVEFORMATEX wfx = { WAVE_FORMAT_PCM, 1, 8000, 8000, 1, 8, 0 };
waveOutOpen(&hWaveOut, WAVE_MAPPER, &wfx, 0, 0, CALLBACK_NULL);
char buffer[8000 * 60] = {};
// See http://goo.gl/hQdTi
for (DWORD t = 0; t < sizeof(buffer); ++t)
buffer[t] = static_cast<char>((((t * (t >> 8 | t >> 9) & 46 & t >> 8)) ^ (t & t >> 13 | t >> 6)) & 0xFF);
WAVEHDR header = { buffer, sizeof(buffer), 0, 0, 0, 0, 0, 0 };
waveOutPrepareHeader(hWaveOut, &header, sizeof(WAVEHDR));
waveOutWrite(hWaveOut, &header, sizeof(WAVEHDR));
waveOutUnprepareHeader(hWaveOut, &header, sizeof(WAVEHDR));
waveOutClose(hWaveOut);
Sleep(60 * 1000);
}
@RETE4QVT345TQtv34t34
Copy link

Bytebeat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment