This discussion is archived
0 Replies Latest reply: Feb 27, 2013 7:07 AM by 993721 RSS

Buffering audio to save audio before trigger

993721 Newbie
Currently Being Moderated
Analogy of what I'm trying to do:
-You have a security camera and a vibration sensor installed.
-The security camera feed is constantly saved on to a hard drive, but any data over 5 minutes old is deleted.
-If the motion sensor is tripped, a new permanent video file is created, with the last 5 minutes stuck on to the beginning. Video is now saved onto this new file (after the first 5 minutes).
Analogy > My code:
Camera feed > javax.sound.sampled.TargetDataLine
5 minute save > byte[] preBuffer
Permanent video file >

I've written some code, it doesn't work, and I'm sure it's horribly done and inefficient:

The start and stop triggers are temporary hackish code, but that are irrelevant to my current problem.

So I need a way to save up data from the line, and once triggered, add some of the saved data to a new stream, and record any additional data as it comes.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points