Be a Supporter!

AS : Microphone

  • 4,493 Views
  • 49 Replies
New Topic Respond to this Topic
Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
AS : Microphone 2006-07-26 11:56:41 Reply

AS:Main - Now comes with No0b repelant

What you'll learn, hopefully
In this tutorial i'll explain about the 'Microphone' Object introduced in Flash MX2004. I'll also show some neat effects
you can use in one of your flashes as mabye a preloader, or with a little more knowledge, a full blown game.

Is it hard?
The mike object is very similar to the Camera Object
in flash. It uses some very similar properties. So if you know about the Camera object, how it works,how to apply it, then this should be a pretty simple tutorial.

How to use it!

Now onto the actual tutorial. If you ever get stuck, or are shouting 'wtf' and hitting your computer, just click on one of the links at the bottom and they should give a little

more info.
Alot of this code is taken from macromedia live docs, so if you get stuck, they are probably a good place to look.

Getting the mike!

To do anything with the mike in flash, you have to actuall find the appropriate mike and apply it to an object to do that
paste these actions in a frame in you flash. I'll explain afterwords:-


this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth());
var active_mic:Microphone = Microphone.get();
sound_mc.attachAudio(active_mic);

Now for the explaination.
1. The first line creates and empty movie clip on the timline, and calls it "sound_mc".
2. Then a new variable called active_mic is created. It is declared a Microphone object.
3. On the same line 'Microphone.get();' is used. This applies the default mike to the Mircophone Object.
4. The last line actually makes out Object usable on the stage. It applies our Object (active_mic) to our MC.

Now, try testing you movie. If you speak into the mike you should be able to hear your voice amplified coming from
your speakers.

Making it clearer!

When you tested the previous example the sound may have appeared muffled, or abit fuzzy. In this part i'll tell you how to
make the sound alot clearer and easier on the ear.

Put this code after the code you just pasted on the timline:-


active_mic.setRate(22);
active_mic.setUseEchoSuppression(true);

Explanation:-
1. The top line sets the Microphone amount of Khz per second, The higher the number(uaually) the better the quality.
2. The second line tells the miek to use echo suppresion. This reduces the amount of feedback from the speakers, making the sound clearer.

Now if you test your movie. The sound should be clearer. If you don't notice any difference, fiddle around with the mike settings by right clicking on your preview movie,
clicking settings, then going onto the mike tab.

How to see sound!
In this final part of the tutorial i'll show you lot how to make a shape's properties change by the level of activity the mike is detecting. You could make it rotate, go smaller,
get bigger, change colour, anything you want. I'm going to work on scale, it is one of the simpler open, so most people should understand it.
It basically makes the shape expand, retract depending on the level of sound detected. The more sound, the bigger the shape.

Just paste this code under your current code:-


var amount:Number =50;
onEnterFrame = function () {
shape._xscale = shape._yscale = active_mic.activityLevel+amount;
};

And then make a Movie Clip on the stage, it can be any size, shape, whatever you want. Give it the instance name 'shape'.

Now if you test the movie when you speak into the mike the shape will expand and retract. To get different effects, just shange the variable 'amount'
to a different number. You can also try using different properties to change the effect, for example:-


var amount:Number =50;
onEnterFrame = function () {
shape._xscale = shape._yscale=active_mic.activityLevel+amo
unt;
shape._rotation = active_mic.activityLevel+amount;
shape._x = active_mic.activityLevel+amount;
shape._y = active_mic.activityLevel+amount;
};

That code will make the shape move around the stage, rotate, expand and retract, all depending on the level of microphone ativity.

That conculdes the long tutorial on the flash microphone object. I hope you understood most of it, don't just copy and paste the code though, read the explanations,
They should explain most of the code. Below is an examples of the final product! If you have any questions, just post them below.

EXAMPLE
Fully Done Project!

HELPFUL LINKS
Marcomedia

Live Doc(MX 2004)
Kirupa's Tutorial
AS : Video - My other AS

1004th Post :)

BBS Signature
citricsquid
citricsquid
  • Member since: Jun. 25, 2005
  • Offline.
Forum Stats
Member
Level 23
Blank Slate
Response to AS : Microphone 2006-07-26 12:05:15 Reply

That is great, i am defiently going to have a go at this, i bet it would be possible to use this to make a game, like a platformer, using commands, like blows to move him.

Great tutorial.

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS : Microphone 2006-07-26 12:14:47 Reply

At 7/26/06 12:05 PM, EscapeFromReality wrote: That is great, i am defiently going to have a go at this, i bet it would be possible to use this to make a game, like a platformer, using commands, like blows to move him.

Great tutorial.

That's be cool. I don't believe that flash can understand vocals (e.g. hello), but it'd be quite cool if you could blow a balloon using the mike.
I might give that a shot aswell, just as an experiment.

Isn't there a DS game like that?

BBS Signature
citricsquid
citricsquid
  • Member since: Jun. 25, 2005
  • Offline.
Forum Stats
Member
Level 23
Blank Slate
Response to AS : Microphone 2006-07-26 12:19:27 Reply

At 7/26/06 12:14 PM, Depredation wrote: That's be cool. I don't believe that flash can understand vocals (e.g. hello), but it'd be quite cool if you could blow a balloon using the mike.
I might give that a shot aswell, just as an experiment.

Isn't there a DS game like that?

A mini game on Mariokart, you drive around blowing uo balloons.

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS : Microphone 2006-07-26 12:29:42 Reply

At 7/26/06 12:19 PM, EscapeFromReality wrote: A mini game on Mariokart, you drive around blowing uo balloons.

I thought so. Cheers.

Anyone else have any comments?

BBS Signature
JamsCo
JamsCo
  • Member since: Jun. 20, 2006
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to AS : Microphone 2006-07-26 12:47:10 Reply

Awesome tutorial, great for beginners.

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS : Microphone 2006-07-26 14:14:05 Reply

At 7/26/06 12:47 PM, JamsCo wrote: Awesome tutorial, great for beginners.

Cheers, it's not complicated AS, it'll probably go in the Basic Section of AS:Main.

Hopefully:)

BBS Signature
GuyWithHisComp
GuyWithHisComp
  • Member since: Nov. 10, 2005
  • Offline.
Forum Stats
Member
Level 28
Blank Slate
Response to AS : Microphone 2006-07-26 15:04:06 Reply

Nice, but you should've added all properties to the object. index for example.
Mic.index equals the mic the user is using.


BBS Signature
AngryFaic
AngryFaic
  • Member since: Jun. 26, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS : Microphone 2006-07-26 15:08:31 Reply

Damn, something must be wrong. My microphone works and it's plugged in correctly, but I don't get any sound from the microphone in Flash.

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS : Microphone 2006-07-26 15:11:49 Reply

At 7/26/06 03:04 PM, ViktorHesselbom wrote: Nice, but you should've added all properties to the object. index for example.
Mic.index equals the mic the user is using.

I decided to leave them out because they are not an essential bit in using the mike. There is a link at the bottom though for the camera object, so poeple can look that up there.

To the person above, i'm not sure what is wrong. Try messing around with your mike settings in the voluem controls.


BBS Signature
AngryFaic
AngryFaic
  • Member since: Jun. 26, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS : Microphone 2006-07-26 15:24:12 Reply

It's tuned properly, it works on Skype and when I go into the volume settings in the tool bar, un-mute the microphone and I can hear myself. When I go into the Flash player I go to settings I go to the microphone settings and it's like it doesn't recognize it.

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS : Microphone 2006-07-26 15:30:57 Reply

At 7/26/06 03:24 PM, TechnoTrepidity wrote: It's tuned properly, it works on Skype and when I go into the volume settings in the tool bar, un-mute the microphone and I can hear myself. When I go into the Flash player I go to settings I go to the microphone settings and it's like it doesn't recognize it.

Weird, i'm afraid its nt to do with my tutorial. Try the example and tell me if it works.


BBS Signature
BitsNBytes
BitsNBytes
  • Member since: Oct. 17, 2004
  • Offline.
Forum Stats
Member
Level 47
Programmer
Response to AS : Microphone 2006-07-26 16:31:13 Reply

Thanks for putting this up, man.


D:

BBS Signature
Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS : Microphone 2006-07-27 07:40:54 Reply

At 7/26/06 04:31 PM, CubeInABox wrote: Thanks for putting this up, man.

No problem. I'm glad it helped.

Any more comments?

BBS Signature
WolfAkela
WolfAkela
  • Member since: Dec. 19, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS : Microphone 2006-07-27 08:07:25 Reply

This is awesome. Lol, do I hear karaoke Flash games?

UnknownFury
UnknownFury
  • Member since: Aug. 10, 2005
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to AS : Microphone 2006-07-27 08:14:42 Reply

Nice tutorial, goes nicely along side AS: Webcam or whatever its called. I have yet to try it out but it looks like it should work :p

Lone-Ronin1
Lone-Ronin1
  • Member since: Dec. 8, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS : Microphone 2006-07-27 08:39:03 Reply

Thanks so much! i am making a game where you use the mike to kill the bad guys ( iam almost done with lvl one

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS : Microphone 2006-07-27 09:16:12 Reply

At 7/27/06 08:39 AM, loneronin1 wrote: Thanks so much! i am making a game where you use the mike to kill the bad guys ( iam almost done with lvl one

Sounds good. I'm glad you all like the tutorial. P.M me when you've done that game, it'd be intresting to see.

Anyone else?

BBS Signature
Lone-Ronin1
Lone-Ronin1
  • Member since: Dec. 8, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS : Microphone 2006-07-27 09:37:55 Reply

At 7/27/06 09:16 AM, Depredation wrote:
At 7/27/06 08:39 AM, loneronin1 wrote: Thanks so much! i am making a game where you use the mike to kill the bad guys ( iam almost done with lvl one
Sounds good. I'm glad you all like the tutorial. P.M me when you've done that game, it'd be intresting to see.

ok i will

Lone-Ronin1
Lone-Ronin1
  • Member since: Dec. 8, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS : Microphone 2006-07-27 22:45:11 Reply

At 7/27/06 09:16 AM, Depredation wrote:
At 7/27/06 08:39 AM, loneronin1 wrote: Thanks so much! i am making a game where you use the mike to kill the bad guys ( iam almost done with lvl one
Sounds good. I'm glad you all like the tutorial. P.M me when you've done that game, it'd be intresting to see.

Anyone else?

you get a cool point!

AS : Microphone

shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS : Microphone 2006-07-28 00:35:21 Reply

At 7/27/06 10:45 PM, loneronin1 wrote: you get a cool point!

He only gets .5 of a cool point!
This is incredibly basic... Any fool who knows how to use the flash help can learn this..

But none the less no one has done this yet. So meh.

Lone-Ronin1
Lone-Ronin1
  • Member since: Dec. 8, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS : Microphone 2006-07-28 01:22:04 Reply

but he gets another .5 of a cool point for giving me an idea for a game

royevans
royevans
  • Member since: Jun. 25, 2006
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to AS : Microphone 2006-07-28 01:26:04 Reply

wow when you type you spare no expense do you? :D

Lone-Ronin1
Lone-Ronin1
  • Member since: Dec. 8, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS : Microphone 2006-07-28 01:44:08 Reply

At 7/28/06 01:26 AM, royevans wrote: wow when you type you spare no expense do you? :D

who?

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS : Microphone 2006-07-28 08:04:22 Reply

At 7/28/06 12:35 AM, shazwoogle wrote: He only gets .5 of a cool point!
This is incredibly basic... Any fool who knows how to use the flash help can learn this..

But none the less no one has done this yet. So meh.

He's right, its not very advanced. I like doing these type of tutorials though, because i never muck up. I thought about doing another one called 'Trignometry for Dummies' but i want to learn more about it before i do :)

Thanks for half a cool point i now have a total of, 0.5 :'(

BBS Signature
Vengeance
Vengeance
  • Member since: Mar. 18, 2005
  • Offline.
Forum Stats
Member
Level 28
Blank Slate
Response to AS : Microphone 2006-07-28 08:06:45 Reply

please stop bumping this thread. if people need help with this they'll ask for it.


========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature
Eggy
Eggy
  • Member since: May. 22, 2005
  • Offline.
Forum Stats
Member
Level 41
Game Developer
Response to AS : Microphone 2006-07-28 08:21:01 Reply

Pretty helpful, thanks. Be cool to see some microphone games.

toxicologist
toxicologist
  • Member since: Jul. 31, 2006
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to AS : Microphone 2006-08-03 15:43:45 Reply

i just wondered if you use the same kind of actionscript to make an object move in time to music?

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS : Microphone 2006-08-04 12:08:10 Reply

At 8/3/06 03:43 PM, technofreak1 wrote: i just wondered if you use the same kind of actionscript to make an object move in time to music?

i don't think so, i tried it, and it didn't work. But i may have mucked it up somwhere, try it, and a few otehr things then if it fails PM the guy who made 'streamline' on the front page, or make a topic for it on the flash forum.
:)


BBS Signature
fwe
fwe
  • Member since: Jul. 24, 2003
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS : Microphone 2006-08-04 14:20:18 Reply

Did you know that if you stick your microphone in your butt it sounds like shit?

LOLOLOLOLOLOLOLOLOLOLOLOLOLOLOL


wtfbbqhax