echonest / remix

Echo Nest Remix: The Internet Synthesizer
http://echonest.github.com/remix
414 stars 90 forks source link

Fixed bug in AudioData.add_at regarding mixing two audio_data files of differing numChannels #17

Closed carmi closed 11 years ago

carmi commented 11 years ago

Consider the case in which you have two Audio files A and B. You wish to add file B to A twice, and different times.

Currently, add_at() may resample B so the numChannels match. However, this modifies the data object of B, but does not correctly also modify B's numChannels. So this leaves B in a state where it's data and numChannels are not congruent. I get an error like:

Traceback (most recent call last): File "song-test.py", line 13, in <module> base.add_at(3, sax) File "/usr/local/lib/python2.7/dist-packages/echonest/audio.py", line 432, in add_at another_audio_data.data = numpy.repeat(another_audio_data.data, self.numChannels).reshape(len(another_audio_data), self.numChannels) ValueError: total size of new array must be unchanged

This pull request fixes this bug.

tkell commented 11 years ago

Thank you! I added your fix manually, without all the whitespace changes - I'll get to those separately.
.t