{"id":3155,"date":"2020-11-24T13:29:49","date_gmt":"2020-11-24T04:29:49","guid":{"rendered":"https:\/\/blog.criware.com\/?p=3155"},"modified":"2020-11-24T13:29:49","modified_gmt":"2020-11-24T04:29:49","slug":"creating-a-gibberish-generator-with-adx2-and-ue4","status":"publish","type":"post","link":"https:\/\/blog.criware.com\/index.php\/2020\/11\/24\/creating-a-gibberish-generator-with-adx2-and-ue4\/","title":{"rendered":"Creating a Gibberish Generator with ADX2 and UE4"},"content":{"rendered":"<h2 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">Introduction<\/h2>\n<p>As the video games medium has evolved, so has the complexity of the stories they try to tell. Usually, this story is told literally through expositional dialog and character interactions. Practically hiring voice actors and recording all the dialog can cost a lot of money and prove prohibitive for smaller developers. There are, fortunately, a few ways that we can attempt to address this.<\/p>\n<p>In this blog, we will create a gibberish generator. It will parse a string and convert each character to a short sound. This approach won\u2019t necessarily produce the most natural-sounding chatter, but it\u2019s a good starting point and avoids silence when a character is speaking. You can find some wave files in the project linked below for testing, excluding letters that sound similar such as k and q (where c has been provided). We can duplicate tracks for these.<\/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-3155-1\" width=\"800\" height=\"450\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator.mp4?_=1\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator.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\/11\/2020-11_GibberishGenerator.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-11_GibberishGenerator.zip<\/a>\n<\/div>\n<p><i>This project was created using CRI Atom Craft Ver.3.44.13 and UE4.25<\/i><\/p>\n<h2 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">Atom Craft<\/h2>\n<p>There are two ways we can approach this. We can either create a Cue for each phoneme or create one Cue with a Track for each phoneme, using a Selector to play the correct one. Let\u2019s opt for the latter since it will allow us to create new characters (we can duplicate the Cue and swap the Materials out). It will also make our project easier to read. To set this up, lets:<\/p>\n<ul>\n<li>Create a Selector named \u201cPhonSelector\u201d\n<ul>\n<li>Create 26 Selector Labels, named according to the alphabet<\/li>\n<li>Create one more Selector Label named \u201cstop\u201d<\/li>\n<\/ul>\n<\/li>\n<li>Create a Polyphonic Cue named \u201cGibberish\u201d\n<ul>\n<li>Drag all Materials onto Cue<\/li>\n<li>Set Selector Label for each Track according to name\n<ul>\n<li>e., for <em>Track_phone_d<\/em>, set Selector Label to <em>d<\/em><\/li>\n<\/ul>\n<\/li>\n<li>Additionally, set Gibberish Cue\u2019s Default Selector Label to <em>stop<\/em><\/li>\n<\/ul>\n<\/li>\n<li>Build project files for importing into UE4<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_1.png\" alt=\"2020-11_GibberishGenerator_1\" width=\"706\" height=\"287\" class=\"alignnone size-full wp-image-3162\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_1.png 706w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_1-300x122.png 300w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/><\/p>\n<h2 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">UE4<\/h2>\n<p>With ADX2 setup and the relevant build files imported, let\u2019s start creating our playback system. To briefly summarize, we need to:<\/p>\n<ol>\n<li>Parse a string into an array of characters<\/li>\n<li>Loop through each character<\/li>\n<li>Play the correct sound<\/li>\n<li>Wait before playing the next sound<\/li>\n<\/ol>\n<p>The default loop functions in Blueprints don\u2019t have a wait function, so we will first need to create our own. In the content browser, right-click \u2192 Blueprints \u2192 Blueprint Macro Library, and name it \u201cLoop with Delay.\u201d We should also open it up and rename the Macro itself to \u201cLoop with Delay\u201d under the Macro\u2019s tab. This name is how it will be referenced as in other Blueprints.<\/p>\n<p>We can create a <em>For Each Loop<\/em>, double-clicking to open it up, and copying all of the content into our <em>Loop with Delay<\/em> Macro. Next, we need to copy the Inputs and Outputs setup to mirror the <em>For Each Loop<\/em>, adding one more float input for our delay. Finally, we need to insert a <em>Delay<\/em> function into the loop, linking it with our delay input float.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_2.png\" alt=\"2020-11_GibberishGenerator_2\" width=\"1920\" height=\"994\" class=\"alignnone size-full wp-image-3171\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_2.png 1920w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_2-300x155.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_2-768x398.png 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_2-1024x530.png 1024w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<p>For our actual generator, in the Content Browser, let\u2019s right-click \u2192 Blueprint Class \u2192 Actor and name it \u201cBP_GibberishGenerator.\u201d We will need two variables, a float named \u201cDelay Amount\u201d and a string named \u201cInput String.\u201d<\/p>\n<p>On whatever Event type makes sense (in this case, <em>Event<\/em> <em>BeginPlay<\/em> for testing purposes), we can trigger our <em>Loop with Delay<\/em> function, using <em>Get Character Array from String <\/em>to create our character array to loop through.<\/p>\n<p>We first check if the character is a space (the bool check below looks empty, but space has been specified), in which case we don\u2019t play anything and delay for a little bit longer. Next, we check if it is either a comma or a full-stop. In either case, the outcome is similar to before, don\u2019t play anything, but pause for even longer. The effect of these instances is to create a more interesting rhythm. For this to work, we need to put a <em>Set Delay Amount <\/em>function at the beginning of the loop body to ensure it resets to 0.1.<\/p>\n<p>In any other case, we play the Gibberish Cue and set the Selector Label to the corresponding letter. If an unfamiliar character is played, the default \u201cstop\u201d Selector Label will be picked.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_3-1.png\" alt=\"2020-11_GibberishGenerator_3\" width=\"1920\" height=\"757\" class=\"alignnone size-full wp-image-3164\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_3-1.png 1920w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_3-1-300x118.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_3-1-768x303.png 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2020\/11\/2020-11_GibberishGenerator_3-1-1024x404.png 1024w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<p>To generate some text, we can select the Input String variable and change the Default Value in the Details panel.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction As the video games medium has evolved, so has the complexity of the stories they try to tell. Usually,<\/p>\n","protected":false},"author":2,"featured_media":3166,"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-3155","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\/3155","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=3155"}],"version-history":[{"count":10,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/3155\/revisions"}],"predecessor-version":[{"id":5301,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/3155\/revisions\/5301"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media\/3166"}],"wp:attachment":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media?parent=3155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/categories?post=3155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/tags?post=3155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}