-
Notifications
You must be signed in to change notification settings - Fork 41
AudioFile changed to ndarray #5
Comments
Since numpy.append() returns an ndarray, and Frame is a subclass of ndarray, wouldn't it be possible to cast the result of the zero padding to a Frame? In Frame.py, frames() method, try replacing the zero padding code with this: diff = len(window) - len(frame) |
Thanks for the reply. I my case it should be cast as an AudioFile since the sample rate is NoneType using Frame. I've tried frame.view(self.class), but this doesn't quite do it. Any other ideas? On Jan 29, 2014, at 8:00 PM, jsawruk [email protected] wrote:
|
Try: |
Tried that too, but it doesn't work either… Thanks for the quick responses and for the library! On Jan 29, 2014, at 8:48 PM, jsawruk [email protected] wrote:
|
It probably doesn't work that way because it's returning a string, though there must be a generic way to do this. A naive way to approach this would be to have a switch statement based on the class name, then cast the view to the appropriate type (if class = Frame, view Frame. if class = AudioFile, view AudioFile etc.) Just out of curiosity, what are you using the library for? It was just something that I put together for myself based on things I had learned about MIR, but if it's useful to others, that's great! |
Yeah, casting as AudioFile returns a data type error as well. I agree that there should be a generic way of handling. Searching for a work around. I'm analyzing audio for sound quality analysis of musical instruments. I am a research assistant at Georgia Tech in the Center for Music Technology and and usually do my MIR stuff in C++ or Matlab. Wanted to check out tools available for Python and your came up in Google. On Jan 29, 2014, at 8:56 PM, jsawruk [email protected] wrote:
|
Please try the latest commit. |
Bummer, no dice. Error below. I looked into it a little bit, and it looks like when casting as AudioFile in the frames() function looses the info extracted from the AudioFile.open(), in the case of the below error the sample rate. File "./analyzeTrumpet.py", line 52, in calculateFeatures On Jan 31, 2014, at 7:21 PM, jsawruk [email protected] wrote:
|
I have changed the zero padding code to restore these properties. |
That seemed to do it. Thanks for helping! On Feb 1, 2014, at 9:36 AM, jsawruk [email protected] wrote:
|
I'm using this library to analyze some audio and it appears that when zero padding in the Frame.frames(), numpy.append() returns a ndarray rather than an AudioFile. Attempting to call spectrum() on this ndarray throws an exception.
The text was updated successfully, but these errors were encountered: