Created
February 13, 2016 14:39
-
-
Save suzukiplan/0a07bbcc8b9b5f75c237 to your computer and use it in GitHub Desktop.
Example of the VGS-SPU
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _WIN32 | |
#include <windows.h> | |
#else | |
#include <unistd.h> | |
#endif | |
#include <stdio.h> | |
#include "vgsspu.h" | |
#ifdef _WIN32 | |
static void usleep(int usec) | |
{ | |
Sleep(usec / 1000); | |
} | |
#endif | |
static unsigned int hz; | |
static unsigned int pw = 22050; | |
static void buffering(void* buffer, size_t size) | |
{ | |
short* sbuf = (short*)buffer; | |
size_t s2 = size >> 1; | |
size_t s1; | |
for (s1 = 0; s1 < s2; s1++, sbuf++, hz++) { | |
if (hz % 440 < 220) { | |
*sbuf = (short)((16384 * pw) / 22050); | |
} else { | |
*sbuf = (short)((-16384 * pw) / 22050); | |
} | |
if (pw) pw--; | |
} | |
} | |
int main(int argc, char* argv[]) | |
{ | |
void* context = vgsspu_start(buffering); | |
if (NULL == context) { | |
puts("failed"); | |
return -1; | |
} | |
usleep(1000000); | |
vgsspu_end(context); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment