{"id":1286,"date":"2011-05-17T16:26:56","date_gmt":"2011-05-17T08:26:56","guid":{"rendered":"http:\/\/www.ccttours.com\/blog\/?p=1286"},"modified":"2011-05-17T16:26:56","modified_gmt":"2011-05-17T08:26:56","slug":"sc%ef%bc%9a%e9%a2%9d%e5%a4%96%e9%9f%b3%e4%b9%90%e5%87%86%e5%88%99%e9%a9%b1%e5%8a%a8%e9%9f%b3%e4%b9%90%ef%bc%8c%e6%95%b0%e6%8d%ae%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/learn.travelchinawith.me\/?p=1286","title":{"rendered":"SC\uff1a\u989d\u5916\u97f3\u4e50\u51c6\u5219\u9a71\u52a8\u97f3\u4e50\uff0c\u6570\u636e\u6587\u4ef6"},"content":{"rendered":"<p>\u672c\u7ae0\uff0c\u6211\u4eec\u5c06\u6d4b\u8bd5\u4e0e\u989d\u5916\u97f3\u4e50\u51c6\u5219\u76f8\u8fde\u7684\u97f3\u4e50\u9009\u62e9\u7684\u53ef\u80fd\u6027\u3002\u51e0\u4e4e\u6240\u6709\u97f3\u4e50\u90fd\u5bf9\u521b\u4f5c\u8005\u7684\u9009\u62e9\u5177\u6709\u97f3\u4e50\u6027\u4e0a\u7684\u5f71\u54cd\uff0c\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u5f3a\u5316\u90a3\u4e2a\u8054\u7cfb\u3002\u8fd9\u4e9b\u51c6\u5219\u53ef\u80fd\u5305\u542b\u8bf8\u5982\u690d\u7269\u7684\u7535\u5b50\u8109\u51b2\u3001\u661f\u661f\u7684\u4f4d\u7f6e\u3001\u4e00\u4e2a\u5c71\u7684\u8f6e\u5ed3\u3001\u6216\u8005\u96e8\u96ea\u7684\u6a21\u5f0f\u7b49\u7b49\u81ea\u7136\u6570\u636e\uff1b\u5b83\u4eec\u53ef\u80fd\u5305\u542b\u7c7b\u4f3c\u5176\u4ed6\u97f3\u4e50\u3001\u6587\u5b57\u3001\u53d1\u8f66\u65f6\u95f4\u8868\u7b49\u4eba\u7c7b\u4f53\u7cfb\uff1b\u6216\u8005\u63a9\u9970\u7684\u8f93\u5165\uff08masked input\uff09\uff0c\u6bd4\u5982\u5728\u6f14\u51fa\u7a7a\u95f4\u4e2d\uff0c\u52a8\u4f5c\u88ab\u6620\u5c04\u5230\u97f3\u9ad8\u3001\u632f\u5e45\u3001\u97f3\u8272\u7b49\u7b49\u4e4b\u4e0a\u7684\u4e00\u4e2a\u542c\u4f17\u3002<br \/>\n<!--more--> <\/p>\n<p>\u4efb\u4f55\u6570\u636e\u6d41\uff0c\u65e0\u8bba\u662f\u4ece\u4e00\u4e2a\u73b0\u5b58\u7684\u6587\u4ef6\u8bfb\u53d6\uff0c\u8fd8\u662f\u6765\u81ea\u4e00\u4e2a\u5b9e\u65f6\u7684\u8f93\u5165\u6e90\uff08\u6bd4\u5982\u9f20\u6807\u6216\u89c6\u9891\u94fe\u63a5\uff09\uff0c\u53ef\u4ee5\u88ab\u7528\u4e8e\u5f71\u54cd\u97f3\u4e50\u7684\u53c2\u6570\u3002SC\u63d0\u4f9b\u4e86\u82e5\u5e72\u5916\u90e8\u63a7\u5236\u6e90\uff0c\u8bf8\u5982MouseX\u548cY\u3001Wacom\u624b\u5199\u677f\u63a7\u5236\u3001MIDI\u8f93\u5165\u3001\u8bfb\u53d6\u6587\u6863\u6570\u636e\u7b49\u7b49\u3002 <\/p>\n<p>\u4e3a\u4ec0\u4e48\u8981\u7528\u5176\u4ed6\u6570\u636e\u6e90\uff1f\u56e0\u4e3a\u6a21\u5f0f\u548c\u7ed3\u6784\u53ef\u4ee5\u4ece\u989d\u5916\u97f3\u4e50\u6e90\u4f20\u9001\u81f3\u521b\u4f5c\u3002\u4e00\u526f\u661f\u56fe\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u7528X\u3001Y\u4f4d\u7f6e\u53ef\u4ee5\u751f\u6210\u4e00\u7ec4\u5747\u5300\u5206\u5e03\u7684\u4e8b\u4ef6\uff1b\u4e00\u4e2a\u5c71\u7684\u8f6e\u5ed3\u5c06\u63d0\u4f9b\u4e00\u4e2a\u5e73\u6ed1\u7684\u8fde\u7eed\u4e8b\u4ef6\u6d41\u3002 <\/p>\n<p>\u9664\u4e86\u5916\u90e8\u6807\u51c6\u63d0\u4f9b\u7684\u7ed3\u6784\uff0c\u8fd8\u6709\u4e00\u4e2a\u4e3a\u521b\u4f5c\u5e26\u6765\u989d\u5916\u610f\u4e49\u7684\u54f2\u5b66\u8054\u7cfb\uff0c\u4f8b\u5982\uff0c\u4ece\u58f0\u7eb9\uff08voice print\uff09\u4e2d\u63d0\u53d6\u7684\u97f3\u8272\uff0c\u6216\u4e00\u573a\u6f14\u51fa\u4e2d\u6700\u559c\u6b22\u7684\u90a3\u9996\u8bd7\u3002 <\/p>\n<p>\u5386\u53f2\u63d0\u4f9b\u4e86\u5f88\u591a\u5173\u4e8e\u8fd9\u79cd\u7c7b\u578b\u4e3b\u9898\u8fde\u63a5\u7684\u4f8b\u8bc1\uff0c\u7279\u522b\u662f\u6587\u5b57\u5bf9\u521b\u4f5c\u7684\u5f71\u54cd\u3002\u4f8b\u5b50\u4e0d\u4ec5\u4ec5\u5305\u62ec\u97f3\u4e50\u5316\u4e00\u4e2a\u8bcd\u6c47\uff0c\u8fd8\u5305\u62ec\u5bf9\u8bcd\u6c47\u7cbe\u51c6\u7684\u97f3\u4e50\u7b26\u53f7\u5316\u590d\u5236\uff0c\u5c31\u50cf\u5df4\u8d6b\u7684\u4e8c\u91cd\u8d4b\u683c\uff0c\u4ece\u56db\u4e2a\u97f3Bb, A, C, B\uff08\u5728\u5fb7\u56fd\u662f\uff1aB, A, C, H\uff09\u5f00\u59cb\u3002\u6587\u5b57\u662f\u4e00\u4e2a\u666e\u904d\u6027\u9009\u62e9\uff0c\u56e0\u6b64\u8ba9\u6211\u4eec\u4ece\u8fd9\u5f00\u59cb\u5427\u3002 <\/p>\n<p>\u6700\u7b80\u5355\u7684\u5c06\u6587\u5b57\u4e0e\u97f3\u4e50\u8054\u7cfb\u7684\u65b9\u6cd5\u662f\u7ed9\u6bcf\u4e2a\u5b57\u6bcd\u4e00\u4e2aMIDI\u503c\uff1aa=0\uff0cb=1\uff0cz=23\u7b49\u7b49\u3002\u8fd9\u5c06\u63d0\u4f9b\u4e24\u4e2a\u516b\u5ea6\u7684\u97f3\u7a0b\u3002\u5b57\u6bcd\u8868\u7684\u5b57\u6bcd\u5728\u8ba1\u7b97\u673a\u4ee3\u7801\u5185\u88ab\u63cf\u8ff0\u4e3aascii\u503c\u3002\u5373\uff0c\u8ba1\u7b97\u673a\u5c06\u5b57\u6bcd\u201ca\u201d\u7406\u89e3\u4e3a\u4e00\u4e2a\u6574\u6570\u3002\u8fd9\u5bf9\u6211\u4eec\u6765\u8bf4\u662f\u4e00\u4e2a\u65b9\u4fbf\u7684\u5de7\u5408\u3002ascii\u6570\u5b57\u5df2\u7ecf\u5b58\u5728\u4e8e\u8ba1\u7b97\u673a\u91cc\uff0c\u6211\u4eec\u4ec5\u9700\u8981\u8c03\u6574\u5b83\u4eec\u5230\u5408\u9002\u7684\u8303\u56f4\u5373\u53ef\u3002 <\/p>\n<h3>\u6587\u5b57\u8f6c\u6362<\/h3>\n<p>digit\u6216ascii\u6d88\u606f\u53ef\u4ee5\u88ab\u7528\u4e8e\u5c06\u4e00\u4e2a\u5b57\u7b26\u8f6c\u6362\u4e3a\u6570\u5b57\u3002\u5728digit\u4e0b\uff0c&#8221;a&#8221; \u548c &#8220;A&#8221; = 10, &#8220;z&#8221; \u548c &#8220;Z&#8221; = 35\u3002\u6d88\u606fascii\u8fd4\u56de\u5b9e\u9645\u7684ascii\u503c\uff1aA = 65, a = 97, Z = 90, z = 122\u3002\u518d\u6b21\u5c1d\u8bd5\u8fd0\u884c\u4e0b\u8fb9\u4ee3\u7801\u4ee5\u8bc1\u5b9eascii\u7684\u5173\u8054\u3002 <\/p>\n<p><strong>28.1. ascii\u503c<\/strong> <\/p>\n<pre class=\"brush:jfx\">a = \"Test string\"; \r\na.at(2).ascii.postln; \r\na.at(2).digit.postln; \r\na.do({arg each; each.post; \" \".post; each.ascii.postln;})<\/pre>\n<p>ascii\u503c\uff08\u5927\u5199\u5b57\u6bcd\u7684\uff09\u7684\u8303\u56f4\u540c\u6837\u4fbf\u5229\u5730\u4e0emidi\u503c\u5339\u914d\uff1a65\uff08F4\u7684midi\u6570\uff09\u81f390\uff08F6\u7684midi\u6570\uff09\u3002\u4f46\u5c0f\u5199\u5b57\u6bcd\u5c31\u6709\u4e00\u70b9\u70b9\u8d85\u8fc7\u4e86\u8fd9\u4e2a\u8303\u56f4\u3002\u56e0\u6b64\u4f60\u53ef\u4ee5\u4ec5\u4f7f\u7528\u5927\u5199\u5b57\u6bcd\uff0c\u6216\u8005\u4f60\u53ef\u4ee5\u7b80\u5355\u7684\u52a0\u51cf\u7f29\u653e\uff08scale\uff09\u5c0f\u5199\u5b57\u6bcd\uff0c\u6216\u8005\u5168\u90e8\u3002 <\/p>\n<p>\u8fd9\u4e2a\u76f4\u63a5\u5173\u8054(A = 60, Z = 90)\u5e26\u6765\u7684\u95ee\u9898\u5f88\u660e\u663e\uff1a\u4f60\u4f1a\u88ab\u5b57\u6bcd\u7684\u503c\u7ed9\u7eca\u4f4f\u3002\u5b57\u6bcda\u548ce\u90fd\u5c06\u59cb\u7ec8\u662f\u4f4e\u97f3\u3002\u53c8\u7531\u4e8ea\u548ce\u5728\u5b57\u6bcd\u4e2d\u51fa\u73b0\u7684\u9891\u7387\u90fd\u5f88\u9ad8\uff0c\u56e0\u6b64\u8fd9\u4e9b\u97f3\u4ea7\u751f\u7684\u6982\u7387\u5c06\u4f1a\u66f4\u9ad8\u3002 <\/p>\n<h3>\u6620\u5c04\uff08mapping\uff09<\/h3>\n<p>\u6620\u5c04\u5c06\u5141\u8bb8\u6211\u4eec\u5bf9\u97f3\u7b26\u548c\u5b57\u6bcd\u95f4\u7684\u5173\u8054\u8fdb\u884c\u66f4\u597d\u5730\u63a7\u5236\u3002\u4e3a\u4e00\u4e2a\u8f93\u5165\u8d4b\u503c\uff0c\u4e0d\u7ba1\u6d41\u7a0b\u5185\u6bcf\u4e2a\u9879\u76ee\u7684\u5185\u5728\u89c4\u5b9a\uff08intrinsic value\uff09\u3002\u8fd9\u6837\uff0c\u4f60\u4fbf\u53ef\u4ee5\u5728\u63a7\u5236\u521b\u4f5c\u672c\u8d28\uff08the nature of the composition\uff09\u7684\u540c\u65f6\uff0c\u4fdd\u7559\u6d41\u7a0b\u5185\u6a21\u5f0f\u7684\u8fde\u63a5\u3002\u5728\u5b57\u6bcd\u4e2d\uff0c\u6bd4\u5982\uff0c\u6211\u4eec\u77e5\u9053\u5143\u97f3\u51e0\u4e4e\u6bcf\u9694\u4e00\u4e2a\u5b57\u6bcd\u5c31\u51fa\u73b0\u3002\u6709\u65f6\u4e24\u4e2a\u6210\u4e00\u884c\uff0c\u5076\u5c14\u53c8\u88ab\u56db\u4e2a\u8f85\u97f3\u9694\u5f00\u3002\u5728\u8fd9\u4e2a\u8ba4\u77e5\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u6620\u5c04\uff0c\u5206\u914d\u7279\u6b8a\u7684\u97f3\u9ad8\u5230\u5143\u97f3\u4e0a\uff0c\u5e76\u83b7\u5f97\uff08\u4e3e\u4e2a\u4f8b\u5b50\uff09\u4e00\u79cd\u97f3\u8c03\uff08tonality\uff09\u7684\u611f\u89c9\uff1aa = C4, e = E4, i = G4, o = C5 (a = 60, e = 64, i = 67, o = 72)\u7b49\u7b49\u3002\u4f60\u4e5f\u53ef\u4ee5\u9650\u5236\u4f60\u7684\u6620\u5c04\u5230\u4f7f\u7528\u4e2d\u7684\u5b57\u6bcd\uff0c\u7701\u7565\uff08\u6216\u5305\u62ec\uff09\u7c7b\u4f3cspaces\u3001punctation\u7b49\u7b49\u8bcd\u3002 <\/p>\n<p>SC\u4f7f\u7528IdentityDictionary\u521b\u5efa\u4e00\u4e2a\u6620\u5c04\uff0c\u5982\u4e0b\u6240\u793a\u3002\u53d8\u91cfpitchMap\u88ab\u5206\u914d\u5230\u5305\u542b\u4e00\u5bf9\u5143\u7d20\uff08\u521d\u59cb\u5b57\u6bcd\u548c\u5b83\u7684\u5173\u8054\u503c\uff09\u7684\u6570\u7ec4IdentityDictianary\u3002\u5173\u8054\u662f\u901a\u8fc7\u8bed\u6cd5&#8221;originalValue -> associatedValue&#8221; \u6216\u5728\u5f53\u524d\u60c5\u51b5\u4e0b &#8220;$b -> 4&#8221; \u7684\u65b9\u5f0f\u5b9e\u73b0\u7684\u3002\u610f\u601d\u662f\uff0c\u8ba9\u5b57\u6bcdb\u7b49\u4e8e\u6574\u65704\u3002 <\/p>\n<p><strong>28.2. pitchMap<\/strong> <\/p>\n<pre class=\"brush:jfx\">pitchMap = IdentityDictionary[ \r\n   $H -> 6, $x -> 6, $b -> 6, $T -> 6, $W -> 6, \r\n   $e -> 11, $o -> 11, $c -> 11, $, -> 11, $. -> 11, \r\n   $n -> 3, $y -> 3, \r\n   $m -> 4, $p -> 8, $l -> 9 \r\n      ];<\/pre>\n<p>\u4e0e\u5b57\u6bcd\u5173\u8054\u7684\u6570\u5b57\u4e4b\u540e\u88ab\u7528\u5230MIDI\u97f3\u4e0a\u3002\u53e6\u4e00\u79cd\u9009\u62e9\uff0c\u5b83\u4eec\u53ef\u4ee5\u88ab\u7528\u4f5cMIDI\u97f3\u7a0b\u3002 <\/p>\n<p>\u5728\u4e3a\u82e5\u5e72\u9879\u76ee\u4f7f\u7528IdentityDictionary\u540e\uff0c\u6211\u53d1\u73b0\u5b83\u5f88\u96be\u5904\u7406\u6570\u503c\u6539\u53d8\uff08\u9700\u8981\u8f93\u5165\u592a\u591a\uff09\u3002\u6240\u4ee5\u6211\u9009\u62e9\u4f7f\u7528\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\u3002\u7b2c\u4e8c\u7ef4\u7684\u7b2c\u4e00\u5143\u7d20\u662f\u7ec4\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684\u5b57\u6bcd\u5217\u8868\uff0c\u7b2c\u4e8c\u5143\u7d20\u662f\u5173\u8054\u7684\u503c\u3002\u5b83\u4eec\u7ecf\u7531\u4e00\u4e2ado\u51fd\u6570\u5206\u6790\uff0c\u8fd9\u4e2a\u51fd\u6570\u904d\u5386\u6bcf\u4e2a\u7b2c\u4e00\u5143\u7d20\uff0c\u5982\u679c\u627e\u5230\u5339\u914d\u7684\uff08\u4f7f\u7528includes\uff09\uff0c\u5219\u5c06\u53d8\u91cfmappedValue\u8bbe\u7f6e\u5230\u7b2c\u4e8c\u5143\u7d20\u3002 <\/p>\n<p><strong>28.3. \u6620\u5c04\u6570\u7ec4<\/strong> <\/p>\n<pre class=\"brush:jfx\">var mappedValue, intervMap; \r\n\r\nintervMap = [ \r\n   [\"ae\", 2], [\"io\", 4], [\" pst\", 5], [\"Hrn\", -2], \r\n   [\"xmp\", -1], [\"lfg\", -4], [\"Th\", -5], [\".bdvu\", 1] \r\n]; \r\n\r\nintervMap.do({arg item; \r\n   if(item.at(0).includes($o), \r\n      {mappedValue = item.at(1)}) \r\n   });<\/pre>\n<p>\u8fd9\u4e2apatch\u4ec5\u63a7\u5236\u5728\u7edd\u5bf9\u5173\u8054\uff08\u5373\uff0c\u5b9e\u9645\u7684\u97f3\u800c\u975e\u97f3\u7a0b\uff09\u5185\u88ab\u97f3\u5316\uff08pitched\uff09\u7684\u5143\u7d20\u3002 <\/p>\n<p><strong>28.4. \u989d\u5916\u97f3\u4e50\u51c6\u5219, \u4ec5\u97f3<\/strong> <\/p>\n<pre class=\"brush:jfx\">( \r\nvar noteFunc, blipInst, midiInst, channel = 0, port = 0, prog = 0, \r\n   intervMap, count = 0, ifNilInt = 0, midin = 0, inputString; \r\n \r\n\/\/\u8f93\u5165\u6d41. \r\n\r\ninputString = \"Here is an example of mapping. The, them, there, these,\" \r\n   \"there, then, that, should have similar musical interpretations.\" \r\n   \"Exact repetition; thatthatthatthatthatthat will also\" \r\n   \"be similar.\"; \r\n\r\n\/\/intervMap\u5305\u542b\u5b57\u6bcd\u548c\u503c\u7684\u96c6\u5408\u7684\u6570\u7ec4\u3002 \r\n\/\/\u5728\u4e0b\u8fb9\u7684\u51fd\u6570\u4e2d\uff0c\u5b57\u6bcd\u5b57\u7b26\u4e32\u4e0e\u6570\u5b57\u76f8\u8fde \r\n\r\nintervMap = [ \r\n   [\"ae\", 2], [\"io\", 4], [\" pst\", 5], [\"Hrn\", 7], \r\n   [\"xmp\", 1], [\"lfg\", 3], [\"Th\", 6], [\".bdvu\", 11] \r\n]; \r\n\r\n\"\/\/ [Char, Interval, ifNilInt, midi interval, octave, midi]\".postln; \r\n\r\nnoteFunc = Pfunc({var parseInt, octave; \r\n\r\n   \/\/intervMap\u5185\u7684\u6bcf\u4e2a\u6570\u7ec4\u90fd\u5728\u68c0\u67e5\u662f\u5426\u5305\u542b\u5b57\u6bcd(inputString.wrapAt(count)) \r\n   \/\/\u5982\u679c\u5305\u542b\uff0cparseInt\u88ab\u8bbe\u7f6e\u4e3a\u5728item.at(1)\u7684\u503c \r\n\r\n   intervMap.do({arg item; \r\n      if(item.at(0).includes(inputString.wrapAt(count)), \r\n         {parseInt = item.at(1)}) \r\n      }); \r\n\r\n   \/\/\u5982\u679cparseInt\u662fnotNil, midin\u5c31\u88ab\u8bbe\u7f6e\u4e3a\u90a3\u6837. \r\n   \/\/ifNilInt\u7528\u6765\u50a8\u5b58\u6bcf\u4e2a\u8981\u88ab\u4f7f\u7528\u7684parseInt \r\n   \/\/\u5982\u679c\u6ca1\u6709\u5339\u914d\u88ab\u53d1\u73b0\u5e76\u4e14\u4e0b\u6b21\u7684parseInt\u662fnil\u3002 \r\n\r\n   if(parseInt.notNil, \r\n      {midin = parseInt; ifNilInt = parseInt}, \r\n      {midin = ifNilInt} \r\n   ); \r\n\r\n   octave = 60; \r\n\r\n   \"\/\/\".post; [inputString.wrapAt(count), parseInt, \r\n      ifNilInt, midin, octave\/12, midin + octave].postln; \r\n\r\n   count = count + 1; \r\n\r\n   midin + octave \r\n}); \r\n\r\nPbind( \r\n   \\midinote, noteFunc, \r\n   \\dur, 0.125, \r\n   \\amp, 0.8, \r\n   \\instrument, \"SimpleTone\" \r\n).play; \r\n)<\/pre>\n<p>\u6211\u627f\u8ba4\u8fd9\u5e76\u4e0d\u5341\u5206\u6709\u8da3\u3002\u8fd9\u6709\u90e8\u5206\u56e0\u4e3a\u72ec\u81ea\u7684\u97f3\u503c\u5e76\u4e0d\u5bf9\u53ef\u8fa8\u8ba4\u7684\u98ce\u683c\u4f5c\u51fa\u89e3\u91ca\u3002\u6211\u4eec\u66f4\u4e60\u60ef\u4e8e\u4e0d\u548c\u8c10\u7684\u4e00\u4e2a\u7279\u5b9a\u7ea7\u522b\uff0c\u800c\u5e76\u975e\u5355\u72ec\u7684\u97f3\u5e8f\u3002\u4e0d\u8c10\u548c\u662f\u97f3\u7a0b\u5206\u5e03\u7684\u4f5c\u7528\uff0c\u800c\u4e0d\u662f\u97f3\u7684\u5206\u5e03\u3002\u4e3a\u5f97\u5230\u4e00\u4e2a\u97f3\u7a0b\u9009\u62e9\u7684\u7279\u5b9a\u5e73\u8861\uff0cintervMap\u5e94\u5305\u542b\u6bd4\u4f8b\u97f3\u7a0b\u503c\u800c\u975e\u7edd\u5bf9\u97f3\u3002\u6570\u5b57\u53ef\u80fd\u770b\u4e0a\u53bb\u5b8c\u5168\u4e00\u81f4\uff0c\u4f46\u5728\u5b9e\u9645\u5206\u6790\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528midin = parseInt + midin%12\uff08\u56e0\u6b64parseInt\u53d8\u4e3a\u4e00\u4e2a\u97f3\u7a0b\uff09\u800c\u4e0d\u662fmidin = parseInt\u3002\u6709\u8da3\u7684\u4e1c\u897f\u540c\u6837\u53ef\u4ee5\u56e0\u5c06\u97f3\u6620\u5c04\u5230\u82e5\u5e72\u4e2a\u516b\u5ea6\uff0c\u6216\u6620\u5c04\u516b\u5ea6\u9009\u62e9\u5230\u5b57\u6bcd\u4e0a\u800c\u51fa\u73b0\u3002 <\/p>\n<p><strong>28.5. \u989d\u5916\u97f3\u4e50\u51c6\u5219, \u5b8c\u5168\u63a7\u5236<\/strong> <\/p>\n<pre class=\"brush:jfx\">( \r\nvar noteFunc, blipInst, midiInst, channel = 0, port = 0, prog = 0, \r\n   intervMap, count = 0, ifNilInt = 0, midin = 0, ifNilDur = 1, \r\n   durMap, durFunc, ifNilSus = 1, susMap, susFunc, ifNilAmp = 0.5, \r\n   curAmp = 0.5, ampMap, ampFunc, inputString; \r\n\r\n\/\/\u8f93\u5165\u6d41 \r\n\r\ninputString = \"Here is an example of mapping. The, them, there, these,\" \r\n   \"there, then, that, should have similar musical interpretations.\" \r\n   \"Exact repetition; thatthatthatthatthatthat will also\" \r\n   \"be similar.\"; \r\n\r\n\/\/intervMap\u5305\u542b\u5b57\u6bcd\u548c\u503c\u7684\u96c6\u5408\u7684\u6570\u7ec4\u3002 \r\n\/\/\u5728\u4e0b\u8fb9\u7684\u51fd\u6570\u4e2d\uff0c\u5b57\u6bcd\u5b57\u7b26\u4e32\u4e0e\u6570\u5b57\u76f8\u8fde \r\n\r\nintervMap = [ \r\n   [\"ae\", 6], [\"io\", 9], [\" pst\", 1], [\"Hrn\", -3], \r\n   [\"xmp\", -1], [\"lfg\", -4], [\"Th\", -5], [\".bdvu\", 1] \r\n]; \r\n\r\ndurMap = [ \r\n   [\"aeiouHhrsnx\", 0.125], [\"mplf\", 0.5], [\"g.T,t\", 0.25], \r\n   [\"dvc\", 2], [\" \", 0] \r\n]; \r\n\r\nsusMap = [ \r\n   [\"aei \", 1.0], [\"ouHh\", 2.0], [\"rsnx\", 0.5], [\"mplf\", 2.0], [\"g.T,t\", 4.0], \r\n   [\"dvc\", 1.0] \r\n]; \r\n\r\nsusMap = [ \r\n   [\"aei \", 1.0], [\"ouHh\", 2.0], [\"rsnx\", 0.5], [\"mplf\", 2.0], [\"g.T,t\", 4.0], \r\n   [\"dvc\", 1.0] \r\n]; \r\n\r\nampMap = [ \r\n   [\"aeHhrsnx \", 0.8], [\"ioumplfg.T,tdvc\", 1.25] \r\n]; \r\n\r\nnoteFunc = Pfunc({var parseInt, octave = 48; \r\n\r\n   \/\/intervMap\u5185\u7684\u6bcf\u4e2a\u6570\u7ec4\u90fd\u5728\u68c0\u67e5\u662f\u5426\u5305\u542b\u5b57\u6bcd(inputString.wrapAt(count)) \r\n   \/\/\u5982\u679c\u5305\u542b\uff0cparseInt\u88ab\u8bbe\u7f6e\u4e3a\u5728item.at(1)\u7684\u503c \r\n\r\n   intervMap.do({arg item; \r\n      if(item.at(0).includes(inputString.wrapAt(count)), \r\n         {parseInt = item.at(1)}) \r\n      }); \r\n\r\n   \/\/\u5982\u679cparseInt\u662fnotNil, midin\u5c31\u88ab\u8bbe\u7f6e\u4e3a\u90a3\u6837. \r\n   \/\/ifNilInt\u7528\u6765\u50a8\u5b58\u6bcf\u4e2a\u8981\u88ab\u4f7f\u7528\u7684parseInt \r\n   \/\/\u5982\u679c\u6ca1\u6709\u5339\u914d\u88ab\u53d1\u73b0\u5e76\u4e14\u4e0b\u6b21\u7684parseInt\u662fnil\u3002 \r\n\r\n   if(parseInt.notNil, \r\n      {midin = parseInt + midin%48; ifNilInt = parseInt}, \r\n      {midin = ifNilInt + midin%48} \r\n   ); \r\n\r\n   [inputString.wrapAt(count)].post; \r\n   [\"pitch\", parseInt, midin, octave\/12, midin + octave].post; \r\n\r\n   midin + octave \r\n}); \r\n\r\ndurFunc = Pfunc({var parseDur, nextDur; \r\n\r\n   durMap.do({arg item; \r\n      if(item.at(0).includes(inputString.wrapAt(count)), \r\n         {parseDur = item.at(1)}) \r\n      }); \r\n\r\n   if(parseDur.notNil, \r\n      {nextDur = parseDur; ifNilDur = parseDur}, \r\n      {nextDur = ifNilDur} \r\n   ); \r\n   [\"dur\", nextDur].post; \r\n   nextDur \r\n}); \r\n\r\nsusFunc = Pfunc({var parseSus, nextSus; \r\n\r\n   susMap.do({arg item; \r\n      if(item.at(0).includes(inputString.wrapAt(count)), \r\n         {parseSus = item.at(1)}) \r\n      }); \r\n\r\n   if(parseSus.notNil, \r\n      {nextSus = parseSus; ifNilSus = parseSus}, \r\n      {nextSus = ifNilSus} \r\n   ); \r\n   [\"sustain\", nextSus.round(0.01)].post; \r\n   nextSus \r\n}); \r\n\r\nampFunc = Pfunc({var parseAmp; \r\n\r\n   ampMap.do({arg item; \r\n      if(item.at(0).includes(inputString.wrapAt(count)), \r\n         {parseAmp = item.at(1)}) \r\n      }); \r\n\r\n   if(parseAmp.notNil, \r\n      {curAmp = curAmp*parseAmp; ifNilAmp = parseAmp}, \r\n      {curAmp = curAmp*ifNilAmp} \r\n   ); \r\n\r\n   count = count + 1; \r\n   if(0.5.coin, {curAmp = rrand(0.2, 0.9)}); \r\n   [\"amp\", curAmp.round(0.01)].postln; \r\n\r\n   curAmp.wrap(0.4, 0.9) \r\n}); \r\n\r\nPbind( \r\n   \\midinote, noteFunc, \r\n   \\dur, durFunc, \r\n   \\legato, susFunc, \r\n   \\amp, ampFunc, \r\n   \\instrument, \"SimpleTone\" \r\n).play; \r\n)<\/pre>\n<h3>\u4e0e\u6587\u4ef6\u534f\u540c\u5de5\u4f5c<\/h3>\n<p>\u5c06\u4f60\u60f3\u7528\u7684\u6587\u672c\u6216\u6570\u636e\u503c\u8f93\u5165\u5b9e\u9645\u4ee3\u7801\u6587\u4ef6\u5185\u5f80\u5f80\u662f\u4e0d\u5b9e\u9645\u7684\u3002\u4e00\u65e6\u4f60\u8bbe\u8ba1\u4e86\u4e00\u4e2a\u53ef\u63a5\u53d7\u7684\u6587\u672c\u6620\u5c04\uff0c\u4f60\u4fbf\u53ef\u4ee5\u5c06\u6620\u5c04\u3001\u521b\u4f5c\u548c\u6587\u672c\u60f3\u505a\u4e00\u4e2a\u9a71\u52a8\u97f3\u4e50\u7684\u6a21\u5757\u7ec4\u4ef6\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e2a\u5c06\u6587\u672c\u4f5c\u4e3a\u6570\u636e\u6d41\u8bfb\u5165\u6b63\u5728\u8fd0\u4f5c\u7a0b\u5e8f\u7684\u65b9\u6cd5\u4fbf\u662f\u5fc5\u987b\u7684\u3002\u968f\u7740\u8fd9\u4e2a\u529f\u80fd\u7684\u5230\u4f4d\uff0c\u6620\u5c04\u521b\u4f5c\u4fbf\u53ef\u4e0e\u50a8\u5b58\u6b32\u8bfb\u6570\u636e\u7684\u6587\u4ef6\u5206\u79bb\u3002SC\u5177\u6709\u6807\u51c6\u7684\u6587\u4ef6\u7ba1\u7406\u5de5\u5177\u53ef\u88ab\u7528\u4e8e\u8fd9\u4e00\u76ee\u7684\u3002 <\/p>\n<p>\u4e0e\u6211\u4eec\u534f\u540c\u5de5\u4f5c\u7684\u6587\u4ef6\u7c7b\u578b\u662f\u6587\u672c\u6587\u6863\uff08\u770b\u4e0b\u8fb9\u7684\u6570\u636e\u7c7b\u578b\uff09\uff0c\u56e0\u6b64\u6211\u4eec\u5e94\u5f53\u521b\u5efa\u6587\u672c\u6587\u4ef6\u3002\u4f46MS Word\u6587\u6863\uff0c\u751a\u81f3\u4e00\u4e2artf\u6587\u6863\uff0c\u90fd\u542b\u6709\u975e\u6587\u672c\u683c\u5f0f\u5316\u4fe1\u606f\uff0c\u8fd9\u662f\u4e00\u79cd\u5e72\u6270\u3002\u6211\u5c1d\u8bd5\u7528SimpleText, BBEdit, SC \u7f16\u8f91\u5668 \u548c Word \u521b\u5efa\u201c\u6587\u672c\u201d\u6587\u4ef6\uff0cWord\u548cBBEdit\u662f\u552f\u4e00\u4e24\u4e2a\u4e0d\u4ea7\u751f\u4e0d\u9700\u8981\u4e1c\u897f\u7684\u7f16\u8f91\u5668\u3002 <\/p>\n<p>\u8def\u5f84\u540d\u540c\u6837\u9700\u8981\u4e00\u70b9\u70b9\u7684\u89e3\u91ca\u3002\u5f53SC\uff08\u4ee5\u53ca\u7edd\u5927\u591a\u6570\u7a0b\u5e8f\uff09\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\u65f6\uff0c\u5b83\u4f1a\u9996\u5148\u5728SC\u6240\u5728\u76ee\u5f55\u5185\u5bfb\u627e\u8fd9\u4e2a\u6587\u4ef6\u3002\u56e0\u6b64\uff0c\u5982\u679c\u4f60\u4f7f\u7528\u7684\u6587\u4ef6\u4e0eSC\u4f4d\u4e8e\u540c\u4e00\u6587\u4ef6\u5939\u5185\uff0c\u90a3\u4e48\u8def\u5f84\u53ef\u4ee5\u4ec5\u662f\u6587\u4ef6\u540d\u3002\u5982\u679c\u6587\u4ef6\u4f4d\u4e8e\u522b\u5904\uff0c\u4e00\u4e2a\u6587\u4ef6\u5939\u5c42\u7ea7\u5fc5\u987b\u5305\u542b\u8fdb\u53bb\u3002\u5c42\u7ea7\u7684\u5199\u6cd5\u7c7b\u4f3c\u8d85\u94fe\u63a5\uff0c\u5404\u4e2a\u6587\u4ef6\u5939\u95f4\u7528\u659c\u6760\u5206\u9694\u5f00\u3002\u5982\u679c\u6570\u636e\u6587\u4ef6\u4f4d\u4e8eSC\u6587\u4ef6\u5939\u5185\u7684\u67d0\u6587\u4ef6\u5939\u5185\uff0c\u90a3\u4e48\u8def\u5f84\u540d\u53ef\u4ee5\u7531\u90a3\u4e2a\u6587\u4ef6\u5939\u5f00\u59cb\u3002\u5982\u679c\u6587\u4ef6\u4f4d\u4e8eSC\u6587\u4ef6\u5939\u4e4b\u5916\uff0c\u90a3\u4e48\u4f60\u5fc5\u987b\u7ed9\u51fa\u6574\u4e2a\u6587\u4ef6\u7684\u8def\u5f84\u3002\u56e0\u6b64\uff0c\u4e00\u4e2a\u4f4d\u4e8eSC\u6587\u4ef6\u5939\u5185\u7684\u6587\u4ef6\u5373\u7b80\u5355\u7684\u201c\u6211MyFile\u201d\uff0c\u5982\u679c\u4f4d\u4e8e\u5b50\u6587\u4ef6\u5939\uff0c\u5b83\u53ef\u80fd\u662f&#8221;\/Data Files\/MyFile&#8221;\uff0c\u5982\u679c\u5728\u5176\u4ed6\u533a\u57df\uff0c\u90a3\u4e48\u53ef\u80fd\u662f&#8221;\/Users\/Students\/Documents\/Computer Music\/Data Files\/MyFile&#8221;\u3002 <\/p>\n<p>\u8981\u6253\u5f00\u6216\u8bfb\u53d6\u6587\u4ef6\uff0c\u9996\u5148\u7533\u660e\u4e00\u4e2a\u627f\u8f7d\u6587\u4ef6\u7684\u53d8\u91cf\u3002\u7136\u540e\u4f7f\u7528File()\u6253\u5f00\u6587\u4ef6\u5e76\u8868\u660e\u4f60\u8981\u7528\u7684\u6a21\u5f0f(read, write, append, \u7b49\u7b49)\u3002\u5728\u672c\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u8bfb\u53d6\u6a21\u5f0f\uff0c\u6216\u8005\u201cr\u201d\u3002 <\/p>\n<p>\u4e00\u65e6\u6253\u5f00\u4e86\u6587\u4ef6\uff0c\u4fbf\u53ef\u4f7f\u7528getChar\u4e00\u6b21\u6027\u68c0\u7d22\u5168\u90e8\u5b57\u7b26\uff0c\u4f46\u6211\u60f3\u5efa\u8bae\u8bfb\u53d6\u6574\u4e2a\u6587\u6863\u5e76\u5c06\u5b83\u5b58\u50a8\u5230\u4e00\u4e2a\u6570\u7ec4\uff0c\u56e0\u4e3a\u5728\u4e4b\u524d\u7684\u4f8b\u5b50\u4e2d\uff0c\u6587\u672c\u88ab\u5b58\u50a8\u5728\u4e00\u4e2a\u6570\u7ec4\u5185\u3002\u8fd9\u91cc\u662f\u4ee3\u7801\uff0c\u5047\u8bbe\u6587\u672c\u6587\u6863\u88ab\u547d\u540d\u4e3a\u201cText File\u201d\u3002\u8fd9\u90e8\u5206\u53ef\u4ee5\u88ab\u63d2\u5165\u4e0a\u4f8binput = &#8220;Here is . . . \u7b49\u7b49\u7684\u90e8\u5206\u3002 <\/p>\n<p><strong>28.6 \u8bfb\u53d6\u4e00\u4e2a\u6587\u4ef6<\/strong><\/p>\n<pre class=\"brush:jfx\">( \r\nvar input, filePointer; \/\/\u7533\u660e\u53d8\u91cf \r\nfilePointer = File(\"Text File\", \"r\"); \r\ninput = filePointer.readAllString; \r\nfilePointer.close; \r\ninput.postln; \r\n)<\/pre>\n<p>\u66f4\u957f\uff0c\u4f46\u4e5f\u66f4\u5bf9\u7528\u6237\u53cb\u597d\u7684\u65b9\u6cd5\uff0c\u4f7f\u7528openDiaglog\u3002\u6211\u901a\u5e38\u53ea\u7528\u4e00\u4e2a\u6587\u4ef6\u5de5\u4f5c\uff0c\u56e0\u6b64\u8fd9\u662f\u6211\u5e76\u4e0d\u9700\u8981\u7684\u989d\u5916\u4e00\u6b65\u3002\u4f46\u5728\u5f88\u591a\u60c5\u51b5\u4e0b\uff0c\u5b83\u53bb\u6389\u4e86\u8def\u5f84\u540d\u7684\u731c\u6d4b\u3002\u5b83\u540c\u6837\u53ef\u88ab\u7528\u4e8e\u6307\u51fa\u4efb\u4f55\u7ed9\u5b9a\u6587\u4ef6\u7684\u786e\u5207\u8def\u5f84\u540d\u3002\u6709\u4e00\u4e2a\u5c0f\u6545\u969c\uff1a\u8981\u4e48\u4e00\u5207\u90fd\u5728openDialog\u91cc\uff0c\u8981\u4e48\u4f7f\u7528\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u5e76\u5206\u522b\u8fd0\u884c\u4ee3\u7801\u7684\u4e24\u4e2a\u90e8\u5206\u3002 <\/p>\n<p><strong>28.7. \u8bfb\u53d6\u4e00\u4e2a\u6587\u4ef6<\/strong> <\/p>\n<pre class=\"brush:jfx\">\/\/ \u5217\u5370\u5168\u90e8\u8def\u5f84\u540d\u5907\u7528 \r\n\r\nFile.openDialog(\"\", { arg pathName; pathName.postln}); \r\n\r\n\/\/ \u7528dialog\u6253\u5f00 \r\n( \r\nvar input, filePointer; \/\/\u7533\u660e\u53d8\u91cf \r\nFile.openDialog(\"\", {arg pathname; \r\n   filePointer = File(pathname, \"r\"); \r\n   input = filePointer.readAllString; \r\n   input.postln; \r\n   \/\/ \u6240\u6709\u4e1c\u897f\u90fd\u5e94\u5728\u8fd9\u4e2a\u51fd\u6570\u5185 \r\n}, \r\n{\"File not found\".postln}); \r\n) \r\n\r\n\/\/ \u6216\u6253\u5f00\u6587\u4ef6\u5e76\u5b58\u5165\u5168\u5c40 \r\n\r\n( \r\nvar filePointer; \/\/\u7533\u660e\u53d8\u91cf \r\nFile.openDialog(\"\", {arg pathname; \r\n   filePointer = File(pathname, \"r\"); \r\n   ~input = filePointer.readAllString; \r\n}, \r\n{\"File not found\".postln}); \r\n) \r\n\r\n\/\/ \u7136\u540e \r\n\r\n~input.postln; \r\n\r\n\/\/ \u6216\u8005\u5c06~input\u542b\u5165patch<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u7ae0\uff0c\u6211\u4eec\u5c06\u6d4b\u8bd5\u4e0e\u989d\u5916\u97f3\u4e50\u51c6\u5219\u76f8\u8fde\u7684\u97f3\u4e50\u9009\u62e9\u7684\u53ef\u80fd\u6027\u3002\u51e0\u4e4e\u6240\u6709\u97f3\u4e50\u90fd\u5bf9\u521b\u4f5c\u8005\u7684\u9009\u62e9\u5177\u6709\u97f3\u4e50\u6027\u4e0a\u7684\u5f71\u54cd\uff0c\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u5f3a\u5316\u90a3\u4e2a\u8054\u7cfb\u3002\u8fd9\u4e9b\u51c6\u5219\u53ef\u80fd\u5305\u542b\u8bf8\u5982\u690d\u7269\u7684\u7535\u5b50\u8109\u51b2\u3001\u661f\u661f\u7684\u4f4d\u7f6e\u3001\u4e00\u4e2a\u5c71\u7684\u8f6e\u5ed3\u3001\u6216\u8005\u96e8\u96ea\u7684\u6a21\u5f0f\u7b49\u7b49\u81ea\u7136\u6570\u636e\uff1b\u5b83\u4eec\u53ef\u80fd\u5305\u542b\u7c7b\u4f3c\u5176\u4ed6\u97f3\u4e50\u3001\u6587\u5b57\u3001\u53d1\u8f66\u65f6\u95f4\u8868\u7b49\u4eba\u7c7b\u4f53\u7cfb\uff1b\u6216\u8005\u63a9\u9970\u7684\u8f93\u5165\uff08masked input\uff09\uff0c\u6bd4\u5982\u5728\u6f14\u51fa\u7a7a\u95f4\u4e2d\uff0c\u52a8\u4f5c\u88ab\u6620\u5c04\u5230\u97f3\u9ad8\u3001\u632f\u5e45\u3001\u97f3\u8272\u7b49\u7b49\u4e4b\u4e0a\u7684\u4e00\u4e2a\u542c\u4f17\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-1286","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\/1286","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=1286"}],"version-history":[{"count":1,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/posts\/1286\/revisions"}],"predecessor-version":[{"id":1287,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/posts\/1286\/revisions\/1287"}],"wp:attachment":[{"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}