defining the volume of one (or at least all) character(s) independently of the "setvolume" script control

  • #1, by bananeisafreeWednesday, 31. August 2016, 20:24 8 years ago
    Hi everyone.

    So yeah. We are like hours away to call our "demo/proof of concept" ready to roll, and we realized that one of the character is overall a bit too loud for our taste compared to the other.
    So I was wondering if there was a way to lower the overall output of a specific character in Visionaire the same way you can do with individual sounds.

    Cheers

    Cesar

    Forum Fan

    120 Posts


  • #2, by afrlmeThursday, 01. September 2016, 00:49 8 years ago
    speech is associated with speech volume, so you could simply listen out for when a display text by a specific character starts & adjust the speech volume accordingly then restore it back to whatever percentage it was at before.

    I'll not go into the exact how as there are plenty of threads on here showing you how to use the registerHookFunction() for setTextPosition or the registerEventHandler with the textStarted, textStopped event handlers. There are examples available on the wiki (look under scripting & player commands - if I remember correctly). Then all you need to do is store current volume level inside of a variable & then adjust current speech volume level - x % if x character is currently speaking, then restore back to value you stored in the variable when character stops speaking.

    Imperator

    7278 Posts

  • #3, by bananeisafreeThursday, 01. September 2016, 01:12 8 years ago
    Thank you for answering.
    I was afraid you say something like this... :p
    I was hopping fort a simpler way to deal with it. (i'm the noobest of all the scripters in the neighborhood)
    Thank you very much, I'll check to see if I can cook up something before the release.

    Cheers

    Forum Fan

    120 Posts

  • #4, by afrlmeThursday, 01. September 2016, 04:55 8 years ago
    Something along the lines of this...
    local tmp_vol = nil
    
    function adaptedTextPosition(text)
     local owner = text.TextOwner
     if owner:getId().tableId == eCharacters and owner:getName() == 'Hero' then
      tmp_vol = getVolume(eSpeechVolume) -- store current volume
      setVolume( eSpeechVolume, (95 / 100) * getVolume(eSpeechVolume) ) -- 95% of current volume value
     end
     return false
    end
     
    registerHookFunction("setTextPosition", "adaptedTextPosition")
    
    
    function txtEnd(text)
     if tmp_vol ~= nil then
      setVolume(eSpeechVolume, tmp_vol)
     end 
    end
    
    registerEventHandler("textStopped", "txtEnd")
    

    ... can't guarantee it will work though as I've not tested it.

    Imperator

    7278 Posts

  • #5, by bananeisafreeThursday, 01. September 2016, 13:53 8 years ago
    Damn ... I was not expecting you to cook something up !
    Thanks a lot mate !
    I'm gonna try it right away !

    Edit :

    Btw, Your name is on our demo credits :p
    (it was before you brought that new script mind you.)

    Forum Fan

    120 Posts

  • #6, by afrlmeThursday, 01. September 2016, 14:56 8 years ago
    haha, cheers & no worries. wink

    It might need a bit of tweaking as I quickly copy/pasted & edited the code in Sublime Text. It was early hours of the morning as you can see from the timestamp, so I couldn't really be bothered trying to implement & test it in a VS project.

    Quick note: you could probably swap out the registerHookFunction with a registerEventHandler with the textStarted event flag. They give me grief sometimes though, so I prefer using the hookfunction as it also listens out for text started & you don't have to reposition text as you can just return false to prevent it from forcing the text position.

    Imperator

    7278 Posts