Community

SCI Programming => SCI Development Tools => Topic started by: troflip on October 08, 2015, 04:09:30 PM

Title: Play speech while digital sound effect is also playing
Post by: troflip on October 08, 2015, 04:09:30 PM
Is this possible?

It appears to work in ScummVM. Like, if I have a background digital sound effect playing (not midi), the speech is played along with it.

But if I run the same game in DOSBox, the digital sound effect stops playing when the speech starts.

Maybe it depends on the aud driver that's used?
Title: Re: Play speech while digital sound effect is also playing
Post by: Collector on October 08, 2015, 08:35:34 PM
Give me a bit to go through a few of my games. There is a similar thread on VOGONS involving Goblin's Quest 3, which is after the point that Sierra started having influence over Cocktel's code. The CDA music cuts out for speech on a real DOS PC, but both play in ScummVM. http://www.vogons.org/viewtopic.php?f=7&t=45145
Title: Re: Play speech while digital sound effect is also playing
Post by: troflip on October 08, 2015, 09:01:16 PM
Interesting. Not sure it's related though, because that's CD audio.

In KQ6, in the opening scene by the beach, the digital audio cuts out, but then comes back once the speech is complete. I'd happy if I could even get that to work.

I don't see any code in KQ6's Talker script to make whatever was playing before the speech resume. It *does* lower the master volume before the speech starts and then restores it afterward. So even if KQ6 did support speech at the same time as digital audio, you wouldn't hear it. Maybe I can modify the KQ6 scripts a bit and see if I can get them playing simultaneously - that would at least show that it's possible with some SCI1.1 interpreters.

[edit:] ok, never mind, the ocean sound is actually a MIDI resource, not digital audio. So it's irrelevant...
Title: Re: Play speech while digital sound effect is also playing
Post by: Collector on October 08, 2015, 10:48:50 PM
I was not suggesting that it was exactly the same or even be of any help, just that it was such a similar issue that I was reminded of the Gob3 thread. Coktel used digital audio for all three Gobliiins games. Gob3 is the first one with synchronized speech. The speech audio is in a file, not the CDA track. While it uses the Gob engine, Coktel could have used shared Sierra code from what Sierra had built on from the Bright Star acquisition for synchronized speech.

Yeah, KQ6 does do a lot of MIDI SFX, like birds.
Title: Re: Play speech while digital sound effect is also playing
Post by: MusicallyInspired on October 08, 2015, 11:09:29 PM
Even simple sounds like knocking on a door, etc. I guess the trick is to use as many MIDI sfx as possible.
Title: Re: Play speech while digital sound effect is also playing
Post by: troflip on October 09, 2015, 12:39:42 AM
I wonder if the "only one digital audio track" limitation is enforced in the interpreter or is a limitation of the audio drivers. Are there any alternative audio drivers (e.g. for more modern soundcards) that people have implemented for sierra games?

Must have been a real art to make sound fx with MIDI. Does anyone know of a repository/source for such fx?
Title: Re: Play speech while digital sound effect is also playing
Post by: MusicallyInspired on October 09, 2015, 01:16:46 AM
Sort of. Quest Studios has a vast database of MT-32 patches from all over, including Sierra games (which includes sound effects along with instruments). Like hundreds. But that's MT-32 only. I suppose the best thing to do would be to go through Sierra sound resources and pick out all the sounds and make a library out of those.
Title: Re: Play speech while digital sound effect is also playing
Post by: Collector on October 09, 2015, 01:17:11 AM
I wonder if the "only one digital audio track" limitation is enforced in the interpreter or is a limitation of the audio drivers. Are there any alternative audio drivers (e.g. for more modern soundcards) that people have implemented for sierra games?
If by driver I would imagine that one from an SCI32 game would be capable, but doubt that any would be compatible with the new template game. Then again, this is exactly the kind of thing that NRS does all of the time.

As to a repository of MIDI SFX many could be ripped from existing SCI games. Wouldn't have to convert to SND, either. It would just be a bunch of busy work to go through them

Anyway, here are some MIDI SFX from the Freddy Disk version. If memory serves the SQ games used a lot of MIDI SFX.
Title: Re: Play speech while digital sound effect is also playing
Post by: troflip on October 09, 2015, 01:45:02 PM
Oh, it's not too much trouble to go through them with SCI Companion and pick out good ones. Ideally I was looking for something that doesn't rip Sierra resources though. I think you would want them in snd format though, since that contains different MIDI tracks for different sound cards.

As for "supporting" speech during looping digital audio background noises, it wouldn't be too hard to fade out a sound completely, and then restart and fade it in after the speech is done. It's not ideal, but it's a workaround.

KQ6 (and I'm sure other games, but not the SQ5-based template game) actually has code to fade out any other sounds to a low level (volume level 4) before speech starts, and then fade them back in. It doesn't work in DOSBox or ScummVM though (and I doubt it works natively) because it isn't based on the game timer. It just uses a for-loop to lower the volume every 1000 iterations, which is probably ends being like a microsecond on a modern computer.
Title: Re: Play speech while digital sound effect is also playing
Post by: Cloudee1 on October 10, 2015, 11:14:35 AM

In KQ6, in the opening scene by the beach, the digital audio cuts out, but then comes back once the speech is complete. I'd happy if I could even get that to work.


Yeah, that would be nice. For instance in my SQ2, if you are in the underground caverns, there is the water background sound. If you blow the whistle it stops the water and plays the whistle... and the water sound doesn't come back. It would be nice to figure out how to make that happen.
Title: Re: Play speech while digital sound effect is also playing
Post by: troflip on October 10, 2015, 01:51:45 PM
Yeah, that would be nice. For instance in my SQ2, if you are in the underground caverns, there is the water background sound. If you blow the whistle it stops the water and plays the whistle... and the water sound doesn't come back. It would be nice to figure out how to make that happen.

Well, that's AGI, so that's a different beast.

In SCI, playing a second midi sound won't cause another to stop (though maybe it does with some drivers? I dunno. Maybe if you're using the PC-speaker).

My thought for SCI speech was to have a class that extends from Sound, say AtmosphericSound. The assumption would be that this is a looping digital sound. Then the Messager or Talker class would find instances of these (well, there should be just one), and fade them to zero over a short time, before starting the speech audio. Then after the speech is finished, it would restart them and fade them back up.


Interestingly, a bug in ScummVM (I claim): In Sierra's interpreter, DoAudio(audSTOP) will stop all digital sounds, even if they were started by DoSound. In ScummVM, DoAudio(audSTOP) only stops sounds that were started by DoAudio (which arguably makes more sense, but is still different than Sierra).
Title: Re: Play speech while digital sound effect is also playing
Post by: MusicallyInspired on October 10, 2015, 03:12:54 PM
I think he's referring to the SQ2 project he's working on in SCI.
Title: Re: Play speech while digital sound effect is also playing
Post by: Collector on October 10, 2015, 03:28:00 PM
Maybe if you're using the PC-speaker).

That reminds me that the Gob games used the PC speaker for some sound FX like footsteps simultaneously with digital sounds on SB.
Title: Re: Play speech while digital sound effect is also playing
Post by: Kawa on October 10, 2015, 04:08:47 PM
That reminds me that the Gob games used the PC speaker for some sound FX like footsteps simultaneously with digital sounds on SB.
Imagine playing one of those with headphones on.
Title: Re: Play speech while digital sound effect is also playing
Post by: Collector on October 10, 2015, 10:13:06 PM
The only way that I can think that you could do that with an SCI would be to append an SB or AdLib driver with the STD driver the way someone did with the SB and GM drivers.
Title: Re: Play speech while digital sound effect is also playing
Post by: Kawa on October 11, 2015, 07:59:19 AM
Why, though?
Title: Re: Play speech while digital sound effect is also playing
Post by: Collector on October 11, 2015, 10:30:46 AM
Just kicking ideas around for simultaneous sounds, that is all. It did make for pretty effective footfall sounds. Granted a bit of a moot point as it would just be another SND resource. Also DOSBox would just play it through the host's soundcard.
Title: Re: Play speech while digital sound effect is also playing
Post by: Kawa on October 13, 2015, 10:59:35 AM
Code: [Select]
// ===========================================================================
// When giving the milk bottle to one of the babies in the garden in KQ6 (room
// 480), script 481 starts a looping baby cry sound. However, that particular
// script also has an overriden check method (cryMusic::check). This method
// explicitly restarts the sound, even if it's set to be looped, thus the same
// sound is played twice, squelching all other sounds. We just rip the
// unnecessary cryMusic::check method out, thereby stopping the sound from
// constantly restarting (since it's being looped anyway), thus the normal
// game speech can work while the baby cry sound is heard.
// Fixes bug: #4955
-- ScummVM, /engines/sci/engine/script_patches.cpp

Actual method being replaced with naught but a return:
Code: [Select]
(method (check)
(if (((babyIsCrying and DoAudio(audPAUSE)) and (== DoAudio(audPOSITION) -1)) and not global84)
(self:play())
)
(super:check())
)
(I named local0 and looked up what subops 4 and 6 are, this should be correct.)

Make of that what you will.
Title: Re: Play speech while digital sound effect is also playing
Post by: troflip on October 13, 2015, 04:59:00 PM
That's definitely some strange code. Does it work properly in Sierra's interpreter? It looks like it would just immediately pause any playing audio (thus the speech).

The other thing is that it's dependent on DoAudio returning a value. In ScummVM it doesn't return a value (well, it just returns whatever was in the accumulator). Maybe DoAudio(audPAUSE) is supposed to return some value, and it returns 0 in Sierra's interpreter in this case... now sure how or why though...
Title: Re: Play speech while digital sound effect is also playing
Post by: Kawa on October 13, 2015, 05:31:49 PM
I would've checked, and I have managed to make the beach connect to the garden with the baby's tears, but I neglected to give myself the bottle because I'm a dumbass so I had no way to make the baby's tears cry.

Edit: okay, edited the beach script again. Getting the ring should get me the bottle as well so I can make these babies cry.
Edit: got the milk, on my way to the babies.
Edit: okay those are clearly two digital samples overlapping in ScummVM. On to SSCI...
Edit: SSCI does not overlap the narrator and babies, and unless I'm mistaken they restart crying when the narrator shuts up.
Title: Re: Play speech while digital sound effect is also playing
Post by: troflip on October 13, 2015, 06:28:30 PM
Ok, I tried plopping that code into my test game (I removed the global84, since that doesn't ever seem to be set, even in KQ6). And it worked!

And of course, in ScummVM, it doesn't work. The speech never happens.

I wish I could get the DebugPrint working in ScummVM. But the FileIO functions seem to work differently...
[edit: ah, ScummVM doesn't support writing arbitrary files... only save game files]



Title: Re: Play speech while digital sound effect is also playing
Post by: Kawa on October 13, 2015, 06:50:24 PM
More confirmation, (send gMusic1: number(5) play()), nice long sound, then a second or so later DoAudio(2 3), it cuts off the first in SSCI and overlaps them in ScummVM. There are no MIDI versions of those sounds. (send gMusic2: number(3) play()) on the other hand does cut off the first sound, as do two DoAudio calls.

One more reason to detect and deny XD
Title: Re: Play speech while digital sound effect is also playing
Post by: troflip on October 13, 2015, 07:26:59 PM
Looks like DoAudio(audPAUSE) isn't supposed to actually do anything. At least in Sierra's terp, it definitely does not pause the currently playing audio track. It also does not return any specific value (just whatever was in the accumulator, which in that snippet of code will likely be the value of babyCrying). So I'm not sure what its purpose is.

Kq6 has an Audio class with a pause function that calls audPAUSE, but no one calls it.
Title: Re: Play speech while digital sound effect is also playing
Post by: troflip on October 13, 2015, 07:47:06 PM
fyi, the following snippet seems to work both in ScummVM and Sierra... In ScummVM the background audio keeps playing. In Sierra's the background audio starts up again after the speech is finished.

Code: [Select]

(local
babyIsCrying = 0
)

(instance windSound of Sound
(properties
priority 15
number 400
loop -1
)

(method (play)
(= babyIsCrying 1)
(super:play())
)

(method (stop)
(= babyIsCrying 0)
(super:stop())
)

(method (check)
(if (babyIsCrying and (== DoAudio(audPOSITION) -1))
(self:play())
)
(super:check())
)
)
Title: Re: Play speech while digital sound effect is also playing
Post by: Kawa on October 16, 2015, 02:40:11 PM
Incidentally, is it me or do audblast.drv and ScummVM speak at different pitches? Something I noticed while making babies cry.
Title: Re: Play speech while digital sound effect is also playing
Post by: troflip on October 16, 2015, 02:57:09 PM
I haven't noticed that.
Title: Re: Play speech while digital sound effect is also playing
Post by: Collector on October 16, 2015, 08:56:40 PM
Incidentally, is it me or do audblast.drv and ScummVM speak at different pitches? Something I noticed while making babies cry.

Are you running the Win or DOS version in ScummVM? Not sure if it would make a difference, but the Win version was intended to be played through the Win31 Sound Mapper and the DOS via AUDBLAST.
Title: Re: Play speech while digital sound effect is also playing
Post by: Kawa on October 17, 2015, 03:44:37 AM
Are you running the Win or DOS version in ScummVM? Not sure if it would make a difference, but the Win version was intended to be played through the Win31 Sound Mapper and the DOS via AUDBLAST.
I recall the slow non-AVI logo, so that'd be DOS on both. Fortunately, I don't need that scene specifically to recheck such a thing.