No announcement yet.

Increasing sound volume in a loop

  • Filter
  • Time
  • Show
Clear All
new posts

  • Increasing sound volume in a loop

    I want to start a sound playing and, in a loop, increase the volume from 0 until it reaches 100%. Here's a screenshot of my program. When it runs, it starts the sound fine but the volume does not increase. Any thoughts? I hope the image is sufficient readable ...

    Increasing volume ev3 program.png

    Attached Files

  • #2
    The image is a bit small and I can't see what is in the other case of the wired switch block. Without knowing that I can't tell you why your program isn't working. I tried to duplicate the code and what I get is a loop that plays the sound over and over at increasing volume. The volume never changes while the sound plays, but each time the sound starts it plays at a slightly higher volume. Volume changes are uneven. 20 is noticeably louder than 19, but sounds exactly like 23.

    Some things to consider:

    1. Once a block begins executing it ignores any changes to the inputs. This is true for all the program blocks including switches and loops. If you expect the sound block to play a sound and increase volume before the sound is done playing it can't. It cannot see the volume change because it only looks at the volume input when it starts playing the sound. This behavior is also true for switch blocks and loops.

    2. A loop waits until all the branches in the code have finished running. This means each time through the loop the variable is incremented once, the display block gets called once, the sound is block runs once. The parallel beam for the sound block doesn't do anything that wouldn't happen if all the blocks were in the same thread.