Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/f_tempPadding'
Browse files Browse the repository at this point in the history
  • Loading branch information
tkoft committed Feb 13, 2016
2 parents 9519681 + fba3c19 commit dd21d23
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Recording settings that can be specified in the config file:
### 10. Termination
The program clean-exits at any time using the 'q' key. Lowercase only right now, lol. It will execute the rest of the main control loop, skipping recording loops, close all streams and files, stop recording, still check for silence and delete if silent.

ONE CAVEAT: If the program is closed or terminated, unexpectedly or not, during the padding interval after a silent recording that was deleted, anything recorded during that padding will NOT be saved. This could be solved by writing to a temp file and deleting it at the top of loop.
ONE CAVEAT: If the program is closed or terminated, unexpectedly or not, during the padding interval after a silent recording that was deleted, anything recorded during that padding will be saved in `temp.wav`. Basically, whenever the program says "DELETED: filename.wav, still recording padding..." it writes to `temp.wav` until the next file starts, then deletes it since it's saved in the new file. `temp.wav` only exists to save this bit of audio in case the program terminates.

### Extraneous Info

Expand Down
14 changes: 0 additions & 14 deletions config.ini

This file was deleted.

Binary file modified dist/wcfmarchiver.exe
Binary file not shown.
4 changes: 1 addition & 3 deletions doc/devnotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ Ideas:

Specify max files and max size on disk? Or max amount of time, and use some math to get #files or size on disk.

Lowercase and uppercase q to quit

If the program is closed or terminated, unexpectedly or not, during the padding interval after a silent recording that was deleted, anything recorded during that padding will NOT be saved. This could be solved by writing to a temp file and deleting it at the top of loop.
Lowercase and uppercase q to quit
28 changes: 20 additions & 8 deletions wcfmarchiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
# Parse config.ini for configuration settings
if (os.path.isfile("config.ini")):
config.read("config.ini")
RECORD_MIN = int(config['FILE']['RecordMin'])
PAD_MIN = int(config['FILE']['PadMin'])
RECORD_MIN = float(config['FILE']['RecordMin'])
PAD_MIN = float(config['FILE']['PadMin'])
WAVE_OUTPUT_FILENAME = config['FILE']['WaveOutputFilename']
MAX_FILES = int(config['FILE']['MaxFiles'])
DELETE_OLD = config['FILE'].getboolean('DeleteOld')
Expand Down Expand Up @@ -138,6 +138,10 @@ def quitPressed():
os.remove(toDelete)
output("* DELETED: \t\t" + toDelete)

# delete temp file
if (os.path.isfile("archives/temp.wav")):
os.remove("archives/temp.wav")

# open file
output("* now writing to: \tarchives/" + fileName)
wf = wave.open("archives/" + fileName, 'wb')
Expand Down Expand Up @@ -169,23 +173,31 @@ def quitPressed():
fileNames.pop(len(fileNames)-1)
output("* DELETED SILENCE: \tarchives/"+fileName)

#record padding for next file
#record padding to temp and for next file
wf = wave.open("archives/temp.wav", 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
output("* still recording padding...")
framesOverlap = []
while (not quitPressed() and int(time.time())%RECORD_SECONDS != PAD_SEC):
data = stream.read(CHUNK)
frame.append(data)
wf.writeframes(b''.join(frame))
frame = []
framesOverlap.append(data)
wf.close()

# no silence detected
else:
# write +/-5 min at bottom of hour, and record into framesOverlap
framesOverlap = []
while (not quitPressed() and int(time.time())%RECORD_SECONDS != PAD_SEC):
data = stream.read(CHUNK)
frame.append(data)
wf.writeframes(b''.join(frame))
frame = []
framesOverlap.append(data)
data = stream.read(CHUNK)
frame.append(data)
wf.writeframes(b''.join(frame))
frame = []
framesOverlap.append(data)

# close audio file
wf.close()
Expand Down

0 comments on commit dd21d23

Please sign in to comment.