This site requires JavaScript, please enable it in your browser!
Greenfoot back
EduandErnst
EduandErnst wrote ...

2015/3/23

Sound Issus

EduandErnst EduandErnst

2015/3/23

#
Hi there, I'm currently facing a problem with my background sound file. I coded it like that.
Greenfoot.playSound("track.mp3");
and it works fine for the moment, but after like 1 min in the game, the game becomes very laggy. I once had the same issue with my pictures, I solved it with setting it final in the field like that.
public static final GreenfootImage picture1 = new GreenfootImage("picture.png");
and I've heard that there is a similar way to do this with sound files, but couldn't find a proper solution so far. The sound file I'm using is .mp3 (3.5Mb) and I've removed all the tags. I also tried it with a .wav file, but it doesn't work either.
danpost danpost

2015/3/23

#
When you comment out the 'playSound' line, does the lag in the game disappear?
EduandErnst EduandErnst

2015/3/23

#
Yes, but in this case I have no more sound
danpost danpost

2015/3/23

#
EduandErnst wrote...
Yes, but in this case I have no more sound
Then it is not a sound issue. It is either excessive image creating/manipulating or excessive actor creating. Stop the scenario after lag shows up and right click the world and select the inherited World method 'numberOfObjects' and see what is returned.
EduandErnst EduandErnst

2015/3/23

#
It says 40, is that too much?
danpost danpost

2015/3/23

#
EduandErnst wrote...
It says 40, is that too much?
Only if most of them are updating their images constantly. May have to go through each of your act methods to see what is going on. If you want to go through each one, start with your world class code.
EduandErnst EduandErnst

2015/3/23

#
There is only one actor that is animated, everything else is at a fixed location with default image settings. Well I'm using your "srcolling Superworld", is there something I need to add for sound?
Super_Hippo Super_Hippo

2015/3/23

#
danpost wrote...
EduandErnst wrote...
Yes, but in this case I have no more sound
Then it is not a sound issue. It is either excessive image creating/manipulating or excessive actor creating.
Why exactly isn't it a sound problem if the problem stops when the sound is commented out?
EduandErnst EduandErnst

2015/3/23

#
Actually I just figured out "why" it's lagging ... my 8*4.6GHz Prozessor is running at a 100% when I play the game..^^ something is wrong :( When I comment out the "playsound", it is at 8%..
Super_Hippo Super_Hippo

2015/3/23

#
Do you start the music only once?
EduandErnst EduandErnst

2015/3/23

#
No indeed I start it every act cycle. How do I create the sound in the World class? Storing it like
GreenfootSound track1 = new GreenfootSound("background.mp3");
but how would I create it?
EduandErnst EduandErnst

2015/3/23

#
Ah ok.. solved it. Thanks for the great help :)
danpost danpost

2015/3/23

#
Super_Hippo wrote...
Why exactly isn't it a sound problem if the problem stops when the sound is commented out?
Sorry, when I was answering that, I was thinking the opposite case (the problem remaining instead of disappearing).
You need to login to post a reply.