blob: 165fd6bcedb8be6a6b026f0a302b171570641b3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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()
|