Files
pyDefis/SW V La confrontation culte.py
Francois JUMELLE 20526d93c8 Initial release
2021-05-03 22:32:40 +02:00

41 lines
1.0 KiB
Python

import wave
filename = "message"
sound = wave.open(filename+".wav")
sound_secret = wave.open(filename+"_decode.wav", "wb")
sound_secret.setnchannels(1)
sound_secret.setsampwidth(sound.getsampwidth())
sound_secret.setframerate(sound.getframerate()*1.25)
frames = sound.getnframes()
framerate = sound.getframerate()
f1 = framerate//12
f2 = framerate//2
offset = 0
while offset < frames:
for f in range(offset, offset+f1):
if f <= frames:
frame = sound.readframes(1)
sound_secret.writeframes(frame)
sound_secret.writeframes(frame)
sound_secret.writeframes(frame)
else:
sound_secret.writeframes(b'\x00\x00')
offset += f1
for f in range(offset, offset+f2):
if f <= frames:
if f%2 == 0:
sound_secret.writeframes(sound.readframes(1))
else:
sound.readframes(1)
else:
sound_secret.writeframes(b'\x00\x00')
offset += f2
sound_secret.close()
sound.close()