{"id":4759,"date":"2023-12-06T18:58:57","date_gmt":"2023-12-06T09:58:57","guid":{"rendered":"https:\/\/blog.criware.com\/?p=4759"},"modified":"2024-05-17T17:35:30","modified_gmt":"2024-05-17T08:35:30","slug":"adx2-beginners-guide-3-selectors-and-game-variables","status":"publish","type":"post","link":"https:\/\/blog.criware.com\/index.php\/2023\/12\/06\/adx2-beginners-guide-3-selectors-and-game-variables\/","title":{"rendered":"ADX Beginner\u2019s Guide #3 &#8211; Selectors and Game Variables"},"content":{"rendered":"<p>Armed with the knowledge of the different <a href=\"https:\/\/blog.criware.com\/index.php\/2023\/11\/10\/adx2-beginners-guide-2-the-cue-system\/\">types of Cues in ADX<\/a>, we can now implement more complex behaviours by using Selectors and Game Variables.<\/p>\n<h1 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">Selectors<\/h1>\n<p><strong>Selectors<\/strong> are objects that can take several predefined values called <strong>Selector Labels<\/strong>. As their name implies, the Selector Labels are defined as strings. At runtime, Cues will check the value of a Selector and only play the Tracks associated with the corresponding Selector Label. Selectors are managed in the Project Tree\u2019s <strong>Selector Folder<\/strong>. To set one up:<\/p>\n<ul>\n<li>Right-click on the Selector Folder and <em>Create a Selector<\/em>.<\/li>\n<li>Under the new Selector, <em>Create Selector Labels.<\/em><\/li>\n<\/ul>\n<p style=\"text-align:center;\">\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/01-Selector-Folder.png\" alt=\"01 Selector Folder\" width=\"700\" height=\"400\" class=\"alignnone size-full wp-image-4762\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/01-Selector-Folder.png 700w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/01-Selector-Folder-300x171.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/>\n<\/p>\n<p>&nbsp;<\/p>\n<p>Cues of the <strong>Switch<\/strong>, <strong>Polyphonic<\/strong>, or <strong>Track Transition by Selector<\/strong> types can use Selectors. This allows for a variety of use cases:<\/p>\n<ul>\n<li><em>Switch Cue<\/em>: Every track must be assigned to a Selector Label. Only the Tracks linked to the selected Label will be played. This type of cue is particularly useful for all the sounds that are bound to a specific type of material in the game, e.g., footsteps, impacts, foley&#8230; In these cases, when the material changes in the game, set the correct label on the code side, and the correct Track will be played.<\/li>\n<\/ul>\n<div style=\"max-width:700px; margin: 0 auto; margin-bottom:20px; border: 1px solid #aaa;\">\n<div style=\"width: 800px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-4759-1\" width=\"800\" height=\"423\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/Video_01_SwitchSelector.mp4?_=1\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/Video_01_SwitchSelector.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/Video_01_SwitchSelector.mp4<\/a><\/video><\/div>\n<\/div>\n<ul>\n<li><em>Polyphonic Cue<\/em>: Tracks can be freely assigned to a Selector Label. A Track without a Label will always be played, while a Track with a Label will only be played when the corresponding Label is selected. This is useful if you want to add a specific layer to a sound depending on the game situation. For example, for an ambience, you could have a daytime label and a nighttime label that play extra layers based on the time of the day.<\/li>\n<\/ul>\n<div style=\"max-width:700px; margin: 0 auto; margin-bottom:20px; border: 1px solid #aaa;\">\n<div style=\"width: 800px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-4759-2\" width=\"800\" height=\"423\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/Video_02_PolyphonicSelector.mp4?_=2\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/Video_02_PolyphonicSelector.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/Video_02_PolyphonicSelector.mp4<\/a><\/video><\/div>\n<\/div>\n<ul>\n<li><em>Track Transition by Selector Cue<\/em>: Tracks must be assigned to a Selector Label. When switching Labels during playback, the sound will cross-fade to the Track corresponding to the selected Label, creating a smooth transition. Because transitions can be synchronized to the beat, it is especially useful when implementing interactive music.<\/li>\n<\/ul>\n<div style=\"max-width:700px; margin: 0 auto; margin-bottom:20px; border: 1px solid #aaa;\">\n<div style=\"width: 800px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-4759-3\" width=\"800\" height=\"423\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/Video_03_TransitionSelector.mp4?_=3\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/Video_03_TransitionSelector.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/Video_03_TransitionSelector.mp4<\/a><\/video><\/div>\n<\/div>\n<p>Here is how to assign a Selector Label to a Track:<\/p>\n<ul>\n<li>Select a Cue of type Switch, Polyphonic, or Track Transition by Selector.<\/li>\n<li>In the timeline view, click on the Combo box with the Selector Label icon at the bottom track\u2019s header.<\/li>\n<li>The <em>Default Selector Label<\/em> property can also be changed if you need to have a default Selector configuration.<\/li>\n<li>\nIn the case of a Switch Cue, the <em>Switch Variable<\/em> property must first be set to a specific Selector in order to assign Labels to the tracks.<\/li>\n<\/ul>\n<p style=\"text-align:center;\">\n<img loading=\"lazy\" decoding=\"async\" style=\"max-width: 980px;\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/02-Selector-Track.png\" alt=\"02 Selector Track\" width=\"1120\" height=\"664\" class=\"alignnone wp-image-4774\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/02-Selector-Track.png 1120w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/02-Selector-Track-300x178.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/02-Selector-Track-768x455.png 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/02-Selector-Track-1024x607.png 1024w\" sizes=\"auto, (max-width: 1120px) 100vw, 1120px\" \/>\n<\/p>\n<p>At runtime, Selector Labels can be changed at the Cue and Player level &#8211; allowing for great granularity &#8211; or globally to affect all cues associated with the targeted selector. To set a Selector globally, the <em>Global Label<\/em> property must be changed programmatically.<\/p>\n<h1 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">Game Variables<\/h1>\n<p>Game Variables work similarly to the Selectors but use float values between 0 and 1 instead of string Labels to switch the Track being playback. Game Variables can be created in the <em>Game Variables<\/em> folder of the project tree. An <em>Initial Value<\/em> can be set for each variable.<\/p>\n<p style=\"text-align:center;\">\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/03-GameVariable-Folder.png\" alt=\"03 GameVariable Folder\" width=\"732\" height=\"391\" class=\"alignnone wp-image-4775\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/03-GameVariable-Folder.png 732w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/03-GameVariable-Folder-300x160.png 300w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/>\n<\/p>\n<p>Game variables are handled globally by the runtime library, so they affect all Cues that reference them. In addition, it is only possible to use Game Variables with a Cue of type Switch. The <em>Switch Variable <\/em>property must be set first, and instead of specifying a Label, a range between 0 and 1 must be set for each Track.<\/p>\n<p style=\"text-align:center;\">\n<img loading=\"lazy\" decoding=\"async\" width=\"1375\" height=\"868\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/04-GameVariable-Settings.png\" alt=\"04 GameVariable Settings\" class=\"alignnone wp-image-4776\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/04-GameVariable-Settings.png 1375w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/04-GameVariable-Settings-300x189.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/04-GameVariable-Settings-768x485.png 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/04-GameVariable-Settings-1024x646.png 1024w\" sizes=\"auto, (max-width: 1375px) 100vw, 1375px\" \/>\n<\/p>\n<p>Game Variables are really useful for changing the sound based on physics parameters like force, velocity, acceleration, etc. For instance, you could design variations of impact sounds at different intensities, and then adjust the Game Variable of the Cue to switch to the correct sound variation based on values received from the game&#8217;s physics engine.<\/p>\n<div style=\"max-width:700px; margin: 0 auto; margin-bottom:20px; border: 1px solid #aaa;\">\n<div style=\"width: 800px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-4759-4\" width=\"800\" height=\"423\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/Video_04_SwitchGameVariable.mp4?_=4\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/Video_04_SwitchGameVariable.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/12\/Video_04_SwitchGameVariable.mp4<\/a><\/video><\/div>\n<\/div>\n<p>Of course, Selectors and Game Variables can be mixed (using Sub Sequences for instance) to create even more complex interactions. In the next post, we will see even more ways to create advanced audio behaviors with Cue\u2019s <strong>Markers<\/strong> and <strong>Actions<\/strong>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Armed with the knowledge of the different types of Cues in ADX, we can now implement more complex behaviours by<\/p>\n","protected":false},"author":2,"featured_media":5388,"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-4759","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\/4759","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=4759"}],"version-history":[{"count":19,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/4759\/revisions"}],"predecessor-version":[{"id":4793,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/4759\/revisions\/4793"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media\/5388"}],"wp:attachment":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media?parent=4759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/categories?post=4759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/tags?post=4759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}