This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-10-25 22:58:14

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Random instrument notes slo-o-ow my project down! -Never before.

My recent project "Walking" has bugs that appear and start to land on one of the walkers. I chose an instrument and set it to play random notes between pitch 70 - 90 for 0.1 beats each. At first everything is really fast, but by the time about 5 bugs have landed the notes start to slow down, and the bugs seem to fly more slowly.  ___I've never had this problem in any of the dozen projects I've created using similar randomized instrumental notes. ______If you're kind enough to look at the scripts, please remember that they have to be written to take account of the fact that *you can't be sure which bug is going to be the last to land*!!  That's why I have my pile of "When clicked" scripts waiting for *each* bug sprite to land before incrementing the "bug count" that will trigger the later action in the story.  But that may be part of the problem....  Here's the link: http://scratch.mit.edu/projects/Larry828/732244  ___Any help would be greatly appreciated: I'm unhappy when I don't understand how to program something!  :-/  Thanks!

Offline

 

#2 2009-10-26 10:15:39

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Re: Random instrument notes slo-o-ow my project down! -Never before.

Quick update: I moved the 'sound' scripts from a tiny direction-setting sprite (for the bugs) to the Stage in hopes it might help the sound execute faster....but no advantage I can see.

Offline

 

#3 2009-10-26 13:29:11

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Re: Random instrument notes slo-o-ow my project down! -Never before.

This is quite an active topic!!  :-)

Could it be that having 8 bugs randomly active (flying and flapping) at the same time, plus the randomized note-playing, is too burdensome?  I may try a rewrite using only 4 active bugs, two of which leave stamps of themselves. But I'll have to explore exactly what is "stamped" when it happens.

Thanks, Larry828, for continuing to explore what's wrong with the scripts!  :-)

Offline

 

#4 2009-10-26 13:32:06

Mr_X
Scratcher
Registered: 2009-09-10
Posts: 1000+

Re: Random instrument notes slo-o-ow my project down! -Never before.

Yo. Talkin' to yourself?


http://img99.imageshack.us/img99/8656/exveemonc.gif The rules of the internet:
1) Every woman is a man    2) Every man is a child    3) Every child is an FBI agent                                        I have psychopathic tendencies. Be afraid

Offline

 

#5 2009-10-26 13:42:51

samurai768
Scratcher
Registered: 2009-07-21
Posts: 1000+

Re: Random instrument notes slo-o-ow my project down! -Never before.

lol Mr_X
I is an FBI agent

Offline

 

#6 2009-10-26 13:54:34

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Re: Random instrument notes slo-o-ow my project down! -Never before.

Mr_X wrote:

Yo. Talkin' to yourself?

I was starting to get that feeling, but now you've added to the topic so it's getting better!  :-)

Offline

 

#7 2009-10-26 14:31:09

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Random instrument notes slo-o-ow my project down! -Never before.

Yeah, one of the biggest issues I have about the online scratch player is the way huge lag is created when sound is played. This doesn't seem to be much of a problem when the project is run offline in presentation mode though. In the online player, every sound creates a considerable amount of lag and having a large sound playing or a series of small sounds playing will dramatically increase lag.

In short, playing sound files in the online player creates a lot of lag and there is nothing you can do about it.

What I would do to lessen the lag is:
1. Give the sound blocks their own forever loop and seperate them from as much as the rest of the code as possible
2. Play sounds at greater intervals (less sound playing every second = less lag)

If you have really reduced the amount of sound in your project and there is still no difference in performance, then there is probably a problem with your scripts. To test for this, just take out the sound and check for difference.

Last edited by archmage (2009-10-26 14:38:03)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#8 2009-10-26 15:14:33

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Re: Random instrument notes slo-o-ow my project down! -Never before.

archmage wrote:

Yeah, one of the biggest issues I have about the online scratch player is the way huge lag is created when sound is played. This doesn't seem to be much of a problem when the project is run offline in presentation mode though. In the online player, every sound creates a considerable amount of lag and having a large sound playing or a series of small sounds playing will dramatically increase lag.

In short, playing sound files in the online player creates a lot of lag and there is nothing you can do about it.

What I would do to lessen the lag is:
1. Give the sound blocks their own forever loop and seperate them from as much as the rest of the code as possible
2. Play sounds at greater intervals (less sound playing every second = less lag)

If you have really reduced the amount of sound in your project and there is still no difference in performance, then there is probably a problem with your scripts. To test for this, just take out the sound and check for difference.

Thanks for your analysis of the whole problem. In the meantime I had changed the project so that instead of keeping 8 bugs randomly flapping even after they landed on the walker, only 2 of them were left flapping (for looks).  That seems to have reduced the demands on both my computer and online. 

I certainly agree with you that increasing the intervals would also have solved the problem, now that I look at your comment. 

It's very gratifying to have someone as famous as archmage comment on one's forum post!  I see your name everywhere, and it's well deserved.  Thanks so much for taking time to think about my project and send your conclusions. 

And, yes, the Scratch player does create lots of lag online. But the way I had written my scripts only made it worse. But I don't give up easily...  :-)

Thanks again, archmage!!

Offline

 

Board footer