Adopt review suggestions
diff --git a/python/lc3.py b/python/lc3.py index 6301e8d..e4a5e90 100644 --- a/python/lc3.py +++ b/python/lc3.py
@@ -66,7 +66,7 @@ if self.frame_duration_us not in [2500, 5000, 7500, 10000]: raise InvalidArgumentError( - "Invalid frame duration: %.1f ms" % self.frame_duration_us + f"Invalid frame duration: {self.frame_duration_us} us ({self.frame_duration_us / 1000:.1f} ms)" ) allowed_samplerate = ( @@ -74,7 +74,7 @@ ) if self.sample_rate_hz not in allowed_samplerate: - raise InvalidArgumentError("Invalid sample rate: %d Hz" % sample_rate_hz) + raise InvalidArgumentError(f"Invalid sample rate: {sample_rate_hz} Hz") if libpath is None: mesonpy_lib = glob.glob(
diff --git a/python/tools/decoder.py b/python/tools/decoder.py index bc3b554..7cc5127 100755 --- a/python/tools/decoder.py +++ b/python/tools/decoder.py
@@ -34,8 +34,8 @@ type=argparse.FileType('wb'), default=sys.stdout.buffer) parser.add_argument( - '--bitdepth', - help='Output bitdepth, default is 16 bits', + '--bit_depth', + help='Output bit depth, default is 16 bits', type=int, choices=[16, 24], default=16) parser.add_argument( @@ -58,13 +58,13 @@ # --- Setup output --- -bitdepth = args.bitdepth -pcm_size = nchannels * (bitdepth // 8) +bit_depth = args.bit_depth +pcm_size = nchannels * (bit_depth // 8) f_wav = args.wav_file wavfile = wave.open(f_wav) wavfile.setnchannels(nchannels) -wavfile.setsampwidth(bitdepth // 8) +wavfile.setsampwidth(bit_depth // 8) wavfile.setframerate(samplerate) wavfile.setnframes(stream_length) @@ -80,7 +80,7 @@ for i in range(0, encoded_length, frame_length): lc3_frame_size = struct.unpack('=H', f_lc3.read(2))[0] - pcm = dec.decode(f_lc3.read(lc3_frame_size), bit_depth=bitdepth) + pcm = dec.decode(f_lc3.read(lc3_frame_size), bit_depth=bit_depth) pcm = pcm[max(encoded_length - stream_length - i, 0) * pcm_size: min(encoded_length - i, frame_length) * pcm_size]
diff --git a/python/tools/encoder.py b/python/tools/encoder.py index 436d769..3246c4c 100755 --- a/python/tools/encoder.py +++ b/python/tools/encoder.py
@@ -51,7 +51,7 @@ samplerate = wavfile.getframerate() nchannels = wavfile.getnchannels() -bitdepth = wavfile.getsampwidth() * 8 +bit_depth = wavfile.getsampwidth() * 8 stream_length = wavfile.getnframes() # --- Setup encoder --- @@ -77,7 +77,7 @@ f_lc3.write(struct.pack('=H', frame_size)) pcm = wavfile.readframes(frame_length) - f_lc3.write(enc.encode(pcm, frame_size, bit_depth=bitdepth)) + f_lc3.write(enc.encode(pcm, frame_size, bit_depth=bit_depth)) # --- Cleanup ---