belangeo / pyo

Python DSP module
GNU Lesser General Public License v3.0
1.31k stars 131 forks source link

Raise exception on error #246

Closed CristiFati closed 2 years ago

CristiFati commented 2 years ago

sndinfo returns None when it can't get file info (for whatever reason). That yields an confusing error message like in [SO]: Can't reproduce audio file using python pyo library.

I thought of other possible fixes, but this seemed the best (or simplest):

After reading the comment did some changes:

Note: There are other places that could be changed (tests, examples) but I don't consider them critical.

belangeo commented 2 years ago

Not sure about this one... Raising an error could break a live performance in a bad way if the user try to load an invalid file (or make a typo in the path). The intended usage here is that the user should always check for None return (like a check for nullptr in C++), and do whatever is the best in its specific setup if the loading of the sound fails.

belangeo commented 2 years ago

Fair enough! Thanks!