Skip to content

Commit

Permalink
Updated pages "Simple FLAC implementation", "Pervasive Displays e-pap…
Browse files Browse the repository at this point in the history
…er panel hardware driver".
  • Loading branch information
nayuki committed Apr 13, 2018
1 parent 29bc6b6 commit a8a99c0
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions simple-flac-implementation/simple-decode-flac-to-wav.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Simple FLAC decoder (Python)
#
# Copyright (c) 2017 Project Nayuki. (MIT License)
# Copyright (c) 2018 Project Nayuki. (MIT License)
# https://www.nayuki.io/page/simple-flac-implementation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
Expand Down Expand Up @@ -124,16 +124,10 @@ def decode_frame(inp, numchannels, sampledepth, out):

# Write the decoded samples
numbytes = sampledepth // 8
if python3:
def write_little_int(val):
out.write(bytes(((val >> (i * 8)) & 0xFF) for i in range(numbytes)))
else:
def write_little_int(val):
out.write("".join(chr((val >> (i * 8)) & 0xFF) for i in range(numbytes)))
addend = 128 if sampledepth == 8 else 0
for i in range(blocksize):
for j in range(numchannels):
write_little_int(samples[j][i] + addend)
out.write(struct.pack("<i", samples[j][i] + addend)[ : numbytes])
return True


Expand Down

0 comments on commit a8a99c0

Please sign in to comment.