The loudness value increases or decreases depending on how loud or quiet the microphone input is. If no microphone is available, the value is consistently -1. Sound is measured as a number from 0 to 100. However, it does not use any specific scale, and can only return up to 100, with any sound louder simply returning 100 as well.
Related Blocks
The following block can be used in conjunction with this value:
loudness
— The Stage Monitor and reporter block that reports the value of the volume detected by the microphone
Prior to Scratch 2.0, the loud?:: sensing
block would return true or false if the loudness value was over 30. The block's value could be displayed as a Stage Monitor.
Example Uses
Some common uses for the loudness value are:
- Voice analyzers
- Depending on how loud a noise is, the greater response
when gf clicked point in direction (pick random (-180.0) to (180.0)) forever move (loudness) steps if on edge, bounce end
- Setting a microphone's size to a noise's loudness
when gf clicked forever set size to ((100)+(loudness)) end
- Loudness graphing
when [timer v] > ((-1)/(0)) // Checks if the timer is greater than -Infinity erase all pen up go to x: (-240) y: (0) pen down repeat until <(x position) = (240)>. { set y to (loudness) change x by (1) }::control
Motion
While the loudness blocks sense microphone input, the video sensing blocks sense webcam input. Together, they can be used to sense real-life action, as shown below:
when green flag clicked forever if < <(video (motion v) on (Stage v)) < [30]> and <(loudness) < [30]>> then say [No fun!] end if < <(video (motion v) on (Stage v)) > [30]> and <(loudness) < [30]>> then say [Turn up the volume!] end if <<(video (motion v) on (Stage v)) < [30]> and <(loudness) > [30]>> then say [Start moving!] end if <<(video (motion v) on (Stage v)) > [30]> and <(loudness) > [30]>> then say [Party!] end