{"id":2363,"date":"2019-06-24T10:21:12","date_gmt":"2019-06-24T01:21:12","guid":{"rendered":"https:\/\/blog.criware.com\/?p=2363"},"modified":"2019-06-24T10:21:12","modified_gmt":"2019-06-24T01:21:12","slug":"creating-immersive-3d-audio-with-adx2-and-unity","status":"publish","type":"post","link":"https:\/\/blog.criware.com\/index.php\/2019\/06\/24\/creating-immersive-3d-audio-with-adx2-and-unity\/","title":{"rendered":"Creating Immersive 3D Audio with ADX2 and Unity"},"content":{"rendered":"<h2 style=\"font-size: 150%; font-weight: bold;\">Introduction<\/h2>\n<p>ADX2 offers a variety of different methods for controlling the spatial playback of sounds. From simple monophonic playback to spatialized playback with distance-based high-frequency attenuation. In this month\u2019s blog, we will dive into the world of 3D audio, looking at the different features available, and when you might use them. We will also hear what this sounds like inside a demo Unity scene.<\/p>\n<div style=\"max-width: 800px; margin: 0 auto; margin-bottom: 20px;\">\n<div style=\"width: 800px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-2363-1\" width=\"800\" height=\"450\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/3daudio.mp4?_=1\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/3daudio.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/3daudio.mp4<\/a><\/video><\/div>\n<\/div>\n<p><em><\/em><\/p>\n<div style=\"text-align: center;\">\n<a style=\"display: inline-block; border: 1px solid #ccc; padding: 20px;\" href=\"https:\/\/www.criware.com\/download-blog-zip\/1906_SpatialAudio.zip\"><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1813\" style=\"display: inline-block;\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2018\/06\/zip.png\" alt=\"zip\" width=\"80\" height=\"78\"><br \/>\n1906_SpatialAudio.zip<\/a><br \/>\n<em>This project was created using CRI Atom Craft V3.41.01 and Unity V2019.1.6f1<\/em>\n<\/div>\n<h2 style=\"font-size: 150%; font-weight: bold;\">2D Sounds<\/h2>\n<p>2D refers to lateral panning of audio, and it is the default mode when setting up sounds in Atom Craft. This playback mode is likely the one you will want to stick with if you are working on a 2D game. If you are working on a 3D game, you might also decide to use 2D playback for non-diegetic sounds such as music and UI sounds, and certain diegetic sounds such as for stereo ambience.<\/p>\n<p>To compare 2D vs 3D in context, we can create a <strong>Polyphonic Cue <\/strong>and drop in some ambient background noise and rename the Cue \u201croomtone\u201d. Since 2D is the default playback state, we won\u2019t need to do anything else for this sound.<\/p>\n<h2 style=\"font-size: 150%; font-weight: bold;\">3D Sounds<\/h2>\n<p>When interacting with a virtual 3D world, we generally expect sounds to propagate in a way that makes sense in the real world. To achieve this, we can the 3D processing features in ADX2.<\/p>\n<p>To get started, we need to set a sound our sound up for 3D playback.<\/p>\n<ul>\n<li>Create a <strong>Polyphonic Cue <\/strong>named \u201cboxhum\u201d<\/li>\n<li>Drop the <em>wav<\/em> Material onto the boxhum Cue<\/li>\n<li>Select the Waveform Region on the Timeline window.<\/li>\n<li>Set Pan Type to 3D in the Inspector<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"\n    display: block;\n    margin: 0 auto; margin-bottom: 40px;\n\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-1.png\" alt=\"11-1\" width=\"1384\" height=\"234\" class=\"alignnone size-full wp-image-2368\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-1.png 1384w, https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-1-300x51.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-1-768x130.png 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-1-1024x173.png 1024w\" sizes=\"auto, (max-width: 1384px) 100vw, 1384px\" \/><\/p>\n<p>Without doing anything else, we can audition this effect in the Session Window. Open it up, drag in the boxhum Cue, select the Positioning 3D tab, and tick the <strong>Attached 3D Object on Player<\/strong> box. By clicking and dragging on the visual display, we can simulate the object moving around. We can also set whether it is the object or the player who is in motion, by highlighting the different Targets: <strong>Listener<\/strong> and <strong>Source<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"\n    display: block;\n    margin: 0 auto; margin-bottom: 40px;\n\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-2.png\" alt=\"11-2\" width=\"763\" height=\"596\" class=\"alignnone size-full wp-image-2369\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-2.png 763w, https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-2-300x234.png 300w\" sizes=\"auto, (max-width: 763px) 100vw, 763px\" \/><\/p>\n<h2 style=\"font-size: 150%; font-weight: bold;\">Tweaking &amp; Finishing Touches<\/h2>\n<p>3D Positioning by itself only offers spatial panning with simple distance-based volume attenuation. We can sell the effect better by introducing a high-frequency roll-off using an AISAC. Think of a distant rock concert, where only the lowest frequencies can be heard. We can also tweak a few other settings to create a more immersive effect.<\/p>\n<ul>\n<li>In the Project Tree, rename AisacControl_00 to \u201cAISAC_Distance\u201d<\/li>\n<li>Create AISAC on boxhum Cue, and set:\n<ul>\n<li><strong>Name<\/strong> = \u201cboxhum_attenuation\u201d<\/li>\n<li><strong>AISAC Control<\/strong> = AISAC_Distance<\/li>\n<li><strong>Graph Type<\/strong> = Bandpass \u2013 Cutoff High<\/li>\n<li>Create a graph roughly as below<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"\n    display: block;\n    margin: 0 auto; margin-bottom: 40px;\n\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-3.png\" alt=\"11-3\" width=\"894\" height=\"215\" class=\"alignnone size-full wp-image-2370\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-3.png 894w, https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-3-300x72.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-3-768x185.png 768w\" sizes=\"auto, (max-width: 894px) 100vw, 894px\" \/><\/p>\n<\/li>\n<li>With the boxhum Cue selected, go to the Inspector and open the Pan[3D] tab<\/li>\n<li>Set <strong>AISAC Control<\/strong> <strong>\u2192 Distance<\/strong> = AISAC_Distance<\/li>\n<li>Set <strong>Attenuation Distance<\/strong> <strong>\u2192<\/strong> <strong>Max <\/strong>= 100.00<\/li>\n<li>Set <strong>Doppler Factor <\/strong>= 1.00<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"\n    display: block;\n    margin: 0 auto; margin-bottom: 40px;\n\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-4.png\" alt=\"11-4\" width=\"525\" height=\"422\" class=\"alignnone size-full wp-image-2371\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-4.png 525w, https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-4-300x241.png 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/p>\n<p>We can test the effect of these settings once again in the Session Window. Notice how you don\u2019t have to travel as far to hear the effects of the audio quietening, and how the higher frequencies die out as the volume decreases. You should also be able to hear a pitch shifting effect the faster you move around relative to the sound source. If the pitch shifting sounds a bit unnatural, you can try values between 0.00 and 1.00 to find a value that works best.<\/p>\n<h2 style=\"font-size: 150%; font-weight: bold;\">Tips<\/h2>\n<p>The <strong>Effective Angle<\/strong> can be used to make sounds hyper-directional (only audible within a smaller cone). This feature can offer a handy way to tidy a mix, making sure the player only hears what is relevant.<\/p>\n<p>The <strong>Attenuation Distance \u2192 Min <\/strong>controls the minimum distance before attenuation happens. Values higher than 1.00 remove the spatialization effect when you\u2019re within that minimum range, which causes the sound to envelop you, rather than being discretely locatable.<\/p>\n<h2 style=\"font-size: 150%; font-weight: bold;\">Unity<\/h2>\n<p>Since ADX2 controls all our 3D audio, we need to do very little to demo this inside of Unity. Build the Project and do the necessary setup to get the CRIWARE plugin loaded in Unity (you can follow the manual for this). In Unity, I have created a default 3D template, loaded a script onto the camera which allows it to be controlled with the mouse and keyboard, and created a cube at the center of the scene. Now we can:<\/p>\n<ul>\n<li>Drop the roomtone Cue onto the scene, and in the Inspector under Cri Atom Source (Script):\n<ul>\n<li>Check <strong>Play On Start<\/strong><\/li>\n<li>Uncheck <strong>3D Positioning<\/strong><\/li>\n<\/ul>\n<\/li>\n<li>Drop the boxhum Cue onto the Cube, and in the Inspector under Cri Atom Source (Script):\n<ul>\n<li>Check <strong>Play On Start<\/strong><\/li>\n<li>Check <strong>3D Positioning<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"\n    display: block;\n    margin: 0 auto; margin-bottom: 40px;\n\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-5.png\" alt=\"11-5\" width=\"1177\" height=\"612\" class=\"alignnone size-full wp-image-2372\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-5.png 1177w, https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-5-300x156.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-5-768x399.png 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2019\/06\/11-5-1024x532.png 1024w\" sizes=\"auto, (max-width: 1177px) 100vw, 1177px\" \/><\/p>\n<p>And we are done! The Unity scene should sound the same as when auditioned inside Atom Craft. Notice how the ambience is unaffected by our movement throughout the scene, but the boxhum sound is very dynamic, even though it\u2019s just a short loop.<\/p>\n<h2 style=\"font-size: 150%; font-weight: bold;\">Conclusion<\/h2>\n<p>Thanks to the intuitive and fleshed out features of ADX2, we can create rich, interactive audio worlds right from within the Atom Craft tool. It can be useful to test how this all relates contextually to a real game, but we can get very far using only the tool.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction ADX2 offers a variety of different methods for controlling the spatial playback of sounds. From simple monophonic playback to<\/p>\n","protected":false},"author":2,"featured_media":2364,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[5,7],"tags":[],"class_list":["post-2363","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-adx","category-tutorials"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/2363","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/comments?post=2363"}],"version-history":[{"count":11,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/2363\/revisions"}],"predecessor-version":[{"id":2383,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/2363\/revisions\/2383"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media\/2364"}],"wp:attachment":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media?parent=2363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/categories?post=2363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/tags?post=2363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}