Author Topic: [SOLVED] Sound Cues Not Cuing  (Read 467 times)

0 Members and 1 Guest are viewing this topic.

Offline MusicallyInspired

[SOLVED] Sound Cues Not Cuing
« on: May 04, 2019, 04:35:39 PM »
I've got this block of code in my changeState method.

Code: [Select]
(if (== (gMusic1 prevSignal?) 20)
(sparkle setCycle: EndLoop self)
else
(-- state)
(= cycles 1)
)

It's supposed to trigger the animation loop from "sparkle" once after it reads the "20" cue from the current sound being played. After that it continues through the changeState states. But it's not happening. Am I doing this right? I'm translating code from an earlier game that I had to start over from scratch with. Using the same code but it's not working like it does in the older version of the game. What am I overlooking?

EDIT: I looked at the sources for both KQ5 and SCI Quest on handling sound cues and tried to copy something:

Code: [Select]
(1
(FadeCode init: 100 1 self)
(if (and
(< (gMusic1 prevSignal?) 20)
(!= (gMusic1 prevSignal?) -1)
)
(-- state)
)
(= cycles 1)
)
(2
(sparkle setCycle: EndLoop self)
)

But that doesn't work either. What happens is after the sound is done playing THEN the animation triggers. I don't get what's happening. I obviously don't understand properly how triggers are supposed to work.
« Last Edit: May 16, 2019, 10:28:51 AM by MusicallyInspired »


Brass Lantern Prop Competition

Offline troflip

Re: Sound Cues Not Cuing
« Reply #1 on: May 04, 2019, 08:20:38 PM »
The same code (roughly) seems to work for me.

Code: [Select]

(instance RoomScript of Script
(method (changeState newState)
(= state newState)
(switch state
(0

)
(1
(if (== (gMusic1 prevSignal?) 20)
(Prints {HELLO})
else
(-- state)
(= cycles 1)
)

)
)
)
)

then to kick off the whole thing:

Code: [Select]
(gMusic1 number: 205 play:)
(RoomScript changeState: 1)
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Sound Cues Not Cuing
« Reply #2 on: May 04, 2019, 10:42:07 PM »
So is there something wrong with my Sound resource then maybe? It has cue points with those values. I'm baffled.
Brass Lantern Prop Competition

Offline troflip

Re: Sound Cues Not Cuing
« Reply #3 on: May 04, 2019, 11:01:26 PM »
Some questions:

  • What code triggers your initial changeState to state 1? You haven't shown that yet.
  • Do any other sounds start playing and interrupt things? (Might be wise to not use the global gMusic1)

Attached is an image of what my sound looks like. I just added a cue to sound 205 in SCI Quest, about halfway through. And that code I posted triggered at the half way point.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Sound Cues Not Cuing
« Reply #4 on: May 05, 2019, 12:48:16 AM »
Well, it's definitely not the case that the states aren't being called. Everything else goes through fine, but this stupid cue thing triggers incorrectly. I'm trying to mimic the Sierra logo with a glint/sparkle that shines in two places from two different cues. And then after that it fades out to black and draws another pic and plays another Sound resource. Instead of the two sparkles animating at the two cues, the first one doesn't cue at all and the second one only cues after the sound has ended and not at the cue point. But it does fade out to black and draws the next Picture and plays the next Sound just fine. Here's the whole changeState code block:

Code: [Select]
(method (changeState newState &tmp temp0 [temp1 10])
(switch (= state newState)
(0
(gMusic1
number: 1001
loop: 1
play: self
)
(sparkle init: posn: 185 42)
(= seconds 4)
)
; Wait 4 seconds before going to the next state.
(1
(FadeCode init: 100 1 self)
(if (and
(< (gMusic1 prevSignal?) 20)
(!= (gMusic1 prevSignal?) -1)
)
(-- state)
)
(= cycles 1)
)
(2
(sparkle setCycle: EndLoop self)
)
(3
(if (and
(< (gMusic1 prevSignal?) 30)
(!= (gMusic1 prevSignal?) -1)
)
(-- state)
)
(= cycles 1)
)
(4
(sparkle posn: 79 133 loop: 1 cel: 0 setCycle: EndLoop self)
)
(5 (= seconds 3))
(6
(gMusic1 stop:)
(sparkle hide:)
(= cyclePalette FALSE)
(= cycles 5)
)
(7
(sparkle dispose:)
(DrawPic 501 dpOPEN_FADEPALETTE dpNO_CLEAR)
(= seconds 1)
)
(8
(Fanfare play:)
(= cycles 1)
)
(9
(if (== (Fanfare prevSignal?) 10)
(One init: setCycle: EndLoop self)
else
(-- state)
(= cycles 1)
)
)
)
)

And it's called and activated from the room's Init method with this:

Code: [Select]
(self setScript: rmScript)
And this is the Sound:

« Last Edit: May 05, 2019, 12:55:31 AM by MusicallyInspired »
Brass Lantern Prop Competition

Offline troflip

Re: Sound Cues Not Cuing
« Reply #5 on: May 05, 2019, 03:05:59 AM »
Can you just sprinkle DebugPrints everywhere? Shouldn't be too hard to debug.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Sound Cues Not Cuing
« Reply #6 on: May 05, 2019, 03:43:40 PM »
Ok it looks like the first cue is never triggered. The game sits in that state waiting for the first cue which never comes until after the sound has ended and then BOTH cues are triggered, which is why only the second sparkle is showing because it's the same Prop it just switches loops and positions. The first sparkle doesn't get a chance to animate because the second one is already being drawn a split second later. So these cues are not being registered until the sound has ended. What could cause that?

I noticed in the SCI Quest source that in some commented text where the code is for the sound room it says that cues aren't read normally because it's a looping sound or something. This sound isn't looping, but is there some sort of relation? I can't think of anything else.
« Last Edit: May 05, 2019, 03:46:55 PM by MusicallyInspired »
Brass Lantern Prop Competition

Offline troflip

Re: Sound Cues Not Cuing
« Reply #7 on: May 05, 2019, 05:52:52 PM »
The thing that scares me most about your code is that you seem to have multiple things moving the state to the next level. In case 0, both the music play: self and the (= seconds 4) will increment the state.

In case 1, you also have this FadeCode thing... I dunno what that is, but you pass self to it, so I assume it cues the RoomScript too at some point.

I dunno if either of these things are actually problems, but they are very suspicious to me.

Code: [Select]
(method (changeState newState &tmp temp0 [temp1 10])
(switch (= state newState)
(0
(gMusic1
number: 1001
loop: 1
play: self
)
(sparkle init: posn: 185 42)
(= seconds 4)
)
; Wait 4 seconds before going to the next state.
(1
(FadeCode init: 100 1 self)
(if (and
(< (gMusic1 prevSignal?) 20)
(!= (gMusic1 prevSignal?) -1)
)
(-- state)
)
(= cycles 1)
)
(2
(sparkle setCycle: EndLoop self)
)
(3
(if (and
(< (gMusic1 prevSignal?) 30)
(!= (gMusic1 prevSignal?) -1)
)
(-- state)
)
(= cycles 1)
)
(4
(sparkle posn: 79 133 loop: 1 cel: 0 setCycle: EndLoop self)
)
(5 (= seconds 3))
(6
(gMusic1 stop:)
(sparkle hide:)
(= cyclePalette FALSE)
(= cycles 5)
)
(7
(sparkle dispose:)
(DrawPic 501 dpOPEN_FADEPALETTE dpNO_CLEAR)
(= seconds 1)
)
(8
(Fanfare play:)
(= cycles 1)
)
(9
(if (== (Fanfare prevSignal?) 10)
(One init: setCycle: EndLoop self)
else
(-- state)
(= cycles 1)
)
)
)
)

Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Sound Cues Not Cuing
« Reply #8 on: May 06, 2019, 12:01:37 AM »
Agh yes there are way too many self calls there. I've fixed those now (I think). Now that I've done that, both sparkles animate, but still only at the end of the sound. It's like the 20 and 30 cues aren't recognized until the sound has finished and the DebugPrints confirm that. It is a mystery. I may have to abandon the cues and just time it to cycles/seconds or something.

Code: [Select]
(0
(gMusic1
number: 1001
loop: 1
play:
)
(sparkle init: posn: 185 42)
(DebugPrint {State 0 Music Plays})
(= seconds 4)
)
; Wait 4 seconds before going to the next state.
(1
(DebugPrint {Fading in from black})
(FadeCode init: 100 1 self)
)
(2
(if (and
(< (gMusic1 prevSignal?) 20)
(!= (gMusic1 prevSignal?) -1)
)
(-- state)
)
(= cycles 1)
)
(3
(DebugPrint {Animating first sparkle})
(sparkle setCycle: EndLoop self)
)
(4
(if (and
(< (gMusic1 prevSignal?) 30)
(!= (gMusic1 prevSignal?) -1)
)
(-- state)
)
(= cycles 1)
)
(5
(DebugPrint {Animating Second Sparkle (30)})
(sparkle posn: 79 133 loop: 1 cel: 0 setCycle: EndLoop self)
)
(6
(DebugPrint {State 6 (3 second pause)})
(= seconds 3)
)
(7
(gMusic1 stop:)
(sparkle hide:)
(= cyclePalette FALSE)
(DebugPrint {State 7 Stop music})
(= cycles 5)
)
(8
(sparkle dispose:)
(DrawPic 501 dpOPEN_FADEPALETTE dpNO_CLEAR)
(DebugPrint {Draw new picture})
(= seconds 1)
)
(9
(DebugPrint {Play Fanfare})
(Fanfare play:)
(One init: hide:)
(= cycles 1)
)
(10
(if (== (Fanfare prevSignal?) 10)
(DebugPrint {Cue detected!})
(One show: setCycle: EndLoop self)
else
(-- state)
(= cycles 1)
)
)
(11
(DebugPrint {State 11 wait 4 seconds})
(= seconds 4)
)
(12
(One dispose:)
(Fanfare stop:)
(DrawPic 502 dpOPEN_FADEPALETTE dpNO_CLEAR)
(= seconds 1)
)
(13
(DebugPrint {State 13 Begin Menu})
(= sMenuStart TRUE)
(= gCursorNumber 999)
(gGame setCursor: 999 1)
(Introduction
init:
;posn: (- 160 (/ (CelWide 2099 0 0) 2)) (Restore y?)
)
(Begin
init:
;posn: (- (- (Restore x?) (CelWide 2099 0 0)) 4) (Restart y?)
)
(Credits
init:
;posn: (+ (Restore x?) (CelWide 2099 0 0) 4) (Quit y?)
)
(Continue
init:
;posn: (+ (Restore x?) (CelWide 2099 0 0) 4) (Quit y?)
)
)

The FadeCode script is taken from a Sierra game (can't remember which) which can fade the screen in and out from/to black slowly by modifying palINTENSITY.

Code: [Select]
(instance FadeCode of Code
(properties)

(method (init param1 param2 param3)
(= local3 0)
(if (>= argc 1)
(= local2 param1)
(if (>= argc 2)
(= local1 param2)
(if (>= argc 3) (= local3 param3))
)
)
(gTheDoits add: self)
)

(method (doit &tmp temp0)
(if (!= local0 local2)
(= local0 (+ local0 (* 1 local1)))
(Palette palSET_INTENSITY 0 255 local0)
(= temp0 0)
(while (< temp0 10)
(++ temp0)
)
else
(gTheDoits delete: self)
(if (and local3 (IsObject local3))
(local3 cue:)
(= local3 0)
)
)
)
)
Brass Lantern Prop Competition

Offline troflip

Re: Sound Cues Not Cuing
« Reply #9 on: May 06, 2019, 12:54:38 AM »
I wonder if the cue thing could be a sound driver issue (that would suck).  Have you tried different drivers? (if your sound resource supports them).
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline MusicallyInspired

Re: Sound Cues Not Cuing
« Reply #10 on: May 06, 2019, 01:07:28 AM »
I'll give it a try.

For what it's worth, though, further experimentation yields that other sound resources cue just fine. Though, it's one ripped right from a Sierra game. Also, instead of invoking gMusic1 I added a new instance of Sound and just made that one play instead. Using the same code for checking the cue value works fine for that sound. I tried changing the other sound invocation to  an instance as well instead of gMusic1 but it still fails. I wonder if it is a custom sound resource issue. Which is weird because yours work in SCI Quest and they are obviously custom.
Brass Lantern Prop Competition

Offline MusicallyInspired

Re: Sound Cues Not Cuing
« Reply #11 on: May 06, 2019, 01:13:35 AM »
Well I'll be. I just tried the game in ADL.DRV and MT32.DRV and the cues aren't observed. However, when I switched to GENMIDI.DRV the cues were observed! So it is a sound device thing. Perhaps cues are tied to certain channels that need to be observed properly by certain sound devices to work? What channels are cues saved in? Are they saved in channels at all? Because if other sound devices don't have the channel that has the cues in them flagged then they won't be observed, right? I don't know it's midnight and I'm taking potshots into the air. I had been utilizing ADl.DRV all this time and MT32.DRV the odd time because those are the sound devices I would like to use the most, but it seems current implementation is geared towards General MIDI and General MIDI alone.
« Last Edit: May 06, 2019, 01:18:15 AM by MusicallyInspired »
Brass Lantern Prop Competition

Offline troflip

Re: Sound Cues Not Cuing
« Reply #12 on: May 06, 2019, 12:03:03 PM »
Hmm, cues stop working for me if I turn off channel 16 in the sounds.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Kawa

Re: Sound Cues Not Cuing
« Reply #13 on: May 06, 2019, 06:26:54 PM »
That's where the cue commands are stored, no?

Offline troflip

Re: Sound Cues Not Cuing
« Reply #14 on: May 06, 2019, 11:04:32 PM »
Possibly, I forget and am too lazy to look at the code. But I notice that channel is disabled in the screenshot MusicallyInspired posted before.
Check out my website: http://icefallgames.com
Groundhog Day Competition


SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.114 seconds with 23 queries.