Play a sound from bytearray in as3 - actionscript-3

I am recording sound using Microphone class. After completing the record, I am getting a byte array.
Now I want to use this byte array and play the sound. Is this possible?
Thanks.

See this manual
In short, make the microphone generate 44.1 kHz samples (mono), duplicate them in your own sample data procedure, and store them in your Sound object. 44kHz are mandatory to not have your sound pitched, as it's always played back as 44.1kHz sound. The resampling is to make mono sound into stereo sound, as you can't have mono sounds in Flash.

Related

What data is needed to be trained when detecting videos by object detection model

I have a task to detect illegal parking,I want to use object detection models like YOLO, SDD and others to detect them on video,Can i train it by video? or all frame from video? or any frame from video that are not similar?

Flash How do flush or empty netstream buffer

I'm experiencing an issue with a 20 video Flash project. We're calling the videos from a local source, and FLVPlayback is opening netstreams and generating this huge Uncategorized chunk of memory. Upon further inspection, it turns out that it's a large amount of netstream buffers. How do I empty these buffers?
I've found this NetStream.Buffer.Empty but I'm not sure how to properly use it.
Instead of using close(); I used dispose(); to stop, close, and flush the NetStream buffer. Many thanks to #batman
netStream.dispose()

Is there is memory limitation to seek play flash Audio player AS3?

Flash Audio Player: I have an audio file which is 6 hours long, i am not able to seek audio beyond (03:22:54) is there is memory limitation to seek play beyond this 12173943 milliseconds?
Apparently, some kind of limitation exists. AS3 fails to seek past 12173943 milliseconds, while AS2 does seek past this point, but with less precision. See this question on SO for further details. I'm not aware of any workaround barring splitting the file into chunks smaller than 12000 seconds.

Obtain the result ByteArray of the current playing sounds

I am developing an AIR application for desktop that simulate a drum set. Pressing the keyboard will result in a corresponding drum sound played in the application. I have placed music notes in the application so the user will try to play a particular song.
Now I want to record the whole performance and export it to a video file, say flv. I have already succeed in recording the video using this encoder:
http://www.zeropointnine.com/blog/updated-flv-encoder-alchem/
However, this encoder does not have the ability to record sound automatically. I need to find a way to get the sound in ByteArray at that particular frame, and pass it to the encoder. Each frame may have different Sound objects playing at the same time, so I need to get the bytes of the final sound.
I am aware that SoundMixer.computeSpectrum() can return the current sound in bytes. However, the ByteArray returned has a fixed length of 512, which does not fit in the requirement of the encoder. After a bit of testing, with a sample rate 44khz 8 bit stero, the encoder expects the audio byte data array to have a length of 5880. The data returned by SoundMixer.computeSpectrum() is much much shorter than the encoder required.
My application is running at 60FPS, and recording at 15FPS.
So my question is: Is there any way I can obtain the audio bytes in the current frame, which is mixed by more than one Sound objects, and has the data length enough for the encoder to work? If there is no API to do that, I will have to mix the audio and get the result bytes by myself, how can that be done?

Adobe AIR - Garbage collection and system.gc()

I'm building an Adobe AIR desktop app with Flash CS5 that makes a lot of use of bitmapdata, bytearrays and base64 strings. After a while the memory usage of the app doubles.
Is it recommended to use system.gc() to free memory at that point or is that bad practice?
Thanks.
system.gc is a debug only functionality in AIR and Flash player. I think the better thing is to recycle bitmapdata and other objects if you can to avoid gc, and if not call bitmapdata.dispose() and bitmapdata = null as soon as you are done with using them.
If you have bitmap objects of the same size at various times in your project, you can use the same instance of BitmapData to operate on them. This is similar to how ItemRenderers recycle items or how even other platforms like iOS's UITableViewController recycles/reuses UITableViewCell. Garbage collection is not panacea, it should be used when easy programmability is more important than performance.
You don't need to call system.gc as it will be called automatically on idle cycles by the Flash runtime. If you call it yourself you might end up slowing down your application for no real gain.
When you don't need a BitmapData or a ByteArray anymore, just call BitmapData.dispose() or ByteArray.clear().