Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add direct path for float32 #520

Merged
merged 2 commits into from
Jul 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lddecode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def make_loader(filename, inputfreq=None):
return load_packed_data_4_40
elif filename.endswith('.r30'):
return load_packed_data_3_32
elif filename.endswith('.rf'):
return load_unpacked_data_float32
elif filename.endswith('.r16') or filename.endswith('.s16'):
return load_unpacked_data_s16
elif filename.endswith('.r8') or filename.endswith('.u8'):
Expand All @@ -156,7 +158,9 @@ def load_unpacked_data(infile, sample, readlen, sampletype):
infile.seek(sample * sampletype, 0)
inbuf = infile.read(readlen * sampletype)

if sampletype == 2:
if sampletype == 4:
indata = np.fromstring(inbuf, 'float32', len(inbuf) // 4) * 32768
elif sampletype == 2:
indata = np.fromstring(inbuf, 'int16', len(inbuf) // 2)
else:
indata = np.fromstring(inbuf, 'uint8', len(inbuf))
Expand All @@ -172,6 +176,9 @@ def load_unpacked_data_u8(infile, sample, readlen):
def load_unpacked_data_s16(infile, sample, readlen):
return load_unpacked_data(infile, sample, readlen, 2)

def load_unpacked_data_float32(infile, sample, readlen):
return load_unpacked_data(infile, sample, readlen, 4)

# This is for the .r30 format I did in ddpack/unpack.c. Depricated but I still have samples in it.
def load_packed_data_3_32(infile, sample, readlen):
start = (sample // 3) * 4
Expand Down Expand Up @@ -782,4 +789,4 @@ def write_json(ldd, outname):
os.rename(outname + '.tbc.json.tmp', outname + '.tbc.json')

if __name__ == "__main__":
print("Nothing to see here, move along ;)")
print("Nothing to see here, move along ;)")