Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <combaseapi.h>
- #include <stdint.h>
- #include <math.h>
- #define KIT_AUDIO_USE_WINMM
- #include <kit_w32.h>
- extern int printf(const char* __format, ...);
- float getSinSample(){
- static int sample=0;
- float value=sinf(PI*2*440*((float)sample/11025));
- ++sample;
- return value;
- }
- void callback(void* userdata, void* stream, unsigned int len){
- float* stream_flt=stream;
- for(unsigned int i=0; i<len; ++i) stream_flt[i]=getSinSample();
- }
- int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR args, int nCmdShow){
- kit_audioSpec spec;
- spec.callback=callback;
- spec.buffer_len=4096;
- spec.frequency=11025;
- spec.channels=1;
- spec.format=KIT_AUDIO_FMT_F32;
- int returnStatus;
- kit_audioDevice* device=kit_audioWaveOutOpen(&spec,-1,&returnStatus);
- if(!device){ printf("returnStatus=%i\n",returnStatus); return 0; }
- kit_audioWaveOutPlay(device,1);
- Sleep(1000);
- //you'd then close the device (if only waveOutReset worked...)
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement