Sound loop and dontstop

edited 2013 Feb 10 in General
Hello, After some advice :) I am trying to implement an environmental sound such as a machine running.

I am not sure if this is the best way about it, but I am using a 'particle generator' to add the sound and get it running. As I dont want the sound to play a thousand times I have set the 'Max Age' to 1 tick. So the sound plays then the generator ends. However I have set the sound to loop. This works fine in game and does exactly what I want.

However, once I have lots of monsters in game and the attack sounds going etc it seems at some point my looping environmental sound is stopped and with the generator stopped there is nothing to get the sound going again.

I have added the flag 'dontstop' so no other sound will cut if off, but this does not seem to work. Im guessing its the way I have spawned the sound into the game?

Flags = "sf_dontstop | sf_repeat";

So am I doing this the right way (seems a little hack and slash), but its the only way I know of and it works mostly. Just need to stop the sound loop being interrupted.

Here is my 'Thing' and my 'Sound' info
Thing
{
ID = "SND_Machine_1"
Name = "S_Mech_1"
DoomEd number = 8403
Spawn State = "Col_1"
Spawn health = -1
Mass = 25

}

Generator {
  Mobj = "SND_Machine_1"
  Center { 0 0 5 }
  Spawn age = -1
  Spawn radius = 1
  Max age = 1
  Spawn rate = 1
 
Stage {
   Tics = 2
   Sound = "Machine_one"
    	
	}
	 
}


Sound {
  ID = "Machine_one";
  Flags = "sf_dontstop | sf_repeat";
  Ext = "Sounds\Machine_1.wav";
  Link pitch = -1;
  Link volume = -1;
  Priority = 70;
  Max channels = -1;
}
Edit (danij): Added /code tags.

Comments

  • I never got dontstop and repeat to work either.

    It's possible they don't do what their names imply or even that they were never fully implemented.

    For instance the deathmatch and co-op XG flags don't check for those game modes as the documentation and their names imply; they both only check if the game mode is multiplayer.
  • I have got "sf_repeat" to work fine, and the other flags seem to work ok such as "sf_nodist" etc, but just the "sf_dontstop" doesnt seem to work :(

    Thats interesting you also had problems with those, maybe its not the way I have implemented the playing of the sound then.

    This is a real pain because I have particles such as sludge pouring out of a pipe. It looks cool, but just does not feel 'alive' with no sound. The sound I added works great, its just that after a battle with more then a few monsters it gets cut off and doesnt come back.

    I need to be able have the sound activate again. If I leave the particle generator going the sound keeps biulding up until there are many many instances of it playing, obviously this is not good.

    I thought maybe I could set the flag "sf_exclude" so only 1 sample will play as any other instances would be stopped, but this seems to have no effect. Maybe I am implementing it wrong?

    The wiki says :-

    "When sample playback begins all other playing samples in the same group will be stopped (otherwise just those of the same emitter will stop). Used in conjunction with the exclusion group feature"

    Im not sure how to set an "exclusion" group, or if that will make any difference, it does say "otherwise just those of the same emitter will stop", so surely just setting the flag is all thats needed.

    Maybe DaniJ can shed any light on this or have any ideas how to play an uninterruptible lopping sound in game?

    Thanks for feedback Vermil, as always I appreciate the help.
  • edited 2013 Jan 30
    The group field in the sound def is needed to specify a group for a sound. It must be a number.

    My guess is that the channel the repeating sound is playing on, is only 'protected' while the emitter is still in the game world; if the emitter is no longer present in the game world, another sound can take the channel.

    Thus, one way to make a stationary sound is to make a mobj like the below:

    To make it appear to loop, time the states (i.e in the below the sound effect was the equivalent of 144.1 tics long.

    Then give it a blank sprite (i.e a sprite with no non-transparent pixels) and it will appear invisible in game (or just stick it in the void).
    Thing {
      ID = "AMBIENT SOUNDX";
      Name = "AMBIENT SOUNDX";
      DoomEd number = 9999;
      Spawn state = "AMBIENTXA";
      See state = "NULL";
      Pain state = "NULL";
      Melee state = "NULL";
      Missile state = "NULL";
      Death state = "NULL";
      Xdeath state = "NULL";
      Raise state = "NULL";
      See sound = "None";
      Attack sound = "None";
      Pain sound = "ambientx";
      Death sound = "None";
      Active sound = "None";
      Reaction time = 0;
      Pain chance = 0;
      Spawn health = 1000;
      Speed = 0;
      Radius = 32;
      Height = 64;
      Mass = 10000000;
      Flags = "mf_noblockmap mf_nosector mf_local";
    }
    
    State {
      ID = "AMBIENTXA";
      Sprite = "BLNK";
      Frame = 0;
      Tics = 1;
      Next state = "AMBIENTXB";
    }
    
    State {
      ID = "AMBIENTXB";
      Sprite = "BLNK";
      Frame = 0;
      Tics = 144.1;
      Action = "A_Pain";
      Next state = "AMBIENTXA";
    }
    
    Edit (danij): Added /code tags
  • Hey, Thanks Vermil!

    Thats a pretty cool idea and in many ways better then a particle generator. Though will that not have the same issue of repeating the sound on top of each other constantly, hence why I had to kill my gnerator and use a loop for continues playback?

    I shall mess about tonight and see if I can get anywhere with this method.

    EDIT : Sorry I missed this bit

    "To make it appear to loop, time the states (i.e in the below the sound effect was the equivalent of 144.1 tics long."

    I did think of this method with the particle generator, but thought it would be a pain to get just right. Any suggestions? How many ticks in 1 second ?
  • 35 tics equals 1 second.
  • Vermil wrote:
    35 tics equals 1 second.
    Excellent! That sounds familiar for some reason, pretty sure I read that on the wiki sometime ago....me being lazy I guess!

    Ok, I have a plan and will post back the results.

    Cheers
  • Just an update :)

    I can happily say problem solved.

    Using advice from above (Thanks again Vermil) I have managed to add a non-stopping envionmental lopping sound into the level.
        Thing {
          ID = "SND_TOX_Flow_1";
          Name = "SND_TOX_Flow_1";
          DoomEd number = 8401;
          Spawn state = "ENV_SND_TOX_FLOW_1_1";
          Pain sound = "Tox_Sludge_Out_one";
          Pain chance = 200;
          Spawn health = 1000;
          Mass = 25;
          Radius = 32;
          Height = 64;
          Flags = "mf_noblockmap mf_nosector mf_local";
        }
    
        State {
          ID = "ENV_SND_TOX_FLOW_1_1";
          Sprite = "BLNK";
          Frame = 0;
          Tics = 1;
          Next state = "ENV_SND_TOX_FLOW_1_2";
        }
    
        State {
          ID = "ENV_SND_TOX_FLOW_1_2";
          Sprite = "BLNK";
          Frame = 0;
          Tics = 104;
          Action = "A_Pain";
          Next state = "ENV_SND_TOX_FLOW_1_1";
        }
    

    When messing about it seems if I have too many sounds setup like this it can 'sometimes' cause one of the sounds to pause or disappear for a second or two, but this seems very rare. Either way its not good to have too many looping sounds anyway, but it really does make a difference when used sparingly.

    One note for the above (though pretty obvious) you do need to subtract 1 tick from the sound length because state 1 uses 1 tick and effectively adds a very minor pause between the sound looping. So if anybody does use this method, keep that in mind.
  • One must remember, that ones computer can only play so many sounds at once. If the sound card runs out of available sound channels, sounds will be cut regardless.

    Dday supports up to 32 channels (well that's as high as Snowberry allows; I don't know if the command line option can go higher) while ZDoom's slider goes up to 255. Though ZDoom's 255 is simply very very future proof; no sound card I am aware of supports anywhere near 255 channels.

    It's also worth noting that Dday has an algorithm that attempts to intelligently pick which sounds to cut if it runs out of sound channels; it is my understanding that the players distance from the emitter and the priority fields in sound defs are two things considered by the algorithm.

    It's also worth noting that modern sound cards regularly use multiple channels at once for a single sound, so the number of channels doesn't equal the number of sounds that can play at once. In the old days, it was more like one channel equals one sound.
  • You could also add them as XG sector types...
    Sector Type {
       ID = 8001;
       Ambient sound = "ambient_001";
       Ambient min interval = 12;
       Ambient max interval = 36;
    }
    
    Sector Type {
       ID = 9001;
       Ambient sound = "ambient_loop_001";
       Ambient min interval = 6.872;
       Ambient max interval = 6.872;
    }
    
    The 8001 will play the sound with random interval between 12 and 36 seconds. The 9001 will loop the sound every 6.872 seconds, but it won't start playing it immediately as the level starts, it waits the min interval. With long sounds the delay may be quite noticeable. Maybe there's some way to get it playing right away...
  • In the first tic of a map, very little can be done as the game hasn't fully initialized.

    That is why in my mobj example above, I had that 1 tic state; to delay the call to play the sound to the second tic of game time. I loop back to it as personal preference, to make sure the sound has finished before playing it again, but one probably doesn't have to and could probably go 1,2,2,2,2,2,2... instead of 1,2,1,2,1,2...

    Indeed, in Dday 1.9, Infine sounds are also affected by the first tic; in the aging 1.8.6 infine could play sounds in the first tic.
  • Vermil wrote:
    Though ZDoom's 255 is simply very very future proof; no sound card I am aware of supports anywhere near 255 channels.
    O rly? Do cheap soundcards /onboard audio have hardware mixing? Doesn't FMOD support software mixing? I just checked that with ZDoom, 192 and 256 sound channels give different sound volumes in second room of Nuts2.wad. So it does seem to work.
  • Doomsday now supports up to 256 channels (up from 64) as of unstable build 769; but one has to use the command line option (-sfxchan), as Dday has no in engine control for it, like ZDoom.

    The default is still 16 though and Snowberry still only allows one to set up to 32. Therefore, if you want more than 32 channels, you can't start Dday using Snowberry.

    Personally though, I don't know why Dday doesn't just default to the very highest value it can support, since as as far as I am aware (i.e I personally haven't heard anything to suggest otherwise), Dday doesn't have issue if it doesn't find as many sound channels as the user has told it to use.
Sign In or Register to comment.