{"id":906,"date":"2021-05-29T11:28:14","date_gmt":"2021-05-29T02:28:14","guid":{"rendered":"https:\/\/machiaworx.net\/?p=906"},"modified":"2021-05-29T11:33:02","modified_gmt":"2021-05-29T02:33:02","slug":"unity%e3%81%a7%e8%87%aa%e5%88%86%e3%81%8c%e3%82%88%e3%81%8f%e4%bd%bf%e3%81%86%e3%82%aa%e3%83%bc%e3%83%87%e3%82%a3%e3%82%aa%e3%81%ae%e3%82%bd%e3%83%bc%e3%82%b9%e3%82%b3%e3%83%bc%e3%83%89%e3%83%86","status":"publish","type":"post","link":"https:\/\/machiaworx.net\/?p=906","title":{"rendered":"Unity\u3067\u81ea\u5206\u304c\u3088\u304f\u4f7f\u3046\u30aa\u30fc\u30c7\u30a3\u30aa\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3002"},"content":{"rendered":"<p>\u3053\u3093\u306a\u306e\u3092\u4f7f\u3063\u3066\u307e\u3059\u3002<\/p>\n<p>\u9069\u5f53\u306a\u30b2\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30a2\u30bf\u30c3\u30c1\u3057\u3066\u3001AudioClip\u3092\u8aad\u307f\u8fbc\u307e\u305b\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n\u30b5\u30a4\u30f3\u6ce2\u3068\u30b5\u30f3\u30d7\u30eb\u304c\u9cf4\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u5909\u308f\u3063\u305f\u3053\u3068\u3057\u3066\u308b\u3068\u3044\u3046\u3068\u3001\u300cAudioClip\u306e\u97f3\u3092Filter\u4e0a\u3067\u9cf4\u3089\u3057\u3066\u3044\u308b\u300d\u3068\u3044\u3046\u3053\u3068\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001UnityEngine\u306e\u3059\u3079\u3066\u306e\u95a2\u6570\u304c\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>\u3058\u3083\u3042\u3069\u3046\u3059\u308b\u304b\u3068\u3044\u3046\u3068\u300c\u81ea\u5206\u3067\u3059\u3079\u3066\u66f8\u304f\u300d\u3068\u3044\u3046\u30a2\u30d7\u30ed\u30fc\u30c1\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3061\u3087\u3063\u3068\u66f8\u304f\u3082\u306e\u304c\u6e9c\u307e\u3063\u3066\u308b\u306e\u3067\u3001\u3053\u3053\u306b\u66f8\u3044\u3066\u304a\u304f\uff08\u3082\u3057\u304f\u306fZenn\u306b\u66f8\u3044\u3066\u304a\u304f\uff09\u3053\u3068\u306b\u3057\u3088\u3046\u304b\u3068\u3002<\/p>\n<h3>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h3>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\r\nusing System.Collections;\r\nusing System.Collections.Generic;\r\nusing UnityEngine;\r\nusing System; \/* Math \u30af\u30e9\u30b9\u3092\u4f7f\u3046\u305f\u3081\u8ffd\u52a0 *\/\r\n\r\npublic class pitchTest : MonoBehaviour\r\n{\r\npublic AudioClip SEClip;\r\nint count=0;\r\nbool playing= false;\r\nint n;\r\nint length;\r\nint temp_length;\r\ndouble increment;\r\ndouble phase;\r\nint sampling_rate;\r\n\r\nfloat[] temp_sample;\r\n[SerializeField, Range(-12, 12)] int pitch = 0;\r\n\r\n\/\/ Start is called before the first frame update\r\nvoid Start()\r\n{\r\nsampling_rate = AudioSettings.outputSampleRate;\r\n\r\ntemp_sample = new float[SEClip.samples* SEClip.channels];\r\nlength = SEClip.samples* SEClip.channels;\r\nSEClip.GetData(temp_sample, 0);\r\n\r\nplaying = true;\r\n}\r\nvoid OnAudioFilterRead (float[] data, int channels)\r\n{\r\n  if( !playing)\r\n    return;\r\n\r\n  for (n = 0; n &lt; data.Length; n = n + channels)\r\n  {\r\n    increment = 2.0 * Math.PI * 440.0 \/ sampling_rate;\/\/pcm.fs;\r\n    \/\/increment = 2.0 * Math.PI * GetFrquency(play_synth_number) \/ sampling_rate;\/\/pcm.fs;\r\n\r\n    float output = 0.0f;\r\n\r\n    output = (float)(0.1f * Math.Sin(phase));\r\n\r\n    \/\/\u30b5\u30f3\u30d7\u30eb\u518d\u751f\u8ffd\u52a0\r\n\r\n    data[n] = output;\r\n    data[n+1] = output;\r\n\r\n    phase = phase + increment;\r\n\r\n    if (phase &gt; 2 * Math.PI)\r\n      phase -= 2*Math.PI;\r\n\r\n    count++;\r\n  }\r\n}\r\n\r\n  \/\/ Update is called once per frame\r\n  void Update()\r\n  {\r\n  }\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306a\u306e\u3092\u4f7f\u3063\u3066\u307e\u3059\u3002 \u9069\u5f53\u306a\u30b2\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30a2\u30bf\u30c3\u30c1\u3057\u3066\u3001AudioClip\u3092\u8aad\u307f\u8fbc\u307e\u305b\u3066\u304f\u3060\u3055\u3044\u3002 \u30b5\u30a4\u30f3\u6ce2\u3068\u30b5\u30f3\u30d7\u30eb\u304c\u9cf4\u308b\u306f\u305a\u3067\u3059\u3002 \u3053\u3053\u3067\u5909\u308f\u3063\u305f\u3053\u3068\u3057\u3066\u308b\u3068\u3044\u3046\u3068\u3001\u300cAudioClip\u306e\u97f3\u3092Filter\u4e0a\u3067&hellip; <span class=\"clear\"><\/span><a href=\"https:\/\/machiaworx.net\/?p=906\" class=\"more-link read-more\" rel=\"bookmark\"><span class=\"screen-reader-text\">Unity\u3067\u81ea\u5206\u304c\u3088\u304f\u4f7f\u3046\u30aa\u30fc\u30c7\u30a3\u30aa\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3002<\/span><i class=\"fa fa-arrow-right\"><\/i> \u306e\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,11,4],"tags":[],"class_list":["post-906","post","type-post","status-publish","format-standard","hentry","category-unity","category-synth-dev","category-pgm"],"_links":{"self":[{"href":"https:\/\/machiaworx.net\/index.php?rest_route=\/wp\/v2\/posts\/906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/machiaworx.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/machiaworx.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/machiaworx.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/machiaworx.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=906"}],"version-history":[{"count":3,"href":"https:\/\/machiaworx.net\/index.php?rest_route=\/wp\/v2\/posts\/906\/revisions"}],"predecessor-version":[{"id":910,"href":"https:\/\/machiaworx.net\/index.php?rest_route=\/wp\/v2\/posts\/906\/revisions\/910"}],"wp:attachment":[{"href":"https:\/\/machiaworx.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/machiaworx.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/machiaworx.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}