{"id":556,"date":"2011-09-14T19:00:00","date_gmt":"2011-09-14T18:00:00","guid":{"rendered":"http:\/\/shadowcovenant.com\/blog\/2011\/09\/14\/sound-woes\/"},"modified":"2011-09-14T19:00:00","modified_gmt":"2011-09-14T18:00:00","slug":"sound-woes","status":"publish","type":"post","link":"http:\/\/shadowcovenant.com\/blog\/2011\/09\/14\/sound-woes\/","title":{"rendered":"Sound woes&hellip;"},"content":{"rendered":"<p align=\"justify\">My artist has been ill these last couple of weeks, and as such I\u2019ve done nothing on \u201cAmoeba\u201d lately\u2026 It\u2019s hard staying motivated when working alone on a project (at least for me).<\/p>\n<p align=\"justify\"><a href=\"http:\/\/shadowcovenant.com\/blog\/wp-content\/uploads\/2011\/09\/sample01.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"sample01\" border=\"0\" alt=\"sample01\" src=\"http:\/\/shadowcovenant.com\/blog\/wp-content\/uploads\/2011\/09\/sample01_thumb.jpg\" width=\"591\" height=\"395\" \/><\/a><\/p>\n<p align=\"justify\">Anyway, since he\u2019s back I decided I should try and get this game finished (still don\u2019t know what I\u2019ll do about the music and from the commercial perspective)\u2026 <\/p>\n<p align=\"justify\">The main thing on this project (for me at least) is getting experience on mobile platforms, and to release this on multiple platforms (first on iPhone, Android and PC, then Mac\/Linux, and finally WM7), and that part of the plan has been working as intended \u2013 although only really experimenting on Android and PC).<\/p>\n<p align=\"justify\">As I\u2019ve said before, I\u2019m using Marmalade to be able to build the game using my existing engine, Spellbook. So far, it\u2019s been a pretty decent experience, I\u2019m using Spellbook to build the game itself, and I just have a very thin abstraction layer that wraps Marmalade, but has the same interface as my main deployment platform (DX9+FMOD+DirectInput).<\/p>\n<p align=\"justify\">But, alas, finally I\u2019ve found problems, with the sound component. The sound API of Marmalade is very poor (understandable, since it\u2019s not very important in the mobile market), and only supports 16-bit PCM RAW files. This requires you to know the sample rate of all the sounds when you play them out (instead of loading that information from the WAV header or something). Of course, this is not the focus of Marmalade, but since they wasted so much time on the graphics APIs, they could have been as complete in the sound API). They have support for compressed audio, but only for the streaming API.<\/p>\n<p align=\"justify\">This is particularly bad for someone like me, that\u2019s been using <a href=\"http:\/\/www.fmod.org\/\">FMod<\/a> for ages, and I\u2019m used to just loading samples with one call, and playing them with another\u2026<\/p>\n<p align=\"justify\">Anyway, it\u2019s relatively simple to do a WAV or some other uncompressed format loader, but for \u201cAmoeba\u201d I can skip that and use RAW files playing at 22Khz\u2026 I\u2019ll have to change this for the PC version (which can use FMod), but for now it\u2019s good enough.<\/p>\n<p align=\"justify\">The real problem I\u2019m having is not related to Marmalade, but with the sound system of the Android handhelds\u2026 There\u2019s a huge latency between the call to the sound player and the actual sound playing (in some cases, almost one second). Some searches online lead me to believe that this is a problem with Samsung mobiles, but it\u2019s a serious flaw, since even 200 ms lag time in a game can make everything look much worse\u2026 I\u2019ve even ran \u201c<a href=\"http:\/\/www.rovio.com\/index.php?page=angry-birds\">Angry Birds<\/a>\u201d on my Samsung S, and although I didn\u2019t notice it before (it\u2019s subtle in the case of that game), there\u2019s a delay present aswell, so I believe it is unavoidable\u2026 Going to try it on a Google Nexus phone in some days to see if the problem is exclusive to Samsung\u2019s implementation of Android\u2026 if so, I\u2019ll have to rethink sound in the game, since it can become annoying, doing things and getting the sound feedback 200-500 ms later\u2026<\/p>\n<p align=\"justify\">On other notes, I\u2019ve also did some memory profiling, trying to see if I have memory leaks or anything, but I found a problem that got me stumped\u2026 According to the ARM emulator, I have about 4 Mb allocated (plus another 4 Mb on OpenGL textures), but my task manager on the Android shows about 40 Mb allocated (more precisely, when I close the application, I get about 40 Mb back). I\u2019m not sure if the Android stack pre-allocates some amount of memory, even if I don\u2019t use it, and I maybe can adjust that on the manifest (saving that for later in the project); but I\u2019m very sure that I don\u2019t allocate 40 Mbs of data on my game!<\/p>\n<p align=\"justify\">But hey, no memory leaks! <img decoding=\"async\" style=\"border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none\" class=\"wlEmoticon wlEmoticon-smile\" alt=\"Smile\" src=\"http:\/\/shadowcovenant.com\/blog\/wp-content\/uploads\/2011\/09\/wlEmoticon-smile1.png\" \/><\/p>\n<div id=\"tweetbutton556\" class=\"tw_button\" style=\"\"><a href=\"http:\/\/twitter.com\/share?url=http%3A%2F%2Fshadowcovenant.com%2Fblog%2F2011%2F09%2F14%2Fsound-woes%2F&amp;text=Sound%20woes%26hellip%3B&amp;related=&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fshadowcovenant.com%2Fblog%2F2011%2F09%2F14%2Fsound-woes%2F\" class=\"twitter-share-button\"  style=\"width:55px;height:22px;background:transparent url('http:\/\/shadowcovenant.com\/blog\/wp-content\/plugins\/wp-tweet-button\/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;\">Tweet<\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>My artist has been ill these last couple of weeks, and as such I\u2019ve done nothing on \u201cAmoeba\u201d lately\u2026 It\u2019s hard staying motivated when working alone on a project (at least for me). Anyway, since he\u2019s back I decided I should try and get this game finished (still don\u2019t know what I\u2019ll do about the [&hellip;]<\/p>\n<div id=\"tweetbutton556\" class=\"tw_button\" style=\"\"><a href=\"http:\/\/twitter.com\/share?url=http%3A%2F%2Fshadowcovenant.com%2Fblog%2F2011%2F09%2F14%2Fsound-woes%2F&amp;text=Sound%20woes%26hellip%3B&amp;related=&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fshadowcovenant.com%2Fblog%2F2011%2F09%2F14%2Fsound-woes%2F\" class=\"twitter-share-button\"  style=\"width:55px;height:22px;background:transparent url('http:\/\/shadowcovenant.com\/blog\/wp-content\/plugins\/wp-tweet-button\/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;\">Tweet<\/a><\/div>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[60,23,6],"tags":[],"class_list":["post-556","post","type-post","status-publish","format-standard","hentry","category-amoeba","category-development","category-games"],"_links":{"self":[{"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/posts\/556","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/comments?post=556"}],"version-history":[{"count":0,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/posts\/556\/revisions"}],"wp:attachment":[{"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/media?parent=556"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/categories?post=556"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/tags?post=556"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}