Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Sign in to follow this  
WoohaDude

se_play causing frame skips

Recommended Posts

My question's fairly simple. I'm using a script that lets you play a sound on each "footstep." Very very simple script, but I get a slight delay or skip every time a SE is played. I'm assuming this is a RPG Maker issue, and that there's nothing you can do about it.

 

On a related note, anybody know what's up with windows 7 and playing midi files? I get like a 10 second delay while it's .. buffered? Fairly annoying. Good thing I'm mixing all the midi files I'm using into symphonic orchestra mp3 versions xD.

 

 

Edit: Got it figured out. Needed to be playing .wav instead of .mp3. Not sure why, but frame delay is now completely gone.

Edited by WoohaDude

Share this post


Link to post
Share on other sites

Well when you have a question with a script, it's always a good idea to post it.

 

Use the following tags:

 

[spoiler][code]
Insert script here
[/ code][/spoiler]

 

As for the footsteps problem, Kevin.ds has a nice system setup in his game, so see if you can get him to tell you how he did it. I'll direct him to this topic if I see him online. :3

Share this post


Link to post
Share on other sites

I evented my step sound thingie by making use of terrain tags , if you would like to know how let me know.

Edited by Kevin.ds

Share this post


Link to post
Share on other sites

Hey guys. Alright, I'll post the script. It's def the Audio.se_play that's causing the frame skip .. and it is fairly minor, but I can foresee the slight delay giving me a headache after a while lol. Also, having NPCs also make sounds is def going to add lag. I just added it, for now, to see "how" much lag it'd make.

 

 

#===============================================================================

# Terrain Step Sound

# Version 1.1

# Author game_guy

#-------------------------------------------------------------------------------

# Intro:

# Create nice aesthetics with terrain noise. As you walk across grass or sand,

# let it play a beautiful noise to add to the atmosphere and realism of the

# game.

#

# Features:

# Specific Sound for Each Terrain

# Specific Sounds for Each Tileset

# Specify Volume and Pitch

#

# Instructions:

# Setup the config below, its pretty self explanatory, more instructions

# with config.

#

# Credits:

# game_guy ~ For creating it

# Tuggernuts ~ For requesting it a long time ago

# Sase ~ For also requeseting it

#===============================================================================

module TSS

 

attr_accessor :Environment

 

# In Frames Recommended 5-10

Wait = 18

# Ignore the next 2 lines

Terrains = []

Tilesets = []

@Environment = ''

#===========================================================================

# Enter in sounds for each terrain tag

# Goes from 0-8. Set as nil to disable that terrain or delete the line.

#===========================================================================

Terrains[0] = nil

Terrains[1] = ['walk_grass_1','walk_grass_2','walk_grass_3', 'walk_grass_4']

Terrains[2] = ['walk_dirt_1','walk_dirt_2', 'walk_dirt_3', 'walk_dirt_4']

Terrains[3] = ['walk_stone_1','walk_stone_2', 'walk_stone_3']

Terrains[4] = ['walk_wood_1','walk_wood_2', 'walk_wood_3', 'walk_wood_4']

Terrains[5] = ['walk_dirt_1_cave','walk_dirt_2_cave', 'walk_dirt_3_cave', 'walk_dirt_4_cave']

Terrains[6] = ['walk_bridge_1','walk_bridge_2','walk_bridge_3', 'walk_bridge_4']

Terrains[7] = nil

#===========================================================================

# If you would like to specifiy a volume and pitch, simply set the

# terrain as an array.

# Terrains[7] = ["sound", volume, pitch]

# Just set it as a string if you would like the volume to be at 100 and

# pitch at 0.

# This also applies for tilesets below.

#===========================================================================

#Terrains[7] = ["sound", 80, 10]

#===========================================================================

# With tilesets, you can set specific sounds for each tileset so you don't

# have the same sounds. Add a new line and put

# Tilesets[tileset id] = []

# Then for each terrain put

# Tilesets[tileset id][terrain id] = "sound file"

# If a sound doesn't exist for a tileset, it will play a default sound,

# if a default doesn't exist, no sound at all.

#===========================================================================

Tilesets[1] = []

Tilesets[1][0] = "Sound"

Tilesets[1][1] = ["sound", 75, 50]

end

 

 

 

#===========================================================================

# ** Environment Type ***

# Set this if you want to specify an "environment".

# will append type to the SE. IE .. type = 'cave', SE = 'grass_1_cave'

#===========================================================================

$TSSEnvironment = ''

 

def setTSSEnvironment(type = '')

if type == ''

$TSSEnvironment = ''

else

$TSSEnvironment = '_' + type

end

end

 

 

class Game_Map

def terrain_sound(event)

if TSS::Tilesets[@map.tileset_id] != nil

return TSS::Tilesets[@map.tileset_id][event.terrain_tag]

else

return TSS::Terrains[event.terrain_tag]

end

return nil

end

end

 

 

class Game_Event

attr_accessor :step_sound

end

 

class Sprite_Character

 

alias TSS_init initialize

 

def initialize(viewport, character = nil)

 

# Check to see if this event wants stepping sounds

if (character.is_a?(Game_Event) and character.list != nil)

for i in 0...character.list.length

if character.list[i].code == 108 and character.list[i].parameters[0] == "stepsound"

character.step_sound = true

break

else

character.step_sound = false

end

end

end

 

TSS_init(viewport, character)

 

end

end

 

class Scene_Map

alias gg_init_terrain_sounds_lat initialize

 

def initialize

@tsswait = TSS::Wait

gg_init_terrain_sounds_lat

end

 

alias gg_update_terrain_sounds_lat update

 

def update

#do the player first

if $game_player.moved?

@tsswait -= $game_player.move_speed != $game_player.dash ? 1 : 1.5

terrain = $game_map.terrain_sound($game_player)

if terrain != nil

if @tsswait <= 0

#vol = terrain.is_a?(Array) ? terrain[1] : 100

#pit = terrain.is_a?(Array) ? terrain[2] : 0

vol = 70; pit = 0;

son = terrain.is_a?(Array) ? terrain[rand(terrain.length)] : terrain

son += $TSSEnvironment.to_s

Audio.se_play('Audio/SE/' + son, vol, pit)

@tsswait = TSS::Wait

end

end

end

 

#do NPCs

$game_map.events.each { |i,event|

if event.moving? and event.walk_anime and event.step_sound

@tsswait -= 1

terrain = $game_map.terrain_sound(event)

if terrain != nil

if @tsswait <= 0

vol = terrain.is_a?(Array) ? terrain[1] : 100

pit = terrain.is_a?(Array) ? terrain[2] : 0

vol = 60; pit = 0;

eX = event.x; eY = event.y;

pX = $game_player.x; pY = $game_player.y;

distance = Math.sqrt( (eX - pX)**2 + (eY-pY)**2 )

distance = 10 if distance > 10

 

vol *= 1 - distance/10.0

 

son = terrain.is_a?(Array) ? terrain[rand(terrain.length)] : terrain

son += $TSSEnvironment.to_s

Audio.se_play('Audio/SE/' + son, vol, pit) if vol > 0

@tsswait = TSS::Wait

end

end

end

}

gg_update_terrain_sounds_lat

end

end

[/ code]

 

 

It basically just seems like the Audio.se_play is calling a check for the file every time it's called, and the slight delay is just engine seeking the file, then playing it. If you could buffer sounds, and then have them stay in ram or something, that'd fix it. But uh ... lol. Don't think RPG Maker can do that :(

Share this post


Link to post
Share on other sites

I agree with kiri, post the script. There should not be a delay with a sound effect--consider that every time you move the cursor or confirm it calls se_play with no delay, which is essentially the same as "footstep" sound effects.

 

EDIT: oops, looks like you posted while I was posting, checking script out now

Share this post


Link to post
Share on other sites

Just did :). Also, one thing I just thought of, is that it may be due to me having put the game's FPS to 60, instead of default. The skip maybe would be less noticeable on lower framerates.

Share this post


Link to post
Share on other sites

Just did :). Also, one thing I just thought of, is that it may be due to me having put the game's FPS to 60, instead of default. The skip maybe would be less noticeable on lower framerates.

 

lol yea, you were too quick for me ;)

 

Anyways, I tried out the script... well first off it kept giving me a bunch of errors :( was there any other parts of this script?

 

I had to change:

if $game_player.moved?
 @tsswait -= $game_player.move_speed != $game_player.dash ? 1 : 1.5

in Scene_Map#update

to

if $game_player.moving?
@tsswait -= 1

I am assuming the dash part was added for a dashing system, and move_speed in a new project is not a public instance variable (which I assume is part of the running/dashing system).

also, Game_Player#moved? does not exist in a new project--but #moving? does...so I just switched it up

 

also,

Tilesets[1] = []
Tilesets[1][0] = "Sound"
Tilesets[1][1] = ["sound", 75, 50]

Gave me an error, so I just commented those lines out because I am pretty sure that's just for specifying different sound files for specific tilesets...

 

anyways, with those changes I got the script to work ( I used the system sounds "001-System01", "002-System02", "003-System03", "004-System04" ) and I did not experience lag...and the frame rate should not make a difference.

(I tried with both 60 fps and 40/20 fps(whatever the default is xD))

 

So I dunno, maybe there is an issue with your sound card/drivers? You also said midi files have a long delay for you? I have windows 7 and it does not give me a delay when playing midi files...

 

OR perhaps another script you are using is causing the lag? Try using the script in a fresh project and see what happens. If you still get lag (and you feel comfortable about sending me your project) you can send your project and I can test it to see if it causes lag on my pc. (or you could even try it yourself on another pc) If it doesn't cause lag on another system, then it must have something to do with your computer...

 

hmmmmmmm....

Share this post


Link to post
Share on other sites

It's most likely either my sound card and/or sound drivers, and the .. fairly high quantity of scripts I have in my project. I think the best way to test that is to just send you my project. I'll PM you the link.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...