Getting a handle on a sound object

edited April 2012 in Help request
Hey guys. This project is due tomorrow! We need a quick response if possible.

Pretty much, when the boss shows up on screen, we want to fade out the stage music and turn on the boss music.

However, we don't know how to get the handle on a sound. There is no orxObject_GetSound, and when we get the sound, how should we manipulate it?

Comments

  • edited April 2012
    If you're using a recent SVN version, you can add an FX on your object to alter its volume (and do an easy cross fade).
    If not, you can get the latest added sound to an object (orxObject_GetLastAddedSound()) and then manipulate it with the orxSound_* interface.

    Good luck for the last rush!
  • edited April 2012
    I got yesterday's subversion build. It is so much better than 1.3rc0. Physics debugging is amazing! (we found out that our hitboxes for almost everything was off-center - we didn't realize that pivot points affected the position of hitboxes!)

    So, how do I use an fx to fade out? I don't see it in the docs...
  • edited April 2012
    Oh excellent! Glad you like the current version, a lot of things have happened over the last year! ;)

    Well it's like any FX, except you use Type = volume in the slot instead of scale, color, etc.
    You can also modify the pitch the same way.

    Here's an example (typed directly in the forum, so not guaranteed 100%):
    In config:
    
    [Game]
    VolCrossFadeDuration = 2.0
    
    [FXVolFadeOut]
    SlotList = SlotVolFadeOut
    
    [FXVolFadeIn]
    SlotList = SlotVolMute # SlotVolFadeIn
    
    [SlotVolFadeOut]
    Type = volume
    Curve = smooth
    StartTime = 0
    EndTime = @Game.VolCrossFadeDuration
    StartValue = 0
    EndValue = -1
    
    [SlotVolFadeIn@SlotVolFadeOut]
    EndValue = 1
    
    [SlotVolMute@SlotVolFadeOut]
    Curve = linear
    EndTime = 0
    
    In code:
    
    void MusicCrossFade(orxOBJECT *_pstOldMusic, orxOBJECT *_pstNewMusic)
    {
      orxASSERT(_pstOldMusic != _pstNewMusic && "Objects need to be different for sound crossfade");
    
      orxObject_AddFX(_pstOldMusic, "FXVolFadeOut");
      orxObject_AddFX(_pstNewMusic, "FXVolFadeIn");
    }
    

    EDIT: I assumed the new music object was set with Volume = 0 by default but we can simply removing that assertion by muting the sound in the first frame. I updated the example above accordingly.

    EDIT2: Also, I forgot to mention that with the svn version you can affect the object's sound volume directly with orxObject_SetVolume() if need be. :)
  • edited April 2012
    Thanks a bunch. You rock!
Sign In or Register to comment.