{"id":1053,"date":"2010-02-28T23:32:30","date_gmt":"2010-02-28T15:32:30","guid":{"rendered":"http:\/\/www.ccttours.com\/blog\/?p=1053"},"modified":"2010-02-28T23:35:48","modified_gmt":"2010-02-28T15:35:48","slug":"supercollider%ef%bc%9a%e5%90%88%e6%88%90%e5%99%a8%e5%ae%9a%e4%b9%89","status":"publish","type":"post","link":"https:\/\/learn.travelchinawith.me\/?p=1053","title":{"rendered":"SuperCollider\uff1a\u5408\u6210\u5668\u5b9a\u4e49"},"content":{"rendered":"<p><strong><span style=\"color: #00ff00;\">SynthDef<\/span><\/strong><\/p>\n<p><strong><em>{}.play<\/em><\/strong> \u6807\u5fd7\u6cd5\u5e76\u975eSuperCollider 3\u7684\u9996\u9009\u6807\u8bb0\u6cd5\uff0c\u4f46\u4ed6\u5374\u5141\u8bb8\u6211\u4eec\u5bf9\u5408\u6210\u5feb\u901f\u4e0a\u624b\u3002\u4ece\u73b0\u5728\u8d77\uff0c\u4f60\u5e38\u770b\u5230\u7684\u90fd\u5c06\u662f\u4f7f\u7528<span style=\"color: #0000ff;\">SynthDef<\/span>\u7ed3\u6784\u5b9a\u4e49\u7684UGen\u7f51\u7edc\u3002\u7136\u540e\u5f88\u591a\u5408\u6210\u90fd\u662f\u7531\u4e00\u4e2a\u5355\u72ec\u7684<span style=\"color: #0000ff;\">SynthDef<\/span>\u6765\u521b\u5efa\uff0c\u8fd9\u5bf9\u4e8e\u5236\u9020\u4e00\u5806\u7c7b\u4f3c\u7684\u58f0\u97f3\u548c\u5176\u5b83\u9897\u7c92\u4ee5\u53ca\u6574\u4f53\u8fdb\u7a0b\u662f\u5c24\u5176\u91cd\u8981\u7684\u3002<br \/>\n<!--more--><\/p>\n<p>SynthDef = Synthesizer Definition\uff08\u5408\u6210\u5668\u5b9a\u4e49\uff09<\/p>\n<hr \/>\n<p>\u4e3a\u4e86\u5728SC\u4e2d\u5408\u6210\u58f0\u97f3\uff0c\u4f60\u5fc5\u987b\u4e3aUGen\u7f51\u7edc\u7528\u7f16\u7a0b\u8bed\u8a00\u5199\u4e00\u4e2a\u79d8\u8bc0\uff08recipe\uff09\u3002\u8fd9\u4e2a\u79d8\u8bc0\u7531\u4e00\u4e2a\u7279\u6b8a\u7684\u8bed\u8a00\u7ed3\u6784\u5199\u5c31\u800c\u6210\uff0c<span style=\"color: #0000ff;\">SynthDef<\/span>\u3002<\/p>\n<pre class=\"brush:jfx\">SynthDef(\\sine, {Out.ar(0,SinOsc.ar(Rand(440,880),0,0.1))}).load(s);<\/pre>\n<p>\u4e00\u65e6\u4e00\u4e2a\u79d8\u8bc0\u88ab\u7cfb\u7edf\u6240\u8ba4\u77e5\uff0c\u4f60\u4fbf\u80fd\u4ee5\u90a3\u4e2a\u89c4\u5219\u521b\u5236\u4e00\u4e2a\u72ec\u7acb\u7684\u5408\u6210\u5668\uff1a<\/p>\n<pre class=\"brush:jfx\">Synth(\\sine);<\/pre>\n<p>\u5b9e\u9645\u4e0a\uff0c\u4f60\u60f3\u7528\u5b83\u4eec\u591a\u5c11\u6b21\u90fd\u53ef\u4ee5\uff08\u6bcf\u6b21\u8dd1\u4e0b\u8fb9\u7684\u4e00\u884c\u4ee3\u7801\uff09\uff1a<\/p>\n<pre class=\"brush:jfx\">a=Synth(\\sine);\r\nb=Synth(\\sine);\r\nc=Synth(\\sine);<\/pre>\n<p>\u7136\u540e\u6bcf\u6b21\u4e00\u884c\u5730\u5206\u522b\u8fd0\u884c\u4e0b\u5217\u4ee3\u7801\u53ef\u4ee5\u5355\u72ec\u505c\u6b62\u6bcf\u4e00\u4e2a\u5408\u6210\uff1a<\/p>\n<pre class=\"brush:jfx\">a.free;\r\nb.free;\r\nc.free;<\/pre>\n<p>\u6ce8\u610f\uff0c\u6bcf\u4e2a\u5408\u6210\u5668\u5728\u521b\u5efa\u4e4b\u521d\u7684\u521d\u59cb\u503c\u90fd\u662f\u5728440\u5230880\u4e4b\u95f4\uff0c\u8fd9\u662f\u7531\u4e8e\u4e0a\u8ff0<span style=\"color: #0000ff;\">SynthDef<\/span>\u4e2d\u7684<span style=\"color: #0000ff;\">Rand<\/span> UGen\u6240\u5b9a\u4e49\u7684\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u6b65\u5230\u4f4d\u7684\u5199\u6cd5\uff1a<\/p>\n<pre class=\"brush:jfx\">SynthDef(\\saw, {Out.ar(0,Saw.ar(Rand(440,880),0.1))}).play(s);<\/pre>\n<hr \/>\n<p>\u4f60\u4f1a\u770b\u5230\u5236\u9020\u548c\u4f7f\u7528<span style=\"color: #0000ff;\">SynthDef<\/span>\u7684\u65b9\u6cd5\u4e2d\u7684\u4e00\u4e9b\u53d8\u5316\uff1a<\/p>\n<pre class=\"brush:jfx\">SynthDef(\"aaa\",{Out.ar(0,SinOsc.ar(440,0,0.1))}).send(s)<\/pre>\n<pre class=\"brush:jfx\">Synth(\"aaa\"); \/\/ \u73b0\u5728\u8fd0\u884c\u8fd9\u4e2a<\/pre>\n<p>\u5728\u547d\u540d<span style=\"color: #0000ff;\">SynthDef<\/span>\u65f6\uff0c\\aaa\u4e0e&#8221;aaa&#8221;\u662f\u76f8\u540c\u7684\u3002<span style=\"color: #0000ff;\">SynthDef<\/span>\u88ab\u53d1\u9001\u800c\u4e0d\u662f\u88ab\u8f7d\u5165\uff0c\u8fd9\u5c5e\u4e8e\u6280\u672f\u4e0a\u7684\u7ec6\u8282\uff0c\u5c06<span style=\"color: #0000ff;\">SynthDef<\/span>\u50a8\u5b58\u5165\u786c\u76d8\u800c\u4e0d\u662f\u76f4\u63a5\u4f7f\u7528\u5b83\u4eec\u3002<\/p>\n<hr \/>\n<p>\u5404\u79cd\u4e0d\u540c\u7684<span style=\"color: #0000ff;\">SynthDef<\/span>\uff1a<\/p>\n<ul>\n<li><strong><em>.send<\/em><\/strong>\u2014\u2014\u5728\u76ee\u524d\u4ec5\u53d1\u9001<span style=\"color: #0000ff;\">SynthDef<\/span>\u5230\u5408\u6210\u670d\u52a1\u5668\uff08synthesis server\uff09\uff0c\u4e0d\u5728\u786c\u76d8\u4e0a\u653e\u7f6e\u4efb\u4f55\u6587\u4ef6\u3002<\/li>\n<li><em><strong>.writeDefFile<\/strong><\/em>\u2014\u2014\u5c06<span style=\"color: #0000ff;\">SynthDef<\/span>\u5199\u5165\u786c\u76d8\u4e0a\u7684\u4e00\u4e2a\u6587\u4ef6\uff0c\u4e0d\u5c06\u5b83\u8f7d\u5165\u5230\u5408\u6210\u670d\u52a1\u5668\u3002<\/li>\n<li><strong><em>.load<\/em><\/strong>\u2014\u2014\u5c06\u6587\u4ef6\u5199\u5165\u786c\u76d8\uff0c\u56e0\u6b64\u5b83\u4ece\u73b0\u5728\u8d77\u5f53\u4f60\u6bcf\u6b21\u5f00\u542f\u5408\u6210\u670d\u52a1\u5668\u7684\u65f6\u5019\u90fd\u88ab\u8f7d\u5165\u5e76\u5feb\u901f\u53d1\u9001\u3002<\/li>\n<li>\u8fd8\u6709\u4e00\u4e9b\u8bf8\u5982 <strong><em>.writeOnce<\/em><\/strong> \u548c <strong><em>.store<\/em><\/strong>\u2014\u2014\u6211\u4eec\u5c06\u5728\u6211\u4eec\u9700\u8981\u5b83\u4eec\u7684\u65f6\u5019\u63a5\u89e6\u5b83\u4eec\u3002<\/li>\n<\/ul>\n<hr \/>\n<p>\u4e0e\u6211\u4eec\u4e4b\u524d\u4f7f\u7528<span style=\"color: #0000ff;\">SinOsc<\/span>\u7684\u4f8b\u5b50\u552f\u4e00\u4e0d\u540c\u7684\u5730\u65b9\uff0c\u4fbf\u662f<span style=\"color: #0000ff;\">SynthDef<\/span>\u5305\u88f9\u4ee5\u53ca\u5bf9<span style=\"color: #0000ff;\">Out<\/span> UGen\u7684\u4f7f\u7528\u3002\u5bf9\u4e8e<span style=\"color: #0000ff;\">Out<\/span> UGen\u5b8c\u6574\u7684\u89e3\u91ca\u5c06\u5728\u6211\u4eec\u8ba8\u8bba\u603b\u7ebf\uff08bus\uff09\u7684\u65f6\u5019\u8fdb\u884c\uff0c\u4f46\u73b0\u5728\u4f60\u53ef\u4ee5\u5c06\u5b83\u6682\u65f6\u60f3\u505a\u201c\u5728\u8ba1\u7b97\u673a\u7684\u7b2c\u4e00\u4e2a\u97f3\u9891\u8f93\u51fa\u64ad\u653e\u201d\u3002<\/p>\n<pre class=\"brush:jfx\">\/\/ \u4e3a\u79d8\u8bc0\u52a0\u5165\u9891\u7387\u5f15\u6570\r\n\/\/ \u6ce8\u610fSynthDef\u53ef\u88ab\u547d\u540d\u4e3a\\sine\u6216\"sine\"\r\nSynthDef(\\sine,{arg freq=440, amp=0.1; Out.ar(0,SinOsc.ar(freq,0,amp))}).load(s);\r\n\r\nSynth(\"sine\"); \/\/ \u73b0\u5728\u8fd9\u4e2a\u63a5\u53d7\u521d\u59cb\u503c\r\n\r\n\/\/ \u901a\u8fc7\u5411SynthDef\u6307\u660e\u9891\u7387\u5f15\u6570\r\n\/\/ \u4ece\u79d8\u8bc0\u4e2d\u521b\u5236\u53e6\u4e00\u4e2a\u9ad8\u516b\u5ea6\u7684\u5408\u6210\u97f3\r\nSynth(\"sine\",[\\freq,880]);<\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u8fd9\u6837\u505a\u5141\u8bb8\u6211\u4eec\u4ece\u4e00\u4e2a\u666e\u901a\u7684\u79d8\u8bc0\u4e2d\u5236\u9020\u51fa\u8bb8\u591a\u53d8\u5316\u7684\u5408\u6210\u97f3\u3002<\/p>\n<hr \/>\n<pre class=\"brush:jfx\">a=Synth(\\sine);\r\nb=Synth(\\sine,[\\freq,550]);\r\nc=Synth(\\sine,[\\freq,660, \\amp, 0.5]);<\/pre>\n<p>\u7136\u540e\u6bcf\u6b21\u4e00\u884c\u5730\u5206\u522b\u8fd0\u884c\u4e0b\u5217\u4ee3\u7801\u53ef\u4ee5\u5355\u72ec\u505c\u6b62\u6bcf\u4e00\u4e2a\u5408\u6210\uff1a<\/p>\n<pre class=\"brush:jfx\">a.free;\r\nb.free;\r\nc.free;<\/pre>\n<hr \/>\n<p><strong>\u7ec3\u4e60\uff1a<\/strong><\/p>\n<p>\u8bd5\u7740\u5c06\u4e00\u4e2a\u4f60\u66fe\u7ecf\u6216\u6b63\u5728\u4f7f\u7528\u7684\u5408\u6210\u5668patch\u8f6c\u5316\u4e3a\u4e00\u4e2a<span style=\"color: #0000ff;\">SynthDef<\/span>\u3002<\/p>\n<p>\u4f60\u53ef\u4ee5\u4ee5\u4e0b\u8ff0\u4ee3\u7801\u4e3a\u539f\u578b\uff1a<\/p>\n<pre class=\"brush:jfx\">(\r\nSynthDef(\\synthdefname,{arg input1; \/\/ \u6240\u6709\u5f15\u6570\u90fd\u5230\u8fd9\r\n\r\n\/\/ \u4e00\u4e9bUGen\u7684\u4ee3\u7801\u2014\u2014\u4e4b\u524d\u4f4d\u4e8e{}.play\u91cc\u7684\u4e1c\u897f\r\n\r\nOut.ar(0, finaloutput) \/\/finaloutput\u662f\u4f60\u60f3\u542c\u5230\u7684UGen\u6700\u540e\u7684\u7ed3\u679c\r\n}).send(s)\r\n)\r\n\r\nSynth(\\synthdefname, [\\input1, inputval1]); \/\/ inputval1\u662f\u6052\u91cf<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>SynthDef {}.play \u6807\u5fd7\u6cd5\u5e76\u975eSuperCollider 3\u7684\u9996\u9009\u6807\u8bb0\u6cd5\uff0c\u4f46\u4ed6\u5374\u5141\u8bb8\u6211\u4eec\u5bf9\u5408\u6210\u5feb\u901f\u4e0a\u624b\u3002\u4ece\u73b0\u5728\u8d77\uff0c\u4f60\u5e38\u770b\u5230\u7684\u90fd\u5c06\u662f\u4f7f\u7528SynthDef\u7ed3\u6784\u5b9a\u4e49\u7684UGen\u7f51\u7edc\u3002\u7136\u540e\u5f88\u591a\u5408\u6210\u90fd\u662f\u7531\u4e00\u4e2a\u5355\u72ec\u7684SynthDef\u6765\u521b\u5efa\uff0c\u8fd9\u5bf9\u4e8e\u5236\u9020\u4e00\u5806\u7c7b\u4f3c\u7684\u58f0\u97f3\u548c\u5176\u5b83\u9897\u7c92\u4ee5\u53ca\u6574\u4f53\u8fdb\u7a0b\u662f\u5c24\u5176\u91cd\u8981\u7684\u3002<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69],"tags":[70],"class_list":["post-1053","post","type-post","status-publish","format-standard","hentry","category-supercollider3","tag-supercollider"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/posts\/1053","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1053"}],"version-history":[{"count":3,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/posts\/1053\/revisions"}],"predecessor-version":[{"id":1055,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/posts\/1053\/revisions\/1055"}],"wp:attachment":[{"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}