From 3996ccb4e2a0d81500d1b1370b2b97256d1ee465 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 12 Mar 2022 09:53:02 -0500 Subject: added transition and the world music --- res/fmod/.cache/fsbcache/Desktop/53616416.fobj | Bin 0 -> 146752 bytes res/fmod/.cache/fsbcache/Desktop/FC4C960C.fobj | Bin 0 -> 153713 bytes .../{4950f6ef-9130-45d0-8b66-14551c459bf7}.pdc | Bin 0 -> 114800 bytes .../{af885a76-58da-456c-8cb9-d59f9cec6e43}.pdc | Bin 0 -> 114800 bytes ...{45d68279-4042-4001-9cc3-fe7741328d02}.user.xml | 1 + ...{866909f7-fd3a-4782-ac46-cb2091c5fa44}.user.xml | 1 + ...{90a8e470-61b2-4f80-a597-f8c9b0341fab}.user.xml | 37 +++++ res/fmod/Assets/transition2.wav | Bin 0 -> 4304308 bytes .../{4950f6ef-9130-45d0-8b66-14551c459bf7}.xml | 23 +++ .../{45d68279-4042-4001-9cc3-fe7741328d02}.xml | 20 +++ .../{866909f7-fd3a-4782-ac46-cb2091c5fa44}.xml | 23 +++ .../{90a8e470-61b2-4f80-a597-f8c9b0341fab}.xml | 161 +++++++++++++++++++++ src/main.cpp | 8 +- src/muxer.cpp | 58 +++++++- src/muxer.h | 12 ++ 15 files changed, 342 insertions(+), 2 deletions(-) create mode 100644 res/fmod/.cache/fsbcache/Desktop/53616416.fobj create mode 100644 res/fmod/.cache/fsbcache/Desktop/FC4C960C.fobj create mode 100644 res/fmod/.cache/{4950f6ef-9130-45d0-8b66-14551c459bf7}.pdc create mode 100644 res/fmod/.cache/{af885a76-58da-456c-8cb9-d59f9cec6e43}.pdc create mode 100644 res/fmod/.user/Metadata/Event/{90a8e470-61b2-4f80-a597-f8c9b0341fab}.user.xml create mode 100644 res/fmod/Assets/transition2.wav create mode 100644 res/fmod/Metadata/AudioFile/{4950f6ef-9130-45d0-8b66-14551c459bf7}.xml create mode 100644 res/fmod/Metadata/Event/{90a8e470-61b2-4f80-a597-f8c9b0341fab}.xml diff --git a/res/fmod/.cache/fsbcache/Desktop/53616416.fobj b/res/fmod/.cache/fsbcache/Desktop/53616416.fobj new file mode 100644 index 0000000..40284c4 Binary files /dev/null and b/res/fmod/.cache/fsbcache/Desktop/53616416.fobj differ diff --git a/res/fmod/.cache/fsbcache/Desktop/FC4C960C.fobj b/res/fmod/.cache/fsbcache/Desktop/FC4C960C.fobj new file mode 100644 index 0000000..07902ee Binary files /dev/null and b/res/fmod/.cache/fsbcache/Desktop/FC4C960C.fobj differ diff --git a/res/fmod/.cache/{4950f6ef-9130-45d0-8b66-14551c459bf7}.pdc b/res/fmod/.cache/{4950f6ef-9130-45d0-8b66-14551c459bf7}.pdc new file mode 100644 index 0000000..6d4dc10 Binary files /dev/null and b/res/fmod/.cache/{4950f6ef-9130-45d0-8b66-14551c459bf7}.pdc differ diff --git a/res/fmod/.cache/{af885a76-58da-456c-8cb9-d59f9cec6e43}.pdc b/res/fmod/.cache/{af885a76-58da-456c-8cb9-d59f9cec6e43}.pdc new file mode 100644 index 0000000..411de71 Binary files /dev/null and b/res/fmod/.cache/{af885a76-58da-456c-8cb9-d59f9cec6e43}.pdc differ diff --git a/res/fmod/.user/Metadata/Event/{45d68279-4042-4001-9cc3-fe7741328d02}.user.xml b/res/fmod/.user/Metadata/Event/{45d68279-4042-4001-9cc3-fe7741328d02}.user.xml index eb068de..88c7262 100644 --- a/res/fmod/.user/Metadata/Event/{45d68279-4042-4001-9cc3-fe7741328d02}.user.xml +++ b/res/fmod/.user/Metadata/Event/{45d68279-4042-4001-9cc3-fe7741328d02}.user.xml @@ -36,6 +36,7 @@ + diff --git a/res/fmod/.user/Metadata/Event/{866909f7-fd3a-4782-ac46-cb2091c5fa44}.user.xml b/res/fmod/.user/Metadata/Event/{866909f7-fd3a-4782-ac46-cb2091c5fa44}.user.xml index 7815593..1c0f735 100644 --- a/res/fmod/.user/Metadata/Event/{866909f7-fd3a-4782-ac46-cb2091c5fa44}.user.xml +++ b/res/fmod/.user/Metadata/Event/{866909f7-fd3a-4782-ac46-cb2091c5fa44}.user.xml @@ -41,6 +41,7 @@ + diff --git a/res/fmod/.user/Metadata/Event/{90a8e470-61b2-4f80-a597-f8c9b0341fab}.user.xml b/res/fmod/.user/Metadata/Event/{90a8e470-61b2-4f80-a597-f8c9b0341fab}.user.xml new file mode 100644 index 0000000..d743432 --- /dev/null +++ b/res/fmod/.user/Metadata/Event/{90a8e470-61b2-4f80-a597-f8c9b0341fab}.user.xml @@ -0,0 +1,37 @@ + + + + + {6e452d5e-5bf7-4827-af9a-8004e6d36ca1} + + + {ef5c4690-ec80-418a-84de-a4dfd37f138c} + + + + + + + + + + 0.0092614869293602322 + + + + + {8f3e4509-baf7-4882-b9ea-8129db6bdebc} + + + + + + + + + + + + + + diff --git a/res/fmod/Assets/transition2.wav b/res/fmod/Assets/transition2.wav new file mode 100644 index 0000000..138c375 Binary files /dev/null and b/res/fmod/Assets/transition2.wav differ diff --git a/res/fmod/Metadata/AudioFile/{4950f6ef-9130-45d0-8b66-14551c459bf7}.xml b/res/fmod/Metadata/AudioFile/{4950f6ef-9130-45d0-8b66-14551c459bf7}.xml new file mode 100644 index 0000000..6a95627 --- /dev/null +++ b/res/fmod/Metadata/AudioFile/{4950f6ef-9130-45d0-8b66-14551c459bf7}.xml @@ -0,0 +1,23 @@ + + + + + transition2.wav + + + true + + + 44.0999985 + + + 2 + + + 16.262857142857143 + + + {4c4e21c6-cc51-4a2c-b05e-fb67da4f7ed1} + + + diff --git a/res/fmod/Metadata/Event/{45d68279-4042-4001-9cc3-fe7741328d02}.xml b/res/fmod/Metadata/Event/{45d68279-4042-4001-9cc3-fe7741328d02}.xml index f1fb334..06d7d7c 100644 --- a/res/fmod/Metadata/Event/{45d68279-4042-4001-9cc3-fe7741328d02}.xml +++ b/res/fmod/Metadata/Event/{45d68279-4042-4001-9cc3-fe7741328d02}.xml @@ -99,6 +99,9 @@ + + {d7d6bfb3-eb09-4739-815b-34432735d093} + {f14bc47b-e50f-4aee-9792-59f5919a7848} @@ -189,6 +192,23 @@ {07e04557-2cf3-4129-81e4-b053182f1e64} + + + volume + + + -80 + + + 0 + + + -0.577777863 + + + 3019.23145 + + {467c1d30-2bc6-4dbc-a22c-c5a90e4f0efd} diff --git a/res/fmod/Metadata/Event/{866909f7-fd3a-4782-ac46-cb2091c5fa44}.xml b/res/fmod/Metadata/Event/{866909f7-fd3a-4782-ac46-cb2091c5fa44}.xml index 89fb73e..f76b1d1 100644 --- a/res/fmod/Metadata/Event/{866909f7-fd3a-4782-ac46-cb2091c5fa44}.xml +++ b/res/fmod/Metadata/Event/{866909f7-fd3a-4782-ac46-cb2091c5fa44}.xml @@ -112,6 +112,9 @@ + + {9717afe5-fde9-458b-8521-5ffd341d46fd} + {883e01ca-d7e5-4d12-8e8c-0aef033c3390} @@ -241,6 +244,26 @@ {b9682560-6a3d-4266-a362-9c44d0be0f85} + + + volume + + + -80 + + + 0 + + + -0.577777863 + + + 3019.23022 + + + 0.0316919424 + + {8b3bb0b1-2f04-42f1-bf22-caecda4ce070} diff --git a/res/fmod/Metadata/Event/{90a8e470-61b2-4f80-a597-f8c9b0341fab}.xml b/res/fmod/Metadata/Event/{90a8e470-61b2-4f80-a597-f8c9b0341fab}.xml new file mode 100644 index 0000000..91315ac --- /dev/null +++ b/res/fmod/Metadata/Event/{90a8e470-61b2-4f80-a597-f8c9b0341fab}.xml @@ -0,0 +1,161 @@ + + + + + transition + + + 1 + + + {b10a4c1b-72f0-4676-bbef-b450aaa46cb6} + + + {cfb15eaa-432d-4df9-9a07-3a225c72d03e} + + + {141265f9-4c9c-4ca5-87e7-7e782e452f0e} + + + {3fd15b13-7a5e-4116-98a1-67ac72f427a0} + + + {a4cf578c-3cf5-4447-800e-4e1d6fd06043} + + + {6616acb0-2201-43eb-91c4-212bbbddd198} + + + {09db67e2-5f36-45b5-96e2-a230642fafe5} + + + {ef5c4690-ec80-418a-84de-a4dfd37f138c} + + + {a23d2b1c-914e-48d4-8df9-80f6edad6c28} + + + + + {a2b220d8-a415-499a-84ce-c723263b372c} + + + + + {a2b220d8-a415-499a-84ce-c723263b372c} + + + + + {8d461d61-bd25-4cca-94be-3fccce828cd7} + + + {9570e1ee-6afd-4143-9c9f-e1b7819ae3d6} + + + {a028aeaa-4166-48ea-881f-bb967c81e6f1} + + + + + + + {6e452d5e-5bf7-4827-af9a-8004e6d36ca1} + + + {8f3e4509-baf7-4882-b9ea-8129db6bdebc} + + + + + {6e452d5e-5bf7-4827-af9a-8004e6d36ca1} + + + + + {5dca91d8-e6fd-4027-9028-1992d986543d} + + + {d205406a-2c3c-4909-8cdc-db61197df975} + + + {cfb15eaa-432d-4df9-9a07-3a225c72d03e} + + + + + {0c312cc0-360a-48d9-834a-6f448c1f6448} + + + + + + 3 + + + 9 + + + {bf90cdf2-31f3-4500-ae87-e7d7e7ad083b} + + + {4950f6ef-9130-45d0-8b66-14551c459bf7} + + + + + Audio 1 + + + {d187417a-6a8d-43d9-9b7c-e9fb0ede344d} + + + {ff8df20f-7581-4164-a600-a0a47ff48ea0} + + + {a2b220d8-a415-499a-84ce-c723263b372c} + + + + + {f422dcf8-7754-4dab-a09d-d0cf521e6b54} + + + + + + + {80da9461-aed2-4945-bcc2-1cf3d134eee2} + + + {edb78426-fb94-4e1b-ae37-eeba2c3625fb} + + + + + {5910ec09-2558-4f9d-a61a-fb1f2c6a1e9c} + + + + + + + 11.624999999999989 + + + 1 + + + 0.25471893 + + + + + 11.999999999999989 + + + 0 + + + + diff --git a/src/main.cpp b/src/main.cpp index cd1a8c2..1805357 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -419,8 +419,12 @@ void setZoom(Game& game, size_t zoom) game.muxer.setMusicLevel(0); } else if (zoomLevel < 3) { game.muxer.setMusicLevel(1); - } else { + } else if (zoomLevel < 5) { game.muxer.setMusicLevel(2); + } else if (zoomLevel < 7) { + game.muxer.setMusicLevel(3); + } else { + game.muxer.setMusicLevel(4); } } @@ -493,6 +497,7 @@ int main(int, char**) quit = true; } else { losing = LoseState::PoppingLamps; + game.muxer.stopMusic(); } } else if (e.type == SDL_KEYDOWN) { @@ -505,6 +510,7 @@ int main(int, char**) quit = true; } else { losing = LoseState::PoppingLamps; + game.muxer.stopMusic(); } break; diff --git a/src/muxer.cpp b/src/muxer.cpp index 5b09ef8..3450187 100644 --- a/src/muxer.cpp +++ b/src/muxer.cpp @@ -62,9 +62,65 @@ void Muxer::playSoundAtPosition(std::string name, float x, float y) { } void Muxer::setMusicLevel(int level) { - ERRCHECK(exploration_event_->setParameterByName("level", level)); + if (transition_state_ == TransitionState::Pre) { + if (level >= 3) { + transition_state_ = TransitionState::Transition; + ERRCHECK(exploration_event_->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT)); + ERRCHECK(exploration_event_->release()); + + FMOD::Studio::EventDescription* eventDescription = nullptr; + ERRCHECK(system_->getEvent("event:/transition", &eventDescription)); + ERRCHECK(eventDescription->createInstance(&transition_event_)); + ERRCHECK(transition_event_->start()); + } else { + ERRCHECK(exploration_event_->setParameterByName("level", level)); + } + } else if (transition_state_ == TransitionState::Post) { + if (level <= 3) { + ERRCHECK(the_world_event_->setParameterByName("level_full", 0)); + } else { + ERRCHECK(the_world_event_->setParameterByName("level_full", level - 3)); + } + } +} + +void Muxer::stopMusic() { + switch (transition_state_) { + case TransitionState::Pre: { + ERRCHECK(exploration_event_->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT)); + break; + } + case TransitionState::Transition: { + ERRCHECK(transition_event_->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT)); + break; + } + case TransitionState::Post: { + ERRCHECK(the_world_event_->stop(FMOD_STUDIO_STOP_ALLOWFADEOUT)); + break; + } + case TransitionState::Stopped: { + // Do nothing. + break; + } + } + + transition_state_ = TransitionState::Stopped; } void Muxer::update() { + if (transition_state_ == TransitionState::Transition) { + FMOD_STUDIO_PLAYBACK_STATE playbackState; + ERRCHECK(transition_event_->getPlaybackState(&playbackState)); + if (playbackState == FMOD_STUDIO_PLAYBACK_STOPPED) { + transition_state_ = TransitionState::Post; + transition_event_->release(); + + FMOD::Studio::EventDescription* eventDescription = nullptr; + ERRCHECK(system_->getEvent("event:/the_world", &eventDescription)); + ERRCHECK(eventDescription->createInstance(&the_world_event_)); + ERRCHECK(the_world_event_->start()); + } + } + ERRCHECK(system_->update()); } diff --git a/src/muxer.h b/src/muxer.h index f99cce4..b1a5b26 100644 --- a/src/muxer.h +++ b/src/muxer.h @@ -15,6 +15,13 @@ public: using fmod_system_ptr = std::unique_ptr; +enum class TransitionState { + Pre, + Transition, + Post, + Stopped +}; + class Muxer { public: Muxer(); @@ -25,11 +32,16 @@ public: void setMusicLevel(int level); + void stopMusic(); + void update(); private: fmod_system_ptr system_; FMOD::Studio::EventInstance* exploration_event_; + FMOD::Studio::EventInstance* transition_event_; + FMOD::Studio::EventInstance* the_world_event_; + TransitionState transition_state_ = TransitionState::Pre; }; #endif /* end of include guard: MUXER_H_3146C802 */ -- cgit 1.4.1