当前位置:   article > 正文

c语言编程发出声音,用C语言发声

c语言输出图形后怎么发出哔哔声音

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

{

static double fAngle ;

short * Point=(short *)pBuffer;

int i ;

for (i=0 ; i < OUT_BUFFER_SIZE / (SAMPLE_BITS*CHANNELS/8) ; i++)

{

fAngle += 2 * PI * Freq / SAMPLE_RATE ;

*Point=(short)0x8000 * sin(fAngle);

Point++;

*Point=(short)0x8000 * sin(fAngle);

Point++;

while (fAngle > 2 * PI)

fAngle -= 2 * PI ;

}

}

void CALLBACK waveOutProc(HWAVEOUT hWaveOut, UINT uMsg,DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)

{

PWAVEHDR pWaveHdr=(PWAVEHDR)dwParam1;

static bool isClose=false;

switch (uMsg)

{

case MM_WOM_DONE:

{

if(!isEnd)

{

FillBuffer (pWaveHdr->lpData, iFreq) ;

waveOutWrite (hWaveOut, pWaveHdr, sizeof (WAVEHDR)) ;

iFreq+=10;

printf("freq=%d\n",iFreq);

}

break;

}

case MM_WOM_OPEN:

case MM_WOM_CLOSE:

break;

}

}

void main()

{

LPSTR pBuffer1   = (LPSTR)malloc (OUT_BUFFER_SIZE) ;

LPSTR pBuffer2   = (LPSTR)malloc (OUT_BUFFER_SIZE) ;

WaveHdr1.lpData=pBuffer1;

WaveHdr2.lpData=pBuffer2;

FillBuffer (pBuffer1, iFreq) ;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/1007019
推荐阅读
相关标签
  

闽ICP备14008679号