{"id":590,"date":"2019-12-06T07:02:13","date_gmt":"2019-12-06T07:02:13","guid":{"rendered":"https:\/\/projects-old.etc.cmu.edu\/jam-session\/?p=590"},"modified":"2019-12-11T20:55:36","modified_gmt":"2019-12-11T20:55:36","slug":"synchronizing-game-events-to-music","status":"publish","type":"post","link":"https:\/\/projects-old.etc.cmu.edu\/jam-session\/index.php\/2019\/12\/06\/synchronizing-game-events-to-music\/","title":{"rendered":"Synchronizing Game Events to Music"},"content":{"rendered":"\n<p><strong>DISCLAIMER: I AM NOT A PROFESSIONAL PROGRAMMER<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Methods of synchronizing game events to music<\/strong><\/h3>\n\n\n\n<p>We used two methods (actually, a combination of the two) for most of our prototypes.<\/p>\n\n\n\n<p><strong>1. Straight up just keeping track of time (in FMOD or Unity)<\/strong><\/p>\n\n\n\n<p>This is the most straightforward way of programming a rhythm game in Unity, and fizzd\u2019s (developer of Rhythm Doctor) <a href=\"http:\/\/ludumdare.com\/compo\/2014\/09\/09\/an-ld48-rhythm-game-part-2\/\">tutorial<\/a> is a great starting point that we used way back when we were developing Beat\u2019Em for BVW festival. We won\u2019t reiterate what\u2019s in the link because it\u2019s already a brilliantly-written tutorial.<\/p>\n\n\n\n<p><strong>Pros:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Easy to get started! You can make a rhythm game right now!<\/li><li>Can accommodate any typical beatmap- or song-based rhythm game<\/li><\/ul>\n\n\n\n<p><strong>Cons:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Doesn\u2019t easily deal with dynamic BPM changes<ul><li>Unless you have some kind of external data structure that tells you when bpm changes happen<\/li><\/ul><\/li><li>Need to write your own events for beat-responsive objects<\/li><li>We experienced issues in Unity when switching between tracks &#8212; it was hard to debug where and when lag was being introduced that threw our beat-tracking system off<\/li><\/ul>\n\n\n\n<p><strong>Use when:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Making a typical rhythm game, like a Guitar Hero clone<\/li><\/ul>\n\n\n\n<p><strong>2. Use beat\/marker events<\/strong><br><\/p>\n\n\n\n<p>This is a technique that requires some knowledge of middleware, in this case, FMOD. Based on <a href=\"https:\/\/alessandrofama.com\/tutorials\/fmod-unity\/beat-marker-system\/\">tutorial by Alessandro Fam\u00e0<\/a>, we created our beat system script for FMOD integration. It utilizes the FMOD event callbacks for when beats and markers are encountered.\u00a0<\/p>\n\n\n\n<p>By assigning this beat system script to each \u2018track\u2019, we then can subscribe to OnBeat\/OnMarker event and \u2018listen\u2019 to particular cues as beats or markers in different tracks (event) from any other script in the project. It also allows us to access Timeline information (can be extended by modifying \u2018TimelineInfo\u2019 class) from FMOD like bpm, timelinePosition, markerPosition as public attributes.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/9rW6Wnk5hHgEQEXWHcgNpiYSNrwUw2OuWZv76GgmDV4qUQMOkN_sfCHyXSjFFlrF1eLXhrNCarW4dMzYluas8j4ETadeciYtg5n7xpqAysnC3F-iMAHWmVCRUnBQm_TnoeS6zvpQ\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Pros:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Precise way of keeping track of beats<\/li><li>Very easy to start spawning things to the beat<\/li><li>Easy workflow if your beatmapper is also your composer<\/li><li>No need for an external data structure to store beatmaps<\/li><\/ul>\n\n\n\n<p><strong>Cons:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>You still have to use techniques from (1), especially when trying to incorporate look-ahead<ul><li>If you want to pre-load your beatmap for some reason (e.g. filling the pipes in <em>Chopin Beets<\/em>) you still need some kind of data structure for the beatmap<\/li><li>For offset: play a silent version of the track with markers before the actual track, use the offset markers to spawn things<\/li><\/ul><\/li><li>Markers are just strings &#8212; pretty limiting if you have a wide variety of cues or cue positions, or if cues need to store a bunch of data (e.g. Kinectic\u2019s linked cues)<\/li><li>There\u2019s more work\/space for your sound designer\/engineer who will work in FMOD to create events with correct timeline information. (It can be a pro if you have a great sound designer like we do!)<\/li><\/ul>\n\n\n\n<p>Use when:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Making a beat-responsive world game that doesn\u2019t require players to perform beat-constrained actions<\/li><\/ul>\n\n\n\n<p>A combination of both methods is what we used most of the time. While it was very tempting to start using method 2 exclusively once we got the system working, the fact of the matter is that rhythm games always benefit from the implementation of some sort of look-ahead, and you can be more flexible with your look-ahead if you don\u2019t solely base your game on beat events.<\/p>\n\n\n\n<p>There are other methods too, e.g. parsing a MIDI file in Unity. We didn\u2019t try this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>DISCLAIMER: I AM NOT A PROFESSIONAL PROGRAMMER Methods of synchronizing game events to music We used two methods (actually, a combination of the two) for most of our prototypes. 1. Straight up just keeping track of time (in FMOD or [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-590","post","type-post","status-publish","format-standard","hentry","category-analysis","col-lg-4 col-md-6"],"_links":{"self":[{"href":"https:\/\/projects-old.etc.cmu.edu\/jam-session\/index.php\/wp-json\/wp\/v2\/posts\/590"}],"collection":[{"href":"https:\/\/projects-old.etc.cmu.edu\/jam-session\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/projects-old.etc.cmu.edu\/jam-session\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/projects-old.etc.cmu.edu\/jam-session\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/projects-old.etc.cmu.edu\/jam-session\/index.php\/wp-json\/wp\/v2\/comments?post=590"}],"version-history":[{"count":1,"href":"https:\/\/projects-old.etc.cmu.edu\/jam-session\/index.php\/wp-json\/wp\/v2\/posts\/590\/revisions"}],"predecessor-version":[{"id":591,"href":"https:\/\/projects-old.etc.cmu.edu\/jam-session\/index.php\/wp-json\/wp\/v2\/posts\/590\/revisions\/591"}],"wp:attachment":[{"href":"https:\/\/projects-old.etc.cmu.edu\/jam-session\/index.php\/wp-json\/wp\/v2\/media?parent=590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/projects-old.etc.cmu.edu\/jam-session\/index.php\/wp-json\/wp\/v2\/categories?post=590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/projects-old.etc.cmu.edu\/jam-session\/index.php\/wp-json\/wp\/v2\/tags?post=590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}