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.

Newcomers AppGameKit Corner / Help clearing up my understanding of sounds

Author
Message
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 15th Jun 2018 21:45
Have I got my thinking straight here....

When I load a sound... SoundID = Loadsound("sound.wav") it occupies some memory

When I play the sound... ID = Playsound(SoundID) - does that occupy more memory?

Guessing it does (on the sound card?) BUT am I right in saying that when the sound gets to its end, it auto deletes itself and frees up any memory it occupied?

If I then play the sound a few more times...
ID = Playsound(SoundID)
ID = Playsound(SoundID)
ID = Playsound(SoundID)
I'm guessing the same applies and I don't need to do any clean-up afterwards because AppGameKit will delete the sound instances (when they get to their ends) and therefore free up any memory they occupied?

So... when all sounds have got to the end of playing - they all get 'unloaded' and all I have to do it delete the original sound... DeleteSound( SoundID) and I'm back to zero memory used?

So... have I understood it correctly or no?
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
puzzler2018
User Banned
Posted: 16th Jun 2018 11:38
Im not 100% sure - but i beleive

1 - LoadSound adds to memory

2 - Playsound - the O/S and AppGameKit takes care of that for us by playing whats in memory from Load (1) (doesnt use any more memory)

3 - DeleteSound - deletes the memory created by Load (1)

So all you need to worry about is



Hope this helps
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 17th Jun 2018 11:07
OK, cool - thanks.

Makes me think it would be good to have the equivalent sprite commands - where you can spawn a sprite and when it gets to the end of it's animation cycle (or 2..3..4 cycles) it auto-deletes itself.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 17th Jun 2018 17:42
So here's a question then....

If I fire off a sound instance with looping set to yes... and then fire another off, because I don't have an ID for the first.... I have no way of stopping the first sound from playing until I stop ALL the instances playing that sound by doing StopSound(SoundNumber)

I'm wondering if I get this sound thing!
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)
puzzler2018
User Banned
Posted: 17th Jun 2018 18:21 Edited at: 17th Jun 2018 18:23
Errrm interesting suggesting and one to think about that one

If your right in what your foreseeing then there maybe a horrible way round it



This is rough an ready and not tested, but my idea is there
puzzler2018
User Banned
Posted: 17th Jun 2018 18:47
hmmm an interesting idea for something, merge many different music material together - a bit like a DJ disco.

Say -

- load 10 peices of music in an array

- store then length of those peices of each music - 1:45, 1:10, 1:05 etc

- using a timer, when the timer gets to say 10 seconds before the end
- decrease volume 0 of music 1 whilst at the same time start to play music 2 with volume 0 and increase that to 100
- repeat of how many is in the array
- loop back to array 0 and start the music sequence again

Just like they do on the Radio Stations lol they repeat exactly the same songs all day everyday


Errrm - something for later but not for your query but given me a fab idea
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 18th Jun 2018 10:48
Use the instance ID you are given when calling PlaySound(), you delete the entire sound (from memory using the ID given when calling LoadSound()) but stop and play instances of the sound.
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Jun 2018 18:05
I don't see how or why you'd ever have a sound playing without knowing the ID.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 25th Jun 2018 17:35
It was sound instance IDs (that get erased) - but I think I was getting confused by the instance ID and the loaded sound file that is used to generate the sound instances...
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)

Login to post a reply

Server time is: 2024-11-23 04:48:51
Your offset time is: 2024-11-23 04:48:51