2
\$\begingroup\$

I'm working on a simple game built in HTML5 using Construct 2, in which a circle eats other circles; nothing fancy. The idea is that a song plays during the game, starting at a low pitch, and rising as more circles get eaten (which along with increasing movement speed, makes it pretty manic). Construct 2 has a way to set the playback speed for audio tracks (using the .ogg or aac formats for browser support), but passes the actual implementation of setting the speed to the browser used.

Since some browsers use a pitch-preserving algorithm, and others do not, the same HTML5 game may have the desired low to high pitch transition in one browser, but a artifact filled pitch-preserving version in another. I was wondering, then, is there a way to force the playback speed of the audio to act equivalently to a pitch setting, regardless of the browser used?

\$\endgroup\$
2
  • \$\begingroup\$ Not enough data here to be a proper answer, but my best guess is that you're going to have to pick some subset of browsers that you choose to support, confirm that each of them has some form of pitch control (both Mozilla and Chrome, for instance, have extensions that seem at first glance to support this; I haven't checked on at Safari yet), and then build your own polyfill - it's most likely that you won't be able to use Construct 2 for this particular part of your game. One of the hazards of riding the 'bleeding edge'... (which audio shouldn't be, but that's a separate rant!) \$\endgroup\$ May 29, 2014 at 22:33
  • \$\begingroup\$ If you are able to access the raw Javascript and raw audio samples, I could write up an answer about how to do Lanczos-Sinc interpolation so you can stretch the sound in software consistently every time. \$\endgroup\$
    – MickLH
    May 30, 2014 at 2:28

1 Answer 1

1
\$\begingroup\$

If you've not found a way, maybe an alternative could be to make low and high pitch versions of the song, but it may mean bigger file.

\$\endgroup\$
2
  • \$\begingroup\$ +1 for a working solution! Unfortunately, on the platform I'm looking about, the space requirements are pretty strict (mobile, web), so I might need to wait until HTML5 canvas/js implement a more robust set of pitch options. \$\endgroup\$
    – B. Elliott
    May 29, 2014 at 16:40
  • \$\begingroup\$ If space is at a substantial premium then you may want to look at whether you'd be able to go with a shorter snippet of music, but I definitely do back this approach too - relying on playback speed to do your pitch control for (essentially) tension-building runs the risk of degrading the quality of your overall audio experience. Your game will just sound better if you can manually craft multiple versions of your music for the different speeds you need. \$\endgroup\$ May 29, 2014 at 22:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .