¦b¤@¯ë¹q¸£¥¥x¤W¡A±`¨£µ°TÀɮתºªþÀɦW¦³ .wav¡B.au¡B.mp3¡B.aifµ¥µ¥¡A§Ú̳£¥i¥H¨Ï¥Î MATLAB ¨Óª½±µÅª¨ú³o´XºØÀɮסA©Ò¥Îªº«ü¥O¬Oaudioread¡C¨Ò¦p¡AYnŪ¨ú¥»³¹½d¨Òµ{¦¡¥Ø¿ý¤ºªºÀÉ®× welcome.wav¡Bµe¥Xµ°Tªºªi§Î¨Ã¼½©ñ¥X¦¹µ°T¡A¥i¨Ï¥Î¤U¦Cµ{¦¡¡G
¦b¤W¨Ò¤¤¡Afs ¬O¨ú¼ËÀW²v¡]sample rate¡^¡A¨äȬ° 11025¡A¥Nªí·íªì¦b¿ý»s³oÓµ°TÀɮ׮ɡA¨C¬íÄÁ·|°O¿ý¤U11025ÓÁnµ°T¸¹ªº¨ú¼ËÈ¡C¦Ó y ¬OÁnµ°T¸¹ªº¦V¶q¡A¨Ï¥Î sound(y, fs) ¥i¼½©ñ¥X¦¹µ°T¡A©Ò¥H§A·|Å¥¨ì§ÚªºÁnµ¡uÅwªï¥úÁ{¡v¡Ctime «h¬O¹ïÀ³¦b¦b®É¶¡¶bªº¦V¶q¡A¦]¦¹±N y ¹ï time °µ¹Ï¡A´N±o¨ì¦b®É¶¡¶b¤W±ªºµ°Tªi§Î¡C
¨Æ¹ê¤W¦b¿ý»sµ°TÀɮ׮ɡA¨C¤@Ó¨ú¼ËÂI¤j³¡¤À³£¬O¥Ñ8©Î16Ӧ줸¡]bits¡^©Ò¥Nªí¡AYnª¾¹D welcome.wav ªº¨ú¼ËÂI¬O¥Ñ¦h¤ÖӦ줸¨Óªí¥Ü¡A¥i¨Ï¥Î audioinfo(¡¥welcome.wav¡¦) ¨Ó¦^¶Ç¦UºØ¬ÛÃö¸ê°T¡A½d¨Ò¦p¤U¡G
ŪªÌ¥i¯à·|¦n©_¡A¬°¤°»ò¦b welcome.wav µ°TÀɮפ¤¡A¨C¤@Ó¨ú¼ËÂI¥Î 8 Ӧ줸¨Óªí¥Ü¡A¦ý¬O±qµ°Tªi§Î¨Ó¬Ý¡A¨C¤@ÂIªºÈ³£¤¶©ó ¡V1 ©M 1 ¤§¶¡¡A³o¤¤¶¡¬O¦p¦óÂà´«ªº¡Hº¥ýnª¾¹D wav Àɮתº 8 ¦ì¤¸¬O¥H unsigned integer¡]¤£±a²Å¸¹ªº¾ã¼Æ¡A§Y¥¿¾ã¼Æ¡^ªº¤è¦¡¨ÓÀx¦s¡A¦]¦¹©Ò¯àªí¥Üªº¼ÆȬO¤¶©ó 0 ©M 255 (2^8-1) ¤§¶¡¡AMATLAB ¦A±N¦¹È³]©w¦ÜÅÜ¼Æ y ®É¡A·|¦Û°Ê±N¨ä¼ÆȽվã¦Ü¤¶©ó ¡V1 ©M 1 ¤§¶¡¡A¦]¦¹Yn±N MATLAB Ū¥X¤§¼ÆÈÂà¦^ì¥ý 8 ¦ì¤¸©Òªí¥Ü¤§¼ÆÈ¡A¥un±NÅÜ¼Æ y ¼¥H 128¡A¦A¥[¤W 128¡A´N¥i¥H±o¨ìì¥ýªº¾ã¼ÆÈ¡A¨Ò¦p¡G
¦b¤W¨Ò¤¤¡AÅÜ¼Æ difference ªºÈ¬O¹s¡A¥Nªí y0 ªºÈ§¹¥þ¬O¾ã¼Æ¡C¦¹¥~¡A¬°¤F¼W¥[µ{¦¡½Xªº³q¥Î©Ê¡A§Ú̥Π2^nbits/2¡A¦Ó¤£ª½±µ¨Ï¥Î128¡C
MATLAB ¹ï©óµÀɸê®Æªº¥¿³W¤Æ¤è¦¡¡A¥i¥H¦Cªí¦p¤U¡G
µ°TÀɮפº³¡Àx¦s¤è¦¡ ¼ÆȽd³ò MATLAB¥¿³W¤Æ¤è¦¡ Unsigned 8-bit integer (uint8) y $\in$ [0, $2^8-1$] (y-$2^7$)/$2^7$ Signed 16-bit integer (int16) y $\in$ [$-2^{15}$, $2^{15}-1$] y/$2^{15}$ Signed 32-bit integer (int32) y $\in$ [$-2^{31}$, $2^{31}-1$] y/$2^{31}$ audioread ¤]¥i¥HŪ¨úÂùÁn¹D©Î¥ßÅéÁn¡]Stereo¡^ªºµ°TÀɮסA¦¹®É¶Ç¦^ªºÅܼƬ°¨ã¦³¨âª½¦æªº°}¦C¡A¨C¤@ª½¦æ¥Nªí¤@ÓÁn¹Dªºµ°T¡A¨Ò¦p¡G
¦¹½d¨Ò·|Ū¨úÂùÁn¹Dªºµ°TÀÉ flanger.wav¡A¼½©ñ¦¹ÂùÁn¹Dªºµ°T¡A¨Ãµe¥X¨âÓÁn¹Dªºµ°Tªi§Î¡C¥Ñ©ó¥ª¥kÁn¹Dªºµ¶q¡]§Yªi§Îªº¾_´T¡^¬Û¤¬®øªø¡A¦]¦¹¼½©ñ¥X¨Óªº®ÄªG¡A·Pı¦n¹³µ·½¦b¥ª¥kÁn¹D¤§¶¡´å²¾¡C¡]¤p°ÝÃD¡Gµ¹§A¤@Ó³æÁn¹DªºÁnµ°T¸¹¡A§A¦p¦ó¨Ï¥Î MATLAB ¹ï¦¹µ°T¶i¦æ³B²z¡A³Ì«á²£¥Íìµ°T¦bÂùÁn¹D¤§¶¡´å²¾ªº®ÄªG¡A¦p¦P¦¹½d¨Ò¤@¯ë¡H¡^
¦pªGµ°TÀɮ׫ܤj¡AµLªk¤@¦¸Åª¤J°O¾ÐÅé¡A§Ṳ́]¥i¥H¨Ï¥Î audioread ¨ÓŪ¥Xµ°TÀɪº¨ä¤¤¤@³¡¥÷¡A¨Ò¦p¡G
³o¤@¬qªi§Î¥Nªí¡uÅwªï¥úÁ{¡v¤¤ªº¡uªï¡vè¶}©lµoµªºªi§Î¡C¥Ñ¤W¹Ï¥i¬Ý¥X¡AÁnªiªº¥~«¬¬O«ÜÃþ¦ü¤@Ó¶g´Áªi¡A¨ä¾_´T¤j¤p´N¥Nªíµ¶q¤j¤p¡A¦Ó¨ä¶g´ÁªºË¼Æ´N¬O¡u°ò¥»ÀW²v¡v¡C¥H¤Wz¹Ï§Î¦Ó¨¥¡A1000Ó¨ú¼ËÂI¤j·§¥]§t¤F10Ó¶g´Á¡A©Ò¥H¨CÓ¶g´Á¤j¬ù¥]§t 100ÂI¡A¹ïÀ³ªº®É¶¡¬O 100/fs = 100/11025 = 0.0091¬í = 9.1 ms¡A¦Ó°ò¥»ÀW²v«h¬O 1/0.0091 = 110.25 Hz¡A´«ºâ¦¨¿ûµ^ªº«öÁä¡A«D±`±µªñ©ó¤¤¥¡ la ¡]¹ïÀ³ÀW²v¬O 440 Hz¡^°16«×¡]¨âÓ¥þµ¶¥¡^©Ò±o¨ìªºµ¡A¤]´N¬O¤U¹Ï¤¤ªº A4¡]¥ªÃä¼Æ¨Ó²Ä 5 Ó¥ÕÁä¡^¡C
300
¤H¦Õ¹ïÁnµ°ª§Cªº·Pı¡A¬O»P°ò¥»ÀW²vªº¹ï¼Æ¦¨¥¿¤ñ¡C¥H¿ûµ^ªºÁä½L¦Ó¨¥¡A¤¤¥¡ la ªºÀW²v¬O 440 Hz (Hertz)¡A°ª¤K«×ªº¤¤¥¡ la «h¬O 880 Hz¡A§C¤K«×ªº¤¤¥¡ la «h¬O 220 Hz¡C¿ûµ^¤¤ªº¨C¤@Ó¥þµ¶¥¥]§t7Ó¥ÕÁä»P5Ó¶ÂÁä¡A¦@¦³ 12 ÓÁä¡A¥Nªí 12 Ó¥bµ¡]semitones¡^¡A¥H MIDI ªº¼Ð·Ç¦Ó¨¥¡A¤¤¥¡ la ªº¥bµÈ¬O 69¡A¹ïÀ³ÀW²v¬O 440 Hz¡A¦]¦¹¥bµ©MÀW²v¤§¶¡ªºÂà´«µ{¦¡¥i¼g¦¨¤U¦C¤½¦¡¡G $$semitone=69+12\log_2\left(\frac{Hz}{440}\right).$$
¥Ñ¤@¬qÁnµ¨Ó¨D¨ú¨äµ°ª¡A¦bµ°T³B²z¤WºÙ¬°µ°ª°lÂÜ¡]Pitch Tracking¡^¡A¬Oµ°T³B²z«Ü«nªº¤@Àô¡A¬ÛÃöÀ³¥Î¦³»yµ¦X¦¨¡Bµ½Õ¿ëÃÑ¡Bó°Û¿ïºqµ¥¡C
«e±»¡©ú¹L¡Aaudioread ·|±NŪ¨ìªºµ°TÀ£ÁY¦b -1 ©M +1 ¤§¶¡¡A¦ý¦pªG§A·QŪ¨úì¨Óµ°TÀx¦s¦bµ°TÀɮפ¤ªºì©l¸ê®Æ¡A¤]¥i¥H¡A½d¨Ò¦p¤U¡G
¥Ñ¤W¨Ò¥i¥H¬Ý¥X¡A·í§ÚÌ¥[¤J 'native' ·í¦¨ audioread ªº²Ä¤TӰѼƮɡA©ÒŪ¥Xªºµ°T´N·|¬O¥Hì¨ÓÀɮפºªº¸ê®Æ«¬ºA¬°·Ç¡A¦]¦¹¥»¨Ò¤¤ªºµ°T¸ê®Æ y ªº¸ê®Æ«¬ºA¬° uint8¡A¦P®Éµe¥Xªºªi§Îªº¾_´T½d³ò¤]¤£¦A©ó -1 ©M +1 ¤§¶¡¡C
MATLABµ{¦¡³]p¡G¤Jªù½g