Skip to content

Commit 38e5bc4

Browse files
committed
improve SFF unpacking
#20
1 parent 7c84603 commit 38e5bc4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

dev/sff/python/sffLib.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ def __init__(self, filePath):
4545
self.decibels = int(filebytes[72]) == 1
4646

4747
# new variables
48-
self.melBinCount = int(filebytes[84])
49-
self.imageHeight = int(filebytes[88])
50-
self.imageWidth = int(filebytes[92])
48+
self.melBinCount = struct.unpack("<l", filebytes[84:88])[0]
49+
self.imageHeight = struct.unpack("<l", filebytes[88:92])[0]
50+
self.imageWidth = struct.unpack("<l", filebytes[92:96])[0]
5151

5252
# useful class properties
5353
self.secPerPx = self.stepSize / self.sampleRate
@@ -122,4 +122,6 @@ def getDescription(self):
122122
f"({self.valuesPerPoint * self.imageWidth * self.imageHeight:,} values) " +\
123123
f"in {self.loadTimeMsec:.02f} ms"
124124
d += "\n"
125+
d += f"\nnumpy array shape: {self.values.shape}"
126+
d += "\n"
125127
return d

0 commit comments

Comments
 (0)