之前做一个小测试,需要在一定时间范围内,有一个提示音提示用户转换左右耳去听朗诵,因为左右耳听得内容不一样,这其实是个对专注度的测试。就拿C语言去实现了这个一个随机提示音,不断的随机播放,间隔时间不等。附上代码:
#include<stdio.h>
#include<windows.h>
#include<mmsystem.h>
#include<time.h>
#pragma comment(lib, "winmm.lib")
void main()
{
int temp_t1, temp_t2, temp_t3;
do
{
temp_t2 = rand() % 10 + 1;
temp_t3 = temp_t2 * 1000;
printf("temp_t2=%dtemp_t3=%d\n", temp_t2, temp_t3);
PlaySound(TEXT("E:\\downloads\\rings\\boom_di.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);
Sleep(500);
PlaySound(NULL, NULL, SND_FILENAME);
Sleep(8000 + temp_t3);
} while (1);
getchar();
return 0;
}