ºìÁªLinuxÃÅ»§
Linux°ïÖú

Linux/ALSAÏÂSRC(Sample Rate Convertion)ÒýÆðµÄÒôÖÊÎÊÌâºÍ½â¾ö·½°¸

·¢²¼Ê±¼ä:2008-02-20 21:00:53À´Ô´:ºìÁª×÷Õß:Travel
ÕâÀï²»Éæ¼°»ù±¾ÒôÖÊÎÊÌ⣬ËùÒÔÈç¹ûÄãÓб¬ÒôµÄÎÊÌâÇë²Î¿¼ÂÛ̳ÀïÈçºÎÉèÖÃPCMÒôÁ¿ÒÔ±ÜÃâÔöÒæ´øÀ´µÄÏ÷²¨Ê§ÕæµÄÎÄÕ£»»òÕßÄãÓб³¾°ÔëÉù£¬Çë³¢ÊԹرÕÉù¿¨µÄ¼ÒôºÍÓëÄãËùÐèÊä³öÉùµÀÎ޹صĽӿڡ£´ËÍâÊý×ÖÊä³öºÍÍâÖýâÂëÆ÷²»ÔÚÌÖÂÛ·¶Î§¡£Èç¹ûÄãÓÐһƬ¹ýµÃÈ¥µÄÉù¿¨£¬ÒôÖÊÔڸоõÉÏÒѾ­²»´íÁË£¬ÄÇôÄã¿ÉÒÔ¿´¿´ÏÂÃæ¡£µ±È»Èç¹ûÄãÖ»ÊÇÒÉ»óLinuxÊÇ·ñÕæÓÐÒôÖÊÎÊÌ⣬»òÕßÊÇÔõô·¢ÉúµÄ£¬Ò²¿ÉÒԲο¼¡£

×î½üÔÚʹÓÃÒ»¿éTerratec DMX 6Fire LT(ÒôƵI/O¿ØÖÆÆ÷ÊÇ Ice1712[Envy24])µÄʱºò£¬ÎÒ·¢ÏÖenvy24controlÕâ¸ö¹¦ÄÜÇ¿´óµÄ¿ØÖÆÈí¼þÃæ°åÉÏ×ÜÊÇÏÔʾÕâƬÉù¿¨ÕýÔÚʹÓÃ48KHzµÄģʽ£¬ÎÒµÄÒôÔ´¿â»ù±¾ÊÇ´ÓCDת»»µÄFLACºÍWAV£¬²ÉÑùÂʶ¼ÊÇ44.1KHz¡£DMX 6FireÊÇһƬ˫¾§ÕñµÄÉù¿¨£¬°åÉÏÓÐ24.576MHzºÍ22.5792MHzÁ½¿Å¾§Ì壬¿ÉÒÔÖ±½ÓÖ§³Ö44.1KHzºÍ48KHzµÈģʽ¶øÎÞÐèת»»¡£ÎÒ³¢ÊÔÖ±½Ó²¥·ÅһƬÆÕͨCD£¬ÒÀÈ»×Ô¶¯Ìøµ½ÁË48KhzÉÏ£¬ÕæÊÇÆæ¹Ö¡£ÓÚÊÇÎÒËÉ¿ªÁË×Ô¶¯ResetƵÂʵÄÑ¡ÏÊÖ¶¯Ëø¶¨µ½44.1KHz£¬È»ºó²¥·Å£¬Ã»Ïëµ½ÉùÒô³öÀ´ÏñÊÇÂý·ÅµÄЧ¹û£¬¿Ï¶¨ÓÐʲôµØ·½²»¶ÔÁË¡£

ÎÒʹÓÃAmarok¹ÜÀíÒôÀֿ⣬Òò´ËÏëµ½ÊÇ·ñÊÇXineºó¶Ë×öÁË×Ô¶¯ÉýƵ´¦Àí£¬¸ÄÓÃALSAÃüÁîÐй¤¾ßaplay²¥·ÅÒ»¶Î44.1KHzµÄWAVºó£¬ÎÊÌâÒÀ¾É¡£ÅųýÁËXine£¬ÏÂÃæ¾ÍÊÇALSA(ÎÒʹÓÃXineµÄALSAÊä³ö²å¼þ)±¾ÉíÁË£¬×îµ×²ãµÄÇý¶¯Ä£¿éÓ¦¸ÃûÓÐÎÊÌ⣬ÒòΪÎÒ¿ÉÒÔÊÖ¶¯Ëø¶¨µ½ÈκθĿ¨¹æ¸ñÉÏÖ§³ÖµÄģʽ£¬Ö»ÊDz¥·ÅЧ¹û²»Õý³£¡£Öð½¥µØÎÒÏëµ½ÁËÒ»¸öÎÊÌ⣬Evny24ÊÇÒ»¸öÒôƵI/OоƬ£¬²¢Ã»ÓÐCS46xxÒ»ÀàDSPµÄ¼ÆËã´¦ÀíÄÜÁ¦£¬Ó¦¸Ã²»Ö§³ÖÓ²¼þ»ìÒô¡£±íÏÖµ½¼ÆËã»úÉÏ£¬¾ÍÊǶà¸öÒôƵÁ÷ÎÞ·¨Í¬Ê±¿ªÆô£¬Äã²»ÄÜÔÚ²¥·ÅÒôÀÖµÄͬʱÔÙÈ¥¿ªÒ»¸öµçÓ°²¥·ÅÆ÷£¬ÉõÖÁIMÈí¼þµÄÏûϢ֪ͨÒô¶¼ÎÞ·¨²¥·Å¡£µ«ÊÇÔÚÎÒµÄϵͳÏÂͬʱ¿ª³öÒ»´òµÄÒôƵ³ÌÐòȷʵÓÖûÓÐÎÊÌ⣬×îÖÕÎÒ°ÑÄ¿¹â·Åµ½ÁËALSAµÄÈí¼þ»ìÒô²å¼þDMixÉÏ¡£

ÓÉÓÚ´ÓÇ°ÎÒµÄÉù¿¨Ê¹ÓÃCS4630оƬ»òÕßEMU10K£¬dsp¾ßÓÐÓ²¼þ¶àÒôƵÁ÷ºÍSRC¹¦ÄÜ£¬Òò´Ë²»Ì«Ê¹ÓÃDMix¡£µ«ÏÖÔÚÎÒ¾ö¶¨»¹ÊÇÈ¥µôDMix¿´¿´ÊÇ·ñÓÐÓá£ÔÚ/usr/share/alsa/cards/Ï£¬ÎÒÕÒµ½ÁËICE1712оƬÉù¿¨µÄÔ¤ÉèÎļþICE1712.conf¡£²¢×¢Ê͵ôÁË¿ªÍ·Ò»¶ÎdmixÏà¹ØµÄÏîÄ¿¡£È»ºóÎÒÓÃaplay²¥·ÅÒ»¶Î44.1KHzµÄWAV£¬Éù¿¨ÖÕÓÚ×Ô¶¯Ìøתµ½ÁËÕýÈ·µÄģʽ£¡µ±È»×÷Ϊ´ú¼Û£¬ÏàÓ¦µØÎÒÔÝʱʧȥÁËÈí¼þ»ìÒôµÄ¹¦ÄÜ¡£

ÒýÓÃ:
# default with dmix & dsnoop
ICE1712.pcm.default {
@args [ CARD ]
@args.CARD {
type string
}
type asym
playback.pcm {
type plug
slave.pcm {
@func concat
strings [ "dmix:" $CARD ",FORMAT=S32_LE" ]
}
}
capture.pcm {
type plug
slave.pcm {
@func concat
strings [ "dsnoop:" $CARD ",FORMAT=S32_LE" ]
}
}
}


½áÂÛºÜÇå³þ£¬ÏÖÔÚµÄALSAĬÈÏÒѾ­Îª²»¾ß±¸Ó²¼þ¶àÒôƵÁ÷»ìÒô¹¦ÄܵÄÉù¿¨Ä¬ÈÏ¿ªÆôÁËDMix£¬¶øÒòΪDMixÐèÒª»ìÒô£¬Ò²¾ÍÊǰѶà¸ö¿ÉÄÜÊDz»Í¬È¡ÑùÂʵÄÒôƵÁ÷»ìºÏÊä³ö£¬Òò´ËËüÐèÒªÒ»¸ö½Ï¸ßµÄ³£ÓÃÈ¡Öµ×÷Ϊ»ù×¼¡£Ä¬ÈÏ»á²ÉÓÃ48KHzµÄSample Rate£¬ÈôÊǵÍÓÚ´ËƵÂÊ£¬ÔòÉýƵµ½48KHz¡£½ÓÏÂÈ¥µÄÎÊÌâÊÇ£¬DMixÔÚSRCÖ®ºó£¬ÊÇ·ñÓ°ÏìÌý¸Ð£¿ÔÚÎÒ¿´À´£¬ÊÇÓÐÒ»¶¨Ó°ÏìµÄ£¬±ÈÈçСÌáÇٵĸßÒôÑÓÕ¹»á²»×㣬¶ø½ÏΪÏËϸµÄ·ºÒô±»DMix×öSRCÖ®ºóÒ²»á±»Ï÷Èõ»òÄ£ºý¡£Òò´ËÈç¹ûÄãÓÐË«¾§ÕðÉù¿¨£¬²¢¶Ô44.1KHz»Ø·ÅµÄÒôÖÊÓÐËù²»Âú£¬ÄÇôÄã¿ÉÒÔ¿¼ÂÇÔÚÐÀÉÍÒôÀÖµÄʱºò¹Ø±ÕDMix£¬ÕâÑù¿ÉÒÔÍêÈ«·¢»ÓË«¾§ÕñÉù¿¨Ó¦ÓеÄʵÁ¦¡£µ±È»Èç¹ûÄãÖ»ÖØÊÓ44.1KHzÒôÔ´ÀýÈç´ÓCD×¥¹ìµÄAPE/FLAC/WAV£¬¶ø¶ÔDVD»òÕßÆäËûÊÓƵÏà¶ÔÀ´ËµÎÞËùνһЩ£¬Í¬Ê±²»ÏëʧȥÈí¼þ¶àÒôƵÁ÷Ö§³Ö£¬ÄÇôÄãÒ²¿ÉÒÔÖ»°ÑDMixÉ趨µ½Ä¬ÈÏ44.1KHz£¬ÏíÊÜÒôÀÖ£¬Ç¨¾ÍÊÓƵ¡£

½«DMixµÄĬÈÏÊä³öƵÂÊÉ趨µ½44.1KHz£¬¿É²Î¿¼ÒÔÏÂ~/.asoundrc×÷³ö×Ô¼ºµÄÉ趨£º

ÒýÓÃ:
pcm.!default {
type plug
slave.pcm "dmixer"
}
pcm.dsp0 {
type plug
slave.pcm "dmixer"
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "hw:0,0"
period_time 0
period_size 1024
buffer_size 8192
rate 44100
}
bindings {
0 0
1 1
}
}
ctl.mixer0 {
type hw
card 0
}


³ý´ËÖ®Í⣬ÓÐЩÉù¿¨Ö»Óе¥¾§Õñ£¬ÎÞ·¨Ö§³ÖÁ½ÖÖƵÂÊ£¬±ØÐë͸¹ýSRC¡£Èç´ËÇé¿öÏ£¬¸ßÆ·ÖʵÄSRCÖÁÉÙ¿ÉÒÔ½µµÍʧÕæ¡£ALSA¿¼Âǵ½ÕâÖÖÇéÐΣ¬ÔÊÐíͨ¹ý²å¼þµ÷ÓÃÍⲿ¸ßÆ·ÖÊSRC¿â½øÐÐת»»ÔËË㡣ΪÁËʹÓÃÍⲿSRC£¬ÄãÐèÒªlibasound2-plugins£¬libsamplerate0µÈÈí¼þ°ü(Ô´ÖоùÓÐ)¡£°²×°Íê±Ïºó£¬ÔÚ~.asoundrc ÖмÓÈëdefault.pcm.rate_converter "samplerate_best"À´ÆôÓÃ×î¼ÑSRCËã·¨¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 1 ÌõÆÀÂÛ

  1. colinro ÓÚ 2014-06-24 15:11:56·¢±í:

    ÌØÒâ»Ø¸´Ï£¬ÕâÌû×Ó°ï½â¾öÁË·¢Òô²»¶ÔµÄÎÊÌ⣬²»´í£¡