(Workaround: Removed hidden comment of deleted image)
(Example Uses)
Line 18: Line 18:
 
Some common uses for the Volume block:
 
Some common uses for the Volume block:
 
*Volume controls
 
*Volume controls
 +
 +
<scratchblocks>when [dial] clicked
 +
repeat until <not <mouse down?>>
 +
point towards [mouse-pointer v]
 +
if <(direction) < [0]>
 +
point in direction (0 v)
 +
else
 +
if <(direction) > [100]>
 +
point in direction (100 v)
 +
else
 +
set volume to (direction)%
 +
end
 +
end
 +
say (join (volume) [%])
 +
end
 +
say (join (volume) [%]) for (2) secs</scratchblocks>
 +
 
*Loops that must stop once the volume is at a certain amount
 
*Loops that must stop once the volume is at a certain amount
 +
 +
<scratchblocks>repeat until <(volume) = [0]>
 +
change volume by (-10)
 +
end</scratchblocks>
 +
 
*Sensing how loud something is being played
 
*Sensing how loud something is being played
 +
 +
<scratchblocks>when gf clicked
 +
forever
 +
say (volume)</scratchblocks>
  
 
==See Also==
 
==See Also==

Revision as of 01:45, 14 June 2012

Volume
Volume.png
Category Sound
Type Reporter

The Volume block is a Sound block and a Reporter block. The block holds the Scratch project's volume. This block can be displayed as a Stage monitor.

Workaround

This block can be simply replicated with the following code:

([volume v] of [sprite v])

where "sprite" is replaced by the sprite you are finding the volume of.

Example Uses

As this block holds how loud sounds, drums, and notes will be played, it is useful in music projects where they must sense how loud an instrument has been played.

Some common uses for the Volume block:

  • Volume controls
when [dial] clicked
repeat until <not <mouse down?>>
point towards [mouse-pointer v]
if <(direction) < [0]>
point in direction (0 v)
else
if <(direction) > [100]>
point in direction (100 v)
else
set volume to (direction)%
end
end
say (join (volume) [%])
end
say (join (volume) [%]) for (2) secs
  • Loops that must stop once the volume is at a certain amount
repeat until <(volume) = [0]>
change volume by (-10)
end
  • Sensing how loud something is being played
when gf clicked
forever
say (volume)

See Also