# Adding voice acting

**URL:** <https://forums.thimbleweedpark.com/t/adding-voice-acting/4382>\
**Category:** Delores Engine\
**Created:** [June 24, 2020, 4:28pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382 "2020-06-24T16:28:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![MChiz](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/mchiz/32/12667_2.png) [@MChiz](https://forums.thimbleweedpark.com/u/MChiz)\
**Post date:** [June 24, 2020, 4:28pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/1 "2020-06-24T16:28:10Z")

</div>

Hi!

I’m toying with the idea of adding Spanish voice acting to the mini adventure. I have been looking at the source code in github, but I can’t figure out how to add the sound files.

Is it possible? If it is, can someone explain me how?

Thanks!

---

<div class="post-metadata">

**Author:** ![Frenzie](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/frenzie/32/4416_2.png) [@Frenzie](https://forums.thimbleweedpark.com/u/Frenzie)\
**Post date:** [June 24, 2020, 7:25pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/2 "2020-06-24T19:25:45Z")

</div>

See [Delores: Meowlation](https://forums.thimbleweedpark.com/t/delores-meowlation/4312/27) for some discussion. It’s not too hard to add and play sounds. You need FMOD Studio version _2.0.3_. Unfortunately the engine doesn’t have dedicated talking code so there’d be some imperfections.

---

<div class="post-metadata">

**Author:** ![RonGilbert](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/rongilbert/32/7_2.png) [@RonGilbert](https://forums.thimbleweedpark.com/u/RonGilbert)\
**Post date:** [June 24, 2020, 11:11pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/3 "2020-06-24T23:11:41Z")

</div>

Unfortunately, the `_startSayline(actor, text)` function doesn’t take the text id, so it’s going to be hard since the audio file need to be saved based on the text id. Also, several lines are formed by string concatenation which also presents issues.

Let me look at the changes need for the engine to pass a text id to `_startSayline()`.

---

<div class="post-metadata">

**Author:** ![MChiz](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/mchiz/32/12667_2.png) [@MChiz](https://forums.thimbleweedpark.com/u/MChiz)\
**Post date:** [June 25, 2020, 9:53am UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/4 "2020-06-25T09:53:13Z")

</div>

@Frenzie, thanks a lot! I will check this out!

@RonGilbert, thank you so much! I hope it is not too much work. My wife and I are very excited to try to add voice acting to the game 🙂

---

<div class="post-metadata">

**Author:** ![RonGilbert](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/rongilbert/32/7_2.png) [@RonGilbert](https://forums.thimbleweedpark.com/u/RonGilbert)\
**Post date:** [June 27, 2020, 9:53pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/5 "2020-06-27T21:53:11Z")

</div>

I changed this right before releasing the code, so I was misremembering how it finally worked.

The callback function `_startSayline(actor, text)` receives the `text` before translation, so it will be in the form of “id:text”. You can do what the `TR()` function does `local id = strslice(text, 0, 4)` to get the id and use that for form a FMOD event like `event:/talkies/es/10567`

```auto
local id = strslice(text, 0, 4)
local event = "event:/talkies/"+currentLanguage()+"/"+id
actor.talkie_sid <- playsound(event)

```

then in `_doneSayline()` do

```auto
if (actor?.talkie_sid) {
    stopsound(actor.talkie_sid)
    actor.talkie_sid <- 0
}

```

That should get to basic talking. There might be some edge cases that will need to be worked out once it’s functioning.

For now, add the talkie events to the main FMOD .bank file, they are easy to copy to a new .bank file when/if that gets implemented.

Keep in mind that that above code is untested and might have small errors in it.

---

<div class="post-metadata">

**Author:** ![MChiz](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/mchiz/32/12667_2.png) [@MChiz](https://forums.thimbleweedpark.com/u/MChiz)\
**Post date:** [June 28, 2020, 3:20pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/6 "2020-06-28T15:20:31Z")

</div>

Hey @RonGilbert! I updated the code and created a .bank file for testing and it is working 🙂 thanks for that!

However, ‘playSound’ always returns 0, so when \_doneSayline is called, the sound doesn’t stop. Do you know what is happening and how I could fix it? This is the added code:

```
function _startSayline(actor, text) {
local text_scale = 3.0
local image = createTextImage(SAYLINE_FONT, TR(text), ALIGN_CENTER|(SCREEN_WIDTH*(0.80/text_scale)))
imageAt(image, point(SCREEN_CENTER_X, SCREEN_HEIGHT*0.90))
imageScale(image, text_scale)
imageColor(image, actor.talkColor())
imageTextOutline(image, COLOR_BLACK)
actor._sayline_image <- image
if (SETTING(jibber)) {
	actor._jibber_sid <- playSound(actor?.jibber_sid)
}

local id = strslice(text, 0, 4)
local event = "event:/talkies/es/"+id
//local event = "event:/talkies/"+currentLanguage()+"/"+id
print("Playing event: " + event)

actor.talkie_sid <- playSound(event)
print("TalkieID: " + actor.talkie_sid)

return image
}

```

Besides that, I guess ‘\_doneSayline’ is called from the engine, right? Can I override the text duration with the audio length for each sentence?

Thanks!

---

<div class="post-metadata">

**Author:** ![RonGilbert](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/rongilbert/32/7_2.png) [@RonGilbert](https://forums.thimbleweedpark.com/u/RonGilbert)\
**Post date:** [June 28, 2020, 3:54pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/7 "2020-06-28T15:54:06Z")

</div>

Yeah, you’re right. It always returns 0. I don’t use that form so never saw this issue. I’ll fix it and upload a new engine today or tomorrow.

I’ll also add a way to override the time so you can track the audio and end it when needed. To do that, you’ll need to start a thread that does a `breakwhilesound(sid)`, then does a `sayLine(actor, null)` to stop them talking.

---

<div class="post-metadata">

**Author:** ![RonGilbert](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/rongilbert/32/7_2.png) [@RonGilbert](https://forums.thimbleweedpark.com/u/RonGilbert)\
**Post date:** [June 28, 2020, 8:35pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/8 "2020-06-28T20:35:11Z")

</div>

I uploaded a new DeloresDev engine (version 1.0.4) to the website ([https://thimbleweedpark.com/deloresdev/](https://thimbleweedpark.com/deloresdev/))

FIX: `playSound("event...")` now correctly returns a playing sound id.  
ADD: `gameprops("sayLineForever", true)` will allow sayLines to remain on screen until stopped.

If you’re using talkies, you’ll want to call the `gameprops()` once and stop the lines when then audio is done. There might be some edge cases that will need to be address, but I can’t think of any right now.

P.S. When I say forever, I really mean 9999 seconds (2.7 hours). So, if you end up taking more the 2.7 hours to say a single line, it will get cut off.

---

<div class="post-metadata">

**Author:** ![MChiz](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/mchiz/32/12667_2.png) [@MChiz](https://forums.thimbleweedpark.com/u/MChiz)\
**Post date:** [June 29, 2020, 2:07pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/9 "2020-06-29T14:07:08Z")

</div>

Awesome! Thanks! The sound now stops correctly.

I have been trying implement the timing override, but I get the error “Can’t find var gameprops”. I tried it with camel case without luck.

Could you help me with that, please? As soon as I get this working, I think I will be able to implement the rest with the instructions you gave to me.

And a question regarding the “sayLineForever” flag: can I enable it if there is a sound for one sentence, and disable it if there is none? Like this (in “\_startSayline” function):

```
	if( actor?.talkie_sid ) {
	    gameprops( "sayLineForever", true )

		startthread( @{
			breakwhilesound( actor.talkie_sid )
			sayLine( actor, null )
		} );
	
	} else {
		gameprops( "sayLineForever", false );
	
	}

```

> P.S. When I say forever, I really mean 9999 seconds (2.7 hours). So, if you end up taking more the 2.7 hours to say a single line, it will get cut off.

That sounds like an interesting idea… 🕶 (just kidding 😂)

---

<div class="post-metadata">

**Author:** ![RonGilbert](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/rongilbert/32/7_2.png) [@RonGilbert](https://forums.thimbleweedpark.com/u/RonGilbert)\
**Post date:** [June 29, 2020, 4:49pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/10 "2020-06-29T16:49:04Z")

</div>

My mistake, it’s called `gameprop()`. It’s also used in Options.dinky.

You need to call `gameprop( "sayLineForever", true)` before the sayLine happens, which means it’s too late by the time you get the callback. This should be set once (probably in boot.dinky) if you have talkies.

This is all kind of a kludge, if I was doing this “for real”, talking would be built into the system (because of lipsync, etc).

---

<div class="post-metadata">

**Author:** ![Vit\_Condak](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/vit_condak/32/3059_2.png) [@Vit\_Condak](https://forums.thimbleweedpark.com/u/Vit_Condak)\
**Post date:** [June 29, 2020, 6:01pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/11 "2020-06-29T18:01:18Z")

</div>

Maybe it’s a good opportunity to build it into the engine, let us do some beta testing and get it ready for the next “real” project…? 😉

Actually, I thought this was one of the reasons for publishing Delores sources.

---

<div class="post-metadata">

**Author:** ![MChiz](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/mchiz/32/12667_2.png) [@MChiz](https://forums.thimbleweedpark.com/u/MChiz)\
**Post date:** [June 30, 2020, 2:43pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/12 "2020-06-30T14:43:12Z")

</div>

Thanks, @RonGilbert! gameprop( … ) is working now.

> This is all kind of a kludge, if I was doing this “for real”, talking would be built into the system (because of lipsync, etc).

No worries! I just need something quick & dirty to start going. I only hope I’m not being a PITA 🙂

I think “breakwhilesound” is not working properly or I’m doing something wrong, because it doesn’t halt the thread. This is the code I have used (inside \_startSayline):

```
if( actor?.talkie_sid ) {
	startthread( @{
		print( "Waiting talkie" )
		
		breakwhilesound( actor.talkie_sid )
		sayLine( actor, null )
		
		print( "Talkie done" )
	} );
	
} else {
	startthread( @{
		print( "Waiting seconds" )

		breaktime( 5.0 )
		sayLine( actor, null )
		
		print( "Done" )
	} );
	
}

```

Do you know what could be happening?

---

<div class="post-metadata">

**Author:** ![RonGilbert](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/rongilbert/32/7_2.png) [@RonGilbert](https://forums.thimbleweedpark.com/u/RonGilbert)\
**Post date:** [June 30, 2020, 7:10pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/13 "2020-06-30T19:10:56Z")

</div>

You you post (or send me via DM) the entire `_startSayline()` function you are using and I’ll try it on my end.

Don’t worry at all about being a PITA, it’s fun for me.

---

<div class="post-metadata">

**Author:** ![RonGilbert](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/rongilbert/32/7_2.png) [@RonGilbert](https://forums.thimbleweedpark.com/u/RonGilbert)\
**Post date:** [June 30, 2020, 7:13pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/14 "2020-06-30T19:13:54Z")

</div>

We briefly thought about doing full voice for Delores. The actor that plays Delores is a good friend and we though it would be fun if she did Delores again and I did all the other voice.

Doing everything voice needs in the engine is a good month of work, so it’s a major undertaking. I’ll do it before my next game, but not anytime in the near future.

---

<div class="post-metadata">

**Author:** ![Vit\_Condak](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/vit_condak/32/3059_2.png) [@Vit\_Condak](https://forums.thimbleweedpark.com/u/Vit_Condak)\
**Post date:** [June 30, 2020, 8:42pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/15 "2020-06-30T20:42:08Z")

</div>

Um, that’s a shame. I thought you could rather easily copy the talking code from TWP and modify it to fit Delores within a day or two but a month is really a lot…

---

<div class="post-metadata">

**Author:** ![RonGilbert](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/rongilbert/32/7_2.png) [@RonGilbert](https://forums.thimbleweedpark.com/u/RonGilbert)\
**Post date:** [June 30, 2020, 8:45pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/16 "2020-06-30T20:45:46Z")

</div>

While from the outside they seem similar, the internal architecture is very different. One of the reasons I wanted to rewrite the TWP engine was it’s a complete mess. Talking was put in towards the end and it was a kludge.

---

<div class="post-metadata">

**Author:** ![MChiz](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/mchiz/32/12667_2.png) [@MChiz](https://forums.thimbleweedpark.com/u/MChiz)\
**Post date:** [June 30, 2020, 9:50pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/17 "2020-06-30T21:50:06Z")

</div>

There you have, @RonGilbert:

```
function _startSayline(actor, text) {
local text_scale = 3.0
local image = createTextImage(SAYLINE_FONT, TR(text), ALIGN_CENTER|(SCREEN_WIDTH*(0.80/text_scale)))
imageAt(image, point(SCREEN_CENTER_X, SCREEN_HEIGHT*0.90))
imageScale(image, text_scale)
imageColor(image, actor.talkColor())
imageTextOutline(image, COLOR_BLACK)
actor._sayline_image <- image
if (SETTING(jibber)) {
	actor._jibber_sid <- playSound(actor?.jibber_sid)
}

local id = strslice(text, 0, 4)
local event = "event:/talkies/es/"+id
//local event = "event:/talkies/"+currentLanguage()+"/"+id
print("Playing event: " + event)

actor.talkie_sid <- playSound(event)
print("TalkieID: " + actor.talkie_sid)

if( actor?.talkie_sid ) {
	startthread( @{
		print( "Waiting talkie" )
		
		breakwhilesound( actor.talkie_sid )
		sayLine( actor, null )
		
		print( "Talkie done" )
	} );
	
} else {
	startthread( @{
		print( "Waiting seconds" )

		breaktime( 5.0 )
		sayLine( actor, null )
		
		print( "Done" )
	} );
	
}

return image

```

}

Thanks a lot for spending time helping me!

---

<div class="post-metadata">

**Author:** ![ZakPhoenixMcKracken](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/zakphoenixmckracken/32/41_2.png) [@ZakPhoenixMcKracken](https://forums.thimbleweedpark.com/u/ZakPhoenixMcKracken)\
**Post date:** [July 1, 2020, 4:31pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/18 "2020-07-01T16:31:20Z")

</div>

> [@Vit\_Condak](#):
>
> within a day or two but a month is really a lot…

Eh … we thought to record all Thimbleweed Park voices in Italian in “several months”. We were too much optimistic, almost 3 years have passed (but now we are near the end).  
It’s not as quick as one can think.

---

<div class="post-metadata">

**Author:** ![Vit\_Condak](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/vit_condak/32/3059_2.png) [@Vit\_Condak](https://forums.thimbleweedpark.com/u/Vit_Condak)\
**Post date:** [July 1, 2020, 8:59pm UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/19 "2020-07-01T20:59:43Z")

</div>

> [@ZakPhoenixMcKracken](#):
>
> almost 3 years have passed (but now we are near the end).  
> It’s not as quick as one can think.

I know things usually take much more time then I expected. Yesterday I added another new feature to a game (Bubble Bobble clone) that we started making in 1996. =)

On the other hand, I usually start programing a new project by opening an older project of mine and removing useless features and I still believe it saves time. (Even though I end up rewriting half of it and then copying rewritten parts of code from the project B back to the project A. =)

---

<div class="post-metadata">

**Author:** ![nihilquest](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.thimbleweedpark.com/nihilquest/32/645_2.png) [@nihilquest](https://forums.thimbleweedpark.com/u/nihilquest)\
**Post date:** [July 2, 2020, 2:46am UTC](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382/20 "2020-07-02T02:46:51Z")

</div>

1996! DOS or Win’95?

[Next page](https://forums.thimbleweedpark.com/t/adding-voice-acting/4382.md?page=2)
