LECTURE 2 ¤Þ¤º¤Ï²»¤ò½Ð¤·¤Æ¤ß¤è¤¦

¡û ¤Ï¤¸¤á¤Ë

¤³¤³¤Ç¤Ï¤Þ¤º¡¢°Ê¹ß¤Î¥×¥í¥°¥é¥ß¥ó¥°¤ÇɬÍפÊÃμ±¤Ç¤¢¤ë PCM ( Pulse Code Modulation ) ¥µ¥¦¥ó¥É¤Ë¤Ä¤¤¤Æ´Êñ¤ËÀâÌÀ¤·¤Þ¤¹¡£¤½¤Î¸å¡¢¤¢¤ë²»Äø¤Î²»¤ò¥¹¥Ô¡¼¥«¤«¤é½ÐÎϤ¹¤ë¤À¤±¤Î´Êñ¤Ê¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹¡£

¡û PCM ¥Ç¡¼¥¿¤Î´ðÁÃ

²»¤Ï¡¢»þ´Ö¤Ë±þ¤¸¤ÆϢ³Ū¤ËÂ礭¤µ¤¬ÊѲ½¤¹¤ë¥¢¥Ê¥í¥°¥Ç¡¼¥¿¤Ç¤¹¡£¤³¤ì¤ËÂФ·¤Æ¡¢PC ¾å¤Ç²»¤ò°·¤¦¤¿¤á¤Ë¤Ï¥Ç¥¸¥¿¥ë¥Ç¡¼¥¿¤È¤·¤Æ°·¤ï¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£¥¢¥Ê¥í¥°²»¸»¤ò°ìÄê»þ´ÖËè¤Ë AD ÊÑ´¹¤·¤ÆÆÀ¤é¤ì¤¿ÃÍ(ÅÀ)¤ò¤½¤Î½Ö´Ö¤Ë¤ª¤±¤ë²»¥Ç¡¼¥¿¤È¤·¡¢¤½¤ÎÅÀ¤Î½¸¤Þ¤ê¤È¤·¤Æɽ¸½¤µ¤ì¤ë²»¤ò PCM ( Pulse Code Modulation ) ¥µ¥¦¥ó¥É¤È¸Æ¤Ó¤Þ¤¹¡£

--- ¿Þ 1 ---
002sound.jpg

¿Þ 1 ¤Î¼ÂÀþ¤¬¥¢¥Ê¥í¥°¥Ç¡¼¥¿¤Ç¤¢¤ê¡¢¼ÂÀþ¾å¤ËÅÀºß¤¹¤ëÅÀ¥Ç¡¼¥¿¤¬ PCM ¥Ç¡¼¥¿¤Ç¤¹¡£ËÜʸ½ñ°Ê¹ß¤Î¥×¥í¥°¥é¥ß¥ó¥°¤Ë¤ª¤¤¤Æ¤Ï¡¢¤³¤Î PCM ¥Ç¡¼¥¿¤ò°·¤¤¤Þ¤¹¡£

PCM ¥Ç¡¼¥¿¤ò°·¤¦ºÝ¤Ë½ÅÍפÊÃͤϡ¢Î̻Ҳ½¥Ó¥Ã¥È¿ô¤ª¤è¤Ó¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô¤Ç¤¹¡£Î̻Ҳ½¥Ó¥Ã¥È¿ô¤È¤Ï¡¢¥¢¥Ê¥í¥°¥Ç¡¼¥¿¤ò AD ÊÑ´¹¤·¤ÆÆÀ¤é¤ì¤¿¥Ç¡¼¥¿¤ò¼ÂºÝ¤Ë²¿¥Ó¥Ã¥È¤Î¿ô¤È¤·¤Æɽ¸½¤¹¤ë¤«¤ò·è¤á¤ëÃͤǤ¹¡£¤³¤ì¤ËÉտ路¤Æ¡¢¥Ç¡¼¥¿¤òÉä¹æ̵¤·¤Çɽ¸½¤¹¤ë¤«¡¢Éä¹æÉÕ¤­¤Çɽ¸½¤¹¤ë¤«¤È¤¤¤¦Í×ÁǤ⸺ߤ·¤Þ¤¹¡£¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô¤Ï¡¢¥¢¥Ê¥í¥°¥Ç¡¼¥¿¤«¤é 1 Éô֤˲¿²ó AD ÊÑ´¹¤·¤Æ¥Ç¡¼¥¿¤ò¼èÆÀ¤¹¤ë¤«¤ò·èÄꤹ¤ëÃͤǤ¹¡£PCM ¤Ë¸ÇÍ­¤È¤¤¤¦¤ï¤±¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¤¬¡¢¥Á¥ã¥ó¥Í¥ë¿ô¤È¤¤¤¦¸ÀÍÕ¤â³Ð¤¨¤Æ¤ª¤¤¤Æ²¼¤µ¤¤¡£¥â¥Î¥é¥ë²»¤Ê¤é 1 ¥Á¥ã¥ó¥Í¥ë¡¢¥¹¥Æ¥ì¥ª²»¤Ê¤é 2 ¥Á¥ã¥ó¥Í¥ë ( º¸¤È±¦ )¤È¤¤¤¦¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£DVD ¤Ç¤Ï 5.1 ¥Á¥ã¥ó¥Í¥ë¤È¤¤¤¦¸ÀÍÕ¤òÎɤ¯Ê¹¤­¤Þ¤¹¤è¤Í¡£

¤Á¤Ê¤ß¤Ë¡¢ÅÅÏäǤÏÎ̻Ҳ½¥Ó¥Ã¥È¿ô 8 bit¡¢¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô 8000 Hz¡¢1 ¥Á¥ã¥ó¥Í¥ë ÄøÅ٤Ǥ¢¤ê¡¢CD ¤Ç¤ÏÎ̻Ҳ½¥Ó¥Ã¥È¿ô 16 bit¡¢¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô 44100 Hz¡¢2 ¥Á¥ã¥ó¥Í¥ë¤Ç¤¹¡£

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à

½é¤á¤Æ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ï¡¢¤¿¤À²»¤ò½ÐÎϤ¹¤ë¤À¤±¤Î¥×¥í¥°¥é¥à¤Ç¤¹¡£A ¤Î²»(¤Ä¤Þ¤ê¥é) ¤ò 5 ÉôֽÐÎϤ·Â³¤±¤Æ½ªÎ»¤¹¤ë sound.c ¤Ç¤¹¡£Èó¾ï¤Ëñ½ã¤Ç¤¹¤¬¡¢OSS API ¤Î»È¤¤Êý¤È¤·¤Æ¤Ï¤¢¤ë°ÕÌ£Á´¤Æ¤òÌÖÍ夷¤Æ¤¤¤ë¤È¸À¤¨¤Þ¤¹¡£¤Ï¤¸¤á¤Ë ¤Î¥Ú¡¼¥¸¤«¤é¡¢Á´¤Æ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò¸Ç¤á¤¿ tar ¥Ü¡¼¥ë¤ò¥À¥¦¥ó¥í¡¼¥É¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£

gcc -o sound sound.c -lm

¤È¤·¤Æ¥³¥ó¥Ñ¥¤¥ë¤·¤Þ¤¹¡£¥³¥ó¥Ñ¥¤¥ë¥ª¥×¥·¥ç¥ó¤Ï³Æ¼«¤Î´Ä¶­¤Ê¤É¤Ë±þ¤¸¤Æ½¤Àµ¤·¤Æ²¼¤µ¤¤¡£¼Â¹Ô¤¹¤ë¤È¡¢Æä˥¨¥é¡¼¤¬Ìµ¤±¤ì¤Ð¥¹¥Ô¡¼¥«¡¼¤«¤é¥é¤Î²»¤¬ 5 ÉÃÄøÅÙ½ÐÎϤµ¤ì¤Þ¤¹¡£²¿¤«¥¨¥é¡¼¤¬É½¼¨¤µ¤ì¤ë¾ì¹ç¤Ï¡¢¥·¥¹¥Æ¥à¤Ç¥µ¥¦¥ó¥É¥«¡¼¥É¤¬Àµ¾ï¤Ë¥»¥Ã¥È¥¢¥Ã¥×¤µ¤ì¤Æ¤¤¤ë¤«¤É¤¦¤«³Îǧ¤·¤Æ²¼¤µ¤¤¡£

º£²ó¤Ï /dev/mixer ¤òÁ´¤¯¤¤¤¸¤Ã¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢²»Î̤ÎÂ礭¤µ¤Ï¥¹¥Ô¡¼¥«¡¼¤Î¥Ü¥ê¥å¡¼¥à¤Î¤ß¤ÇÄ´À°¤·¤Æ²¼¤µ¤¤¡£¥¹¥Ô¡¼¥«¡¼¤Î¥Ü¥ê¥å¡¼¥à¤ò¤¤¤¯¤é¤¤¤¸¤Ã¤Æ¤â²»¤¬Ê¹¤³¤¨¤Ê¤¤¾ì¹ç¤Ï¡¢¥ß¥­¥µ¡¼¤Î¥Ü¥ê¥å¡¼¥à¤¬ 0 ¤Ë¤Ê¤Ã¤Æ¤¤¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹ ( ÆÃ¤Ë ALSA ¤ò»È¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ë¤¢¤ê¤¬¤Á )¡£¤½¤Î¾ì¹ç¤Ï¡¢¥ß¥­¥µ¡¼ÁàºîÍÑ¥½¥Õ¥È¤ò»È¤Ã¤ÆÀßÄꤷ¤Æ¤ß¤Æ²¼¤µ¤¤ ( ¤³¤ì°Ê¹ß¤Î¥µ¥ó¥×¥ë¤Ç¤âƱÍÍ )¡£¤Ê¤ª¡¢/dev/mixer ¤ò¼«Ê¬¤ÇÁàºî¤¹¤ëÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï¤¤¤º¤ì²òÀ⤷¤Þ¤¹¡£

--- sound.c ---

    1	#include <fcntl.h>
    2	#include <limits.h>
    3	#include <linux/soundcard.h>
    4	#include <math.h>
    5	#include <stdio.h>
    6	#include <sys/ioctl.h>
    7	#include <unistd.h>
    8	
    9	
   10	/*
   11	 * Î̻Ҳ½¥Ó¥Ã¥È¿ô : 16 bits
   12	 * ¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô : 44.1 KHz
   13	 * ¥Á¥ã¥ó¥Í¥ë¿ô : 1
   14	 * ºÆÀ¸»þ´Ö : 5 sec
   15	 *
   16	 * ʬ¤Î¥Ð¥Ã¥Õ¥¡Îΰè
   17	 *
   18	 * 16 (bits) * 44100 (Hz) * 5 (sec) = 3528000 (bits)
   19	 *                                  = 441000  (bytes)
   20	 */
   21	#define BUFSIZE 441000
   22	
   23	static int setup_dsp( int fd );
   24	
   25	int 
   26	main( void )
   27	{
   28		/* ºÆÀ¸»þ´Ö 5 Éà */
   29		double total = 5.0, t; 
   30	
   31		/* ºÆÀ¸²»¼þÇÈ¿ô 440 Hz ( A ) */
   32		double freq = 440.0;
   33	
   34		short  buf[ BUFSIZE / sizeof(short) ];
   35		int    fd, i;
   36	
   37	
   38		if ( ( fd = open( "/dev/dsp", O_WRONLY ) ) == -1 ) {
   39			perror( "open()" );
   40			return 1;
   41		}
   42	
   43	
   44		/* /dev/dsp ¤ÎÀßÄê */
   45		if ( setup_dsp( fd ) != 0 ) {
   46			fprintf( stderr, "Setup /dev/dsp failed.\n" );
   47			close( fd );
   48			return 1;
   49		}
   50	
   51	
   52		/* ºÆÀ¸ÍѤÎÀµ¸¹Çȥǡ¼¥¿ºîÀ® */
   53		for ( i = 0; i < BUFSIZE / sizeof(short); i ++ ) {
   54			t = ( total / (BUFSIZE / sizeof(short)) ) * i;
   55			buf[i] = SHRT_MAX * sin( 2.0 * 3.14159 * freq * t );
   56		}
   57	    
   58	
   59		if ( write( fd, buf, BUFSIZE ) == -1 ) {
   60			perror( "write()" );
   61			close( fd );
   62			return 1;
   63		}
   64	
   65		close( fd );
   66		return 0;
   67	}
   68	
   69	
   70	/*
   71	 * /dev/dsp ¤ò°Ê²¼¤ÎÍͤËÀßÄꤹ¤ë¡£
   72	 *
   73	 * Î̻Ҳ½¥Ó¥Ã¥È¿ô     : 16   bits
   74	 * ¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô : 44.1 KHz
   75	 * ¥Á¥ã¥ó¥Í¥ë¿ô       : 1
   76	 * PCM ¥Ç¡¼¥¿¤ÏÉä¹æÉÕ¤­¡¢¥ê¥È¥ë¥¨¥ó¥Ç¥£¥¢¥ó
   77	 *
   78	 */
   79	static int
   80	setup_dsp( int fd )
   81	{
   82		int fmt     = AFMT_S16_LE;
   83		int freq    = 44100;
   84		int channel = 1;
   85	
   86		/* ¥µ¥¦¥ó¥É¥Õ¥©¡¼¥Þ¥Ã¥È¤ÎÀßÄê */
   87		if ( ioctl( fd, SOUND_PCM_SETFMT, &fmt ) == -1 ) {
   88			perror( "ioctl( SOUND_PCM_SETFMT )" );
   89			return -1;
   90		}
   91	
   92		/* ¥Á¥ã¥ó¥Í¥ë¿ô¤ÎÀßÄê */
   93		if ( ioctl( fd, SOUND_PCM_WRITE_CHANNELS, &channel ) == -1 ) {
   94			perror( "iotcl( SOUND_PCM_WRITE_CHANNELS )" );
   95			return -1;
   96		}
   97	
   98		/* ¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô¤ÎÀßÄê */
   99		if ( ioctl( fd, SOUND_PCM_WRITE_RATE, &freq ) == -1 ) {
  100			perror( "iotcl( SOUND_PCM_WRITE_RATE )" );
  101			return -1;
  102		}
  103	
  104		return 0;
  105	}
  106	
  107	/* End of sound.c */
  108	

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÎÀâÌÀ

¤Ç¤Ï¡¢¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£

  • 1 ¡Á 7 ¹ÔÌÜ

    ɬÍפʥإåÀ¥Õ¥¡¥¤¥ë¤ò¥¤¥ó¥¯¥ë¡¼¥É¤·¤Æ¤¤¤Þ¤¹¡£OSS API ¤ò»È¤Ã¤¿¥µ¥¦¥ó¥É¥×¥í¥°¥é¥ß¥ó¥° ¤Î¤¿¤á¤ËɬÍפʥإåÀ¥Õ¥¡¥¤¥ë¤Ï¡¢3 ¹ÔÌܤΠsoundcard.h ¤Ç¤¹¡£¤³¤Î¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤Ë¤ª¤¤¤Æ OSS API ¤äɬÍפÊÄê¿ô¤Ê¤É¤ÎÄêµÁ¤¬¹Ô¤ï¤ì¤Æ¤¤¤Þ¤¹¡£ OSS API ¤Ë¤è¤ë¥×¥í¥°¥é¥ß¥ó¥°¤Ç¤Ïɬ¤º¤³¤Î¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤ò¥¤¥ó¥¯¥ë¡¼¥É¤·¤Þ¤¹¡£

  • 10 ¡Á 21 ¹ÔÌÜ

    PCM ¥Ç¡¼¥¿¤ò³ÊǼ¤¹¤ë¤¿¤á¤ËɬÍפʥХåե¡Îΰè¤Î¥µ¥¤¥º¤ò¥Þ¥¯¥íÄêµÁ¤·¤Æ¤¤¤Þ¤¹¡£sound.c ¤Ç¤Ï¡¢Î̻Ҳ½¥Ó¥Ã¥È¿ô 16 ¥Ó¥Ã¥È¡¢¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô 44.1 KHz¡¢¥Á¥ã¥ó¥Í¥ë¿ô 1 ¤È¤¤¤¦ PCM ¥Ç¡¼¥¿¤ò°·¤¤¤Þ¤¹¡£¤³¤ì¤Ï¡¢1 ÅÀ¤Î¥Ç¡¼¥¿¤ò 16 ¥Ó¥Ã¥È¤Çɽ¤·¡¢1 ÉÃ´Ö¤Ë 44100 ¸Ä¤Î ¥Ç¡¼¥¿¤òɬÍפȤ¹¤ë¤È¤¤¤¦°ÕÌ£¤Ç¤¹¡£ ¹¹¤Ë¤³¤Î¥Ç¡¼¥¿¤ò 5 ÉôÖʬ»ÈÍѤ¹¤ë¤¿¤á¡¢É¬ÍפʥХåե¡Îΰè¤Ï 16 ( bits ) * 44100 (Hz) * 5 (sec) = 441000 (bytes) ¤È¤¤¤¦¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£ ¥Á¥ã¥ó¥Í¥ë¿ô¤¬ 2 ¥Á¥ã¥ó¥Í¥ë¤Î¾ì¹ç¤Ïº¸¤È±¦ÍѤËÎΰ褬ɬÍפȤʤ뤿¤á¡¢¤³¤Î 2 ÇܤΥµ¥¤¥º¤¬É¬Íפˤʤê¤Þ¤¹¡£

    2007/12/03 Äɵ­¡£34 ¹ÔÌܤǼºݤ˥Хåե¡¤ò³ÎÊݤ·¤Æ¤¤¤Þ¤¹¤¬¡¢short ·¿¤Ç³ÎÊݤ·¤Æ¤¤¤ë¤Ë¤â´Ø¤ï¤é¤º BUFSIZE ¤ò¤½¤Î¤Þ¤ÞÍ×ÁÇ¿ô¤Ë»ØÄꤷ¤Æ¤¤¤Þ¤·¤¿ (short buf[BUFSIZE];)¡£ Àµ¤·¤¯¤Ï short buf[BUFSIZE / sizeof(short)]; ¤Ç¤·¤¿¡£ËÙ¤µ¤ó¡¢¤´»ØŦ¤¢¤ê¤¬¤È¤¦¤´¤¶¤¤¤Þ¤·¤¿¡ª

  • 25 ¡Á 67 ¹ÔÌÜ ( main() )
    • 31 ¡Á 32 ¹ÔÌÜ

      sound.c ¤Ç¤Ï A ( ¥é ) ¤Î²»¤ò 5 ÉôֽÐÎϤ·¤Þ¤¹¡£¤³¤ÎÍͤ˰ì¤Ä¤Î²»Äø¤Î¤ß¤òɽ¤¹²»¤Ï ¤¢¤ë¼þÇÈ¿ô¤ÎÀµ¸¹ÇȤÇɽ¤¹¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£A ¤Î¼þÇÈ¿ô¤Ï¤³¤³¤ÇÀë¸À¤·¤Æ¤¤¤ëÍÍ¤Ë 440 Hz ¤Ç¤¹¡£

    • 38 ¡Á 41 ¹ÔÌÜ

      ¥Ç¥Ð¥¤¥¹¥Õ¥¡¥¤¥ë /dev/dsp ¤ò open() ¤·¤Æ¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò¼èÆÀ¤·¤Æ¤¤¤Þ¤¹¡£ PCM ¥Ç¡¼¥¿¤ÎÆþ½ÐÎϤˤϡ¢¤³¤ÎÍÍ¤Ë /dev/dsp ¤ò»ÈÍѤ·¤Þ¤¹¡£¤³¤³¤Ç¤Ï½ÐÎϤΤߤ˻ÈÍÑ ¤¹¤ë¤¿¤á¡¢O_WRONLY (½ñ¤­¹þ¤ßÀìÍÑ) ¤Ç open() ¤·¤Æ¤¤¤Þ¤¹¡£Æɤ߽Ф·ÀìÍѤξì¹ç¤Ï O_RDONLY¡¢Æɤ߽ñ¤­Î¾ÍѤξì¹ç¤Ï O_RDWR ¤È¤·¤Þ¤¹¡£

      °Ê²¼ 2002/8/20 Äɵ­

      ËÜÍè OSS API ¤Ç¤ÏÊ£¿ô¤Î¥×¥í¥»¥¹¤«¤éƱ¤¸¥Ç¥Ð¥¤¥¹¥Õ¥¡¥¤¥ë¤ò open() ¤¹¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¥¨¥é¡¼½ªÎ»¤·¡¢errno ¤Ë -EBUSY ¤¬ÀßÄꤵ¤ì¤ë¤Ï¤º¤Ç¤¹¡£¤¬¡¢¸½ºß¥«¡¼¥Í¥ë¤È°ì½ï¤ËÇÛÉÕ¤µ¤ì¤Æ¤¤¤ë Linux Sound System ¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ë¥É¥é¥¤¥Ð¤ä¡¢¥µ¥¦¥ó¥É¥Á¥Ã¥×¤Î¥á¡¼¥«¤Ê¤É¤¬ÇÛÉÕ¤·¤Æ¤¤¤ë Linux® Íѥɥ饤¥Ð¤Ê¤É¤Ë´Ø¤·¤Æ¤Ï¡¢É¬¤º¤·¤â¤½¤¦¤È¤Ï¸Â¤é¤Ê¤¤ÍͤǤ¹¡£

      Î㤨¤Ð¡¢¼«Ê¬¤Î´Ä¶­ ( ¤³¤ì¤ò½ñ¤¤¤Æ¤¤¤ë»þÅÀ¤Ç¤Ï AU8820B2 ¥Á¥Ã¥×¤Î¥µ¥¦¥ó¥É¥«¡¼¥É + Vortex of Sound Ä󶡤ΠLinux Íѥɥ饤¥Ð ) ¤Ç¤Ï¡¢O_RDONLY ( ÆɤßÀìÍÑ ) ¤È O_WRONLY ( ½ñ¤­ÀìÍÑ ) ¤Ç¤¢¤ì¤Ð 2 ¤Ä¤Î¥×¥í¥»¥¹¤¬Æ±»þ¤Ë open() ¤Ç¤­¤Þ¤·¤¿¡£°ÊÁ°»È¤Ã¤Æ¤¤¤¿ Sound Blaster Live! ÍѤΠemu10k1 ¥É¥é¥¤¥Ð¤Ç¤ÏÆɤßÀìÍѤȤ«½ñ¤­ÀìÍѤȤ«´Ø·¸Ìµ¤¯Ê£¿ô open() ¤Ç¤­¤¿Íͤʡ£¡£¡£ ( ¤³¤Á¤é¤Ïµ­²±¤¬¤¢¤ä¤Õ¤ä¤Ç¤¹ m(__)m )¡£

      ÀµÄ¾¤Ê½ê¡¢¥«¡¼¥É¤È¥É¥é¥¤¥Ð¼¡Âè¤È¤¤¤¦¤Î¤¬¸½¾õ¤È¸«¤¦¤±¤é¤ì¤Þ¤¹¡£

      Äɵ­¤³¤³¤Þ¤Ç
    • 44 ¡Á 49 ¹ÔÌÜ

      ¼«ºî´Ø¿ô setup_dsp() ¤Ç /dev/dsp ¤ÎÀßÄê¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£ÆâÍƤ˴ؤ·¤Æ¤Ï¸å½Ò¤·¤Þ¤¹¡£

    • 52 ¡Á 56 ¹ÔÌÜ

      A ¤Î²»¤òɽ¤¹Àµ¸¹Çȥǡ¼¥¿¤ò 5 ÉôÖʬºîÀ®¤·¤Æ¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤·¤Æ¤¤¤Þ¤¹¡£¤¢¤ë¼þÇÈ¿ô f ¤ÎÀµ¸¹ÇȤϡ¢»þ¹ï¤ò t¡¢Â礭¤µ¤ò a ¤È¤¹¤ë¤È a sin( 2¦Ð f t ) ¤Èɽ¤»¤Þ¤¹¡£sound.c ¤Ç¤ÏºÇ½é¤Î¥Ç¡¼¥¿¤ò»þ¹ï 0 ¤È¤·¡¢¤½¤Î¸å¤Î»þ¹ï¤Ï¥Ð¥Ã¥Õ¥¡Á´ÂΤËÂФ¹¤ë¥Ç¡¼¥¿°ÌÃ֤γä¹ç ¤Ë¤è¤Ã¤Æ·èÄꤷ¤Æ¤¤¤Þ¤¹¡£setup_dsp() ¤ÎÀâÌÀ¤Ë¤ª¤¤¤Æ¸å½Ò¤·¤Þ¤¹¤¬¡¢signed short ¤È¤·¤Æ PCM ¥Ç¡¼¥¿¤ò°·¤¦¤¿¤á¡¢ºÇÂçÃÍ SHRT_MAX ( 32767¡¢limits.h ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë )¡¢ºÇ¾®ÃÍ - SHRT_MAX ¤ÎÀµ¸¹Çȥǡ¼¥¿¤òºîÀ®¤·¤Æ¤¤¤Þ¤¹¡£

    • 59 ¡Á 63 ¹ÔÌÜ

      ¤³¤³¤¬ PCM ¥Ç¡¼¥¿½ÐÎϤΥᥤ¥ó½èÍý¤Ç¤¹¡ª¤È¸À¤Ã¤Æ¤â¡¢write() ¤Ç /dev/dsp ¤Ë½ñ¤­¹þ¤ó¤Ç¤¤¤ë¤À¤±¤Ç¤¹¡£OSS API ¤Ç¤Ï¡¢PCM¥Ç¡¼¥¿¤ò /dev/dsp ¤Ë½ñ¤­¹þ¤à¤À¤±¤Ç ²»¤¬½ÐÎϤµ¤ì¤Þ¤¹¡£´Êñ¤Ç¤·¤ç¤¦¡©

      ¤³¤³¤ÇÃí°Õ¤·¤Æ¤ª¤¤¤ÆÍߤ·¤¤¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£PCM ¥Ç¡¼¥¿¤ò¥µ¥¦¥ó¥É¥É¥é¥¤¥Ð¤Ë ½ñ¤­¹þ¤àºÝ¡¢¤½¤Î¥Ç¡¼¥¿Î̤¬¥µ¥¦¥ó¥É¥É¥é¥¤¥ÐÆâÉô¤Î¥Õ¥é¥°¥á¥ó¥È¤È¸Æ¤Ð¤ì¤ë¥Ð¥Ã¥Õ¥¡ ¤Î¥µ¥¤¥º¤ËËþ¤¿¤Ê¤¤¾ì¹ç¤ÏºÆÀ¸¤µ¤ì¤Þ¤»¤ó ( ¥µ¥¦¥ó¥É¥É¥é¥¤¥Ð¤ÎÆâÉô¥Ð¥Ã¥Õ¥¡¥µ¥¤¥º¤Î¼èÆÀÊýË¡¤Ï LECTURE 3 /dev/dsp ¤Îµ¡Ç½¤òÄ´¤Ù¤ë ¤ÇÀâÌÀ¤·¤Æ¤¤¤Þ¤¹ )¡£ ³¤±¤Æ¥Ç¡¼¥¿¤ò½ñ¤­¹þ¤à¤³¤È¤Ç¥Õ¥é¥°¥á¥ó¥È¤¬°ìÇդˤʤ뤫¡¢¥Ç¥Ð¥¤¥¹¤ò close() ¤¹¤ë¤ÈºÆÀ¸¤µ¤ì¤Þ¤¹¡£

      ¤Þ¤¿¡¢ÆâÉô¥Ð¥Ã¥Õ¥¡¤¬°ìÇդˤʤäƤ¤¤ë¾õÂÖ¡¢¤â¤·¤¯¤Ï½ñ¤­¹þ¤ß¥Ç¡¼¥¿Î̤è¤ê¤â¾¯¤Ê¤¤Îΰ褷¤« ÆâÉô¥Ð¥Ã¥Õ¥¡¤Ë¶õ¤­¤¬Ìµ¤¤¤è¤¦¤Ê¾õÂÖ¤Ç write() ¤ò¹Ô¤Ã¤¿¾ì¹ç¡¢write() ¤¬¥Ö¥í¥Ã¥¯¤·¤Æ¤·¤Þ¤¤¤Þ¤¹¡£

      ¤³¤ì¤À¤È¡¢¥²¡¼¥à¤Î¸ú²Ì²»¤ÎÍͤËû¤¤²»¤ò½ñ¤­¹þ¤ó¤Ç¤¹¤°¤ËºÆÀ¸¤µ¤ì¤ÆÍߤ·¤¤Íͤʾì¹ç¤ä¡¢ ¥ê¥¢¥ë¥¿¥¤¥à½èÍý¤ò¹Ô¤¤¤¿¤¤¾ì¹ç¤Ë¤Ïº¤¤ê¤Þ¤¹¡£ ¤³¤ì¤òÈò¤±¤ë¤Ë¤Ï¥Õ¥é¥°¥á¥ó¥È¤Î¥µ¥¤¥º¤òÊѹ¹¤·¤¿¤ê¡¢ ÌÀ¼¨Åª¤ËºÆÀ¸¤ò»Ø¼¨¤·¤¿¤ê¡¢¥Ö¥í¥Ã¥¯¤»¤º¤Ë½ñ¤­¹þ¤à¤³¤È¤Î¤Ç¤­¤ë¥Õ¥é¥°¥á¥ó¥È¤Î¿ô¤ò ¼èÆÀ¤·¤¿¤ê¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£¤³¤ì¤é¤ÎÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï LECTURE 5 ¥ê¥¢¥ë¥¿¥¤¥àÀ­¤ò¹Íθ¤¹¤ë ¤Ç¾Ò²ð¤·¤Þ¤¹¤¬¡¢ ¤³¤³¤Ç¤Ï¤³¤ÎÍͤÊÌäÂ꤬¤¢¤ë¤³¤È¤ò³Ð¤¨¤Æ¤ª¤¤¤Æ²¼¤µ¤¤¡£

  • 70 ¡Á 105 ¹ÔÌÜ ( setup_dsp() )

    /dev/dsp ¤ÎÀßÄê¤ò¹Ô¤¦¤¿¤á¤Î´Ø¿ô¤Ç¤¹¡£¥Ç¥Ð¥¤¥¹¤ÎÀßÄê¤ÏÁ´¤Æ ioctl() ¥·¥¹¥Æ¥à¥³¡¼¥ë ¤Ç¹Ô¤¤¤Þ¤¹¡£ËÜ´Ø¿ô¤Ç¤Ï /dev/dsp ¤ò°Ê²¼¤ÎÍͤËÀßÄꤷ¤Þ¤¹¡£ 1 ¡Á 4 ¤ò¤Þ¤È¤á¤Æ¥µ¥ó¥×¥ê¥ó¥°¥Ñ¥é¥á¡¼¥¿¤È¸Æ¤Ó¤Þ¤¹¡£

    1. °·¤¦¥Ç¡¼¥¿¤Ï PCM·Á¼°¡¢Éä¹æÉÕ¤­¡¢¥ê¥È¥ë¥¨¥ó¥Ç¥£¥¢¥ó
    2. Î̻Ҳ½¥Ó¥Ã¥È¿ô 16 ¥Ó¥Ã¥È
    3. ¥Á¥ã¥ó¥Í¥ë¿ô 1
    4. ¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô 44100 Hz

    OSS API ¤Ç¤Ï¡¢1 ¤È 2 ¤ò¤Þ¤È¤á¤Æ¥µ¥¦¥ó¥É¥Õ¥©¡¼¥Þ¥Ã¥È¤È¤¤¤¦·Á¤ÇÄ󶡤·¤Æ¤¤¤Þ¤¹ ( 2 ¤Ë ¤Ä¤¤¤Æ¤ÏÊ̸ĤËÀßÄꤹ¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹ )¡£soundcard.h ¤ò¸«¤ë¤ÈÄ󶡤µ¤ì¤Æ¤¤¤ë ¥Õ¥©¡¼¥Þ¥Ã¥È¤¬Ê¬¤«¤ê¤Þ¤¹¤¬¡¢¤½¤ÎÃæ¤Î¤¤¤¯¤Ä¤«¤Ë¤Ä¤¤¤Æ°Ê²¼¤Ë¼¨¤·¤Þ¤¹¡£

    ¥Õ¥©¡¼¥Þ¥Ã¥È̾ÆâÍÆ
    AFMT_MU_LAWmu-law ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°·Á¼°
    AFMT_A_LAW a-law ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°·Á¼°
    AFMT_U8 unsigned 8 bit¡¢Î̻Ҳ½¥Ó¥Ã¥È¿ô¤¬ 8 ¤Î WAVE ¥Õ¥¡¥¤¥ë¤Ï ¤³¤Î·Á¼°
    AFMT_S8 signed 8 bit
    AFMT_S16_LEsigned 16 bit¤Ç¥ê¥È¥ë¥¨¥ó¥Ç¥£¥¢¥ó¡¢Î̻Ҳ½¥Ó¥Ã¥È¿ô 16 ¤Î WAVE ¥Õ¥¡¥¤¥ë¤Ï¤³¤Î·Á¼°
    AFMT_S16_BEsigned 16 bit¤Ç¥Ó¥Ã¥°¥¨¥ó¥Ç¥£¥¢¥ó
    AFMT_U16_LEunsigned 16 bit ¤Ç¥ê¥È¥ë¥¨¥ó¥Ç¥£¥¢¥ó
    AFMT_U16_BEunsigned 16 bit ¤Ç¥Ó¥Ã¥°¥¨¥ó¥Ç¥£¥¢¥ó

    sound.c ¤Ç¤Ï AFMT_S16_LE ¤òºÎÍѤ·¤Þ¤¹¡£

    ¥µ¥ó¥×¥ê¥ó¥°¥Ñ¥é¥á¡¼¥¿¤ÎÀßÄê¤Ï¡¢

    1. ¥µ¥¦¥ó¥É¥Õ¥©¡¼¥Þ¥Ã¥È¤ÎÀßÄê
    2. ¥Á¥ã¥ó¥Í¥ë¿ô ( ¥â¥Î¥é¥ë¡¢¥¹¥Æ¥ì¥ª )¤ÎÀßÄê
    3. ¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô¤ÎÀßÄê

    ¤Î½ç½ø¤Ç¹Ô¤¦É¬Íפ¬¤¢¤ë¡¢¤È OSS ¤Î¥×¥í¥°¥é¥Þ¡¼¥º¥¬¥¤¥É¤Ë¤Ï½ñ¤«¤ì¤Æ¤¤¤Þ¤¹¡£ ¤Þ¤¿¡¢¤³¤ì¤é¤Î¥Ñ¥é¥á¡¼¥¿¤òÀßÄê¤Ç¤­¤ë¤Î¤Ï¡¢¥Ç¥Ð¥¤¥¹¤ò open() ¤·¤¿¸å read() ¤ä write()¡¢ ¥µ¥ó¥×¥ê¥ó¥°¥Ñ¥é¥á¡¼¥¿¤ÎÀßÄê°Ê³°¤Î ioctl() ¤òȯ¹Ô¤¹¤ëÁ°¤Ç¤¢¤ë¤È¤â½ñ¤«¤ì¤Æ¤¤¤Þ¤¹¡£ ¤¿¤À¤·¡¢Á°½Ò¤Î¥Õ¥é¥°¥á¥ó¥È¤Î¥µ¥¤¥º¤òÊѲ½¤¹¤ëºÝ¤Ë¤Ï¤½¤Á¤é¤òÀè¤Ë¹Ô¤¦¤Ê¤É¤ÎÎã³°¤Ï¤¢¤ê¤Þ¤¹¡£ ¤Î¤Ç¡¢´ðËÜŪ¤Ë¤Ï¥Ç¥Ð¥¤¥¹¤ò open() ¤·¤¿¤é¹Ô¤¦¤È»×¤Ã¤Æ¤ª¤±¤ÐÎɤ¤¤È»×¤¤¤Þ¤¹¡£

    ¥Ñ¥é¥á¡¼¥¿¤òºÆÅÙÊѹ¹¤¹¤ëºÝ¤Ï¡¢°ìÅ٥ǥХ¤¥¹¤ò close() ¤·¤ÆºÆÅÙ open() ¤¹¤ë¤«¡¢ ioctl() ¥³¥Þ¥ó¥É¤Ç¤¢¤ë SNDCTL_DSP_RESET ¤òȯ¹Ô¤·¤Æ¥Ç¥Ð¥¤¥¹¤ò¥ê¥»¥Ã¥È¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£SNDCTL_DSP_RESET ¤Ë¤Ä¤¤¤Æ¤Ï¡¢ ËÜ¥Ú¡¼¥¸¤ÎËöÈø ¤ÇÀâÌÀ¤·¤Æ¤¤¤Þ¤¹¡£

    • 86 ¡Á 90 ¹ÔÌÜ

      ÀèÄøÀâÌÀ¤·¤¿¥µ¥¦¥ó¥É¥Õ¥©¡¼¥Þ¥Ã¥È¤ÎÀßÄê¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£¥µ¥¦¥ó¥É¥Õ¥©¡¼¥Þ¥Ã¥È¤ò ÀßÄꤹ¤ë¤Ë¤Ï¡¢ioctl() ¤ÎÂè 2 °ú¿ô¤Ë SNDCTL_DSP_SETFMT ¤â¤·¤¯¤Ï SOUND_PCM_SETFMT ¤ò»ØÄꤷ¤Þ¤¹ ( SOUND_PCM_SETFMT ¤Ï SNDCTL_DSP_SETFMT ¤Î¥¨¥¤¥ê¥¢¥¹ )¡£ Âè 3 °ú¿ô¤Ë¤Ï¥µ¥¦¥ó¥É¥Õ¥©¡¼¥Þ¥Ã¥È¤òÀßÄꤷ¤¿ÊÑ¿ô¤Î¥¢¥É¥ì¥¹¤ò»ØÄꤷ¤Þ¤¹¡£

        int format;
        ioctl( fd, SOUND_PCM_SETFMT, &format );
      
      

      ioctl() ¤¬Àµ¾ï½ªÎ»¤¹¤ë¤È¡¢¼ÂºÝ¤ËÀßÄꤵ¤ì¤¿¥Õ¥©¡¼¥Þ¥Ã¥È¤¬Âè 3 °ú¿ô¤ÎÊÑ¿ô¤Ë ³ÊǼ¤µ¤ì¤Þ¤¹¡£»ÈÍѤ·¤Æ¤¤¤ë¥µ¥¦¥ó¥É¥«¡¼¥É¤â¤·¤¯¤Ï¥µ¥¦¥ó¥É¥É¥é¥¤¥Ð¤Ë¤è¤Ã¤Æ¤Ï »ØÄꤷ¤¿¥Õ¥©¡¼¥Þ¥Ã¥È¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤²ÄǽÀ­¤â¤¢¤ë¤¿¤á¡¢ ¸·Ì©¤Ë¤Ï¥Á¥§¥Ã¥¯¤¬É¬ÍפǤ¹¡£

      ¤Ê¤ª¡¢Î̻Ҳ½¥Ó¥Ã¥È¿ô¤Î¤ß¤òÀßÄꤹ¤ë¾ì¹ç¤Ï¡¢SOUND_PCM_WRITE_BITS ¤òÂè 2 °ú¿ô¤Ë ÀßÄꤷ¤Æ¡¢Âè 3 °ú¿ô¤Ë 8 ¤« 16 ¤òÀßÄꤷ¤¿ÊÑ¿ô¤Î¥¢¥É¥ì¥¹¤ò»ØÄꤷ¤Þ¤¹¡£

        int bits = 16;
        ioctl( fd, SOUND_PCM_WRITE_BITS, &bits );
      
      

      ¤³¤ì¤Ë¤Ä¤¤¤Æ¤Ç¤¹¤¬¡¢ËͤδĶ­¤Î OSS/Free 3.8.2 ¤Î soundcard.h ¤òÇÁ¤¤¤Æ¤ß¤ë¤È SOUND_PCM_WRITE_BITS ¤Ï SNDCTL_DSP_SETFMT ¤Î¥¨¥¤¥ê¥¢¥¹¤È¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£ ¤³¤Î¤³¤È¤È¥µ¥¦¥ó¥É¥Õ¥©¡¼¥Þ¥Ã¥È¤ÎÄêµÁÃͤ«¤é¹Í¤¨¤ë¤È¡¢SOUND_PCM_WRITE_BITS ¤Ç 8 ¥Ó¥Ã¥È¤ò»ØÄꤹ¤ë¤È AFMT_U8 ¤¬¡¢16 ¥Ó¥Ã¥È¤ò»ØÄꤹ¤ë¤È AFMT_S16_LE ¤¬ÁªÂò¤µ¤ì¤ëÍͤǤ¹¡£

    • 92 ¡Á 96 ¹ÔÌÜ

      ¥Á¥ã¥ó¥Í¥ë¿ô¤ÎÀßÄê¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£ioctl() ¤ÎÂè 2 °ú¿ô¤Ë SNDCTL_DSP_CHANNELS ¤â¤·¤¯¤Ï SOUND_PCM_WRITE_CHANNELS ¤ò»ØÄꤷ¡¢Âè 3 °ú¿ô¤Ë¥Á¥ã¥ó¥Í¥ë¿ô¤òÀßÄꤷ¤¿ ÊÑ¿ô¤Î¥¢¥É¥ì¥¹¤ò»ØÄꤷ¤Þ¤¹ ( SOUND_PCM_WRITE_CHANNELS ¤Ï SNDCTL_DSP_CHANNELS ¤Î¥¨¥¤¥ê¥¢¥¹ )¡£

        int channels;
        ioctl( fd, SOUND_PCM_WRITE_CHANNELS, &channels );
      
      

      ioctl() ¤¬Àµ¾ï½ªÎ»¤¹¤ë¤È¡¢¼ÂºÝ¤ËÀßÄꤵ¤ì¤¿¥Á¥ã¥ó¥Í¥ë¿ô¤¬Âè 3 °ú¿ô¤ÎÊÑ¿ô¤Ë ³ÊǼ¤µ¤ì¤Þ¤¹¡£¤³¤ì¤Ë¤Ä¤¤¤Æ¤â¸·Ì©¤Ë¤Ï¥Á¥§¥Ã¥¯¤¬É¬ÍפȤʤê¤Þ¤¹¡£

    • 98 ¡Á 102 ¹ÔÌÜ

      ¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô¤ÎÀßÄê¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£ioctl() ¤ÎÂè 2 °ú¿ô¤Ë SNDCTL_DSP_SPEED ¤â¤·¤¯¤Ï SOUND_PCM_WRITE_RATE ¤ò»ØÄꤷ¡¢Âè 3 °ú¿ô¤Ë¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô¤ò Hz ñ°Ì¤ÇÀßÄꤷ¤¿ÊÑ¿ô¤Î¥¢¥É¥ì¥¹¤ò»ØÄꤷ¤Þ¤¹ ( SOUND_PCM_WRITE_RATE ¤Ï SNDCTL_DSP_SPEED ¤Î¥¨¥¤¥ê¥¢¥¹ )¡£

        int freq;
        ioctl( fd, SOUND_PCM_WRITE_RATE, &freq );
      
      

      ioctl() ¤¬Àµ¾ï½ªÎ»¤¹¤ë¤È¡¢¼ÂºÝ¤ËÀßÄꤵ¤ì¤¿¥µ¥ó¥×¥ê¥ó¥°¼þÇÈ¿ô¤¬Âè 3 °ú¿ô¤Î ÊÑ¿ô¤Ë³ÊǼ¤µ¤ì¤Þ¤¹¡£¤³¤ì¤Ë¤Ä¤¤¤Æ¤â¡¢¸·Ì©¤Ë¤Ï¥Á¥§¥Ã¥¯¤¬É¬ÍפȤʤê¤Þ¤¹¡£


sound.c ¤ÎÀâÌÀ¤Ï°Ê¾å¤Ç¤¹¡£OSS API ¤ò»È¤Ã¤¿¥×¥í¥°¥é¥ß¥ó¥°¤Ç¤Ï¡¢¥¹¥Ô¡¼¥«¡¼¤«¤é²»¤ò½Ð¤¹¤Î¤ÏÀ¨¤¯´Êñ¤Ê¤³¤È¤À¤È¤¤¤¦¤Î¤¬Ê¬¤«¤Ã¤Æ¤¤¤¿¤À¤±¤¿¤Î¤Ç¤Ï¤Ê¤¤¤Ç¤·¤ç¤¦¤«¡©

¡û ¥Ç¥Ð¥¤¥¹¤Î¥ê¥»¥Ã¥È ( SNDCTL_DSP_RESET )

¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÎÀâÌÀ¤ÎºÝ¤Ë¤Õ¤ì¤¿ SNDCTL_DSP_RESET ¥³¥Þ¥ó¥É¤Ï¡¢¥Ç¥Ð¥¤¥¹¤ÎºÆÀ¸¤äÏ¿²»Æ°ºî¤ò¨ºÂ¤ËÄä»ß¤·¤¿¤¤¾ì¹ç¤ä¡¢¥µ¥ó¥×¥ê¥ó¥°¥Ñ¥é¥á¡¼¥¿¤Ê¤É¤Î¥Ñ¥é¥á¡¼¥¿¤ò¿·¤¿¤ËÀßÄꤷ¤¿¤¤¾ì¹ç¤Ë»ÈÍѤ·¤Þ¤¹¡£

²¼µ­¤Î ioctl() ¤ò¼Â¹Ô¤¹¤ë¤È¡¢¤½¤Î»þÅÀ¤Ç¹Ô¤ï¤ì¤Æ¤¤¤ëºÆÀ¸¡¢Ï¿²»Æ°ºî¤Ï¨ºÂ¤ËÄä»ß¤µ¤ì¤Þ¤¹¡£¤½¤·¤Æ¥É¥é¥¤¥Ð¤Ï³Æ¼ï¤Î¥Ñ¥é¥á¡¼¥¿ÀßÄê¤ò¼õ¤±ÉÕ¤±¤ë¤³¤È¤Î¤Ç¤­¤ë¾õÂ֤Ȥʤê¤Þ¤¹¡£¤Ê¤ª¡¢SNDCTL_DSP_RESET ¤ÎÂå¤ï¤ê¤Ë SOUND_PCM_RESET ¤ò»È¤¦¤³¤È¤â¤Ç¤­¤Þ¤¹( SOUND_PCM_RESET ¤Ï SNDCTL_DSP_RESET ¤Î¥¨¥¤¥ê¥¢¥¹ )¡£

ioctl( fd, SNDCTL_DSP_RESET, 0 );

Âè 3 °ú¿ô¤Ï 0 ¤òÀßÄꤹ¤ì¤ÐÎɤ¤¤Ç¤¹ ( Àµ³Î¤Ë¤Ï¡¢¤³¤Î°ú¿ô¤Ï»È¤ï¤ì¤Ê¤¤ )¡£

¿·¤¿¤Ë¥Ñ¥é¥á¡¼¥¿ÀßÄê¤ò¼õ¤±ÉÕ¤±¤ë¤³¤È¤Î¤Ç¤­¤ë¾õÂ֤ˤʤë¤È¤Ï¸À¤¤¤Þ¤·¤¿¤¬¡¢¤³¤Î¥³¥Þ¥ó¥É¤ò»È¤Ã¤Æ¥Ñ¥é¥á¡¼¥¿¤ÎºÆÀßÄê¤ò¹Ô¤¦¤Î¤Ï¤¢¤Þ¤êÎɤ¯¤Ê¤¤ÍͤǤ¹¡£OSS ¤Î¥×¥í¥°¥é¥Þ¡¼¥º¥¬¥¤¥É¤Ë¤Ï¡¢¤³¤Î¥³¥Þ¥ó¥É¤ÏºÆÀ¸¡¢Ï¿²»¤òÄä»ß¤·¤¿¤¤¾ì¹ç¤Ë¤Î¤ßɬÍפȤµ¤ì¡¢È¯¹Ô¸å¤Ï¥Ç¥Ð¥¤¥¹¤ò°ìÅÙ close() ¤·¤ÆºÆÅÙ open() ¤¹¤ë¤³¤È¤ò¤ª´«¤á¤¹¤ë¤È¤¤¤Ã¤¿ÆâÍƤ¬½ñ¤«¤ì¤Æ¤¤¤Þ¤¹¡£

²»³Ú¥×¥ì¡¼¥ä¡¼¤ÎÍͤʥ¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¡¢ºÆÀ¸Ãæ¤ËÄä»ß¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿»þ¤ËºÆÀ¸¤ò»ß¤á¤ë¡¢¤È¤¤¤Ã¤¿¾ì¹ç¤Ë»È¤¦¤³¤È¤Ë¤Ê¤ë¤Ç¤·¤ç¤¦¡£