How to capture sound from the Line-In device - actionscript-3

I am trying to record the sound of my device connected to Line-In via ActionScript 3.
According to adobe docs ( http://livedocs.adobe.com/flex/3/html/help.html?content=Working_with_Sound_02.html ), The Microphone class lets your application connect to a microphone or other sound input device on the user's system .
But the Microphone class detects only microphones on my sound card ( Microphone.names array ) , not the "other sound input devices". Maybe there is another way to capture sound from Line-In devices?
Thank you!

Flash is built with security in mind, it won't let you access any hardware except predefined classes like Microphone and Camera (and only after user permission!)
You may have better luck with plugging the device into microphone socket or reroute its signal programmatically, if your soundcard software allows it.

Related

In flash as3 webcam how to get newly connected webcam name at run-time?

I have a flash as3 based webcam video recorder that publishes the webcam video stream and to do this i am using the following codes :
var camera:Camera = Camera.getCamera(0);
var arr:Array = Camera.names;
if(camera != null)
{
videoWidth = topBorderContainer.width;
videoHeight = topBorderContainer.height;
camera.setMode(videoWidth, videoHeight, 30, false);
camera.setQuality(0, 100);
if (camera)
{
videoDisplay.videoObject.attachCamera(camera);
}
}
But problem is that if i am connecting a new document camera at run time and running my webcam tool then Camera.names returning the previously connected document camera name instead of returning the new document camera name.
And to get new document webcam name i have to restart my application again.
But i have no knowledge how to get newly connected document camera name at run time so if anybody know how to get the newly connected document camera name at run time please help me to solve.
It is very likely that you will not be able to pull the trick:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Camera.html#getCamera()
"Scanning the hardware for cameras takes time. When the runtime finds at least one camera, the hardware is not scanned again for the lifetime of the player instance. However, if the runtime doesn't find any cameras, it will scan each time getCamera is called. This is helpful if the camera is present but is disabled; if your SWF file provides a Try Again button that calls getCamera, Flash Player can find the camera without the user having to restart the SWF file."
It is possible that Flash Player treats Workers (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Worker.html) as separate Flash Player instances and thus a new Worker would be able to access the renewed list of Cameras. You might want to try it.

SimpleWebRTC: consume video when peer machine has no webcam and microphone

I am using SimpleWebRTC to create a video chat room application.
One of the requirements is, a peer machine that has no microphone and webcam, should atleast be able to hear and see the video of other peers.
Is it possible to do?
I tried this using constraints{audio: false, video: false} in regular webRTC and it works on a machine that has no microphone and webcam.
How to accomplish this using simpleWebRTC?
Thanks!
I am not familiar with simpleWebRTC, but I use PeerJS. To answer even if you don't have a webcam or mic, all I do is I answer with 'null' instead of the stream.
So in Peerjs instead of
call.answer(window.localStream);
you can say
call.answer(null);
Try to find the code in SimpleWebRTC where the call is made or answered and try this.

ActionScript USB microphone stutter

I have a problem with USB mic input. When using my laptops internal microphone the following recorded buffer plays back just fine:
microphone = Microphone.getMicrophone();
microphone.codec = SoundCodec.SPEEX;
microphone.setLoopBack(false);
microphone.rate = 16;
microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, processMicData);
private function gotMicData(micData:SampleDataEvent):void {
micBuffer.writeBytes(micData.data);
}
But when I select the USB mic the sound stutters, like it's adding silence between the buffers. By the way, if I use a program like Audacity to record the USB microphone, everything works fine.
I would recommend trying to use the Microphone.setSilenceLevel() method. It allows you to set a level of microphone activity necessary for flash to read the audio input. Then, when no input is recorded, it won't write in silence when no information is received.
For more info:
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d0c.html

Can I get audio data from microphone in background task?

I want to implement a feature in Windows Phone 8, let it calculate decibel by using the audio data from microphone in background task. Is it possible?
You can't access the microphone from a background task according to this:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202962(v=vs.105).aspx
Unsupported APIs:
System.Windows.Media A/V Capture
Microsoft.Xna.*

Adobe Air - Choose webcam manually

How to choose the webcam/camera manually in Adobe Air? In Flash it's working through this:
Security.showSettings(SecurityPanel.CAMERA);
Is there something like that in Adobe Air?
Thank
In the Adobe Air Player (up to 3.4) there is no equivalent of the Flash Player security panel that can be triggered with Security.showSettings(SecurityPanel.CAMERA);
If you want to let the user pick a camera, you will have to create some sort of menu by using the info from the Camera.names array. Then, you can assign the user's choice via code by using something like :
var cam:Camera = Camera.getCamera('1');
Important: contrary to what was said above you CANNOT specify the camera by name. The getCamera() function expects a string representation of the camera's index number as a parameter. This is weird behaviour but it's how it works. So if you want to retrieve the second camera, you will have to pass the string '1' to the getCamera() function.
If you try to set the camera by specifying it's name, the function will return null.
I don't think there is any feature that you can use to select camera in AIR.
Instead you have to do it by coding.
get list of cameras using Camera.names property and then get selected camera instance using Camera.getCamera("name of camera");
I think this is best way to Do it.
Do you really need that typical dialog?
You can set a camera manually first by showing a list by:
var cameraNames:Array = Camera.names;
And then.....
var cameraInstance:Camera = Camera.getCamera('selectedCameraName');