summaryrefslogtreecommitdiff
path: root/hacks/pldec.py
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-09-16 15:22:11 +0100
committerCarl Hetherington <cth@carlh.net>2015-09-16 15:22:11 +0100
commit0a3d5ea0900ed0f9aaa0b5a5f1b7dcec854fc4f9 (patch)
treebef52fc31a6d6c8eae0bce40dc44f97d8c0f4f4b /hacks/pldec.py
parent815666a7bab7ab5bc9143569e9b73351c04b6f8f (diff)
Add hack.
Diffstat (limited to 'hacks/pldec.py')
-rw-r--r--hacks/pldec.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/hacks/pldec.py b/hacks/pldec.py
new file mode 100644
index 000000000..165fd6bce
--- /dev/null
+++ b/hacks/pldec.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+
+import numpy as np
+import scipy.signal
+import matplotlib.pylab as plt
+import math
+
+radians = np.pi * 16
+points = 1024
+cut = math.pow(10, -3 / 20.0)
+print cut
+
+t = np.linspace(0, radians, points)
+inL = np.zeros((points,))
+inC = np.sin(t)
+inR = np.zeros((points,))
+inS = np.zeros((points,))
+
+# Encode
+Lt = inL + inC * cut + np.imag(scipy.signal.hilbert(inS * cut))
+Rt = inR + inC * cut - np.imag(scipy.signal.hilbert(inS * cut))
+
+# Decode
+outL = Lt
+outR = Rt
+outS = Lt - Rt
+
+plt.plot(t, outL, label='L')
+plt.plot(t, outR, label='R')
+plt.plot(t, outS, label='S')
+plt.legend()
+plt.show()
+