Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / SetSoundInstanceRate not working under latest release?

Author
Message
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 23rd Sep 2020 11:32
SetSoundInstanceRate doesn't appear to be working for me - AppGameKit classic 2020.04.30c Can someone confirm? Sound card definitely allows for rate changes.
Lupo4mica37
4
Years of Service
User Offline
Joined: 1st Jun 2020
Location:
Posted: 23rd Sep 2020 13:26 Edited at: 23rd Sep 2020 13:27
Can you please post some code to see how you are using the command SetSoundInstanceRate() and how you generate the sound instance ID?

Also there are certain limitations as to this command, please read THIS.
????????
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 23rd Sep 2020 20:34
Loopme = Loadsound("Waterfall.wav")
PlaySound(Loopme, 100, 1)
Rate# = 0.5

Do
If GetRawKeyState(32) = 1 // Is the space key pressed?
Rate# = Rate# + 0.01
Endif
Print(Rate#)
SetSoundInstanceRate(Loopme, Rate# )
Sync()
Loop
SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 23rd Sep 2020 21:01 Edited at: 23rd Sep 2020 21:03
Looks like you tried to apply your rate value to the base sound index, rather than the active instance playing. Change these lines:

LoopMeInstance=PlaySound(Loopme, 100, 1)

...

SetSoundInstanceRate(LoopMeInstance, Rate# )


You need to apply commands tied to instances to the instance ID of the sound actively playing, rather than the base index you load the sound into. The AppGameKit sound system is pretty powerful in that it handles multiple instances of any sound you play 'on the fly' and on demand. This means you create a new instance ID every time you play a loaded sound so that they can do things like layer automatically without you having to manage multiple base indexes to do the same. So you only have to load a sound once and you can then play it repeatedly any time you need to without forcing a reset of the sound each time. It will play every time you execute a 'PlaySound()' command without clipping or cropping if the sound is already playing.

This does mean there is an extra layer of index management in terms of instances. But the trade off is well worth it to have the kind of capability AppGameKit offers. Just think of the base index you load a sound into as the source and each instance you play as a 'channel' of the sound and manage those instances/channels as needed for copies of the sound being actively played.
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 25th Sep 2020 08:14
Hi SFSW,

Sorry, could have sworn I replied to this?!?! Thanks for super clear help. Sorted - embarrassingly I wasn't noticing that the sound was actually being rate changed, just not enough! :S Thanks for explanation though - I've always been slightly confused about sound instances! The more I use them though, the more I feel we need sprite equivalents!
SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 25th Sep 2020 20:25
Glad you got it sorted out. It can be a bit confusing, but I really appreciate how AppGameKit takes care of multi-channel audio playback so seamlessly and effectively. In much of my earlier work, I would have to load one sound multiple times to achieve the same type of multiple instance playback capability. But with AppGameKit, I can just load it once and play it whenever I need to as many times as I need to and not worry about index limits or bloating memory overhead for redundant loads. It's a fantastic improvement.

I think that applying the same type of system to sprites would provide what the particle system achieves. That is, many instances of the same sprite rendered many times in the same way that the same sound can be played back in many instances (with different volumes and rates).
Lupo4mica37
4
Years of Service
User Offline
Joined: 1st Jun 2020
Location:
Posted: 26th Sep 2020 01:50
How did you get the sound instance rate to change without generating the sound instance integer variable? From personal experience of the equivalent volume command, your code would not change the rate of the sound instance, unless what SFSW suggested was applied. Did you actually debug it using the GetSoundInstanceRate function to find out whether it really did change or you just assumed it changed through audio input?

Whether it works for you or not, for the actual proper functionality of AppGameKit it ought to work properly not unproperly, so in the case it would change the sound instance rate or volume without the instance id being generated, then it would be abnormal behaviour, which ought to be reported to the developers personally.

BTW, I checked your Youtube page, and I must say that is some really nice platformer with some really amazing graphics and animation. Really good work brother!
????????
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 5th Oct 2020 20:04
Thanks for kind words!

Sorry, the actual code was in various functions I call in the game, so I replicated what I had in the game to be easier to read... only I did a bad job! I was infact changing the rate of the instances but just not enough to audibly notice! :S
Lupo4mica37
4
Years of Service
User Offline
Joined: 1st Jun 2020
Location:
Posted: 6th Oct 2020 00:33
You're welcome David. Good it works.
????????

Login to post a reply

Server time is: 2024-11-21 22:41:50
Your offset time is: 2024-11-21 22:41:50