Created
January 27, 2016 16:36
-
-
Save meise/6d3e5c91e5003da0fd76 to your computer and use it in GitHub Desktop.
extract floats from gr message queue without numpy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
msg = tb.msgq_out.delete_head() | |
msg_string = msg.to_string() | |
samples = np.fromstring(msg_string, dtype='float32') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pull from message queue | |
msg = tb.msgq_out.delete_head() | |
msg_string = msg.to_string() | |
samples = [] | |
# extract floats from msg string | |
# it is slow. very slow! :/ | |
for i in range(0,len(sample),4): | |
# unpack sample to have a tuples | |
unpacked = struct.unpack_from('f', sample[i:i+4]) | |
samples.append(unpacked[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment