Bug Issue: Set volume on channel only applies if a sound is playing


Pages: 1

Luyren

  • Master Stencyler
  • *
September 11, 2019, 02:48:15 pm
b10417, on Windows 10. Happens on Flash and Windows standalone.

When using the block, it only sets the volume if there is already a sound playing at the given channel. If you set the volume and then play the sound, it will play at full volume.

Having the ability to set the volume on a channel before any sound plays would be useful to have different volume controls for soundtrack and sound effects in-game.

The block sets the volume correctly, with or without sounds playing in any channel.

Sample game: follow the on screen commands. Set the volume to 50, then loop the music. It will play at 100% volume, which you can then check by setting the volume to 50 again. Also included to commands that directly set the volume before playing a sound, and you'll notice that the volume is the same. All code is in the scene event.


New attachment added by Luyren - September 11, 2019, 02:48:36 pm


jaughnaugh

  • Subscriber - Stencyl Studio
  • *
September 26, 2019, 12:16:06 pm
I found this issue too and it used to work fine in previous builds. What I did was find the function and found that someone added 2 lines of code to the function that plays/loops sound on channel. If you open script.hx (path: Stencyl/plaf/haxe/lib/stencyl/1,00/com/stencyl/behavior/Script.hx) in a text editor and add // to sc.setVolume(1); and sc.setPanning(0); it will work again. I think these 2 codes are resetting the volume and panning.
Code: [Select]
public static function playSoundOnChannel(clip:Sound, channelNum:Int)
{
var sc:SoundChannel = engine.channels[channelNum];
sc.playSound(clip);
//sc.setVolume(1);
//sc.setPanning(0);
}
public static function loopSoundOnChannel(clip:Sound, channelNum:Int)
{
var sc:SoundChannel = engine.channels[channelNum];
sc.loopSound(clip);
//sc.setVolume(1);
//sc.setPanning(0);
}


Justin

  • Master Stencyler
  • *
October 05, 2019, 06:38:24 am
Previously discussed in these issues:
http://community.stencyl.com/index.php?issue=1471.0
http://community.stencyl.com/index.php?issue=1505.0

Per #1505, you should set channel properties immediately after playing a sound on the channel. You could also make the changes that jaughnaugh mentioned, but you would then need to always avoid the "play sound" block, because it may pick a channel that had previously had it's volume/panning changed.
« Last Edit: October 05, 2019, 06:42:17 am by Justin »


Issue updated by Justin - October 05, 2019, 06:42:58 am
  • Status changed from New to Closed


Pages: 1

Details

  • Reported
    September 11, 2019, 02:48:15 pm
  • Updated
    October 05, 2019, 06:42:58 am

  • View Status
    Public
  • Type
    Bug
  • Status
    Closed
  • Priority
    Normal
  • Version
    3.5.0 beta 1
  • Fixed in
    (none)
  • Assigned to
    (none)
  • Category
    Design Mode Blocks

Tags


Attachments

* Music Test.stencyl (3011.09 kB - downloaded 34 times.)