[XP] Ryex's Dynamic Sounds UPDATE:Version 2 is out!

Started by Ryex, October 18, 2009, 01:50:39 am

Previous topic - Next topic

swick

Sorry about that, it probably wasn't HB I got it from then, I don't exactly remember, I've been looking through several different forums and sites looking for scripts when I came upon this one. All I know is that I replaced the script with the one from the first page of this thread and it worked :P

Btw, I can't seem to find a good Radius and Power for SE's on enemies. I'm working on a Silent Hill fan project, and in the original games, a white noise sound would come from your radio to indicate that enemies were nearby, and it would get louder the closer they came. What do you think a good radius and power would be to duplicate this system using this script do ya think? If you don't mind me asking ofcourse :P

Ryex

I don't really know as I've never played the game, I would suggest setting it so that if the enemy is just out side the visible area of the map, try something around 7 to 12 map tiles remember that the range is in pixels so multiply tiles by 32 to get pixels.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

swick

Sorry for all the questions but it's a bit hard for me to grasp, even after reading the whole PDF guide xD

So when I use the normal "Play BGS" command in an event, it doesn't work the way its supposed to. So what I did was I used a point source to change the BGS (Wind BGS). It works, but when I want to change the wind BGS on the same map (like when it starts raining), I try to use another point source (for rain), to override the wind BGS but the wind BGS I was using before remains, and the rain BGS doesn't come at all. And since it isn't really a dynamic source I can't mute the Wind BGS to replace it with the Rain BGS. How do I go about changing BGS's? Sorry if it's a dumb question haha.

Ryex

ok look closely at the demo, thats why i made it so that people could use it as an example along with the manual.  the map with the mage trying to light a fire should teach you how to play a SE source dynamically (notice that the source it muted by default)  the last map in the moutians teaches how to mute sources. a source does NOT have to be dynamic to be muted I'm not sure how you got that idea. you do how ever need to tell the method  if the source your muteing is dynamic.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Agckuu Coceg

I have a some kind of problem during the formulation of dynamic SE. I put the event code:
Quote\dee[dse|name|radius|power|delay|volume limit]

check that, and sound not works. Where I'm mistakes in the code? I've tried everything, but it have zero sense.
I'm not retarded, but I'm busy. Sorry for patience.


Galick Hou

I'm having some trouble setting up the script to mute a source. I've made an event of a soldier that walks around making noises (using the dynamic position source), but I want to mute him when he stops or see the player. I know I have to use the script call with the [, dynamic] property but it doesn't work! Here's what I'm trying to use:
RyexCFG:: D_S.mute_piece(0, DA, D1[, dynamic ])

How should I place the [, dynamic ] in the script call to make the soldier silent? Thanks for your attention!

Heretic86

I've run into a bit of a bug that I'm not sure how to work around.

I am trying to change the Background Sound to "Quake", but when I do, it plays for a split second, then cuts out.  It needs to be a BGS the sound needs to loop due to waiting for player input.  There are no script conflits, running latest version, yadda yadda yadda.  Any help from anyone (not just the original author) would be appreciated.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Heretic86

Yay, another bug.  Since it seems Ryex is no longer active, I'll have to ask for help.

Simple bug - F12 breaks all dynamic sounds.

Suggestions?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Ryex

Lol, I'm still active, sorry about not responding to your first problem

as for your F12 problem. I assume you have the F12 fix script that fixes the "Stack Level Too Deep" error?
your first problem I cant understand what you mean, you will have to clarify.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Heretic86

February 20, 2013, 03:48:34 am #49 Last Edit: February 24, 2013, 02:59:06 am by Ryex
Wow!  You are still active!  Awesomesauce!

No, I dont have the F12 "Stack Level" error script.  Since we dont know each other, I do some scripting myself, and normally can fix 99% of issues.  One that I saw caused F12 to just exit the game.  Off topic, what I normally find on Stack Level errors is some scripts try to redefine self after instantiated.  My workaround for that is usually two lines.  One global variable so it doesnt get stored when the game is quit, but if the variable already exists, dont try to redefine self or the class name.

module Input
 unless $input_class_defined # F12 Fix 1
   $input_class_defined = true # F12 Fix 2
   class << Input
   or
   class << self
     (some code)
   end
 end
end


Exiting game kills the global variable, but hitting F12 does not get rid of the global, thus, the class is not redefined again, which is usually where the Stack Too Deep crashes on most crashable scripts I've seen.  Might not be the best way to do it, but it is simple and seems to be compatible and effective.  End of off topic.

The F12 bug that I mentioned doesnt cause a Stack Level Too Deep crash.  It doesnt crash.  But all dynamic sounds stop playing altogether after F12 is pressed.  I took a crack at fixing it, but didnt come up with any solutions at all.

The older problem that I mentioned had more to do with my lack of understanding of how to use the script.  Through some eventing, I wanted to play Quake as a BGS, but the audio would start for a split second, then just stop.  I wasnt using script calls, just evented stuff to change the background sound  Event Commands (Page 2), "Play BGS..." button.  Probably dont need a fix for that, just an example of how to do it as a non dynamic sound.  Sometimes certain sounds play better as dynamic, sometimes they dont.  Maybe def bgs_play should be aliased to stop background sounds if that is what is causing it?  Not spending much time thinking on solutions here...

---

But what the hell, while we're at it, I'll just unload.  I also have an event that I want to play a Dynamic BGS once the player activates it.  Light a Campfire basically, but the Fire animation (where I want the SE) is on another Event Page.  Cant seem to get Page Changes and Dynamic Sounds to work right for me.  Im thinking alias event refresh in class Game_Event < Game_Character to scan the active page for that event for sound effects, and play them from there.  Its your script, so I wont mess with it, but just a thought.

Also, an option to Fade In BGM / BGS / SE would be nice.

And, I want a Pony, and a shiny new bicycle with frilly tassles, and peace and love for everyone in the world!

Thanks Santa!

Sarcasm aside, I get there are some limitations due to the audio nature of RMXP, and hope just a few things in the script that could be tweaked a bit.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Ryex

well I applaud your ingenuity for fixing the problem that method will for the most part fix the stack overflow error with the F12 reset on MOST scripts.

however the F12 rest in RMXP is imperfect and implemented incorrectly which is why the error happens in the first place. instead of actually restarting the interpreter and clearing memory so the reset get a clan state they merely stops current execution and tells it to re run the scripts form the beginning. this means things can go wrong quite easily when you take into account that the memory for things like sounds and the drawing context aren't being properly handled.  I can not pinpoint the exact cause of the error nor is it likely that something I could do in the script itself would fix it.

but there IS a solution

#==============================================================================
# F12 fix
#==============================================================================

if $game_exists
 Thread.new {system('Game')}
 exit
end

$game_exists = true


this is the accepted solution for the F12 reset fix. it forces the game to start another, clean, process and exit the current one. you do have to change the 'Game' text if you have renamed the 'Game.exe' to match but it works far better and more consistently than nay other solution I know. your current problem will for the most part vanish using this solution. you just make that gode the FIRST script in your stack and all will be well.


as for your other question you will note that I included to mute sources and pieces of a source. you can even have a source start muted with an autorun event and a short script call. you can then use a script call to unmute the source. but the source event comment on the first page as normal but have it start muted. then on the second page unmute it with a script call.
if you cant get this process to work as you need feel free to let me know and I'll update the script with some added utility (new script calls ect.).
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Heretic86

Alright, I have a couple of requests:

- Fade In Background Sound / Music
- Play Non Dynamic Background Sounds  **

Right now, I cant get the option of "Play BGS..." to change to a Non Dynamic Sound at all.  It plays for a sec, then cuts out.

If you're bored, how about some Pitch Shifting over Time too?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

exile360

This is pretty great, loving this script!

It's a shame rmxp doesn't allow playing 2 BGS'es at once, it'd make things a lot more realistic. It's a tad strange when my ambiance sound of birds cuts out whenever you go near a campfire or something, but I don't really want to use SE's because they don't have that dynamic fade effect. :P Guess I'll make do with BGS'es.

Anyway, I do seem to have a slight issue. Is it just me, or does max volume for BGS not work at all? Maybe it's just me because it's 4 am and I'm tired, but I can't seem to understand what I'm doing wrong.
Here's the bit of comment I have, but the BGS is still played at what seems to be 100%, no matter what I set the last number to (seems to be the same in your demo).
\dee[bgs|point|env_fireburn4|250|fire|50]


Terv

As for the multiple BGSs I'd still appreciate it if you could make it use FMod which supports multiple audio channels. Maybe even add stereo panning for 3D sound :D

Kiwa

Hey this is a real fun script!!
I can think of probably 100 uses for this.. I'm playing with your demo to learn it.
i was looking to find dynamics for music with fade in and fade out and thought id check this out.

Its really great!
Its almost exactly what i was looking for...It doesn't include dynamic music...(or ME as of now that is)

But anyone wishing to add music into the dynamics make a copy of your song or tune and place it into the SE folder. I played with a 30 second .wav file that worked well that way.

If i use it or not, thanks for such a cool script Ryex!

Heretic86

Nasty bug found!

Save your game, DO NOT EDIT, then start it back up again.  Dynamic Sounds dont load from Save Games properly when there is no EDIT occuring.

When we edit, Magic Number changes so the map is refreshed, but when we dont Edit, as in playing a completed game, the map doesnt refresh so we end up with some data being lost if it isnt saved.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Ryex

ah yes, I remember finding that a while back but I never got around to posting up a fix. should be a simple as modifying the script to rescan for sound sources during updates. thouse would allow sounds to be added to the map by adding events via script as well. done intelligently it shouldn't add load either.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Heretic86

July 31, 2016, 07:42:09 am #57 Last Edit: August 22, 2016, 08:51:29 pm by Heretic86
I took a swing at it.  I just ended up writing a patch for it tho...

Dynamic Sounds Patch for Save Game Crashes
Spoiler: ShowHide
Redacted - See two posts down for updated patch


I had to add in a way to disable dynamic sounds so I could play Rain without D_S messing with a sound I didnt want to be dynamic.  It would be nice to do multiple sounds, but maybe I'll take a crack at that too once I have time and am done with Dynamic Lighting...
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Ryex

not a bad fix at all.  if you want the sounds mute state to restore from savegames  you can do one more edit to save and restore the DEE::MapSources data structure with the save game. doing this actually provides a path to a better fix for your original problem as you no longer need to perform a event search just call the D_S.setup on the map ID.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Heretic86

I just dumped the entire $DEE to File, but is this what you meant?

Patch Code:
Spoiler: ShowHide
#=============================================================================
#
#          DYNAMIC SOUNDS PATCH
#          Author: Heretic
#          Version: 1.0
#          Date: Saturday, July 30th, 2016
#
#   Instructions: Place Below Dynamic Sounds
#
#   ----   Patch for Ryex's Dynamic Sound Engine----
#
# - Fixes a bug that causes a Fatal Game Crash when a Non Edited Save Game
#   has been loaded.  Any Sounds that were Muted before having been saved
#   will be enabled again.
# - Adds the ability to temporarily turn off Dynamic Engine Effects
#   with a Script Call: $game_system.disable_dee
#
#  Intended for use with DEE Version 1.6 and Dynamic Sounds 2.0
#
#=============================================================================

if DEE::DEE_VERSION > 1.6 and RyexCFG::D_S::VERSION > 2.0
  print "ERROR: Ryex\'s Dynamic Sounds Patch isnt needed with\n",
        "versions higher than version 1.6, you may wish to\n",
        "remove the Patch."
end

module DEE
  class System
    #------------------------------------------------------------------------
    # * Update - DEE::System
    #  - Allows disabling DEE
    #------------------------------------------------------------------------
    alias alias_dee_update update unless $@
    def update
      # Return if DEE is Disabled
      return if $game_system.disable_dee
      # Call Original
      alias_dee_update
    end
  end
end

#==============================================================================
# ** Game_System
#==============================================================================
class Game_System
  attr_accessor :disable_dee    # Allow turning off Dynamic Sounds when true
end

#==============================================================================
# ** Scene_Save
#==============================================================================
class Scene_Save < Scene_File
  #--------------------------------------------------------------------------
  # * Write Save Data - Scene_Save
  #  - Saves DEE in addition to other Game Variables
  #     file : write file object (opened)
  #--------------------------------------------------------------------------
  alias dynamic_sounds_patch_write_save_data write_save_data unless $@
  def write_save_data(file)
    # Call Original or other Aliases
    dynamic_sounds_patch_write_save_data(file)
    # Save DEE to File
    Marshal.dump($DEE, file)
  end
end

#==============================================================================
# ** Scene_Load
#==============================================================================
class Scene_Load < Scene_File
  #--------------------------------------------------------------------------
  # * Read Save Data - Scene_Load
  #  - Rebuilds entire Dynamic Sounds for a Map when Game is Loaded
  #     file : file object for reading (opened) 
  #--------------------------------------------------------------------------
  alias dynamic_sounds_patch_read_save_data read_save_data unless $@
  def read_save_data(file)
    # Call Original or other Aliases
    dynamic_sounds_patch_read_save_data(file)
    # Restore DEE
    $DEE = Marshal.load(file)
    # If magic number is different from when saving
    # (if editing was added with editor)
    if $game_system.magic_number == $data_system.magic_number
      # Setup Dynamic Sounds on Loaded Map
      RyexCFG::D_S.setup($game_map.map_id)
    end
  end
end
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)