{"id":3621,"date":"2022-01-04T10:46:19","date_gmt":"2022-01-04T01:46:19","guid":{"rendered":"https:\/\/blog.criware.com\/?p=3621"},"modified":"2024-05-21T10:31:02","modified_gmt":"2024-05-21T01:31:02","slug":"synchronizing-sfx-and-music","status":"publish","type":"post","link":"https:\/\/blog.criware.com\/index.php\/2022\/01\/04\/synchronizing-sfx-and-music\/","title":{"rendered":"Synchronizing SFX and Music"},"content":{"rendered":"<p>Some types of gameplays &#8211; for instance puzzles \u2013 are perfect to explore the relationships between sound effects and music. In this post, we will describe two implementation techniques in AtomCraft for music-driven sound effects. We will synchronize the sound effects to the music both time-wise and frequency-wise.<\/p>\n<div style=\"text-align: center; max-width: 800px; margin: 0 auto;\">\n<div style=\"width: 800px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3621-1\" width=\"800\" height=\"450\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/Blog-VideoSynchronizing-SFX-and-Music.mp4?_=1\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/Blog-VideoSynchronizing-SFX-and-Music.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/Blog-VideoSynchronizing-SFX-and-Music.mp4<\/a><\/video><\/div>\n<\/div>\n<h2 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">Music<\/h2>\n<p>Let\u2019s start by preparing the music by creating a Cue of type \u201cTrack Transition by Selector\u201d. This type of Cue will allow us to smoothly switch Tracks during playback via a Selector, using fading transitions and beat synchronization.<\/p>\n<p>In our case, we designed 3 short loops in different keys (C, F and A). \u00a0After creating a Selector called \u201cMusic_Key\u201d and three Selector Labels named C, F and A; we add three tracks to our Music Cue, and opt for the Selector for the Switch Variable. We assign the Selector Labels to each Track, and finally drag and drop the loops onto the corresponding tracks.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3622\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/01-Music-Transition-Cue.jpg\" alt=\"01 Music Transition Cue\" width=\"1805\" height=\"639\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/01-Music-Transition-Cue.jpg 1805w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/01-Music-Transition-Cue-300x106.jpg 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/01-Music-Transition-Cue-768x272.jpg 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/01-Music-Transition-Cue-1024x363.jpg 1024w\" sizes=\"auto, (max-width: 1805px) 100vw, 1805px\" \/><\/p>\n<p>It is now possible to switch between the different keys, simply by changing the value of the Music_Key Selector. Depending of the content of your loops, you may also want to set up Fade-In and Fade-Out times in the Track Transition properties of your Cue.<\/p>\n<p>Moreover, to ensure that the switch always happens on a beat, we create a Beat Sync Parameter object on the timeline of our Music Cue. In our example, we set the tempo to 100 bpm. In the Beat Pattern tab of the Beat Sync properties, it is possible to select exactly on which beats the transitions are allowed to occur (here we chose the 1<sup>st<\/sup> and 3<sup>rd<\/sup> beats).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3623\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/02-Beat-Sync-Parameter.jpg\" alt=\"02 Beat Sync Parameter\" width=\"1161\" height=\"557\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/02-Beat-Sync-Parameter.jpg 1161w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/02-Beat-Sync-Parameter-300x144.jpg 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/02-Beat-Sync-Parameter-768x368.jpg 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/02-Beat-Sync-Parameter-1024x491.jpg 1024w\" sizes=\"auto, (max-width: 1161px) 100vw, 1161px\" \/><\/p>\n<p>From now on, if we try to change the value of the Selector during playback, the run-time will wait for the 1<sup>st<\/sup> or 3<sup>rd<\/sup> beat to trigger the transition to another track.<\/p>\n<h2 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">Sound Effects<\/h2>\n<p>On the sound effect side, let\u2019s create some Bonus \/ Power Up sounds. They will be played on the beat and their key will change accordingly to the music. To spice it up a bit, for each key we set up 3 variations in a Combo Sequential Cue. This will allow us to create a progression when the player picks up several Bonuses within a short amount of time. As we have 3 tracks, we set the Combo Loop Back parameter to 2 in the Cue\u2019s Special Playback settings. We also adjust the Combo Interval (between 1500 and 2000ms in our case).<\/p>\n<p>This means that each time the player grabs a Bonus less than 1.5 seconds after the previous one, the next track of the Combo Cue will be played. Once the third track is reached, it will be played for each subsequent bonus, until the Combo is reset. For more information, you can check <a href=\"https:\/\/blog.criware.com\/index.php\/2016\/11\/05\/implement-combo-sfx-in-a-few-clicks\/\">this blog dedicated to the Combo Sequential Cue<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3624\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/03-Combo-Cues.jpg\" alt=\"03 Combo Cues\" width=\"1434\" height=\"623\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/03-Combo-Cues.jpg 1434w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/03-Combo-Cues-300x130.jpg 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/03-Combo-Cues-768x334.jpg 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/03-Combo-Cues-1024x445.jpg 1024w\" sizes=\"auto, (max-width: 1434px) 100vw, 1434px\" \/><\/p>\n<p>The next step is to create a Switch Cue, on which we drop the Combo Cues (one for each key, on a different Track). \u00a0On the music side, we will use our Music Cue and the Music_Key Selector to switch between the tracks. Again, we need to select the Music_Key Selector for the Switch Variable, and then assign each label to the corresponding Track.<\/p>\n<p><i>&#8211; &#8211; Addendum: From version 3.46.06, it is recommended to use Sub-Sequences (of type Combo Sequential in our case) instead of Cue Links inside the Switch Cue if you plan to link that same Switch Cue to an Action as we explain afterward. Both projects are available in the archive linked at the end of the article to reflect this change &#8211; &#8211;<\/i><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3625\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/04-Switch-Cue.jpg\" alt=\"04 Switch Cue\" width=\"1530\" height=\"633\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/04-Switch-Cue.jpg 1530w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/04-Switch-Cue-300x124.jpg 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/04-Switch-Cue-768x318.jpg 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/04-Switch-Cue-1024x424.jpg 1024w\" sizes=\"auto, (max-width: 1530px) 100vw, 1530px\" \/><\/p>\n<p>Note that to play our sounds on the beat, we cannot use the Switch Cue directly, but we have to go through an Action. For example, here we create a new Cue called SFX_Bonus_Cue, as well as an Action Track, and we add a Start Action on this Track. Then, we can drop our Switch Cue directly on that Track to link it to the Action.<\/p>\n<p>Now, if we play the SFX Bonus Cue alongside the Music Cue, it will trigger the sound effects on the beat (it will follow what you set for the Beat Sync Parameter in the Music Cue). Then, when we switch to another key using the Selector, both Music and SFX will follow!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3626\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/05-Action-Track.jpg\" alt=\"05 Action Track\" width=\"886\" height=\"541\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/05-Action-Track.jpg 886w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/05-Action-Track-300x183.jpg 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/05-Action-Track-768x469.jpg 768w\" sizes=\"auto, (max-width: 886px) 100vw, 886px\" \/><\/p>\n<p>&nbsp;<\/p>\n<div style=\"max-width: 800px; margin: 0 auto; margin-bottom: 20px; text-align: center;\"><a style=\"display: block; border: 1px solid #ccc; padding: 20px; max-width: 100%; margin: 0 auto;\" href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2022\/01\/AtomCraft_Project_Sync-SFX-with-Music.zip\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1813\" style=\"display: block; margin: 0 auto;\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2018\/06\/zip.png\" alt=\"zip\" width=\"80\" height=\"78\" \/>Sync_SFX_and_Music<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Some types of gameplays &#8211; for instance puzzles \u2013 are perfect to explore the relationships between sound effects and music.<\/p>\n","protected":false},"author":2,"featured_media":5503,"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-3621","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\/3621","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=3621"}],"version-history":[{"count":7,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/3621\/revisions"}],"predecessor-version":[{"id":5502,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/3621\/revisions\/5502"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media\/5503"}],"wp:attachment":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media?parent=3621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/categories?post=3621"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/tags?post=3621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}