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

added format check for method read_data in rawread #70

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion audioread/rawread.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

# Produce two-byte (16-bit) output samples.
TARGET_WIDTH = 2
PATCH_BYTE = b'\xff'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above doesn't apply to this constant. So please add a blank line above it and, ideally, write a brief sentence explaining what this is useful for.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really thanks to your advice, I am a fresh graduate, so there must be lots of things to learn lol. The suggestions are quite helpful to me.


# Python 3.4 added support for 24-bit (3-byte) samples.
if sys.version_info > (3, 4, 0):
Expand Down Expand Up @@ -130,7 +131,10 @@ def read_data(self, block_samples=1024):
data = self._file.readframes(block_samples)
if not data:
break


remainder = len(data) % old_width
if remainder != 0 :
data = data + PATCH_BYTE*(old_width-remainder)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are some very low-level style (i.e., PEP8) comments:

  • Please remove the whitespace on the blank line.
  • Please remove the space between the 0 and the : in the if statement.
  • Please add spaces around the binary operators * and -.

# Make sure we have the desired bitdepth and endianness.
data = audioop.lin2lin(data, old_width, TARGET_WIDTH)
if self._needs_byteswap and self._file.getcomptype() != 'sowt':
Expand Down