Computer Science Canada Game slows down when music is added |
Author: | NikG [ Tue Sep 05, 2006 6:13 pm ] |
Post subject: | 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? |
Author: | Windsurfer [ Tue Sep 05, 2006 6:17 pm ] |
Post subject: | |
Don't play music? Turing sucks! There isn't much you can do when it comes to media, apart from using less. |
Author: | Windsurfer [ Tue Sep 05, 2006 6:18 pm ] |
Post subject: | |
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. |
Author: | NikG [ Tue Sep 05, 2006 6:21 pm ] |
Post subject: | |
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? |
Author: | Windsurfer [ Tue Sep 05, 2006 6:31 pm ] |
Post subject: | |
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% |
Author: | NikG [ Tue Sep 05, 2006 10:37 pm ] |
Post subject: | |
Windsurfer wrote: 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 |
Author: | [Gandalf] [ Wed Sep 06, 2006 3:55 am ] |
Post subject: | |
Windsurfer wrote: 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. |
Author: | Clayton [ Wed Sep 06, 2006 2:32 pm ] |
Post subject: | |
NikG wrote: ...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. |
Author: | NikG [ Wed Sep 06, 2006 6:43 pm ] |
Post subject: | |
SuperFreak82 wrote: NikG wrote: ...any ideas why this is happening or how I can get around it? learn another language? 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... |
Author: | BenLi [ Wed Sep 06, 2006 6:54 pm ] |
Post subject: | |
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. |
Author: | do_pete [ Thu Sep 07, 2006 9:14 am ] |
Post subject: | |
NikG wrote: 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 free sound effects on Google. |
Author: | r.3volved [ Thu Sep 07, 2006 9:45 am ] |
Post subject: | |
Been a long time sinc I touched any turing...does it have threading abilities? or multi-process? |
Author: | Clayton [ Thu Sep 07, 2006 2:35 pm ] |
Post subject: | |
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 here |
Author: | [Gandalf] [ Thu Sep 07, 2006 3:29 pm ] |
Post subject: | |
BenLi wrote: 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. SuperFreak82 wrote: 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 here
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. |
Author: | Clayton [ Thu Sep 07, 2006 4:56 pm ] |
Post subject: | |
ok, i should have rephrased that, processes suck in turing when used improperly |
Author: | [Gandalf] [ Thu Sep 07, 2006 5:05 pm ] |
Post subject: | |
As they would in other languages... |
Author: | NikG [ Fri Sep 08, 2006 7:58 pm ] |
Post subject: | |
BenLi wrote: 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...) |
Author: | [Gandalf] [ Fri Sep 08, 2006 8:04 pm ] | ||
Post subject: | |||
Replace Pic.Merge with picMerge, which is a 4.0.5 feature.
|
Author: | NikG [ Fri Sep 08, 2006 9:53 pm ] | ||
Post subject: | |||
[Gandalf] wrote: Replace Pic.Merge with picMerge, which is a 4.0.5 feature.
Ahhh... now that I have used! So you're saying replacing that (with say picCopy) will speed up my game? I gotta try that!
|
Author: | [Gandalf] [ Sat Sep 09, 2006 7:15 am ] |
Post subject: | |
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. |
Author: | NikG [ Sat Sep 09, 2006 3:11 pm ] |
Post subject: | |
[Gandalf] wrote: 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... |
Author: | Wolf_Destiny [ Sat Sep 09, 2006 4:47 pm ] |
Post subject: | 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 |
Author: | lordroba [ Sat Sep 09, 2006 9:38 pm ] |
Post subject: | |
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. ![]() |
Author: | TokenHerbz [ Sun Sep 10, 2006 10:31 pm ] |
Post subject: | |
that might work for an intro, but i think he wants in in his game, throughout the whole time. |
Author: | Wolf_Destiny [ Mon Sep 11, 2006 2:17 pm ] |
Post subject: | |
Then they could try Lordroba's suggestion: lordroba wrote: 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.
![]() 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. |