

{"id":470,"date":"2026-09-21T11:01:10","date_gmt":"2026-09-21T03:01:10","guid":{"rendered":"https:\/\/6589jk.cn\/?p=470"},"modified":"2026-09-21T22:21:26","modified_gmt":"2026-09-21T14:21:26","slug":"c-%e6%bc%94%e5%a5%8f%e3%80%8a%e8%87%b4%e7%88%b1%e4%b8%bd%e4%b8%9d%e3%80%8b%ef%bc%9awindows-beep-%e5%b0%8f%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/6589jk.cn\/index.php\/2026\/09\/21\/c-%e6%bc%94%e5%a5%8f%e3%80%8a%e8%87%b4%e7%88%b1%e4%b8%bd%e4%b8%9d%e3%80%8b%ef%bc%9awindows-beep-%e5%b0%8f%e7%a8%8b%e5%ba%8f\/","title":{"rendered":"C# \u6f14\u594f\u300a\u81f4\u7231\u4e3d\u4e1d\u300b\uff1aWindows Beep \u5c0f\u7a0b\u5e8f"},"content":{"rendered":"<h2>\u8fd9\u662f\u4ec0\u4e48<\/h2>\n<p>\u4e00\u4e2a\u7528 <strong>C#<\/strong> \u5199\u7684\u63a7\u5236\u53f0\u5c0f\u7a0b\u5e8f\uff0c\u5728 Windows \u4e0a\u7528\u7cfb\u7edf <code>Beep<\/code> \u63a5\u53e3\u6f14\u594f\u8d1d\u591a\u82ac\u300a\u81f4\u7231\u4e3d\u4e1d\u300b\uff08F\u00fcr Elise\uff09\u7684\u4e3b\u9898\u6bb5\u843d\u3002<\/p>\n<p>\u6e90\u7801\u4ed3\u5e93\uff1a<a href=\"https:\/\/git.6589jk.cn\/Sherry\/fur-elise-csharp\" target=\"_blank\" rel=\"noopener\">Sherry\/fur-elise-csharp<\/a><\/p>\n<h2>\u6548\u679c<\/h2>\n<p>\u8fd0\u884c\u540e\u4f1a\u5728\u63a7\u5236\u53f0\u6253\u5370\u8fdb\u5ea6\uff08\u6216\u5728 <code>--dry-run<\/code> \u6a21\u5f0f\u4e0b\u6253\u5370\u97f3\u7b26\u8868\uff09\uff0c\u540c\u65f6\u901a\u8fc7 <code>kernel32!Beep(frequency, duration)<\/code> \u6309\u9891\u7387\u53d1\u58f0\uff0c\u91cd\u73b0\u7ecf\u5178\u65cb\u5f8b\uff1a<\/p>\n<p><code>E5 \u2192 D#5 \u2192 E5 \u2192 D#5 \u2192 E5 \u2192 B4 \u2192 D5 \u2192 C5 \u2192 A4 \u2026<\/code><\/p>\n<h2>\u5b9e\u73b0\u601d\u8def<\/h2>\n<ol>\n<li>\u7528 <code>(\u97f3\u540d, \u65f6\u503c)<\/code> \u6570\u7ec4\u8868\u793a\u4e50\u8c31\uff0c<code>R<\/code> \u8868\u793a\u4f11\u6b62<\/li>\n<li>\u97f3\u540d\u6620\u5c04\u5230\u5e73\u5747\u5f8b\u9891\u7387\uff08<code>A4=440<\/code>\u3001<code>E5=659<\/code>\u3001<code>Ds5=622<\/code> \u7b49\uff09<\/li>\n<li>\u6839\u636e BPM \u5c06\u300c\u5341\u516d\u5206\u97f3\u7b26\u300d\u6362\u7b97\u6210\u6beb\u79d2<\/li>\n<li>P\/Invoke \u8c03\u7528 <code>Beep(uint freq, uint duration)<\/code>\uff1b\u5931\u8d25\u65f6\u56de\u9000 <code>Console.Beep<\/code><\/li>\n<\/ol>\n<h3>\u6838\u5fc3 P\/Invoke<\/h3>\n<pre><code>[DllImport(\"kernel32.dll\", SetLastError = true)]\nstatic extern bool Beep(uint dwFreq, uint dwDuration);\n<\/code><\/pre>\n<h3>\u4e50\u8c31\u6570\u636e\u793a\u4f8b<\/h3>\n<pre><code>static readonly (string Note, int Units)[] Score = {\n    (\"E5\", 2), (\"Ds5\", 2), (\"E5\", 2), (\"Ds5\", 2), (\"E5\", 2),\n    (\"B4\", 2), (\"D5\", 2), (\"C5\", 2),\n    (\"A4\", 6), (\"R\", 2),\n    \/\/ ...\n};\n<\/code><\/pre>\n<h2>\u600e\u4e48\u8dd1<\/h2>\n<pre><code># \u514b\u9686\ngit clone https:\/\/git.6589jk.cn\/Sherry\/fur-elise-csharp.git\ncd fur-elise-csharp\n\n# \u6709 SDK \u65f6\ndotnet run -- --dry-run\ndotnet run -- --bpm 80\n\n# \u6216\u76f4\u63a5\u8dd1\u5df2\u7f16\u8bd1\u4ea7\u7269\ndotnet FurElise.dll --dry-run\n<\/code><\/pre>\n<h2>\u547d\u4ee4\u884c\u53c2\u6570<\/h2>\n<table>\n<thead>\n<tr>\n<th>\u53c2\u6570<\/th>\n<th>\u8bf4\u660e<\/th>\n<th>\u9ed8\u8ba4<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>--dry-run<\/code><\/td>\n<td>\u53ea\u6253\u5370\u97f3\u7b26\uff0c\u4e0d\u53d1\u58f0<\/td>\n<td>\u5173<\/td>\n<\/tr>\n<tr>\n<td><code>--bpm &lt;n&gt;<\/code><\/td>\n<td>\u901f\u5ea6<\/td>\n<td>72<\/td>\n<\/tr>\n<tr>\n<td><code>--loops &lt;n&gt;<\/code><\/td>\n<td>\u91cd\u590d\u6b21\u6570<\/td>\n<td>1<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u9002\u5408\u8c01\u770b<\/h2>\n<ul>\n<li>\u60f3\u7528 C# \u505a\u4e00\u70b9\u300c\u80fd\u542c\u89c1\u300d\u7684\u5c0f\u73a9\u5177<\/li>\n<li>\u5b66\u4e60 P\/Invoke \u8c03 Windows API<\/li>\n<li>\u9700\u8981\u63a7\u5236\u53f0\u7248\u97f3\u7b26\u5e8f\u5217 \/ \u7b80\u6613 MIDI \u98ce\u683c\u6f14\u793a<\/li>\n<\/ul>\n<h2>\u6ce8\u610f\u4e8b\u9879<\/h2>\n<ul>\n<li>\u4f9d\u8d56 Windows <code>Beep<\/code>\uff0c\u975e Windows \u9700\u6362\u53d1\u58f0\u65b9\u5f0f<\/li>\n<li>\u65cb\u5f8b\u4e3a\u4e3b\u9898\u6bb5\u843d\u7b80\u5316\u7f16\u914d\uff0c\u9002\u5408\u6f14\u793a\u800c\u975e\u5b8c\u6574\u6f14\u594f<\/li>\n<li>\u4ed3\u5e93\u4e0e\u6587\u7ae0<strong>\u4e0d\u5305\u542b<\/strong>\u4efb\u4f55\u7ad9\u70b9\u8d26\u53f7\u5bc6\u7801<\/li>\n<\/ul>\n<p>\u5206\u7c7b\uff1a\u5b66\u4e60 \u00b7 \u6807\u7b7e\u8bdd\u9898\uff1aC# \/ Windows API \/ \u97f3\u4e50\u7f16\u7a0b \/ \u81f4\u7231\u4e3d\u4e1d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u4ec0\u4e48 \u4e00\u4e2a\u7528 C# \u5199\u7684\u63a7\u5236\u53f0\u5c0f\u7a0b\u5e8f\uff0c\u5728 Windows \u4e0a\u7528\u7cfb\u7edf Beep \u63a5\u53e3\u6f14\u594f\u8d1d\u591a\u82ac\u300a\u81f4 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[29],"tags":[45,5,44,46,43,47],"class_list":["post-470","post","type-post","status-publish","format-standard","hentry","category-29","tag-beep","tag-c","tag-windows","tag-46","tag-43","tag-47"],"_links":{"self":[{"href":"https:\/\/6589jk.cn\/index.php\/wp-json\/wp\/v2\/posts\/470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/6589jk.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/6589jk.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/6589jk.cn\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/6589jk.cn\/index.php\/wp-json\/wp\/v2\/comments?post=470"}],"version-history":[{"count":1,"href":"https:\/\/6589jk.cn\/index.php\/wp-json\/wp\/v2\/posts\/470\/revisions"}],"predecessor-version":[{"id":471,"href":"https:\/\/6589jk.cn\/index.php\/wp-json\/wp\/v2\/posts\/470\/revisions\/471"}],"wp:attachment":[{"href":"https:\/\/6589jk.cn\/index.php\/wp-json\/wp\/v2\/media?parent=470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/6589jk.cn\/index.php\/wp-json\/wp\/v2\/categories?post=470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/6589jk.cn\/index.php\/wp-json\/wp\/v2\/tags?post=470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}