Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Sound Detection?
- vallraiene
- Scratcher
3 posts
Sound Detection?
Oh boy howdy I sure hope I started this thread in the right category.
My brother and I are making a real life-ish game with the help of Scratch for Halloween. Basically we're recreating a few parts of sister location, specifically Bellora's room. Feel free to cringe at us.
I tried to find a video example but I was afraid to link one because of bad words/scary stuff in the video, and I kind of don't want to be banned from Scratch. So hopefully you've seen/played the level I'm referring to.
We need to set up a microphone in a hallway, and the more sound that is detected/the louder the sound that is detected, a variable number will get higher. Not sure how else to explain it, but it would start at 0, and someone yelling could bump the number up to 90 something, maybe talking would set it to 50, etc. (I'm making up these numbers as I go.) Ideally the number wouldn't tick back down, so if it was at 50 it'd stay at 50 until it went up.
We'd have a music track in the background, and the variable would change the volume of the song. It'll play louder if the background noise of the room is louder.
So we ran into a few problems when trying to do this.
1. There's no way to detect sound in a Scratch project? I've been on Scratch for many-a many-a years now, and I swear I remember that being a feature. Mind you I did take a five month break, but I REMEMBER. Is there some kind of mod for this?
2. We can't have the soundtrack pick up in the microphone and change the volume level. This is probably an easy fix, I'm just lazy.
If there isn't a mod for this, what other programs can I use? Sadly I am not a very intelligent person and Scratch is the extent of my coding ability, so it's gotta be something I can learn fast.
Thanks for any help. Stay spooky my dudes.
My brother and I are making a real life-ish game with the help of Scratch for Halloween. Basically we're recreating a few parts of sister location, specifically Bellora's room. Feel free to cringe at us.
I tried to find a video example but I was afraid to link one because of bad words/scary stuff in the video, and I kind of don't want to be banned from Scratch. So hopefully you've seen/played the level I'm referring to.
We need to set up a microphone in a hallway, and the more sound that is detected/the louder the sound that is detected, a variable number will get higher. Not sure how else to explain it, but it would start at 0, and someone yelling could bump the number up to 90 something, maybe talking would set it to 50, etc. (I'm making up these numbers as I go.) Ideally the number wouldn't tick back down, so if it was at 50 it'd stay at 50 until it went up.
We'd have a music track in the background, and the variable would change the volume of the song. It'll play louder if the background noise of the room is louder.
So we ran into a few problems when trying to do this.
1. There's no way to detect sound in a Scratch project? I've been on Scratch for many-a many-a years now, and I swear I remember that being a feature. Mind you I did take a five month break, but I REMEMBER. Is there some kind of mod for this?
2. We can't have the soundtrack pick up in the microphone and change the volume level. This is probably an easy fix, I'm just lazy.
If there isn't a mod for this, what other programs can I use? Sadly I am not a very intelligent person and Scratch is the extent of my coding ability, so it's gotta be something I can learn fast.
Thanks for any help. Stay spooky my dudes.
- liam48D
- Scratcher
1000+ posts
Sound Detection?
There is indeed a block for that:
I believe it reports from 0 to 100. (edit: or -1 for no microphone.)
(loudness)
I believe it reports from 0 to 100. (edit: or -1 for no microphone.)
Last edited by liam48D (Oct. 9, 2016 18:10:00)
202e-202e-202e-202e-202e UNI-CODE~~~~~
- blob8108
- Scratcher
1000+ posts
Sound Detection?
No easy fix for that I'm afraid! You'll just have to hope it doesn't pick it up :-) 2. We can't have the soundtrack pick up in the microphone and change the volume level. This is probably an easy fix, I'm just lazy.
- vallraiene
- Scratcher
3 posts
Sound Detection?
There is indeed a block for that:(loudness)
I believe it reports from 0 to 100. (edit: or -1 for no microphone.)
Oh. Whoops. I saw that but thought it was something else. Maybe if it had been named “microphone volume” or something I would've found it, haha. Thanks.
No easy fix for that I'm afraid! You'll just have to hope it doesn't pick it up :-) 2. We can't have the soundtrack pick up in the microphone and change the volume level. This is probably an easy fix, I'm just lazy.
Hmm… Okay. I'll figure something out. I'm just worried about feedback is all, but I've got a pretty decent mic so it might not be a problem.
Last edited by vallraiene (Oct. 9, 2016 19:05:50)
- PullJosh
- Scratcher
1000+ posts
Sound Detection?
Sounds* like an interesting project! I've thrown together a bit of code that should do what you're looking for:
The volume of your music will fluctuate between 10% and 100% depending on the volume of the room. Try it out, and if you need any changes or want me to explain the code, just let me know.
* hue hue hue
when green flag clicked
set [music vol v] to [0]
forever
change [music vol v] by ((music vol) * (-.005))
if <(music vol) < (loudness)> then
set [music vol v] to (loudness)
end
set volume to ((10) + ((music vol) * (0.9))) %
end
when green flag clicked
forever
play sound [scary music v] until done
end
The volume of your music will fluctuate between 10% and 100% depending on the volume of the room. Try it out, and if you need any changes or want me to explain the code, just let me know.
* hue hue hue
- Jonathan50
- Scratcher
1000+ posts
Sound Detection?
What's Scratch for Halloween and who is Bellora?
Not yet a Knight of the Mu Calculus.
- vallraiene
- Scratcher
3 posts
Sound Detection?
What's Scratch for Halloween and who is Bellora?
Oh no, Scratch for Halloween isn't a thing hehe. I'm making something for Halloween for me and some friends, with the help of Scratch. Hope that makes sense.
Bellora is a character from Sister Location. I wish I could tell you more but I'm not that far in the game yet and really don't know much else, other that when you're in her room you should probably be quiet. >-< Scary video game.
- MegaApuTurkUltra
- Scratcher
1000+ posts
Sound Detection?
Use a microphone with a long cable and keep it far away from the speakersNo easy fix for that I'm afraid! You'll just have to hope it doesn't pick it up :-) 2. We can't have the soundtrack pick up in the microphone and change the volume level. This is probably an easy fix, I'm just lazy.
If I'm understanding this correctly
$(".box-head")[0].textContent = "committing AT crimes since $whenever"
- Jonathan50
- Scratcher
1000+ posts
Sound Detection?
Oh, all right. Oh no, Scratch for Halloween isn't a thing hehe. I'm making something for Halloween for me and some friends, with the help of Scratch. Hope that makes sense.
Bellora is a character from Sister Location. I wish I could tell you more but I'm not that far in the game yet and really don't know much else, other that when you're in her room you should probably be quiet. >-< Scary video game.
Not yet a Knight of the Mu Calculus.
- STAPLES999
- Scratcher
1 post
Sound Detection?
I still don't get how to detect sound in a program. Please Help.
- Zerofile
- Scratcher
100+ posts
Sound Detection?
(loudness)
This is the sound detection block.
Someone has already said that and you are aware this post is from 4 years ago?
thanks for the website ST
- beware4
- Scratcher
11 posts
Sound Detection?
It is very easy to make a sound detector. I made one in this project, https://scratch.mit.edu/projects/432293152/ It is very simple. Here is the code:
I hope this helped you!
when green flag clicked
go to x: (-145) y: (-92)
set [ghost] effect to (100)
show
clear
set pen size to (4)
set pen color to [#7FFF00]
forever
pen down
change x by (2)
set y to (loudness)
pen up
if <touching [edge] ?> then
clear
go to x: (-145) y: (-92)
pen down
change x by (2)
set y to (loudness)
pen up
end
end
I hope this helped you!
- --Explosion--
- Scratcher
1000+ posts
Sound Detection?
Thanks for that solution… But… The first post asking for help is from 4 years ago.
- samq64
- Scratcher
1000+ posts
Sound Detection?
Sounds* like an interesting project! I've thrown together a bit of code that should do what you're looking for:when green flag clicked
set [music vol v] to [0]
forever
change [music vol v] by ((music vol) * (-.005))
if <(music vol) < (loudness)> then
set [music vol v] to (loudness)
end
set volume to ((10) + ((music vol) * (0.9))) %
end
when green flag clicked
forever
play sound [scary music v] until done
end
The volume of your music will fluctuate between 10% and 100% depending on the volume of the room. Try it out, and if you need any changes or want me to explain the code, just let me know.
* hue hue hue
Cool idea, I think I`ll try it!
- atiksh31
- Scratcher
9 posts
Sound Detection?
IT IS EASY CHECK THIS YOU WILL UNDERSTAND https://scratch.mit.edu/projects/473671244
- atiksh31
- Scratcher
9 posts
Sound Detection?
when
clicked
set
music vol
to
0
forever
change
music vol
by
music
vol
*
-.005
if
music
vol
<
loudness
then
set
music vol
to
loudness
set
volume
to
10
+
music
vol
*
0.9
%
when
clicked
forever
clicked
set
music vol
to
0
forever
change
music vol
by
music
vol
*
-.005
if
music
vol
<
loudness
then
set
music vol
to
loudness
set
volume
to
10
+
music
vol
*
0.9
%
when
clicked
forever
- FOLLOWINGEVERYONE123
- Scratcher
1 post
Sound Detection?
(loudness)
This is the sound detection block.
Someone has already said that and you are aware this post is from 4 years ago?
No he means to detect the loudness of the sound playing in the project
- medians
- Scratcher
1000+ posts
Sound Detection?
No, that's what they meant, and this has been answered a long time ago so don't necropost:No he means to detect the loudness of the sound playing in the project(loudness)
This is the sound detection block.
Someone has already said that and you are aware this post is from 4 years ago?
Oh. Whoops. I saw that but thought it was something else. Maybe if it had been named “microphone volume” or something I would've found it, haha. Thanks.
Medians bamboozled by 3.0 (version 3.0): https://scratch.mit.edu/projects/979822351/
hi875230163394: You're similar to valve in that you both hate a certain number…
Scratch 0.x, 1.x, 2.x, 3.x and LogoBlocks Archives
Bamboozlement: https://scratch.mit.edu/studios/33739789
Years on internet: 15 (soon 16)
medians: Oh god not this utc - 12 thing again..
Fun_Cupcake_i81: What, were you expecting not to see the utc - 12 thing again? THE UTC - 12 THIGN ALWAYS RETURNS. ALWAYS.
medians: I knew it would happen. I was the one who started it last year.
Fun_Cupcake_i81: Well then if you didn't want it back maybe you need to time travel to last year and fix that
Oh wait if you could time travel I think we all know exactly when you would go-
user1: That picture is from 2.0. Now he’s at my house and is my pet.
user2: But this is medians we're talking about, so “from 2.0” can mean the same thing as “from five seconds ago”.
Detect Scratch version here
My other accounts: @selfexplanatory @modesties @chaircard @fireflyhero @dividendyield @colloids @radians @skeuamorphism @dihectogon @anglebisector @aau- @EditBlockColors @AdamantOrb @MoongeistBeam @festively @Ampharos_ @straightforwardness
i trolled redcat LOL
if you see this
{what method did you use::control hat;
answer on profile ::motion
} ::operators
- Honey-Tabby-Slime
- Scratcher
3 posts
Sound Detection?
guysh i finally founje out wihch block detectsh mic shoundsh
(loudness)
- Discussion Forums
- » Advanced Topics
- » Sound Detection?