AGS Awards votes close at 13:59 BST on Wednesday 07 March 2018. You've already voted, so you've got 14 days and 21 hours left to wait before voting closes!

Author Topic: Simultaneous Speech  (Read 466 times)

Simultaneous Speech
« on: 23 Jan 2018, 21:20 »
Hi,

I've been trying to find this for some time; and I have someone who I was prepared to pay to make a plugin for it, but he's not avilable atm.

Are there any functions, plugins, or anything else, that can produce code which follows these principles:
-saying lines of character A would be said, and block other lines of the same character (so lines A1 A2 and A3 would be said one after the other, A1 A2 A3)
-saying lines of character A and B would have them both spoken simultaneously, so A1 and B1 would be spoken at the same time.

so:

Code: Adventure Game Studio
  1. //said one after the other: - "1 and 2"
  2. cA.SimultanneousSpeech("1 ")
  3. cA.SimultanneousSpeech("and 2")
  4.  
  5. //said simultaneously
  6. //"1 2 3"
  7. //"4 5 6"
  8. cA.SimultanneousSpeech("1 2 3")
  9. cB.SimultanneousSpeech("4 5 6")
  10.  
  11. //all speech is paused, or cache is cleaned - this makes easy to differentiate A B A from all being played simultaneously
  12. PauseAllSpeech()
  13.  
  14. //B says something
  15. cB.SimultanneousSpeech("something")
  16. PauseAllSpeech()
  17. //A says something else
  18. cA.SimultanneousSpeech("something else")
  19.  

Instead of PauseAllSpeech(), perhaps using a blocking function like Say would be easier?..

This allows speech, and lipsync (using TotalLipSync) to work independantly of eachother - in other word, on 2 or 3 characters simultaneously.

Gurok

  • Rottwheelers
  • When life hands you lemons, combine them with the mop
    • I can help with AGS tutoring
    •  
    • Best Innovation Award Winner 2016, for improving and extending the AGS scripting language
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • Gurok worked on a game that was nominated for an AGS Award!
      Gurok worked on a game that won an AGS Award!
Re: Simultaneous Speech
« Reply #1 on: 24 Jan 2018, 04:29 »
Just so you're aware, the only practical way to do this is to use SayBackground. I don't know this will impact your lip sync.

Here's a script module:

http://www.mediafire.com/file/vjd74pf5s45yfs3/SimultaenousSpeech.scm

I understood your PauseAllSpeech() function as wanting to wait synchronously till the queued events completed. I also implemented an alternate wait that's asynchronous. There's also a wait function for individual characters as you'll probably want that for speech timing. Here's an example of both in use:

Code: Adventure Game Studio
  1.         /* Method 1 */
  2.         cEgo.SaySimultaneous("My ding a ling...");
  3.         cEgo.WaitSimultaneous(30);
  4.         cEgo.SaySimultaneous("... My ding a ling...");
  5.         SimultaneousSpeech.WaitForSpeech(); // This is like calling Wait() -- it pauses the game and gives you a busy cursor
  6.         cChar1.SaySimultaneous("I want you to play");
  7.         cChar1.SaySimultaneous("with my ding a ling!");
  8.         cChar2.SaySimultaneous("I want you to play");
  9.         cChar2.SaySimultaneous("with my ding a ling!");
  10.        
  11.         /* Method 2 */
  12.         cEgo.SaySimultaneous("My ding a ling...");
  13.         cEgo.WaitSimultaneous(30);
  14.         cEgo.SaySimultaneous("... My ding a ling...");
  15.         cChar1.WaitSimultaneousForCharacter(cEgo); // These let a character wait for another before they start talking
  16.         cChar2.WaitSimultaneousForCharacter(cEgo);
  17.         cChar1.SaySimultaneous("I want you to play");
  18.         cChar1.SaySimultaneous("with my ding a ling!");
  19.         cChar2.SaySimultaneous("I want you to play");
  20.         cChar2.SaySimultaneous("with my ding a ling!");
  21.  

You can send money along to <pen(nospam)neyb@tpg.com.au> (PayPal, remove (nospam)) if you found it helpful, or I can PM you my bank details. I won't say no to that.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
Re: Simultaneous Speech
« Reply #2 on: 24 Jan 2018, 14:18 »
I won't be very useful here, just wanted to mention that I was participating in a game project which had paralllel character speech and characters interrupting each other, and from playtester's perspective that annoyed the hell out of me. Having player to read two or more lines of text at the same time - it's a quite a unusual game design choice. Please be careful with that, or your players may hate you. :)

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Simultaneous Speech
« Reply #3 on: 24 Jan 2018, 14:35 »
I can see a couple of use-cases for this:

-To have multiple characters speaking in unison (like the pirate leaders all shouting "GROG!!!" at the same time in Monkey Island) or contradicting each other ("So the most important thing in life is..." "-Family! -Money!")
-In a scrolling room, to have multiple background conversations going on in parallel in different parts of the room

Re: Simultaneous Speech
« Reply #4 on: 24 Jan 2018, 21:41 »
Snarky and Crimson, exactly that. No plugins for this? Is it possible with the sound system, perhaps if I just did play(someline, noblock)?

Re: Simultaneous Speech
« Reply #5 on: 25 Jan 2018, 03:07 »
Snarky, could I do the following:

Code: Adventure Game Studio
  1. cJulius.DisplayABubbleNonBlocking("this is a line")
  2. cSomeoneElse.DisplayABubbleNonBlocking("this is a line, too")
  3. chan1=TheCombinedLineOfTwoPlayers.Play(prioritynormal,once);
  4.  

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Simultaneous Speech
« Reply #6 on: 25 Jan 2018, 05:10 »
It's easy enough to do by itself. The hard part is if you want to make the whole thing non-blocking, but still queue it so that there are other lines before and after it.

In a blocking conversation, you could just do:

Code: Adventure Game Studio
  1.   game.bgspeech_stay_on_display = 1;
  2.   cSomeoneElse.SayBackgroundBubble("this is a line, too", true); // Putting the LONGER line as non-blocking
  3.   cJulius.SayBubble("&123 this is a line"); // Where JULI123.ogg is the combined speech clip
  4.   cSomeoneElse.StopBackgroundBubble();

(Depending on how long the speech clip is, cSomeoneElse's line might disappear before it finished playing, but otherwise this ought to work.)

And yes, to do just this particular line entirely non-blocking you could do basically what you said:

Code: Adventure Game Studio
  1.   cJulius.SayBackgroundBubble("this is a line");
  2.   cSomeoneElse.SayBackgroundBubble("this is a line, too", true);
  3.   chan1 = aCombinedLine.Play();

Again, the trick is to be able to embed this inside a queued, non-blocking conversation. That's where I assume Gurok's code comes in. It might just need to be adapted to use the SpeechBubble SayBackgroundBubble() function instead of the plain AGS SayBackground() function, but I haven't looked at it.

Re: Simultaneous Speech
« Reply #7 on: 31 Jan 2018, 11:27 »
I tried the solution:

Code: Adventure Game Studio
  1. game.bgspeech_stay_on_display = 1;
  2. chan1 = aCombinedLines.Play(eAudioPriorityNormal, eOnce);
  3. cJulius.SayBackgroundBubble("a slightly longer line",true);
  4. cNerd.SayBubble("a bit shorter line");
  5. cJulius.StopBackgroundBubble();
  6. aCombinedLines.Stop();
  7.  

The result was the only one that worked; I tried all the others, but they had a habit of: allowing one character to lipsync, but not the other; giving non-blocking to one character, so that clicking anywhere would have him move, and then cause an error; etc. etc. etc.

Granted, some of these were perversions of what you wrote originally, some were combinations, and some had 'true' as a second argument, or the longer line first/last, *BUT*, this one works all the time ;)
« Last Edit: 31 Jan 2018, 12:45 by bx83 »

Re: Simultaneous Speech
« Reply #8 on: 31 Jan 2018, 12:48 »
Also, to set the game fade in/fade out option correctly:

Code: Adventure Game Studio
  1.     SetGameOption(OPT_CROSSFADEMUSIC, 0);
  2.     [do all code from example above]
  3.     SetGameOption(OPT_CROSSFADEMUSIC, 2);
  4.  

I found the sound was fading in/out whether this was sample was set as Sound, Music (which is supposed to have the crossfade effect), or "3 [unknown]" (whatever the hell that is).

Re: Simultaneous Speech
« Reply #9 on: 10 Feb 2018, 06:32 »
Well I've run into a problem :(

The speech is said simultaneously; but only the second speech bubble (SayBubble as opposed to SayBackgroundBubble) is getting the lipsync right.
I use TotalLipSync 5.0 - Here

Why is this happening? No other combination of the code get's the 1st person (Julius) to lipsync correctly. What is it with Bakground?

Exactly as in my game:
Code: Adventure Game Studio
  1. SetGameOption(OPT_CROSSFADEMUSIC, 0);      
  2. game.bgspeech_stay_on_display = 1;
  3. chan1 = aCombinedLine_110_1321.Play(eAudioPriorityNormal, eOnce);
  4. cJulius.SayBackgroundBubble("&1321 We are very sorry to makers of Everyone Loves Raymond. He is not our own creation and wholly the property of 'Where's Lunch', 'Worldwide Pants', and 'HBO Independent Productions'. Thankyou for viewing our slapstick play. Peace out.",true);
  5. cNerd.SayBubble("&110 We are very sorry to makers of Everybody Loves Raymond. He is not our own creation and wholly the property of 'Where's Lunch', 'Worldwide Pants', and 'HBO Independent Productions'.");
  6. cJulius.StopBackgroundBubble();
  7. aCombinedLine_110_1321.Stop();
  8. SetGameOption(OPT_CROSSFADEMUSIC, 2);
  9.  

Yes, the .TSV's are correct and exist in Compiled/sync and Compiled/Windows/sync.

UPDATE: I was missing a piece of code that allowed SayBackgroundBubble to animate:

Code: Adventure Game Studio
  1. bool SB_sayBackgroundAnimateImpl(this Character*, String message)
  2. {
  3.     this.SaySync(message);        //<--- THIS LINE
  4.     return true;
  5. }
  6.  

Now, the speechbubble is displayed (behind another speechbubble with exactly the same text and no background..?), and speech animation is animated.
BUT NOW nothing is simultaneous; because (I assume) TotalLipSync has a function which animates the lines... that's a blocking function! :cheesy::cheesy::cheesy:
So everything blocks, and 1 line is said after the other, Background or not.
So I don't know, I give up. :/
« Last Edit: 10 Feb 2018, 07:14 by bx83 »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Simultaneous Speech
« Reply #10 on: 10 Feb 2018, 07:02 »
The reason this doesn't work is that TotalLipSync doesn't support background speech:

Just so you're aware, the only practical way to do this is to use SayBackground. I don't know this will impact your lip sync.

It's on my TODO list of future extensions for the module, but it's not a trivial change: it might require an almost total rewrite of the code. (The two main problems: first, the current code assumes only one lip-syncing character at a time, with state variables that would now have to become arrays and logic to match; and second, the code relies on a blocking speech clip to determine the length of the line. And not all the lip-sync formats store the total length of the clip, which might be different from the length of the animation, so some way to find and store this information somewhere would be needed.)

Especially with the AGS Awards coming up, I can't commit to making this change any time soon. Maybe in a couple of months. If that's not soon enough, I recommend you accept that characters that use background speech won't be lip-synced, and just use normal speech animation in these cases. (You could make a separate "non-lipsync speech view", and it wouldn't be too hard to switch their speech view to this whenever they're background-speaking, and back when they're done.)
« Last Edit: 10 Feb 2018, 07:04 by Snarky »

Re: Simultaneous Speech
« Reply #11 on: 10 Feb 2018, 07:17 »
Yep, as I thought.
I was thinking of that (separate speech animation), but this could be veeeeery tedious. But it looks like my only option, for the moment.
I can wait a month though, I have until the end of the year and this is minor.

Also, I can pay...? ;)

PS - You could attach this to a run-one-time function? Like is (message=="JUSTTHIS") then do this else do everything as normal.
« Last Edit: 10 Feb 2018, 07:25 by bx83 »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Simultaneous Speech
« Reply #12 on: 10 Feb 2018, 07:27 »
I can wait a month though, I have until the end of the year and this is minor.

I said "maybe in a couple of months". :P
Well before the end of the year shouldn't be a problem.

Quote
Also, I can pay...? ;)

I simply don't have time right now. If someone else wants to hack away at the TLS code for pay they are free to, but otherwise I'll get around to it later.

Re: Simultaneous Speech
« Reply #13 on: 10 Feb 2018, 23:18 »
Well, did the frames myself. Quicker than I thought it would be, but working off the TSV file means I have to use a custom delay for *every frame* - I didn't bother. Most of it works. I just put the stop frame code in at the points where there was a pause, 80% of the rest is like semi random speech. Meh.
I await your edit, probably, in 3 months or whatever :P