Audio Scripting Questions

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Here is the wonderful & amazing script for your website or fun with maths.
  • Good 'noon!

    I'm new to scripting, but have a good grasp on most areas... except Audio.

    I had a few questions, they will be noobish, enjoy:

    1. What's the difference between using C3's Audio scripting AudioContext, compared to creating a new one entirely?

    2. How much can be read/changed with C3's AudioContext? E.G. Could I change a value of an existing "distortion" effect that I added in C3 event sheets? Could I read the "duration" of a loaded audio buffer?

    3. Could unavailable features be crammed into C3's AudioContext, e.g. "detune": developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/detune (Detune is particularly interesting to me)

    4. I think I understand that "audio tags" are deeply-rooted in C3 rather than being something we can use within Audio scripting, but can any info about tags be gained, whether scripting an "is playing" or scripting "play sound with tags", or must we always make C3 bridge functions to achieve this?

    From historical memory of Ashley's replies, C3 handles a heck-tonne of quirks from the Web Audio API, iirc things like tags, or even getting the playback time, so I am certainly not curious to "make my own audio system", but I do hope to poke with as much as possible.

  • 1. What's the difference between using C3's Audio scripting AudioContext, compared to creating a new one entirely?

    If you use the Audio plugin, Construct creates an AudioContext for that anyway, and so you may as well use the same one. Also Construct's Audio plugin handles all the surprisingly complicated code necessary to ensure that audio playback can be properly unmuted (such as handling unmuting via gamepad input), so you may as well re-use that instead of having to reinvent all that unmuting code.

    2. How much can be read/changed with C3's AudioContext?

    I can't think of any reason why you can't do absolutely anything you want with it. If you want to modify things created via Construct though, that will be tricky as it basically creates its own node graph and doesn't expose anything about that to script.

    3. Could unavailable features be crammed into C3's AudioContext, e.g. "detune"

    From script you can do anything you like with the AudioContext, so yes.

    4. I think I understand that "audio tags" are deeply-rooted in C3 rather than being something we can use within Audio scripting, but can any info about tags be gained, whether scripting an "is playing" or scripting "play sound with tags", or must we always make C3 bridge functions to achieve this?

    Tags exist solely in the Construct Audio plugin. Currently there is no way to interact with that part of Construct via the script API. At the moment the intent is either you play audio with event sheets, or play it via script. You can mix and match those approaches, but you cannot use event sheets to control audio played via script, and vice versa.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Could unavailable features be crammed into C3's AudioContext, e.g. "detune"

    I know what you're after and if I remember correctly detune sadly doesn't actually do it much different than setting the playback rate. It just uses a different unit of measurement. :(

  • Thank you Ashley, very good to know, been exploring more and have learned a lot!

    WackyToaster ... hahahahahha... yes you are correct on what I was looking for. After over year of on-and-off attempts to use detune, I finally figured it out yesterday, and, the disappointment I felt...

    The link explaining detune is vague, it does seem like it is for pitch-shifting without tempo change, but nope, all along, just a variation of playback rate. I cannot believe it.

    On the flip side, I found SoundTouchJS, which allows real-time pitch/tempo shifting, and I managed to get it to work (whether I've implemented it the correct/optimal way, how much it can integrate with Audio plugin or not, who knows... the important thing is, it works!).

    github.com/cutterbl/SoundTouchJS

    I'm on the fence about handling audio entirely through script. It's making sense, so maybe, but then all benefits from Audio plugin, effects, headaches that Scirra already handled for us... Hmm...

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)