Currently, when you hit the record button, it fires the pulse which starts recording the answer, not the question. What do I need to do to start recording the question first and then delay start of the answer by a number of seconds?
Adding a delay allows the camera to start before firing the pulse
Related
I'm working on a small app that requires the video camera to record the last 20,30,40,50seconds while its continually previewing on my rectangle. I can record and save as I wish but the movies are really big and I cant have the app recording all the time, I only need the last portion of the movie.
I though of putting frames of the movie in a queue but that would be too expensive in data structures as I'm also saving gps data and accelerometer data. I think I need some sort of a buffer so when the user presses save it saves what is in the buffer as a movie.
Any help would be appreciated, I'm not looking for code, just a way round this problem.
use the background timer and invoke the record option at required intervals.
I am using the nodeOscillator function from Web Audio API to generate a sound, however when the sound cuts it makes a pop sound (the amplitude is not zero at the cut). Does anyone know a way to check the amplitude of a nodeOscillator and wait until it is zero before I call nodeOff()?
Just fade it out on a gain node over a short time interval 1ms or so - use a setTargetAtTime - and schedule the stop for just longer than that interval.
If you are using an Apple computer, take a look at this: https://vsee.zendesk.com/hc/en-us/articles/204973595-Mac-audio-pop-click-sound
After searching the net high and low, I just cannot for the life of me figure this out. I'm definitely a newbie with all things Flash, but I'm teaching myself where I can. I've gotten a simple Flash piano working, and would like to add record & play back functions. This is where the problem comes in- I can find any multitude of answers for recording from the microphone and saving/playing it back with Flash, but the only things I can find relating to internal audio (or Flash-based pianos) at all are questions like this one with either really vague answers or just no answers at all.
I have some sort of idea that I should be creating an array that tracks the clicks? (It's a mouse-playable piano at the moment, but if it's better for me to make it keyboard-based, that's something I can do at least). After (before? during?) creating that array, how do I keep the rhythm/timing correct?
I'm just super lost and really need your expertise...
You're on the right track in storing the clicks in an array. As far as rhythm and timing, when the user wants to start "recording" you can start a timer, I'd every 200ms or so. You can use that timer to determine at what point in time the key was clicked for use when playing it back.
I don't know if something like a long press is something you'd need, but to do that, with the same timer, you can set a start time and end time (press-->release) and just subtract the end time from the start time and now you have the duration of how long the key was pressed
EDIT: here is a quick example of what I was referring to in my original post: http://ronnieswietek.com/piano/piano_example.swf
the source: http://ronnieswietek.com/piano/piano_example.fla
I'm writing a recorder for website with flash using the flash.events.SampleDataEvent from the Microphone. But there is one strange thing:
At the beginning the SampleEvent occurs approximately every second. That's really slow. But after waiting a while in front of the browser and starting it again, it's very fast.
So 2 questions:
Is there a way to influence the time between the events
Why is this happening?
Thanks in advance
That is kind of strange. There's no way to tell the event when to dispatch. It just gets triggered when the microphone has sound data in the buffer. For some reason, it doesn't seem like your microphone is recording very much data at first. Try adjusting Microphone.gain and also Microphone.rate. Higher gain will amplify what you are recording to hopefully trigger the event faster and increasing the rate will give you more samples per event.
I'm building a remote presentation tool in AS3. In a nutshell, one user (the presenter) has access to a "table of contents" HTML page with links for each slide in the presentation, and an arbitrary number of viewers can watch the presentation on another page, which in turn is in the form of a SWF that polls the server every second to ensure that it's on the right slide. Whenever the admin clicks a slide link in the TOC, the database gets updated, and on its next request the presentation swf compares the label of the slide it's currently displaying to the response it got from the server. If the response differs from the current label, the swf scrubs through the timeline until it finds the right frame label; otherwise, it does nothing and waits for the next poll result (a second later).
Each slide consists of a movieclip with its own nested timeline that loops as long as the slide is displayed. There's no actionscript controlling any of the nested movieclips, nor is there any actionscript on the main timeline except the stop();s on each keyframe (each of which is a slide in the presentation).
Everything is built and working perfectly. The only thing that's troubling is that if the presentation swf is open for long enough (say, 20 minutes), the polling starts to have a noticeable effect on the framerate of the movieclips animating on any given slide. That is, every second, there's a noticeable drop in the framerate of the animations that lasts about three-tenths of a second, which is quite noticeable (and hence is a deal-breaker for the whole presentation suite!).
I know that AS3 has issues with memory management, and I've tried to be diligent in my re-use of objects and event listeners. The code itself is dead simple; there's a Timer instance that fires every second, which triggers a new URLRequest to be loaded by a URLLoader. The URLLoader is reused from call to call, while the URLRequest is not (it needs to be initialized with a new cache-killing value each time, retrieved from a call to new Date().time). The only objects instantiated in the entire class are the Timer, the URLLoader, the various URLRequests (which should be garbage-collected), and the only event listeners are on the Timer (added once), the URLLoader (added once), and on the routines that scrub backwards and forwards in the timeline to find the right slide (and they're removed once the correct slide is found).
I've been using mr doob's stats package to monitor memory usage, which definitely grows over time, so there's gotta be a leak somewhere (it grows from ~30 MB initially to > 200 MB after some scrubbing and about 25 minutes of uptime).
Does anyone have any ideas as to what might be causing the performance problems?
UPDATE: I'm not entirely sure the performance troubles are tied directly to memory; I ran an instance of the presentation swf for about 15 minutes and although memory usage only climbed to around 70 MB (and stayed there), a noticeable hiccup started appearing at one-second intervals, coinciding with the polling calls (tracked via Firebug's Net panel). What else might cause stuttering movieclips?
I know this is coming a bit late, but I have been using Flash Builder's profiler frequently and one thing I found is that the TimerEvent generated by the timer class
uses up quite a bit of memory individually and
seems to not get released properly during garbage collection (even if you stopped the timer and removed all references to it).
A new event is generated for each Timer tick. I use setInterval instead, even though a few AS3 evangelists seem to recommend against that. I don't know why. setInterval still generates timer events, but they appear to be garbage-collected properly over time.
So one strategy may be that
you replace the Timer with a call to setInterval() ... which is arguably more robust code anyway and
(CAUTION) force garbage collection on each slide scrub (but not on each poll). See this question for more details on the pros and cons.
The second suggestion is only a stop-gap measure. I really encourage you to use the profiling tools to find the leak. Flash Builder Pro has a 60-day trial that might help.
Finally, when moving to a completely new slide SWF (not a new timeline position in the current slide), how are you making sure that the previous slide SWF got unloaded properly? Or am I misunderstanding your setup and there is only one actual slide SWF?
Just two things that came into my mind:
Depending on the version of the Flash player and the cpu usage the garbage collections sometimes does not start before 250 MB (or even more) memory are consumed.
Moviesclips, Sprites, Loader and whatever that has an Eventlistener listening will not be killed by the garbage collection.
So I believe your problem is, that either the slides or the loader are not cleaned correctly after you used them, so the were keept in memory.
A good point to start reading: http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html