- Install boost in your machine as instructed over here -> https://trillbit.slack.com/files/rajanya/F3CEJ0U9E/Interaction_of_C___and_Python_via_Boost_Python
- Clone C++ repository -> https://bitbucket.org/trillbit/bpskdemodulation_c
cd ~/Download/bpskdemodulation
- Pull the latest(if any) C++ code changes.
- Open Eclipse CDT -> Open this project -> Build Project. [This generates 'bpsk.so' in Debug folder]
sudo cp /Debug/bpsk.so /Library/Python/2.7/site-packages/
- Create
test.py with following code for demodulation. ( Ensure hellotrill.wav file is in the same folder as the python file )
import numpy as np
from scipy.io.wavfile import read
from scipy import signal
import bpsk
def convertArrToStr(array):
array_list = array.tolist();
array_str = ",".join(str(x) for x in array_list)
return array_str
mod_signal = read("hellotrill.wav")
data_signal = np.array(mod_signal[1], dtype=float)
data_signal_str = convertArrToStr(data_signal)
data_output = np.fromstring(bpsk.finddata(data_signal_str), dtype=float, sep=',')
data_output_str = convertArrToStr(data_output)
data = np.fromstring(bpsk.demod(data_output_str), dtype=float, sep=',')
print data
No comments:
Post a Comment