{"id":576,"date":"2009-10-26T16:36:34","date_gmt":"2009-10-26T08:36:34","guid":{"rendered":"http:\/\/test999.eblhost.com\/blog\/?p=576"},"modified":"2010-02-26T20:54:04","modified_gmt":"2010-02-26T12:54:04","slug":"minim%ef%bc%9a%e6%8e%a7%e5%88%b6%e5%99%a8","status":"publish","type":"post","link":"https:\/\/learn.travelchinawith.me\/?p=576","title":{"rendered":"Minim\uff1a\u63a7\u5236\u5668"},"content":{"rendered":"<p>[ <a href=\"http:\/\/code.compartmental.net\/minim\/javadoc\/ddf\/minim\/Controller.html\" target=\"_blank\">javadoc<\/a> | <a href=\"http:\/\/code.compartmental.net\/minim\/examples\/Controller\/\" target=\"_blank\">\u8303\u4f8b<\/a> ]<\/p>\n<p>\u50cf\u4e4b\u524d\u7684\u7ae0\u8282\u91cc\u63d0\u5230\u7684\uff0cJavaSound\u4f7f\u7528Line\u5728\u4f60\u7684\u7cfb\u7edf\u548c\u7a0b\u5e8f\u95f4\u4f20\u9012\u97f3\u9891\u3002\u6bcf\u6761\u7ebf\u8def\u90fd\u53ef\u4ee5\u901a\u8fc7\u5b83\u8fdb\u884c\u58f0\u76f8\u3001\u5e73\u8861\u3001\u589e\u76ca\u548c\u97f3\u91cf\u8c03\u8282\u3002\u4f18\u70b9\u662f\u4f60\u65e0\u987b\u5728\u4f60\u7684\u5408\u6210\u7c7b\u91cc\u6267\u884c\u4ee5\u4e0a\u7684\u63a7\u5236\uff0c\u4f46\u7f3a\u70b9\u662f\u5728\u56de\u653e\u97f3\u9891\u65f6\uff0c\u53ea\u6709\u5f53\u4f60\u7684\u8f6f\u4ef6\u63a5\u5230\u91c7\u6837\u540e\u8fd9\u4e9b\u63a7\u5236\u624d\u4f1a\u8d77\u4f5c\u7528\u3002\u8fd9\u610f\u5473\u7740\u4f60\u5728\u64ad\u653e\u4e00\u4e2a\u7acb\u4f53\u58f0\u97f3\u9891\u65f6\uff0c\u5373\u4f7f\u5c06\u5e73\u8861\u8c03\u81f3\u6781\u53f3\uff0c\u4f60\u4e5f\u4e0d\u4f1a\u5728\u4f60\u7684\u91c7\u6837\u4e2d\u770b\u5230\u4efb\u4f55\u5dee\u522b\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u5f53\u4f60\u4ee5\u4e3a\u5de6\u58f0\u9053\u7684\u503c\u4e3a0\u7684\u65f6\u5019\uff0c\u5b83\u4ecd\u5c06\u4fdd\u5b58\u539f\u59cb\u97f3\u9891\u6587\u4ef6\u5de6\u58f0\u9053\u5185\u7684\u4e00\u8d77\u5b9e\u9645\u5b58\u5728\u7684\u4e1c\u897f\u3002\u53e6\u5916\uff0c\u5728\u76d1\u542c\u97f3\u9891\u8f93\u5165\u7684\u65f6\u5019\uff0c\u8bbe\u7f6e\u4e00\u4e2a\u63a7\u5236\u5c06\u88ab\u53cd\u6620\u5165\u91c7\u6837\u7f13\u51b2\u5668\u4e2d\uff0c\u56e0\u4e3a\u5b83\u5c06\u5728\u4f60\u7684\u8f6f\u4ef6\u6536\u5230\u97f3\u9891\u4e4b\u524d\u8d77\u6548\u3002<\/p>\n<p><strong>\u6253\u5370\u63a7\u5236<\/strong><\/p>\n<p>\u5e76\u975e\u6240\u6709\u63a7\u5236\u5728\u6240\u6709\u7ebf\u8def\u4e0a\u90fd\u53ef\u7528\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u65b9\u6cd5printControls\u6253\u5370\u51fa\u4e00\u4e2a\u63a7\u5236\u5668\u4e0a\u53ef\u7528\u7684\u63a7\u5236\uff0c\u540c\u65f6\u5305\u62ec\u90a3\u4e9b\u63a7\u5236\u7684\u8303\u56f4\u3002<\/p>\n<p><strong>\u793a\u8303\u4ee3\u7801<\/strong>\uff08<a href=\"http:\/\/code.compartmental.net\/minim\/examples\/Controller\/printControls\/\" target=\"_blank\">\u5728\u7ebf\u8303\u4f8b<\/a>\uff09<\/p>\n<pre class=\"brush:processing\">import ddf.minim.*;\r\n\r\nMinim minim;\r\nAudioOutput out;\r\n\r\nvoid setup()\r\n{\r\n  size(512, 200);\r\n  minim = new Minim(this);\r\n  out = minim.getLineOut();\r\n  out.printControls();\r\n}\r\n\r\nvoid draw()\r\n{\r\n  background(0);\r\n}\r\n\r\nvoid stop()\r\n{\r\n  \/\/ \u65e5\u5b8c\u8bb0\u5f97\u5173\u95edMinim\u97f3\u9891\u7c7b\r\n  out.close();\r\n  minim.stop();\r\n\r\n  super.stop();\r\n}<\/pre>\n<p><strong>\u8be2\u95ee\u63a7\u5236<\/strong><\/p>\n<p>Controller\u63d0\u4f9b\u65b9\u6cd5hasControl\uff0c\u8fd9\u6837\u4f60\u53ef\u4ee5\u5728\u5c1d\u8bd5\u4f7f\u7528\u4e00\u4e2a\u63a7\u5236\u524d\u6d4b\u5b9a\u5b83\u662f\u5426\u5b58\u5728\u3002hasControl\u7684\u5f15\u6570\u4e3aControl.Type\u3002\u63a7\u5236\u5668\u5305\u62ec\u4e09\u4e2a\u9759\u6001\u6210\u5458\uff08member\uff09\uff0c\u4ed6\u4eec\u662fBALANCE, GAIN, PAN, MUTE, SAMPLE_RATE\u548cVOLUME\u3002<\/p>\n<p><strong>\u793a\u8303\u4ee3\u7801<\/strong>\uff08<a href=\"http:\/\/code.compartmental.net\/minim\/examples\/Controller\/hasControl\/\" target=\"_blank\">\u5728\u7ebf\u8303\u4f8b<\/a>\uff09<\/p>\n<pre class=\"brush:processing\">import ddf.minim.*;\r\n\r\nMinim minim;\r\nAudioOutput out;\r\n\r\nvoid setup()\r\n{\r\n  size(512, 200);\r\n  minim = new Minim(this);\r\n  out = minim.getLineOut();\r\n\r\n  textFont(createFont(\"Arial\", 12));\r\n}\r\n\r\nvoid draw()\r\n{\r\n  background(0);\r\n\r\n  if ( out.hasControl(Controller.PAN) )\r\n  {\r\n    text(\"The output has a pan control.\", 5, 15);\r\n  }\r\n  else\r\n  {\r\n    text(\"The output doesn't have a pan control.\", 5, 15);\r\n  }\r\n\r\n  if ( out.hasControl(Controller.VOLUME) )\r\n  {\r\n    text(\"The output has a volume control.\", 5, 30);\r\n  }\r\n  else\r\n  {\r\n    text(\"The output doesn't have a volume control.\", 5, 30);\r\n  }\r\n\r\n  if ( out.hasControl(Controller.SAMPLE_RATE) )\r\n  {\r\n    text(\"The output has a sample rate control.\", 5, 45);\r\n  }\r\n  else\r\n  {\r\n    text(\"The output doesn't have a sample rate control.\", 5, 45);\r\n  }\r\n\r\n  if ( out.hasControl(Controller.BALANCE) )\r\n  {\r\n    text(\"The output has a balance control.\", 5, 60);\r\n  }\r\n  else\r\n  {\r\n    text(\"The output doesn't have a balance control.\", 5, 60);\r\n  }\r\n\r\n  if ( out.hasControl(Controller.MUTE) )\r\n  {\r\n    text(\"The output has a mute control.\", 5, 75);\r\n  }\r\n  else\r\n  {\r\n    text(\"The output doesn't have a mute control.\", 5, 75);\r\n  }\r\n\r\n  if ( out.hasControl(Controller.GAIN) )\r\n  {\r\n    text(\"The output has a gain control.\", 5, 90);\r\n  }\r\n  else\r\n  {\r\n    text(\"The output doesn't have a gain control.\", 5, 105);\r\n  }\r\n}\r\n\r\nvoid stop()\r\n{\r\n  \/\/ \u65e5\u5b8c\u8bb0\u5f97XXXXXX\r\n  out.close();\r\n  minim.stop();\r\n\r\n  super.stop();\r\n}<\/pre>\n<p><strong>\u83b7\u53d6\u548c\u8bbe\u7f6e\u63a7\u5236\u5668<\/strong><\/p>\n<p>\u5f53\u4f60\u77e5\u9053\u4e86\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ec0\u4e48\u63a7\u5236\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u9002\u5f53\u7684\u65b9\u6cd5get\uff08\u83b7\u53d6\uff09\u548cset\uff08\u8bbe\u7f6e\uff09\u64cd\u4f5c\u5b83\u4eec\u3002<\/p>\n<pre class=\"brush:processing\">setBalance(float value)\r\ngetBalance()\r\nsetGain(float value)\r\ngetGain()\r\nsetPan(float value)\r\ngetPan()\r\nsetVolume(float value)\r\ngetVolume()<\/pre>\n<p>\u5e73\u8861\u7684\u8303\u56f4\u662f-1~1\uff0c\u589e\u76ca\u5e38\u4ece-80~6\uff0c\u58f0\u76f8\u4e5f\u662f\u4ece-1~1\uff0c\u97f3\u91cf\u7684\u8303\u56f4\u4f5c\u8005\u8bf4\u4ed6\u81ea\u5df1\u4e5f\u4e0d\u77e5\u9053\u3002\u3002\u3002\u4ece\u6240\u6709\u7684\u4f7f\u7528\u4e0a\uff0c\u589e\u76ca\u57fa\u672c\u4e0a\u7b49\u540c\u4e8e\u97f3\u91cf\u3002\u4ee5\u4e0b\u662f\u64cd\u4f5c\u4e00\u4e2a\u8f93\u51fa\u7684\u589e\u76ca\u7684\u4f8b\u5b50\u3002\u5176\u4ed6\u63a7\u5236\u7684\u4f8b\u5b50\u53ef\u4ee5\u5728<a href=\"http:\/\/code.compartmental.net\/minim\/examples\/Controller\/\" target=\"_blank\">\u8fd9\u91cc<\/a>\u627e\u5230\u3002<\/p>\n<p><strong>\u793a\u8303\u4ee3\u7801<\/strong>\uff08<a href=\"http:\/\/code.compartmental.net\/minim\/examples\/Controller\/getSetGain\/\" target=\"_blank\">\u5728\u7ebf\u8303\u4f8b<\/a>\uff09<\/p>\n<pre class=\"brush:processing\">import ddf.minim.*;\r\nimport ddf.minim.signals.*;\r\n\r\nMinim minim;\r\nAudioOutput out;\r\nOscillator  osc;\r\nWaveformRenderer waveform;\r\n\r\nvoid setup()\r\n{\r\n  size(512, 200);\r\n  minim = new Minim(this);\r\n  out = minim.getLineOut();\r\n\r\n  \/\/ see the example AudioOutput &gt;&gt; SawWaveSignal for more about this class\r\n  osc = new SawWave(100, 0.2, out.sampleRate());\r\n  \/\/ see the example Polyphonic &gt;&gt; addSignal for more about this\r\n  out.addSignal(osc);\r\n\r\n  waveform = new WaveformRenderer();\r\n  \/\/ see the example Recordable &gt;&gt; addListener for more about this\r\n  out.addListener(waveform);\r\n\r\n  textFont(createFont(\"Arial\", 12));\r\n}\r\n\r\nvoid draw()\r\n{\r\n  background(0);\r\n  \/\/ see waveform.pde for more about this\r\n  waveform.draw();\r\n\r\n  if ( out.hasControl(Controller.GAIN) )\r\n  {\r\n    \/\/ \u5c06\u9f20\u6807\u4f4d\u7f6e\u6620\u5c04\u5230\u53ef\u542c\u5230\u7684\u589e\u76ca\u8303\u56f4\u5185\r\n    float val = map(mouseX, 0, width, 6, -48);\r\n    \/\/ \u5982\u679c\u4e00\u4e2a\u589e\u76ca\u63a7\u5236\u4e0d\u53ef\u7528\uff0c\u8fd9\u91cc\u5c06\u4ec0\u4e48\u90fd\u4e0d\u505a\r\n    out.setGain(val);\r\n    \/\/ \u5982\u679c\u4e00\u4e2a\u589e\u76ca\u63a7\u5236\u4e0d\u53ef\u7528\uff0c\u8fd9\u91cc\u5c06\u8f93\u51fa0\r\n    text(\"The current gain is \" + out.getGain() + \".\", 5, 15);\r\n  }\r\n  else\r\n  {\r\n    text(\"The output doesn't have a gain control.\", 5, 15);\r\n  }\r\n}\r\n\r\nvoid stop()\r\n{\r\n  \/\/ \u65e5\u5b8c\u8bb0\u5f97XXXXX\r\n  out.close();\r\n  minim.stop();\r\n\r\n  super.stop();\r\n}<\/pre>\n<p><strong>\u53d8\u5316\u63a7\u5236<\/strong><\/p>\n<p>\u56e0\u4e3a\u53cd\u6620\u7684\u662f\u4e00\u7cfb\u5217\u8fde\u7eed\u503c\u7684\u8303\u56f4\uff0c\u6240\u4ee5\u6240\u6709\u8fd9\u4e9b\u63a7\u5236\u90fd\u88ab\u79f0\u4e3a\u6d6e\u70b9\u63a7\u5236\u3002Controller\u4e3a\u6301\u7eed\u6539\u53d8\u8fd9\u4e9b\u63a7\u5236\u4e4b\u4e00\u7684\u503c\u63d0\u4f9b\u65b9\u6cd5\u3002\u8fd9\u88ab\u79f0\u4e3a\u53d8\u5316\uff08shifting\uff09\u3002shifting\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush:processing\">shiftBalance(float from, float to, int ms)\r\nshiftGain(float from, float to, int ms)\r\nshiftPan(float from, float to, int ms)\r\nshiftVolume(float from, float to, int ms)<\/pre>\n<p>\u5f88\u660e\u663e\u7684\uff0cfrom\u662f\u4e00\u4e2a\u503c\u5f00\u59cb\u7684\u70b9\uff0cto\u662f\u76ee\u6807\u503c\uff0cms\u662f\u4ee5\u6beb\u79d2\u8ba1\u7684shift\u4f5c\u7528\u65f6\u95f4\u3002<\/p>\n<p><strong>\u793a\u8303\u4ee3\u7801<\/strong>\uff08<a href=\"http:\/\/code.compartmental.net\/minim\/examples\/Controller\/shifting\/\" target=\"_blank\">\u5728\u7ebf\u8303\u4f8b<\/a>\uff09<\/p>\n<pre class=\"brush:processing\">import ddf.minim.*;\r\nimport ddf.minim.signals.*;\r\n\r\nMinim minim;\r\nAudioOutput out;\r\nWaveformRenderer waveform;\r\nSawWave saw;\r\n\r\nvoid setup()\r\n{\r\n  size(512, 200);\r\n  minim = new Minim(this);\r\n  out = minim.getLineOut();\r\n\r\n  waveform = new WaveformRenderer();\r\n  \/\/ see the example Recordable &gt;&gt; addListener for more about this\r\n  out.addListener(waveform);\r\n\r\n  \/\/ see the example AudioOutput &gt;&gt; SawWaveSignal for more about this\r\n  saw = new SawWave(100, 0.2, out.sampleRate());\r\n  \/\/ see the example Polyphonic &gt;&gt; addSignal for more about this\r\n  out.addSignal(saw);\r\n\r\n  textFont(createFont(\"Arial\", 12));\r\n}\r\n\r\nvoid draw()\r\n{\r\n  background(0);\r\n  \/\/ see waveform.pde for more about this\r\n  waveform.draw();\r\n\r\n  if ( out.hasControl(Controller.PAN) )\r\n  {\r\n    text(\"The current pan value is \" + out.getPan() + \".\", 5, 15);\r\n  }\r\n  else\r\n  {\r\n    text(\"The output doesn't have a pan control.\", 5, 15);\r\n  }\r\n\r\n  if ( out.hasControl(Controller.VOLUME) )\r\n  {\r\n    text(\"The current volume value is \" + out.getVolume() + \".\", 5, 30);\r\n  }\r\n  else\r\n  {\r\n    text(\"The output doesn't have a volume control.\", 5, 30);\r\n  }\r\n\r\n  if ( out.hasControl(Controller.BALANCE) )\r\n  {\r\n    text(\"The current balance value is \" + out.getBalance() + \".\", 5, 45);\r\n  }\r\n  else\r\n  {\r\n    text(\"The output doesn't have a balance control.\", 5, 45);\r\n  }\r\n\r\n  if ( out.hasControl(Controller.GAIN) )\r\n  {\r\n    text(\"The current gain value is \" + out.getGain() + \".\", 5, 60);\r\n  }\r\n  else\r\n  {\r\n    text(\"The output doesn't have a gain control.\", 5, 60);\r\n  }\r\n}\r\n\r\nvoid keyReleased()\r\n{\r\n  if ( key == 'v' ) out.shiftVolume(0, 1, 2000);\r\n  if ( key == 'g' ) out.shiftGain(-40, 0, 2000);\r\n  if ( key == 'b' ) out.shiftBalance(-1, 1, 2000);\r\n  if ( key == 'p' ) out.shiftPan(1, -1, 2000);\r\n}\r\n\r\nvoid stop()\r\n{\r\n  \/\/ always close Minim audio classes when you are finished with them\r\n  out.close();\r\n  minim.stop();\r\n\r\n  super.stop();\r\n}<\/pre>\n<p><strong>\u9759\u97f3<\/strong><\/p>\n<p>\u5982\u4e0b<\/p>\n<pre class=\"brush:processing\">isMuted()\r\nmute()\r\nunmute()<\/pre>\n<p>\u518d\u6b21\uff0c\u5982\u679c\u9759\u97f3\u4e0d\u662f\u4e00\u4e2a\u53ef\u7528\u7684\u63a7\u5236\uff0c\u9759\u97f3\u548c\u975e\u9759\u97f3\u5c06\u4e0d\u8d77\u4efb\u4f55\u4f5c\u7528\uff0c\u5e76\u4f1a\u5728PDE\u63a7\u5236\u53f0\u8f93\u51fa\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<p><strong>\u793a\u8303\u4ee3\u7801<\/strong>\uff08<a href=\"http:\/\/code.compartmental.net\/minim\/examples\/Controller\/muting\/\" target=\"_blank\">\u5728\u7ebf\u8303\u4f8b<\/a>\uff09<\/p>\n<pre class=\"brush:processing\">import ddf.minim.*;\r\nimport ddf.minim.signals.*;\r\n\r\nMinim minim;\r\nAudioOutput out;\r\nWaveformRenderer waveform;\r\nSawWave saw;\r\n\r\nvoid setup()\r\n{\r\n  size(512, 200);\r\n  minim = new Minim(this);\r\n  out = minim.getLineOut();\r\n\r\n  waveform = new WaveformRenderer();\r\n  \/\/ see the example Recordable &gt;&gt; addListener for more about this\r\n  out.addListener(waveform);\r\n\r\n  \/\/ see the example AudioOutput &gt;&gt; SawWaveSignal for more about this\r\n  saw = new SawWave(100, 0.2, out.sampleRate());\r\n  \/\/ see the example Polyphonic &gt;&gt; addSignal for more about this\r\n  out.addSignal(saw);\r\n\r\n  textFont(createFont(\"Arial\", 12));\r\n}\r\n\r\nvoid draw()\r\n{\r\n  background(0);\r\n  \/\/ see waveform.pde for more about this\r\n  waveform.draw();\r\n\r\n  if ( out.hasControl(Controller.MUTE) )\r\n  {\r\n    if (mousePressed)\r\n    {\r\n      out.mute();\r\n    }\r\n    else\r\n    {\r\n      out.unmute();\r\n    }\r\n    if ( out.isMuted() )\r\n    {\r\n      text(\"The output is muted.\", 5, 15);\r\n    }\r\n    else\r\n    {\r\n      text(\"The output is not muted.\", 5, 15);\r\n    }\r\n  }\r\n  else\r\n  {\r\n    text(\"The output doesn't have a mute control.\", 5, 15);\r\n  }\r\n}\r\n\r\nvoid stop()\r\n{\r\n  \/\/ always close Minim audio classes when you are finished with them\r\n  out.close();\r\n  minim.stop();\r\n\r\n  super.stop();\r\n}<\/pre>\n<p><strong>\u76f4\u63a5\u4f7f\u7528\u4e00\u4e2a\u63a7\u5236<\/strong><\/p>\n<p>\u4f7f\u7528\u63a7\u5236\u66f4\u76f4\u63a5\u7684\u65b9\u5f0f\u662f\u4f7f\u7528Controller\u7684\u65b9\u6cd5getControls\u3002\u8fd9\u4e2a\u65b9\u6cd5\u8fd4\u56deControl\u5bf9\u8c61\u7684\u6570\u7ec4\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u65b9\u6cd5getType\u6d4b\u5b9a\u4e00\u4e2a\u63a7\u5236\u7684\u7c7b\u578b\u3002<\/p>\n<p><strong>\u793a\u8303\u4ee3\u7801<\/strong>\uff08<a href=\"http:\/\/code.compartmental.net\/minim\/examples\/Controller\/getControls\/\" target=\"_blank\">\u5728\u7ebf\u8303\u4f8b<\/a>\uff09<\/p>\n<pre class=\"brush:processing\">import ddf.minim.*;\r\nimport ddf.minim.signals.*;\r\nimport javax.sound.sampled.Control;\r\n\r\nMinim minim;\r\nAudioOutput out;\r\nControl[] controls;\r\n\r\nvoid setup()\r\n{\r\n  size(512, 200);\r\n  minim = new Minim(this);\r\n  out = minim.getLineOut();\r\n  controls = out.getControls();\r\n\r\n  textFont(createFont(\"Arial\", 12));\r\n}\r\n\r\nvoid draw()\r\n{\r\n  background(0);\r\n\r\n  for ( int i = 0; i &lt; controls.length; i++ )\r\n  {\r\n    text(\"Control \" + (i+1) + \" is a \" + controls[i].toString() + \".\", 5, 15 + i*15);\r\n  }\r\n}\r\n\r\nvoid stop()\r\n{\r\n  \/\/ always close Minim audio classes when you are finished with them\r\n  out.close();\r\n  minim.stop();\r\n\r\n  super.stop();\r\n}<\/pre>\n<p>\u6240\u6709\u8fd9\u4e9b\u65b9\u6cd5\u90fd\u8fd4\u56de\u9002\u5f53\u7684FloatControl\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528pan()\u800c\u4e0d\u662fsetPan\u8fdb\u5165\u58f0\u76f8\u63a7\u5236\u7684\u4f8b\u5b50\uff1a<\/p>\n<p><strong>\u793a\u8303\u4ee3\u7801<\/strong>\uff08<a href=\"http:\/\/code.compartmental.net\/minim\/examples\/Controller\/FloatControl\/getSetValue\/\" target=\"_blank\">\u5728\u7ebf\u8303\u4f8b<\/a>\uff09<\/p>\n<pre class=\"brush:processing\">import ddf.minim.*;\r\nimport ddf.minim.signals.*;\r\n\r\nMinim minim;\r\nAudioOutput out;\r\nOscillator  osc;\r\nWaveformRenderer waveform;\r\n\r\nvoid setup()\r\n{\r\n  size(512, 200);\r\n  minim = new Minim(this);\r\n  out = minim.getLineOut();\r\n\r\n  \/\/ see the example AudioOutput &gt;&gt; SawWaveSignal for more about this class\r\n  osc = new SawWave(100, 0.2, out.sampleRate());\r\n  \/\/ see the example Polyphonic &gt;&gt; addSignal for more about this\r\n  out.addSignal(osc);\r\n\r\n  waveform = new WaveformRenderer();\r\n  \/\/ see the example Recordable &gt;&gt; addListener for more about this\r\n  out.addListener(waveform);\r\n\r\n  textFont(createFont(\"Arial\", 12));\r\n}\r\n\r\nvoid draw()\r\n{\r\n  background(0);\r\n  \/\/ see waveform.pde for more about this\r\n  waveform.draw();\r\n\r\n  if ( out.hasControl(Controller.PAN) )\r\n  {\r\n    \/\/ map the mouse position to the range of the pan\r\n    float val = map(mouseX, 0, width, out.pan().getMinimum(), out.pan().getMaximum());\r\n    out.pan().setValue(val);\r\n    text(\"The current pan is \" + out.pan().getValue() + \".\", 5, 15);\r\n  }\r\n  else\r\n  {\r\n    text(\"There is no pan control for this output.\", 5, 15);\r\n  }\r\n}\r\n\r\nvoid stop()\r\n{\r\n  \/\/ always close Minim audio classes when you are finished with them\r\n  out.close();\r\n  minim.stop();\r\n\r\n  super.stop();\r\n}<\/pre>\n<p>\u8981\u7ec6\u8bb2FloatControl\u7684\u6240\u6709\u65b9\u6cd5\u5b9e\u5728\u592a\u591a\uff0c\u6240\u4ee5\u8fd8\u662f\u4ed4\u7ec6\u8bfb\u8bfb<a href=\"http:\/\/java.sun.com\/j2se\/1.5.0\/docs\/api\/javax\/sound\/sampled\/FloatControl.html\" target=\"_blank\">javadoc<\/a>\u6216\u8005\u7814\u7a76\u4e00\u4e0b<a href=\"http:\/\/code.compartmental.net\/minim\/examples\/Controller\/FloatControl\/\" target=\"_blank\">\u5728\u7ebf\u8303\u4f8b\u4eec<\/a>\u5427\u3002<\/p>\n<div id=\"_mcePaste\" style=\"overflow: hidden; position: absolute; left: -10000px; top: 7456px; width: 1px; height: 1px;\"><code>FloatControl<\/code><\/div>\n","protected":false},"excerpt":{"rendered":"<p>[ javadoc | \u8303\u4f8b ] \u50cf\u4e4b\u524d\u7684\u7ae0\u8282\u91cc\u63d0\u5230\u7684\uff0cJavaSound\u4f7f\u7528Line\u5728\u4f60\u7684\u7cfb\u7edf\u548c\u7a0b\u5e8f\u95f4\u4f20\u9012\u97f3\u9891\u3002\u6bcf\u6761\u7ebf\u8def\u90fd\u53ef\u4ee5\u901a\u8fc7\u5b83\u8fdb\u884c\u58f0\u76f8\u3001\u5e73\u8861\u3001\u589e\u76ca\u548c\u97f3\u91cf\u8c03\u8282\u3002\u4f18\u70b9\u662f\u4f60\u65e0\u987b\u5728\u4f60\u7684\u5408\u6210\u7c7b\u91cc\u6267\u884c\u4ee5\u4e0a\u7684\u63a7\u5236\uff0c\u4f46\u7f3a\u70b9\u662f\u5728\u56de\u653e\u97f3\u9891\u65f6\uff0c\u53ea\u6709\u5f53\u4f60\u7684\u8f6f\u4ef6\u63a5\u5230\u91c7\u6837\u540e\u8fd9\u4e9b\u63a7\u5236\u624d\u4f1a\u8d77\u4f5c\u7528\u3002\u8fd9\u610f\u5473\u7740\u4f60\u5728\u64ad\u653e\u4e00\u4e2a\u7acb\u4f53\u58f0\u97f3\u9891\u65f6\uff0c\u5373\u4f7f\u5c06\u5e73\u8861\u8c03\u81f3\u6781\u53f3\uff0c\u4f60\u4e5f\u4e0d\u4f1a\u5728\u4f60\u7684\u91c7\u6837\u4e2d\u770b\u5230\u4efb\u4f55\u5dee\u522b\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u5f53\u4f60\u4ee5\u4e3a\u5de6\u58f0\u9053\u7684\u503c\u4e3a0\u7684\u65f6\u5019\uff0c\u5b83\u4ecd\u5c06\u4fdd\u5b58\u539f\u59cb\u97f3\u9891\u6587\u4ef6\u5de6\u58f0\u9053\u5185\u7684\u4e00\u8d77\u5b9e\u9645\u5b58\u5728\u7684\u4e1c\u897f\u3002\u53e6\u5916\uff0c\u5728\u76d1\u542c\u97f3\u9891\u8f93\u5165\u7684\u65f6\u5019\uff0c\u8bbe\u7f6e\u4e00\u4e2a\u63a7\u5236\u5c06\u88ab\u53cd\u6620\u5165\u91c7\u6837\u7f13\u51b2\u5668\u4e2d\uff0c\u56e0\u4e3a\u5b83\u5c06\u5728\u4f60\u7684\u8f6f\u4ef6\u6536\u5230\u97f3\u9891\u4e4b\u524d\u8d77\u6548\u3002 \u6253\u5370\u63a7\u5236 \u5e76\u975e\u6240\u6709\u63a7\u5236\u5728\u6240\u6709\u7ebf\u8def\u4e0a\u90fd\u53ef\u7528\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u65b9\u6cd5printControls\u6253\u5370\u51fa\u4e00\u4e2a\u63a7\u5236\u5668\u4e0a\u53ef\u7528\u7684\u63a7\u5236\uff0c\u540c\u65f6\u5305\u62ec\u90a3\u4e9b\u63a7\u5236\u7684\u8303\u56f4\u3002 \u793a\u8303\u4ee3\u7801\uff08\u5728\u7ebf\u8303\u4f8b\uff09 import ddf.minim.*; Minim minim; AudioOutput out; void setup() { size(512, 200); minim = new Minim(this); out = minim.getLineOut(); out.printControls(); } void draw() { background(0); } void stop() { \/\/ \u65e5\u5b8c\u8bb0\u5f97\u5173\u95edMinim\u97f3\u9891\u7c7b out.close(); minim.stop(); super.stop(); } \u8be2\u95ee\u63a7\u5236 Controller\u63d0\u4f9b\u65b9\u6cd5hasControl\uff0c\u8fd9\u6837\u4f60\u53ef\u4ee5\u5728\u5c1d\u8bd5\u4f7f\u7528\u4e00\u4e2a\u63a7\u5236\u524d\u6d4b\u5b9a\u5b83\u662f\u5426\u5b58\u5728\u3002hasControl\u7684\u5f15\u6570\u4e3aControl.Type\u3002\u63a7\u5236\u5668\u5305\u62ec\u4e09\u4e2a\u9759\u6001\u6210\u5458\uff08member\uff09\uff0c\u4ed6\u4eec\u662fBALANCE, GAIN, PAN, MUTE, SAMPLE_RATE\u548cVOLUME\u3002 \u793a\u8303\u4ee3\u7801\uff08\u5728\u7ebf\u8303\u4f8b\uff09 import ddf.minim.*; Minim minim; AudioOutput [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[60],"tags":[61],"class_list":["post-576","post","type-post","status-publish","format-standard","hentry","category-minim","tag-minim"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/posts\/576","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=576"}],"version-history":[{"count":5,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/posts\/576\/revisions"}],"predecessor-version":[{"id":1045,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=\/wp\/v2\/posts\/576\/revisions\/1045"}],"wp:attachment":[{"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learn.travelchinawith.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}