Stop the script music... How?

Post » Fri May 04, 2012 1:50 pm

All fixed, so you can ignore this unless you'd like a journey through my dimwitted struggle... :D

_____________________________________________________________________________
For the better part of the last 24 hours, I've been pounding away trying to make this simple little script work consistently.

The concept is simple, equip a particular torch, and music plays. Unequip it and it stops. What could be so hard about that, eh? :biggrin:

But,when the torch is first equipped it usually (not always) begins to stutter as if the sound is being started and restarted every frame. the music will play fine after equipping the torch when the game is paused, as in when the inventory is open.

Sometimes going into a hand to hand combat stance or equipping a shield will stop the stutter, and the music will play.

However, under no circumstances whatsoever will the music cease to play or stutter, one the two.

When the torch is unequipped, and placed wither in inventory or dropped into the world, all local variables show a value of 0, as does the global that shows the torch equipped. The global that shows the torch unequipped has a value of 1, but the music plays on...

I have no idea what is going on. Is there some command besides StopSound that stops sound from playing?

This script is just a small part of a larger script that does other things, and the script when complete works fine, except the sound part posted here. The men from the funny farm are going to be coming for me if I have to listen to that music much longer...

Here's the script:

Begin 1NDTestScriptshort doOnceshort OnPCEquipshort NDTorch;' Globals 1NDEquipped, 1NDNotEquippedIf ( menuMode == 1 )		ReturnendIfIf ( OnPCEquip == 1 ) ;' Check that flute is equipped, set one instance to play.	set 1NDEquipped to 1 ;' Set globals to show values for debugging	set 1NDNotEquipped to 0			If ( doOnce == 0 )			set NDTorch to 1	endIfElse		set doOnce to 0		set NDTorch to 0  ;' show torch unequipped		set 1NDEquipped to 0 ;' Set globals to show values for debugging		set 1NDNotEquipped to 1		StopSound "RatDance" ;' Stop the music... Oh, Please...endIfIf ( NDTorch == 1 )  ;' Check that flute is equipped, play music if so.		PlayLoopSound3D "RatDance" play the music		set doOnce to 1endIfEnd 1NDTestScript 

I found the solution to making it stop in another thread. I wouldn't have thought the player fix would work since the script is attached to a torch. I'll add my thanks to the other person's whose thread it is. ...and...Thanks for being here...

That still leaves me with the stutter, and no clue about getting rid of that. Any thoughts?
Okay, I forgot to check with "GetSoundPlaying" and that fixed it, so no more problems...
User avatar
Nathan Barker
 
Posts: 3554
Joined: Sun Jun 10, 2007 5:55 am

Post » Fri May 04, 2012 11:43 am

I messed around with scripted music and sound in my Ruby Inn mod and found that some pieces of music don't like to be played in Morrowind. I think it might not be the script itself but the bit rate or size of the music/sound. In my case, I just assumed my computer was crap and changed it over to a smaller piece of music and that fixed it.

Maybe to test this replace the "stuttering" music with something else temporarily. Just find one of the pieces of music you know runs well, make a copy of it and rename the copy to whatever the piece is you are having trouble with. The script will play it as it would the original.

Maybe this helps. Good luck!
User avatar
Peter P Canning
 
Posts: 3531
Joined: Tue May 22, 2007 2:44 am

Post » Fri May 04, 2012 6:09 am

For anyone who has this stutter issue, here's what happened, and here's what fixed it.

I thought I had it solved by adding a getsoundplaying statement, but it didnt suit the script well. What was happening was that the playsoundloop ould start inframe one, the variable would be reset, and the rest ofthe script would run taking us to frame 2 where the variable ahd been reset, so the playsound loop tired to start again, although it was already started, and it did this over and over again every fram, creating the stutter.

The solution was to isolate the playsound in an if block restricted with a doOnce condition that kept it from starting again. Simple, but it drove me crazy.... When you're too close to an issue, you sometimes focus too closely on a wrong cause, and lose the perception that brings solutions.

Thanks for responding, Crankgorilla. Your solution may help someone else even though it wasn't right in my case. :)
User avatar
Latisha Fry
 
Posts: 3399
Joined: Sat Jun 24, 2006 6:42 am


Return to III - Morrowind