Skip to content

Commit

Permalink
Fix various bugs with loading WAV files
Browse files Browse the repository at this point in the history
  • Loading branch information
thebigmunch committed Nov 13, 2018
1 parent 193d8fd commit 9e722a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](https://semver.org).

* Loading MP3 files with less than 4 MPEG frames
now works so long as there is a XING header.
* Various bugs with loading WAV files.


## [0.1.0](https://github.com/thebigmunch/audio-metadata/releases/tag/0.1.0) (2018-10-19)
Expand Down
9 changes: 5 additions & 4 deletions src/audio_metadata/formats/wav.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__all__ = ['WAV', 'WAVStreamInfo']

import os
import struct

from attr import attrib, attrs
Expand Down Expand Up @@ -53,13 +54,13 @@ def load(cls, data):
bitrate = byte_rate * 8

self._obj.read(subchunk_size - 16) # Read through rest of subchunk if not PCM.
elif subchunk_id == b'self._obj':
elif subchunk_id == b'data':
audio_start = self._obj.tell()
audio_size = subchunk_size
elif subchunk_id.upper() == b'ID3 ':
self._obj.seek(subchunk_size, os.SEEK_CUR)
elif subchunk_id.lower() == b'id3 ':
try:
id3 = ID3v2()
id3._load(self._obj)
id3 = ID3v2.load(self._obj)
self._id3 = id3._header
self.pictures = id3.pictures
self.tags = id3.tags
Expand Down

0 comments on commit 9e722a5

Please sign in to comment.