
-----------------------------------
NikG
Tue Sep 05, 2006 6:13 pm

Game slows down when music is added
-----------------------------------
I just tried adding some background music to my rts game and I noticed a HUGE reduction in the framerate (from 40+ to 6 fps!).  I expected some lag but not this much!
All I did was add the Music.PlayFileLoop command... any ideas why this is happening or how I can get around it?

-----------------------------------
Windsurfer
Tue Sep 05, 2006 6:17 pm


-----------------------------------
Don't play music?
Turing sucks! There isn't much you can do when it comes to media, apart from using less.

-----------------------------------
Windsurfer
Tue Sep 05, 2006 6:18 pm


-----------------------------------
Don't play music?
Turing sucks! There isn't much you can do when it comes to media, apart from using less.

Okay, actually, i hear playing midis are easier on a machine than mp3s or wavs, but i didn't notice much difference.

-----------------------------------
NikG
Tue Sep 05, 2006 6:21 pm


-----------------------------------
Actually, I was using a midi.

If you don't mind my asking, Windsurfer, how did you manage to get around this problem in Forces?

-----------------------------------
Windsurfer
Tue Sep 05, 2006 6:31 pm


-----------------------------------
I didn't get around it... Forces still runs slow, by my standards. I'm still using Music.PlayFileReturn() to play anything. It's just that the rest of my program uses little resources.

I just remembered, though... What version of Turing are you using? I hear 4.1 may speed up displaying of images and sound by up to 50%

-----------------------------------
NikG
Tue Sep 05, 2006 10:37 pm


-----------------------------------
What version of Turing are you using? I hear 4.1 may speed up displaying of images and sound by up to 50%Darn! 4.0.5

-----------------------------------
[Gandalf]
Wed Sep 06, 2006 3:55 am


-----------------------------------
I hear 4.1 may speed up displaying of images and sound by up to 50%
It seems everyone thinks there is some magical speed boost in Turing 4.1...  It increased the speed of images in certain situations (ie. by using GIFs instead of BMPs with Pic.SetTransperentColour), not sounds, or even graphics in general.

-----------------------------------
Clayton
Wed Sep 06, 2006 2:32 pm


-----------------------------------

...any ideas why this is happening or how I can get around it?


learn another language?

there's really nothing to do the help with lag issues when dealing with media in turing, your best bet is to just take out music altogether.

-----------------------------------
NikG
Wed Sep 06, 2006 6:43 pm


-----------------------------------

...any ideas why this is happening or how I can get around it?


learn another language?Haha.  Well I'm not about to convert my rts into another language anytime soon (if ever) so I guess I'll have to settle for no background music.

I know I've seen this question asked before, but is there a site where I can get some decent sound effects for my game?  Guns firing, explosions, cheers (like when you finish a mission in C&C) and the like...

-----------------------------------
BenLi
Wed Sep 06, 2006 6:54 pm


-----------------------------------
a suggestion actually. You should check other things and not only the playing music command. For example in last year's final project, I acheived an enormous increase in frame rate when i simply took out the Pic.Merge commands and re-ordered the code.

-----------------------------------
do_pete
Thu Sep 07, 2006 9:14 am


-----------------------------------
I know I've seen this question asked before, but is there a site where I can get some decent sound effects for my game?  Guns firing, explosions, cheers (like when you finish a mission in C&C) and the like...Just search [url=http://www.google.ca/search?hl=en&q=free+sound+effects&meta=]free sound effects on Google.

-----------------------------------
r.3volved
Thu Sep 07, 2006 9:45 am


-----------------------------------
Been a long time sinc I touched any turing...does it have threading abilities? or multi-process?

-----------------------------------
Clayton
Thu Sep 07, 2006 2:35 pm


-----------------------------------
um for general purposes, NO!

however, if you have a program, or wish to make a program where multi-threading is absolutely necessary then yes there *is*, but if you plan to multi-thread in turing, dont be surprised when you come up with many, many problems, this is because processes in turing suck, if you need more info go [url=http://compsci.ca/v2/viewtopic.php?t=7842]here

-----------------------------------
[Gandalf]
Thu Sep 07, 2006 3:29 pm


-----------------------------------
I acheived an enormous increase in frame rate when i simply took out the Pic.Merge commands and re-ordered the code.
Indeed, Pic.Merge is probably the single slowest feature of Turing...  Well, close to it.

however, if you have a program, or wish to make a program where multi-threading is absolutely necessary then yes there *is*, but if you plan to multi-thread in turing, dont be surprised when you come up with many, many problems, this is because processes in turing suck, if you need more info go 
Actually, processes are.. decent for multi threading.  The problem is that threads are simply not the way to go for most of the problems that people post.

-----------------------------------
Clayton
Thu Sep 07, 2006 4:56 pm


-----------------------------------
ok, i should have rephrased that, processes suck in turing when used improperly

-----------------------------------
[Gandalf]
Thu Sep 07, 2006 5:05 pm


-----------------------------------
As they would in other languages...

-----------------------------------
NikG
Fri Sep 08, 2006 7:58 pm


-----------------------------------
a suggestion actually. You should check other things and not only the playing music command. For example in last year's final project, I acheived an enormous increase in frame rate when i simply took out the Pic.Merge commands and re-ordered the code.Is that a Turing 4.1 command?  Cuz as I said before, I have Turing 4.0.5.

And, as I've also said before, I'm achieving 40+ fps without the music, which to me is very good.  Since with music it's dropping to below 10, I'd need an increase of over 30 fps, which I'm not sure is possible.  (Even if it was I'd then have to implement a frame limiter so that it doesn't go too fast...)

-----------------------------------
[Gandalf]
Fri Sep 08, 2006 8:04 pm


-----------------------------------
Replace Pic.Merge with picMerge, which is a 4.0.5 feature.

Pic.Draw (picID, x, y, picMerge)

-----------------------------------
NikG
Fri Sep 08, 2006 9:53 pm


-----------------------------------
"]Replace Pic.Merge with picMerge, which is a 4.0.5 feature.

Pic.Draw (picID, x, y, picMerge)Ahhh... now that I have used!  So you're saying replacing that (with say picCopy) will speed up my game?  I gotta try that!

-----------------------------------
[Gandalf]
Sat Sep 09, 2006 7:15 am


-----------------------------------
Oh it most definately will, but a heck of a lot.  The problem is, unless you have 4.1 with GIFs, you won't be able to use transparency at all without picMerge.

-----------------------------------
NikG
Sat Sep 09, 2006 3:11 pm


-----------------------------------
"]Oh it most definately will, but a heck of a lot.  The problem is, unless you have 4.1 with GIFs, you won't be able to use transparency at all without picMerge.Thanks Gandalf... I need the transparency effect so I guess that doesn't work for me.

But I was just surprised to realize that in my entire code, I only use  picUnderMerge twice and picMerge once.  The speed increase was about 10 fps when I changed those 3 to picCopy, so I still wouldn't be able to play bg music even if I could use picCopy...

-----------------------------------
Wolf_Destiny
Sat Sep 09, 2006 4:47 pm

Back to the sound issue...
-----------------------------------
Anyways going back to the sound issue...
Try using >  Sys.Exec ("path/to/file/filename.mp3")  < to use the default external program to play the music. I made a quick Tic-Tac-Toe game last year and added music in this way to an animated intro. The only lag is the actual opening of the file. (The user also has to switch back to the window, but...like people have said, it is Turing [although there may be a way to do this that I don't know, I have 4.0.3 and trying to set the window as the active one doesn't work, and neither does hiding and showing it])

Hmm, most of what I said was in brackets, meh...
~Wolf_Destiny

-----------------------------------
lordroba
Sat Sep 09, 2006 9:38 pm


-----------------------------------
To reduce lag, you could try doing what I did with my Tactics game.  You simply open another window to play your music in, and then switch back to the main window right after.  It doesn't always help, but you can always give it a try.  :D

-----------------------------------
TokenHerbz
Sun Sep 10, 2006 10:31 pm


-----------------------------------
that might work for an intro, but i think he wants in in his game, throughout the whole time.

-----------------------------------
Wolf_Destiny
Mon Sep 11, 2006 2:17 pm


-----------------------------------
Then they could try Lordroba's suggestion:
To reduce lag, you could try doing what I did with my Tactics game.  You simply open another window to play your music in, and then switch back to the main window right after.  It doesn't always help, but you can always give it a try.  :D
And use a looping process (Don't kill me!!) to run the music. The process would set the other window as active, play the music, hide the window, wait, show the window, set it as active, play the music...lather, rinse, repeat as needed.
