{"id":3056,"date":"2020-08-25T13:39:38","date_gmt":"2020-08-25T04:39:38","guid":{"rendered":"https:\/\/blog.criware.com\/?p=3056"},"modified":"2020-08-25T13:59:16","modified_gmt":"2020-08-25T04:59:16","slug":"controlling-game-volume-in-ue4-with-adx2","status":"publish","type":"post","link":"https:\/\/blog.criware.com\/index.php\/2020\/08\/25\/controlling-game-volume-in-ue4-with-adx2\/","title":{"rendered":"Controlling Game Volume in UE4 with ADX2"},"content":{"rendered":"<p>Once we have successfully implemented and mixed the audio for our games, we will likely want to offer the player the ability to adjust their volume. For example, in a competitive shooter, the player might want their music to be quieter, or if playing an adventure game, they might wish to have the dialog a bit louder. In this blog, we will cover the different methods that ADX2 offers for applying broad-stroke changes to the volume.<\/p>\n<p>To test this system, we will be extending on our <a href=\"https:\/\/blog.criware.com\/index.php\/2020\/08\/19\/creating-interactive-footsteps-in-ue4-with-adx2\/\">footstep blog<\/a>, only adding in some Music and Ambience Cues with relevant Materials.<\/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-3056-1\" width=\"800\" height=\"450\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/2020_08_GameVolume_1.mp4?_=1\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/2020_08_GameVolume_1.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/2020_08_GameVolume_1.mp4<\/a><\/video><\/div>\n<\/div>\n<p><\/p>\n<div style=\"max-width: 800px; margin: 0 auto; margin-bottom: 20px; text-align:center;\"><a style=\"display: inline-block; border: 1px solid #ccc; padding: 20px;\" href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/2020_08_GameVolume.zip\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1813\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2018\/06\/zip.png\" alt=\"zip\" width=\"80\" height=\"78\" style=\"\n    display: block;\n    margin: 0 auto;\n\">2020_08_GameVolume.zip<\/a><\/div>\n<p><i>This project was created using CRI Atom Craft Ver.3.43.09 and UE4.24.3<\/i><\/p>\n<h2 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">Atom Craft<\/h2>\n<p>To allow for a few different options, we are going to implement three solutions for volume adjustments: setting by bus, Category, and AISAC. Setting by bus won\u2019t require any additional setup for our purposes since we will be using use the default MasterOut bus. However, we could design our project so that Cues of certain types (such as SFX or dialog) are sent to specified busses and only summed in our Bus Map. <\/p>\n<p>\nAnother approach is to use the Categories feature. Here, we can define sound types, and drag our Cues onto these Categories. If we want to define a custom attenuation curve, we can also apply AISAC to our sounds. In the Project Tree, let\u2019s:<\/p>\n<ul>\n<li>Under AISAC-Controls, rename AisacControl_00 to \u201cAisacControl_Volume\u201d<\/li>\n<li>Right-click Categories folder \u2192 New Object \u2192 Create CategoryGroup<\/li>\n<ul>\n<li>Name it \u201cSoundCategories\u201d<\/li>\n<\/ul>\n<\/li>\n<li>Right-click this group and create two new Categories named \u201cMusic\u201d and \u201cSFX\u201d<\/li>\n<ul>\n<li>On each, right-click and create new AISAC as follows:<\/li>\n<ul>\n<li><b>AISAC Name<\/b>: Volume<\/li>\n<li><b>AISAC Control<\/b>: AisacControl_Volume<\/li>\n<li><b>AISAC Graph<\/b>: Volume<\/li>\n<\/ul>\n<\/li>\n<li>For each, create a linear curve from 0 to 1, and set the last point\u2019s Curve Type to Slow Change\n<\/ul>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_1.png\" alt=\"GameVolume_1\" width=\"1426\" height=\"427\" class=\"alignnone size-full wp-image-3059\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_1.png 1426w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_1-300x90.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_1-768x230.png 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_1-1024x307.png 1024w\" sizes=\"auto, (max-width: 1426px) 100vw, 1426px\" \/><\/p>\n<h2 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">UE4<\/h2>\n<p>To control the audio levels in UE4, we will be using a simple Widget with sliders for our master, music, and SFX volume controls. The <a href=\"https:\/\/docs.unrealengine.com\/en-US\/Engine\/UMG\/UserGuide\/CreatingWidgets\/index.html\">UE4 documentation<\/a> covers the process of Widget creation and interaction in much more detail, but briefly, we are:<\/p>\n<ul>\n<li>Creating a Menu Widget on Begin Play<\/li>\n<li>Making it visible and showing the cursor when we push the Tab key<\/li>\n<li>Hiding the Widget and the cursor when we press the Tab key again<\/li>\n<\/ul>\n<p>This setup isn\u2019t an ideal implementation, but entirely usable for our testing purposes.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_2-1.png\" alt=\"GameVolume_2\" width=\"1530\" height=\"734\" class=\"alignnone size-full wp-image-3061\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_2-1.png 1530w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_2-1-300x144.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_2-1-768x368.png 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_2-1-1024x491.png 1024w\" sizes=\"auto, (max-width: 1530px) 100vw, 1530px\" \/><\/p>\n<p>Next, we can drag-and-drop our Music and Ambience Cues into our scene, where ADX2 will take care of automatic playback for us. Finally, we can create the logic for our sliders. In the menu Widget, let\u2019s create an <b>On Value Changed<\/b> event for each slider. We can quickly find these events in the Details tab when the relevant slider is selected.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_3.png\" alt=\"GameVolume_3\" width=\"345\" height=\"357\" class=\"alignnone size-full wp-image-3062\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_3.png 345w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_3-290x300.png 290w\" sizes=\"auto, (max-width: 345px) 100vw, 345px\" \/><\/p>\n<p>Since sliders in UE4 go from 0 to 1 by default, we don\u2019t need to apply any scaling (ADX2 also uses this range by default). And so, to set our master volume, we need to <b>Get Asr Rack<\/b> and <b>Set Bus Volume by Name<\/b>, setting Bus Name to \u201cMasterOut\u201d (this is the default name for ADX2\u2019s master bus). <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_4.png\" alt=\"GameVolume_4\" width=\"833\" height=\"193\" class=\"alignnone size-full wp-image-3063\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_4.png 833w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_4-300x70.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_4-768x178.png 768w\" sizes=\"auto, (max-width: 833px) 100vw, 833px\" \/><\/p>\n<p>For our music, if we want to use our custom AISAC curve, we can <b>Set Aisac Control by Name<\/b>, setting Category name to \u201cMusic\u201d and Aisac Name to \u201cAisacControl_Volume.\u201d These values are based on what we set in Atom Craft.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_5.png\" alt=\"GameVolume_5\" width=\"545\" height=\"193\" class=\"alignnone size-full wp-image-3064\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_5.png 545w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_5-300x106.png 300w\" sizes=\"auto, (max-width: 545px) 100vw, 545px\" \/><\/p>\n<p>For our SFX, if all we want to do is directly set the volume, we can instead <b>Set Volume by Name<\/b>, setting Category Name to \u201cSFX.\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_6.png\" alt=\"GameVolume_6\" width=\"529\" height=\"145\" class=\"alignnone size-full wp-image-3065\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_6.png 529w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/08\/GameVolume_6-300x82.png 300w\" sizes=\"auto, (max-width: 529px) 100vw, 529px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Once we have successfully implemented and mixed the audio for our games, we will likely want to offer the player<\/p>\n","protected":false},"author":2,"featured_media":3079,"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-3056","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\/3056","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=3056"}],"version-history":[{"count":11,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/3056\/revisions"}],"predecessor-version":[{"id":3080,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/3056\/revisions\/3080"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media\/3079"}],"wp:attachment":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media?parent=3056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/categories?post=3056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/tags?post=3056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}