{"id":114,"date":"2014-07-23T09:00:49","date_gmt":"2014-07-23T09:00:49","guid":{"rendered":"https:\/\/blogs.scummvm.org\/uruk\/?p=114"},"modified":"2022-05-22T18:51:28","modified_gmt":"2022-05-22T18:51:28","slug":"sounds","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/uruk\/2014\/07\/23\/sounds\/","title":{"rendered":"Sounds"},"content":{"rendered":"<div id=\"post-body-1445278634235623497\" class=\"post-body entry-content\">Hi all! \ud83d\ude42<\/p>\n<p>During the past week, I mostly spend my time with the missing\/badly working sound parts of my engine. The first and most nasty problem I had to solve was that in the original, every animation is blocked while a sound was playing. Clearly, it wasn&#8217;t the case with my version of the game until now. To specify the problem, it&#8217;s not true for every sound, only for the the speech of the characters. To achieve that, I had to add a block to the script parser of the engine, so there won&#8217;t be any action until the actual sound is fully played out. Luckily, that\u00a0<a href=\"https:\/\/github.com\/urukgit\/scummvm\/blob\/cge2\/engines\/cge2\/snail.cpp#L71\" target=\"_blank\" rel=\"noopener\">checking of the blocking flag<\/a>\u00a0was already in the original as well as\u00a0<a href=\"https:\/\/github.com\/urukgit\/scummvm\/blob\/cge2\/engines\/cge2\/snail.cpp#L751\" target=\"_blank\" rel=\"noopener\">the setting of it to true<\/a>. The tricky part was to decide where, when and how to reset this flag. Again, ScummVM&#8217;s very friendly library came to my rescue. In the main loop of the game, I simply have to check the responsible sound handle:<\/p>\n<pre class=\"brush: cpp\">void Sound::checkSoundHandle() {\r\n\u00a0\u00a0\u00a0 if (!_vm-&gt;_mixer-&gt;isSoundHandleActive(_soundHandle))\r\n\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 _smpinf._counter = 0;\r\n}<\/pre>\n<p>As you can see, if it&#8217;s no longer active &#8211; there&#8217;s no sound playing at the moment &#8211; I set the counter back to 0. This counter tells\u00a0<a href=\"https:\/\/github.com\/urukgit\/scummvm\/blob\/cge2\/engines\/cge2\/sound.cpp#L96\" target=\"_blank\" rel=\"noopener\">our LoopingAudioStream instance<\/a>\u00a0how many times it has to loop when playing the given sound, and the script parser checks for this number and doesn&#8217;t do anything if it&#8217;s a positive number.<\/p>\n<p>After this issue fixed, my attention was fully paid to the buttons on the toolbar what are connected to sound manipulation. The &#8220;hard&#8221; part here was not the actual implementation of the buttons, but the fact that I have to pay extra attention to them so they keep in synchronization with ScummVM&#8217;s Launcher&#8217;s and Global Main Menu&#8217;s sound settings.<br \/>\nYou can see the mentioned buttons on the toolbar with a cute pink outline around them on this picture:<br \/>\n<img decoding=\"async\" src=\"https:\/\/blogs.scummvm.org\/uruk\/wp-content\/uploads\/sites\/48\/2022\/05\/vulcaaa.png\" \/><\/p>\n<div class=\"separator\"><\/div>\n<p>Until now, I was only able to achieve complete functionality (and parallel behavior with ScummVM&#8217;s options) with the music on\/off button. (This is the big grey round plate in the middle with a note on it.) Currently, I am working on the speech\/text mode switches (to the right, with two blue arrows above them), so they&#8217;ll take into account the global options in the Launcher regarding speech only\/text only\/both modes.<\/p>\n<p>Besides that, Arnaud is still progressing nicely with the translation. It&#8217;s not far from being complete, but there is still a very nasty blocking bug concerning the dentist&#8217;s scene we are looking at almost constantly.<\/p>\n<p>For the next week, I&#8217;ll finish with the sounds completely, including the two remaining switches on the toolbar. Then I&#8217;ll keep on refactoring the code &#8211; what I already started to do\u00a0<a href=\"https:\/\/github.com\/urukgit\/scummvm\/commit\/cd8b7c0d15ab6dd190a21ed2bc785959a077332d\" target=\"_blank\" rel=\"noopener\">here<\/a>\u00a0and\u00a0<a href=\"https:\/\/github.com\/urukgit\/scummvm\/commit\/a6eb08903351d916d2c243ca031392a5ebd2240a\" target=\"_blank\" rel=\"noopener\">there<\/a>\u00a0-, and fix memory leak issues as well as other persisting bugs. I already paid attention to eliminate all the remaining stubs in the engine, but there are still a bunch of them in the script parser. I plan to take care of these too as soon as possible.<\/p>\n<p>See ya next time! \ud83d\ude09<\/p>\n<div><\/div>\n<\/div>\n<div class=\"post-footer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hi all! \ud83d\ude42 During the past week, I mostly spend my time with the missing\/badly working sound parts of my engine. The first and most nasty problem I had to solve was that in the original, every animation is blocked while a sound was playing. Clearly, it wasn&#8217;t the case with my version of the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-114","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/uruk\/wp-json\/wp\/v2\/posts\/114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/uruk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/uruk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/uruk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/uruk\/wp-json\/wp\/v2\/comments?post=114"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/uruk\/wp-json\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":115,"href":"https:\/\/blogs.scummvm.org\/uruk\/wp-json\/wp\/v2\/posts\/114\/revisions\/115"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/uruk\/wp-json\/wp\/v2\/media?parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/uruk\/wp-json\/wp\/v2\/categories?post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/uruk\/wp-json\/wp\/v2\/tags?post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}