{"id":1250,"date":"2011-04-14T16:08:07","date_gmt":"2011-04-14T08:08:07","guid":{"rendered":"http:\/\/www.ccttours.com\/blog\/?p=1250"},"modified":"2011-04-14T16:10:49","modified_gmt":"2011-04-14T08:10:49","slug":"sc%ef%bc%9a%e7%94%a8do%e5%81%9a%e8%bf%ad%e4%bb%a3%ef%bc%8cmidiout","status":"publish","type":"post","link":"https:\/\/learn.travelchinawith.me\/?p=1250","title":{"rendered":"SC\uff1a\u7528do\u505a\u8fed\u4ee3\uff0cMIDIOut"},"content":{"rendered":"<p>\u51fd\u6570\u548c\u6d88\u606f\u4f7f\u7528\u5f15\u6570\u3002\u53c8\u662f\u5f15\u6570\u4e4b\u4e00\u662f\u53e6\u4e00\u4e2a\u51fd\u6570\u3002\u51fd\u6570\u53ef\u88ab\u8d4b\u5230\u4e00\u4e2a\u53d8\u91cf\uff0c\u7136\u540e\u8fd9\u4e2a\u53d8\u91cf\u88ab\u7528\u5230\u5f15\u6570\u5217\uff0c\u6216\u8005\u8bf4\u5b83\u53ef\u4ee5\u88ab\u5d4c\u5957\u5982\u5f15\u6570\u5217\u3002\u5168\u90e8\u4f8b\u5b50\u89c1\u4e0b\u3002<br \/>\n<!--more--><br \/>\n.<br \/>\n.<br \/>\n.<br \/>\n.<br \/>\n<strong>20.1. \u88ab\u7528\u4f5c\u5f15\u6570\u4f20\u9012\u7684\u51fd\u6570<\/strong><\/p>\n<pre class=\"brush:jfx\">\/\/ \u88ab\u7528\u4f5c\u53d8\u91cf\u4f20\u9012\u7684\u51fd\u6570\r\nvar myFunc;\r\n\r\nmyFunc = {\r\n(10*22).rand\r\n};\r\n\r\nmax(45, myFunc.value);\r\n\r\n\/\/ \u88ab\u5d4c\u5957\u7684\u51fd\u6570\r\nmax(45, {(10*22.rand)})<\/pre>\n<h3>do<\/h3>\n<p>do\u51fd\u6570\u6216\u6d88\u606f\u88ab\u7528\u4e8e\u5c06\u4e00\u4e2a\u8fdb\u7a0b\u91cd\u590d\u4e00\u5b9a\u7684\u6b21\u6570\u3002\u7b2c\u4e00\u5f15\u6570\u662f\u4e00\u4e32\u5c06\u88ab\u201c\u505a\u201d\u7684\u5143\u7d20\uff0c\u4e00\u4e2a\u6570\u7ec4\u662f\u6bd4\u8f83\u5178\u578b\u7684\u3002\u7b2c\u4e8c\u5f15\u6570\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u4e3a\u5217\u8868\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u8fdb\u884c\u5faa\u73af\u3002\u5217\u8868\u4e2d\u7684\u5143\u7d20\u9700\u8981\u88ab\u4f20\u9012\u7ed9\u51fd\u6570\uff0c\u56e0\u6b64\u5b83\u4eec\u624d\u80fd\u5728\u51fd\u6570\u5185\u88ab\u4f7f\u7528\u3002\u8fd9\u7531\u4e00\u4e2a\u5f15\u6570\u5b8c\u6210\u3002\u4f60\u53ef\u4ee5\u5c06\u8fd9\u4e2a\u5f15\u6570\u547d\u540d\u4e3a\u4efb\u4f55\u4f60\u559c\u6b22\u7684\u540d\u5b57\u3002\u4f46\u5b83\u9700\u8981\u662f\u7b2c\u4e00\u4e2a\u5f15\u6570\u3002 <\/p>\n<p><strong>20.2. do\u8303\u4f8b <\/strong><\/p>\n<pre class=\"brush:jfx\">do([\"\u8fd9\", \"\u662f\", \"\u4e00\u4e2a\", \"\u5b57\u7b26\u4e32\", \"\u7684\", \"\u5217\u8868\"], {arg \u6bcf\u4e2a\u5143\u7d20; \u6bcf\u4e2a\u5143\u7d20.postln;})<\/pre>\n<p>\u6216\u8005 <\/p>\n<pre class=\"brush:jfx\">do([46, 8, 109, 45.8, 78, 100], {arg \u65e0\u8bba\u4ec0\u4e48; \u65e0\u8bba\u4ec0\u4e48.postln;})<\/pre>\n<p>\u5982\u679c\u7b2c\u4e00\u5f15\u6570\u662f\u4e00\u4e2a\u6570\u5b57\uff0c\u90a3\u4e48\u5b83\u4ee3\u8868do\u5c06\u91cd\u590d\u7684\u6b21\u6570\u3002\u56e0\u6b64do(5, {\u53fd\u53fd\u6b6a\u6b6a})\u5c06\u201c\u505a\u201d0\uff0c1\uff0c2\uff0c3\u548c4\u3002 <\/p>\n<p><strong>20.3. do\u8303\u4f8b<\/strong> <\/p>\n<pre class=\"brush:jfx\">do(5, {arg theNumber; theNumber.postln;})<\/pre>\n<p>\u786e\u4fdd\u7b2c\u4e8c\u5f15\u6570\u662f\u4e00\u4e2a\u653e\u7f6e\u4e8e\u82b1\u62ec\u53f7\u5185\u7684\u51fd\u6570\u3002\u628a\u4e0a\u4f8b\u7684\u82b1\u62ec\u53f7\u53bb\u6389\u540e\u8fd0\u884c\uff0c\u770b\u770b\u6709\u4ec0\u4e48\u4e0d\u540c\u3002 <\/p>\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528\u63a5\u6536\u5668\u8868\u793a\u6cd5\uff0c5\uff0c\u662f\u5bf9\u8c61\u6216\u63a5\u6536\u5668\uff0cdo\u662f\u6d88\u606f\u3002\u4e24\u79cd\u8bed\u6cd5\u662f\u4e00\u81f4\u7684\u3002 <\/p>\n<p><strong>20.4. \u63a5\u6536\u5668\u4e2d\u7684do<\/strong> <\/p>\n<pre class=\"brush:jfx\">do(5, {\"boing\".postln}) \r\n\/\/\u76f8\u540c\u7684\u7ed3\u679c \r\n5.do({\"boing\".postln;})<\/pre>\n<p>\u5728\u4e4b\u524d\u7684\u7ae0\u8282\u4e2d\uff0c\u6211\u4eec\u53d1\u73b0\u4fdd\u6301\u5bf9\u6bcf\u4e2a\u8fdb\u7a0b\u91cd\u590d\u7684\u8bb0\u5f55\u662f\u5f88\u6709\u5e2e\u52a9\u7684\u3002do\u51fd\u6570\u4e5f\u6709\u4e00\u4e2a\u8fd9\u4e48\u505a\u7684\u65b9\u6cd5\u3002\u88ab\u641e\u5b9a\u7684\u5143\u7d20\u88ab\u4f20\u9012\u7ed9\u51fd\u6570\uff0cdo\u540c\u6837\u8ba1\u6570\u6bcf\u6b21\u5faa\u73af\u5e76\u5c06\u6570\u5b57\u4f5c\u4e3a\u51fd\u6570\u7684\u7b2c\u4e8c\u5f15\u6570\u4f20\u9012\u3002\u4f60\u540c\u6837\u53ef\u4ee5\u5c06\u5b83\u547d\u540d\u4e3a\u4efb\u4f55\u4f60\u559c\u6b22\u7684\u540d\u5b57\uff0c\u4f46\u4e24\u8005\u5e94\u4f4d\u4e8e\u6b63\u786e\u7684\u987a\u5e8f\u4e0a\u3002\u8fd9\u7b2c\u4e8c\u4e2a\u6982\u5ff5\u6709\u4e00\u70b9\u70b9\u4ee4\u4eba\u6df7\u6dc6\uff0c\u56e0\u4e3a\u5982\u679c\u572810.do\u7684\u60c5\u51b5\u4e0b\uff0c\u7b2c\u4e00\u548c\u7b2c\u4e8c\u5f15\u6570\u662f\u4e00\u6837\u7684\uff1a\u5b83\u4ee5\u6b64\u201c\u505a\u201d\u7684\u6570\u5b57\u4ece0\uff5e9\uff0c\u540c\u65f6\uff0c\u8ba1\u6570\u5668\u5728\u8ba1\u6570\u5faa\u73af\u662f\u540c\u6837\u4e5f\u662f\u4ece0\u79fb\u52a8\u52309. <\/p>\n<p><strong>20.5. \u6709\u5f15\u6570\u7684do(10) <\/strong><\/p>\n<pre class=\"brush:jfx\">do(10, {arg eachItem, counter; eachItem.postln; counter.postln})<\/pre>\n<p>\u5c06\u4e00\u4e2a\u6570\u7ec4\u7528\u4e8e\u7b2c\u4e00\u5f15\u6570\u66f4\u6e05\u695a\u4e00\u4e9b\uff0c\u6216\u88ab\u201c\u505a\u201d\u7684\u5bf9\u8c61\u3002\u8bb0\u4f4f\u5f15\u6570\u7684\u4f4d\u7f6e\uff0c\u800c\u4e0d\u662f\u540d\u5b57\uff0c\u786e\u5b9a\u54ea\u4e2a\u662f\u54ea\u4e2a\u3002\u6ce8\u610f\u7b2c\u4e8c\u4f8b\uff0c\u540d\u5b57\u770b\u8d77\u6765\u4e0d\u5bf9\uff0c\u4f46\u88ab\u53cd\u590d\u5faa\u73af\u7684\u5143\u7d20\u662f\u7b2c\u4e00\u5f15\u6570\uff0c\u8ba1\u6570\u662f\u7b2c\u4e8c\u4e2a\u3002\u4f7f\u7528\u6570\u5b57(5.do)\uff0c\u533a\u522b\u662f\u7406\u8bba\u4e0a\u7684\u3002\u4f46\u4f7f\u7528\u4e00\u4e2a\u6570\u7ec4\uff0c\u7ed3\u679c\u53ef\u80fd\u5927\u4e0d\u76f8\u540c\uff0c\u50cf\u7b2c\u4e09\u4f8b\u793a\u8303\u7684\u3002\u540c\u6837\u6ce8\u610f\u5728\u8fd9\u4e2a\u6570\u7ec4\u5185\u7684\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u540c\u6837\u662f\u4e00\u4e2a\u6570\u7ec4\uff1a\u4e00\u4e2a\u5d4c\u5957\u6570\u7ec4\u3002 <\/p>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528\u6761\u6b3einf\u4ee5\u5f97\u5230\u4e00\u4e2a\u65e0\u9650\u7684do\u3002\u5f53\u4f60\u5c1d\u8bd5\u524d\u4fdd\u5b58\u4e00\u5207\uff01 <\/p>\n<p><strong>20.6. \u7528\u5f15\u6570\u7684array.do<\/strong> <\/p>\n<pre class=\"brush:jfx\">[10, \"hi\", 12.56, [10, 6]].do({arg eachItem, counter; [counter, eachItem].postln}) \r\n\r\n[10, \"hi\", 12.56, [10, 6]].do({arg count, list; [count, list].postln}) \/\/\u9519\u8bef \r\n\r\n[10, 576, 829, 777].do({arg count, items; (items*1000).postln}); \r\n\r\n[10, 576, 829, 777].do({arg items, count; (items*1000).postln}); \r\n\r\ninf.do({arg i; i.postln}) \/\/\u8fd9\u5f53\u7136\u4f1a\u4f7fSC\u5d29\u6e83<\/pre>\n<h3>MIDIOut<\/h3>\n<p>\u5c3d\u7ba1\u533a\u522b\u662f\u6a21\u7cca\u7684\uff0c\u6211\u4ecd\u5c06\u7535\u8111\u97f3\u4e50\u5212\u5206\u4e3a\u4e24\u5927\u7c7b\uff1a\u5408\u6210\uff0c\u4e5f\u5c31\u662f\u4e50\u5668\u6216\u58f0\u97f3\u8bbe\u8ba1\uff1b\u7b2c\u4e8c\u7c7b\u662f\u4e8b\u4ef6\/\u7ed3\u6784\u8bbe\u8ba1\u3002\u4e8b\u4ef6\/\u7ed3\u6784\u8bbe\u8ba1\u6d89\u53ca\u97f3\u7684\u7ec4\u7ec7\u3001\u6301\u7eed\u3001\u4e0b\u4e00\u4e8b\u4ef6\u5b89\u6392\u3001\u4e50\u5668\u9009\u62e9&#8230;\u7b49\u7b49\u3002\u5982\u679c\u4f60\u5bf9\u90a3\u79cd\u521b\u4f5c\u7c7b\u578b\u66f4\u611f\u5174\u8da3\uff0c\u90a3\u4e48\u771f\u6ca1\u592a\u591a\u7406\u7531\u53bb\u8bbe\u8ba1\u4f60\u81ea\u5df1\u7684\u4e50\u5668\uff0c\u4f60\u51e0\u4e4e\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u4e1c\u897f\u3002\u8fd9\u4fbf\u662fMIDI\u7684\u7528\u6b66\u4e4b\u5904\u3002 <\/p>\n<p>MIDI\u56e0\u672c\u5730\u5b89\u88c5\u7684\u53d8\u5316\u800c\u663e\u5f97\u590d\u6742\u3002\u672c\u5b50\u4e0a\u4f7f\u7528SimpleSynth\u7684\u65f6\u5019\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u56db\u4e2a\u901a\u8fc7\u4e00\u4e2aMIDI\u63a5\u53e3\u8fde\u63a5\u7684\u5916\u90e8\u952e\u76d8\u3002\u56e0\u6b64\uff0c\u6211\u5c06\u7ec6\u8282\u7559\u7ed9\u4e86\u6bcf\u4e2a\u4e2a\u4f53\uff0c\u4f46\u4e0b\u4f8b\u5c55\u793a\u4e86\u6211\u5982\u4f55\u5f97\u5230MIDI\u56de\u653e\u3002 <\/p>\n<p>\u8981\u5f00\u59cb\u548c\u505c\u6b62\u97f3\u7b26\uff0c\u6211\u4eec\u4f7f\u7528noteOn\u548conteOff\uff0c\u6bcf\u4e2a\u90fd\u4ee5MIDI\u901a\u9053\u3001\u97f3\u9ad8\u548c\u529b\u5ea6\u4f5c\u4e3a\u5f15\u6570\u3002onteOff\u6709\u4e00\u4e2a\u529b\u5ea6\u5f15\u6570\uff0c\u4f46\u97f3\u7b26\u505c\u6b62\u547d\u4ee4\u771f\u7684\u4ec5\u662f\u4e00\u4e2a\u529b\u5ea6\u4e3a\u96f6\u7684\u97f3\u7b26\u5f00\u59cb\uff0c\u56e0\u6b64\u6211\u8ba4\u4e3a\u5b83\u662f\u591a\u4f59\u7684\uff1am.noteOn(1, 60, 100); m.noteOn(1, 60, 0)\u3002\u4ee5\u4e0b\u4f7f\u7528MIDI\u7684\u8303\u4f8b\u5047\u8bbe\u4f60\u5df2\u521d\u59cb\u5316MIDI\uff0c\u5206\u914d\u4e86\u4e00\u4e2a\u53eb\u505a\u201cm\u201d\u7684\u8f93\u51fa\u3002 <\/p>\n<p>\u7b2c\u4e8c\u4f8b\u5c55\u793a\u4e86\u53e6\u4e00\u4e2a\u7b80\u5355\u7684\u4e50\u5668\u3002 <\/p>\n<p><strong>20.7. MIDI out<\/strong> <\/p>\n<pre class=\"brush:jfx\">( \r\nMIDIClient.init; \r\nm = MIDIOut(0, MIDIClient.destinations.at(0).uid); \r\n) \r\n\r\nm.noteOn(1, 60, 100); \/\/\u901a\u9053, MIDI\u97f3\u7b26, \u529b\u5ea6 (\u6700\u5927\u503c127) \r\n\r\nm.noteOff(1, 60); \/\/\u901a\u9053, MIDI\u97f3\u7b26, \u529b\u5ea6 (\u6700\u5927\u503c127)\r\n\r\n\/\/\u540c\u6837\u7684\u4e1c\u897f: \r\n\r\nm.noteOn(1, 60, 100); \/\/\u901a\u9053, MIDI\u97f3\u7b26, \u529b\u5ea6 (\u6700\u5927\u503c127) \r\n\r\nm.noteOn(1, 60, 0); \/\/\u901a\u9053, MIDI\u97f3\u7b26, \u529b\u5ea6 (\u6700\u5927\u503c127) \r\n\r\n\/\/ \u6216\u8005\u8bf4\u5047\u5982\u4f60\u6ca1\u6709MIDI\u7684\u8bdd \r\n\r\n( \r\nSynthDef(\"SimpleTone\", \r\n   { \/\/UGen\u51fd\u6570\u7684\u5f00\u59cb \r\n   arg midiPitch = 60, dur = 0.125, amp = 0.9; \r\n   var out; \r\n   out = SinOsc.ar(midiPitch.midicps, mul: amp); \r\n   out = out*EnvGen.kr(Env.perc(0, dur), doneAction:2); \r\n   Out.ar(0, out) \r\n   } \r\n).play(s); \r\n) \r\n\r\n\/\/\u7136\u540e\u5c06\u4f8b\u5b50\u4e2d\u7684\u8fd9\u884c \r\n\r\nm.noteOn(arguments) \r\n\r\n\/\/\u7528\u8fd9\u884c\u4ee3\u66ff \r\n\r\nSynth(\"SimpleTone\", arguments)<\/pre>\n<p>\u4e0b\u4e00\u4f8b\u662f\u6982\u5ff5\u7684\u6216\u5047\u60f3\u7684\u97f3\u4e50\u3002\u5728\u6211\u5f00\u59cb\u8fdb\u884c\u8ba1\u7b97\u673a\u8f85\u52a9\u521b\u4f5c\u7684\u5934\u51e0\u5e74\uff0c\u6211\u5f00\u59cb\u601d\u8003\u5199\u51fa\u6240\u6709\u53ef\u80fd\u7684\u65cb\u5f8b\u3002\u6211\u786e\u4fe1\u8fd9\u5728\u4e00\u4e2a\u8ba1\u7b97\u673a\u7a0b\u5e8f\u7684\u8303\u56f4\u5185\u3002\u5728\u5b9e\u73b0\u6240\u6709\u53ef\u80fd\u7684\u53d8\u6570\uff08\u8282\u594f\uff0c\u957f\u5ea6\uff0c\u53d8\u594f\uff0cregister\uff0c\u6e05\u6670\u7684\u7ed3\u5408\uff09\u4e4b\u540e\uff0c\u6211\u51b3\u5b9a\u4ec5\u5c1d\u8bd5\u97f3\u9ad8\u7684\u6709\u9650\u5b66\u4e60\uff1a\u6bcf\u4e2a\u53ef\u80fd\u768412\u97f3\u5217\uff0812-tone row\uff09\u3002\u8fd9\u4e2a\u5b9e\u9a8c\u4e5f\u662f\u6211\u82e5\u5e72\u6b21\u5c06\u4e3b\u673a\u641e\u5d29\u4e2d\u7684\u4e00\u4e2a\u3002\u7136\u540e\u6211\u5f00\u59cb\u89c9\u5f97\u662f\u5426\u771f\u7684\u6709\u5fc5\u8981\u771f\u7684play\u6bcf\u4e00\u5217\uff0c\u6216\u80fd\u5426\u5c06\u5b83\u770b\u4f5c\u521b\u4f5c\u6765\u5199\uff1f\u6784\u6210\u521b\u4f5c\u7684\u662f\u4ec0\u4e48\uff1f\u5217\u5370\uff08print out\uff09\u4f1a\u5417\uff1f\u4e00\u4e2a\u8f6f\u62f7\u8d1d\uff08soft copy\uff09\u5982\u4f55\u5462\uff1f\uff08\u540e\u6765\u6211\u8ba4\u4e3a\u8fd9\u662f\u771f\u6b63\u4f7f\u673a\u5668\u5d29\u6e83\u7684\u539f\u56e0\uff09\u4e3a\u4ec0\u4e48\u4e0d\u5199\u6bcf\u4e2a\u65cb\u5f8b\uff1f\u5177\u5907\u6bcf\u4e2a12\u97f3\u5217\u7684\u4ee3\u7801\u672c\u8eab\uff0c\u96be\u9053\u4e0d\u80fd\u53d8\u6210\u6bcf\u4e2a12\u97f3\u5217\u65cb\u5f8b\u7684\u8868\u73b0\uff1f\u6982\u5ff5\u97f3\u4e50\uff1a\u8fd9\u662f\u6211\u79bb\u5f00\u5b83\u7684\u5730\u65b9\u3002 <\/p>\n<p>\u7136\u540e\u8fd9\u91cc\u662f\u6700\u65b0\u7684\u5316\u8eab\uff0c\u5b83\u5b9e\u9645\u4e0a\u6f14\u594f\u6bcf\u4e00\u5217\uff0c\u7ed9\u4e88\u8db3\u591f\u7684\u65f6\u95f4\u3002\u5b83\u4e0d\u5305\u542b\u53cd\u5411\uff0c\u5012\u9000\uff0c\u6216\u53cd\u8f6c\u540e\u9000\u3002\u56e0\u4e3a\u7406\u8bba\u4e0a\uff0c\u90a3\u4e9b\u5c06\u5982\u539f\u6765\u822c\u663e\u73b0\u51fa\u6765\u3002\u5b83\u4ece\u4e2d\u90e8\u7684\u67d0\u5904\u5f00\u59cb\uff0c\u7136\u540e\u73af\u7ed5\uff0c\u56e0\u6b64\u5b83\u5c06\u5728\u6700\u540e\u6f14\u594f\u51fa\u6bcf\u4e00\u4e2a\u53d8\u594f\u3002 <\/p>\n<p>total.do\u5c06\u5faa\u73af\u6bcf\u4e2a\u53ef\u80fd\u7684\u53d8\u594f\u3002\u5b83\u533a\u522b\u4e8e\u4e00\u4e2aloop\uff0c\u56e0\u4e3a\u6211\u53ef\u4ee5\u4f20\u9012count\u4f5c\u4e3a\u4e00\u4e2a\u8ba1\u6570\u5668\uff0c\u5b83\u80fd\u4fc3\u8fdb\u6bcf\u4e2a\u65b0\u7684\u7f6e\u6362\uff08permutation\uff09\u3002permute\u6d88\u606f\u53bb\u4e00\u4e2a\u5355\u72ec\u7684\u5f15\u6570\uff0c\u7f6e\u6362\u7684\u6570\u91cf\u3002\u5b83\u8fd4\u56de\u4e00\u4e2a\u6240\u6709\u88ab\u8bb0\u5f55\u4e3a\u6ca1\u6709\u5faa\u73af\u7684\u5143\u7d20\u3002\u9996\u5148\u8bd5\u8bd5\u7b80\u77ed\u7684\u4f8b\u5b50\u4f5c\u4e3a\u4e00\u4e2a\u8bf4\u660e\u3002 <\/p>\n<p>\u6211\u8ba1\u7b9712\u7684\u9636\u4e58479,001,600\uff1a\u5168\u90e8\u53ef\u80fd\u7684\u53d8\u594f\u3002\u4e00\u65e6\u7f6e\u6362\u88ab\u9009\u5b9a\uff0c\u77ac\u95f4do\u5c06\u9010\u53e5\u901a\u8fc7\u90a3\u4e2a\u6570\u7ec4\u6f14\u594f\u6bcf\u4e2a\u97f3\u7b26\u3002r.start\u548cr.stop\u5f00\u542f\u548c\u505c\u6b62Task\u3002\u6700\u540e\u7684127.do\u662f\u4e00\u4e2a\u201c\u5168\u90e8\u97f3\u7b26\u505c\u6b62\u201d\u7684\u4fe1\u606f\uff0c\u5b83\u88ab\u7528\u6765\u505c\u6b62\u5982\u679c\u4f60\u5728\u4e00\u4e2a\u65f6\u95f4\u4e2d\u90e8\u6267\u884cr.stop\u540e\u6240\u6709\u6302\u8d77\u7684\u97f3\u3002thisThread.clock.sched\u88ab\u7528\u6765\u5173\u95edMIDI\u97f3\u3002\u5b83\u4e3anext*art\u5b89\u6392\u505c\u6b62\u65f6\u95f4\uff0c\u8fd9\u91ccart\u662f\u6e05\u6670\u7ed3\u5408\uff08articulation\uff09\u3002\u56e0\u6b64\uff0c\u5982\u679c\u7ed3\u5408\u88ab\u8bbe\u7f6e\u4e3a0.9\uff0c\u76f8\u5f53\u4e8e\u8fde\u594f\uff08legato\uff09\u3002\u5982\u679c\u5b83\u88ab\u8bbe\u7f6e\u4e3a0.1\uff0c\u5b83\u5c06\u662f\u65ad\u594f\uff08staccato\uff09\u3002 <\/p>\n<h3>\u7ec3\u4e60\uff0cdo\uff0cMIDIout\uff0c\u6bcf12\u97f3\u5217<\/h3>\n<p><strong>20.8. \u6bcf\u5217<\/strong> <\/p>\n<pre class=\"brush:jfx\">\/\/ \u7f6e\u6362 \r\n\r\n25.do({arg count; \r\npostf(\"Permutation %: %\\n\", count, [1, 2, 3, 4].permute(count));}) \r\n\r\n\/\/\u6bcf\u5217 \r\n( \r\n\/\/\u8fd0\u884c\u8fd9\u4e2a\u5148 \r\nvar original, total, begin, next, art; \r\noriginal = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; \r\ntotal = 479001600; \r\nbegin = total.rand; \r\nnext = 0.125; \r\nart = 0.9; \r\n(\"Total playback time = \" ++ (total*next\/3600).asString ++ \" hours.\").postln; \r\nr = Task({ \r\n   total.do({arg count; \r\n      var thisVar; \r\n      thisVar = original.permute(count+begin); \r\n      thisVar.postln; \r\n      (thisVar + 60).do({arg note; \r\n         m.noteOn(1, note, 100); \r\n         thisThread.clock.sched(next*art, {m.noteOff(1, note, 100); nil}); \r\n         (next).wait \r\n      }); \r\n   }) \r\n}) \r\n) \r\n\r\n\/\/\u7136\u540e\u8fd9\u4e9b \r\nr.start; \r\nr.stop; 127.do({arg i; m.noteOff(1, i, 0)})<\/pre>\n<p>\u8fd9\u5728\u6982\u5ff5\u4e0a\u662f\u6b63\u786e\u7684\uff0c\u56e0\u4e3a\u5b83\u904d\u5386\u6bcf\u4e2a\u53ef\u80fd\u7684\u7f6e\u6362\u3002\u5b83\u662f\uff0c\u65e0\u8bba\u5982\u4f55\uff0c\u6709\u4e00\u70b9\u5356\u5f04\u5b66\u95ee\u7684\uff0c\u56e0\u4e3a\u4ece\u4e00\u4e2a\u7f6e\u6362\u5230\u53e6\u4e00\u4e2a\u7684\u53d8\u594f\u5dee\u522b\u662f\u5f88\u5fae\u5f31\u7684\u3002 <\/p>\n<p>\u63a5\u4e0b\u6765\u7684\u4ee3\u7801\u968f\u673a\u9009\u62e9\u4e00\u5217\u3002\u5e76\u4e0d\u4e25\u683c\u9650\u5236\u4e8e12\u97f3\uff0c\u56e0\u4e3a\u5b83\u5141\u8bb8\u4e24\u4e2a\u97f3\u88ab\u5faa\u73af\u3002\u7406\u8bba\u4e0a\u8fd9\u5c06\u9700\u8981\u66f4\u591a\u65f6\u95f4\u6765\u5448\u73b0\u4e00\u5217\u4e2d\u6bcf\u4e2a\u53ef\u80fd\u7684\u7f6e\u6362\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5faa\u73af\u7f6e\u6362\u3002 <\/p>\n<p><strong>20.9. \u6bcf\u4e2a\u968f\u673a\u5217 <\/strong><\/p>\n<pre class=\"brush:jfx\">( \r\nvar original, total, begin, next, art; \r\noriginal = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; \r\ntotal = 479001600; \r\nnext = 0.125; \r\nart = 0.9; \r\n(\"Total playback time = \" ++ (total*next\/3600).asString ++ \" hours.\").postln; \r\nr = Task({ \r\n   total.do({ \r\n      var thisVar; \r\n      thisVar = original.permute(total.rand); \r\n      thisVar.postln; \r\n      (thisVar + 60).do({arg note; \r\n         m.noteOn(1, note, 100); \r\n         thisThread.clock.sched(next*art, {m.noteOff(1, note, 100); nil}); \r\n         (next).wait \r\n      }); \r\n   }) \r\n}) \r\n) \r\n\r\nr.start; \r\nr.stop; 127.do({arg i; m.noteOff(1, i, 0)})<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u51fd\u6570\u548c\u6d88\u606f\u4f7f\u7528\u5f15\u6570\u3002\u53c8\u662f\u5f15\u6570\u4e4b\u4e00\u662f\u53e6\u4e00\u4e2a\u51fd\u6570\u3002\u51fd\u6570\u53ef\u88ab\u8d4b\u5230\u4e00\u4e2a\u53d8\u91cf\uff0c\u7136\u540e\u8fd9\u4e2a\u53d8\u91cf\u88ab\u7528\u5230\u5f15\u6570\u5217\uff0c\u6216\u8005\u8bf4\u5b83\u53ef\u4ee5\u88ab\u5d4c\u5957\u5982\u5f15\u6570\u5217\u3002\u5168\u90e8\u4f8b\u5b50\u89c1\u4e0b\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[72],"class_list":["post-1250","post","type-post","status-publish","format-standard","hentry","category-supercollider3","tag-sc"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/posts\/1250","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1250"}],"version-history":[{"count":4,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/posts\/1250\/revisions"}],"predecessor-version":[{"id":1254,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/posts\/1250\/revisions\/1254"}],"wp:attachment":[{"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}