4
#include <SDL/SDL_mixer.h>
7
#include <emscripten.h>
12
int channel = Mix_PlayChannel(-1, sound, 1);
19
int main(int argc, char **argv) {
20
SDL_Init(SDL_INIT_AUDIO);
22
int ret = Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024);
25
Uint16* buffer = (Uint16*)malloc(10*44100*sizeof(Uint16));
26
for (Uint32 i = 0; i < 10*44100; ++i) {
27
buffer[i] = (i * 5) % UINT32_MAX;
29
sound = Mix_QuickLoad_RAW((Uint8*) buffer, 10*44100*sizeof(Uint16));
34
emscripten_run_script("element = document.createElement('input');"
35
"element.setAttribute('type', 'button');"
36
"element.setAttribute('value', 'replay!');"
37
"element.setAttribute('onclick', 'Module[\"_play\"]()');"
38
"document.body.appendChild(element);");
40
printf("you should one sounds. press the button to replay!\n");