Linux»·¾³ÏÂÓÃcÓïÑÔдµÄ²¥·ÅwavÎļþµÄС³ÌÐò
±¾³ÌÐò¿ÉÒÔ¶ÁÈ¡.wavÎļþ£¬È»ºó½øÐв¥·Å¡£
È·ÈÏ·½·¨£ºcat /etc/sndstat£¬Èç¹ûÏÔʾÎÞ´ËÉ豸£¬ÔòûÓа²×°Çý¶¯¡£
#include <unistd.h>#include <fcntl.h>#include <sys/types.h>#include <sys/ioctl.h>#include <stdlib.h>#include <stdio.h>#include <linux/soundcard.h>/* ÏÂÃæµÄÈý¸ö²ÎÊýÊǸú¾ßÌåÎļþÏà¹ØµÄ£¬ÎļþʲôÑù£¬¾ÍÒªÉèÖóÉʲôÑù */
int main(){ int fd; int wavfd; //wavÎļþµÄÃèÊö·û
if (fd < 0) { printf("open of /dev/dsp failed"); exit(1);} wavfd = open("12193767609.wav",O_RDONLY); if (wavfd < 0) { printf("open of wav failed"); exit(1); }
/* .......... */ arg = CHANNELS; status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg); if (status == -1) perror("SOUND_PCM_WRITE_CHANNELS ioctl failed"); if (arg != CHANNELS) perror("unable to set number of channels");
/* ´ÓwavÎļþÖжÁbuf´óСµÄÄÚÈÝ£¬È»ºóдÈë/etc/dspÖУ¬Ö±µ½Îļþ½áÊø */ int time = 0; //¶¯Ì¬ÏÔʾ²¥·Åʱ¼äÓÃ
/*status = ioctl(fd, SOUND_PCM_SYNC, 0);
}}±¾³ÌÐòÖÐÐèÒªÒ»¸ö.wavÎļþ²ÅÄܲ¥·Å£¬Äã¿ÉÒÔµ½°Ù¶Èmp3ÉÏÈ¥ËÑË÷Ò»¸ö.wavÎļþ£¬·Åµ½³ÌÐòĿ¼Ï¡£È»ºó£¬°Ñ³ÌÐòÖеÄÎļþÃû¸Ä³É¸ÃÒôƵµÄÎļþÃû¡£
Ïà¹ØÎĵµ£º
ÔÚÇ°ÃæÒѾ½éÉܹý£¬£ÃÔ´³ÌÐòÊÇÓɺ¯Êý×é³ÉµÄ¡£ËäÈ»ÔÚÇ°Ãæ¸÷ÕµijÌÐòÖдó¶¼Ö»ÓÐÒ»¸öÖ÷º¯Êýmain()£¬µ«ÊµÓóÌÐòÍùÍùÓɶà¸öº¯Êý×é³É¡£º¯ÊýÊÇ£ÃÔ´³ÌÐòµÄ»ù±¾Ä£¿é£¬Í¨¹ý¶Ôº¯ÊýÄ£¿éµÄµ÷ÓÃʵÏÖÌض¨µÄ¹¦ÄÜ¡££ÃÓïÑÔÖеĺ¯ÊýÏ൱ÓÚÆäËü¸ß¼¶ÓïÑÔµÄ×Ó³ÌÐò¡££ÃÓïÑÔ²»½öÌṩÁ˼«Îª·á¸»µÄ¿âº¯Êý(ÈçTurbo C£¬MS C¶¼ÌṩÁËÈý°Ù¶à¸ö¿âº¯Êý)£¬» ......
11.1 ¶¨ÒåÒ»¸ö½á¹¹µÄÒ»°ãÐÎʽ
ÔÚʵ¼ÊÎÊÌâÖУ¬Ò»×éÊý¾ÝÍùÍù¾ßÓв»Í¬µÄÊý¾ÝÀàÐÍ¡£ÀýÈ磬ÔÚѧÉúµÇ¼Ç±íÖУ¬ÐÕÃûӦΪ×Ö·ûÐÍ£»Ñ§ºÅ¿ÉΪÕûÐÍ»ò×Ö·ûÐÍ£»ÄêÁäӦΪÕûÐÍ£»ÐÔ±ðӦΪ×Ö·ûÐÍ£»³É¼¨¿ÉΪÕûÐÍ»òʵÐÍ¡£ ÏÔÈ»²»ÄÜÓÃÒ»¸öÊý×éÀ´´æ·ÅÕâÒ»×éÊý¾Ý¡£ÒòΪÊý×éÖи÷ÔªËصÄÀàÐͺͳ¤¶È¶¼±ØÐëÒ»Ö£¬ÒÔ±ãÓÚ±àÒëϵͳ´¦Àí¡ ......
¿ìËÙÅÅÐòµÄºËÐÄÔÚÓÚ·ÖÖÎ.
·ÖÖÎËã·¨:
1. È϶¨Ö»ÓÐÒ»¸öÔªËØ»òûÓÐÔªËصÄÊý×éÊÇÓÐÐòµÄ.
2. ½«Êý×é°´ÕÕÒ»¸ö·Ö½çÖµ·ÖΪ×óÓÒÁ½²¿·Ö. ×óÃæËùÓÐÔªËØÖµ±È·Ö½çֵС, ÓÒÃæËùÓÐÔªËØÖµ±È·Ö½çÖµ´ó»òµÈÓÚ.
3. ½«×óÓÒÁ½²¿·Ö·Ö±ðÔÙ·ÖÖÎ, Ö±µ½Òª·ÖÖ§µÄ²¿·ÖÖ»ÓÐÒ»¸öÔªËØ»òûÓÐÔªËØ, ÄÇôÕû¸öÊý×é¾ÍÊÇÓÐÐòµÄÁË.
×÷Õß: selfimpr
²©¿Í: http ......
תÔØ×Ô£º
Ü°ÈÙ¼ÒÔ°blog
ÔÚCÓïÑÔÖУ¬¼ÙÉèÎÒÃÇÓÐÕâÑùµÄÒ»¸öº¯Êý£º
int function(int a,int b)
µ÷
ÓÃʱֻҪÓÃresult =
function(1,2)ÕâÑùµÄ·½Ê½¾Í¿ÉÒÔʹÓÃÕâ¸öº¯Êý¡£µ«ÊÇ£¬µ±¸ß¼¶ÓïÑÔ±»±àÒë³É¼ÆËã»ú¿ÉÒÔʶ±ðµÄ»úÆ÷Âëʱ£¬ÓÐÒ»¸öÎÊÌâ¾Í͹ÏÖ³öÀ´£ºÔÚCPUÖУ¬¼ÆËã
»úûÓа취֪µÀÒ»¸öº¯Êýµ÷ÓÃÐèÒª¶àÉÙ¸ö¡¢Ê²Ã´ÑùµÄ²ÎÊý£¬Ò² ......