#from http://jellymatter.com/2012/01/04/a-secret-message-from-another-dimension/
import random
import numpy as np
from scikits.audiolab import *
file = open("encoder.dat","a")
def map(x):
return 3.9*x*(1-x)
message_file = Sndfile("message.wav","r")
message = message_file.read_frames(message_file.nframes)
chaos = [random.uniform(0,1)]
for i in xrange(message_file.nframes-1):
chaos.append(map(chaos[-1]))
print >>file, '%g %g'%(i,chaos[-1])
chaos = np.array(chaos)
encrypted_message = chaos+message/100
format = Format("wav")
encrypted_file = Sndfile("chaos_encrypted.wav", 'w', format, 1, 44100)
encrypted_file.write_frames(encrypted_message)
file.close()