Conversation
|
Would this information be meant for a human to read or for re-use in a Python program? In the latter case I don't think a separate function is necessary, because it's easy to open the file in a context manager and get any information you want. In the former case this might be useful, but we'll have to choose what information to present and how to format it. I think the only way this makes sense, is to We'll have to answer the following questions:
File name, sampling rate, channels, format string, subtype string,
The possibilities are basically infinite ... |
|
I was thinking of a top-level function much like Probably something like import pysoundfile as sf
sf.info('myfile.wav')
>>> { "format": "WAV",
"subtype": "PCM_16",
"endian": "FILE",
"samplerate": 44100,
"channels": 2,
"length": 88200 } |
OK, I'm merging this. > I don't see why we need `format` should require `subtype` and `endian`, but if you insist on it, we'll do it that way. I'd rather have always too much information than a different amount of information for different files. If we get annoyed by the large amount of information, we can still remove the `format`/`subtype`/`endian` triple at a later point. Also, let's see if the implementation of #58 sheds a different light on this.
|
This should probably help people to get information about marker times and labels for WAV files. |
|
I would prefer |
|
What do you think about this implementation? I also tried making it a dict subclass, but that was confusing in practice. The only issue I have with the current implementation is that the |
|
The idea with Did you consider making a There are a few formatting things which I don't like ... The indentation is annoying, please remove it. The I don't really like the equals signs, but that's of course very much a matter of taste. The commas at the line endings are unnecessary and distracting. The I think I would display the format strings as strings (e.g. For comparison, this is how the output of
I don't see this as a problem at all, since this is only the |
soundfile.py
Outdated
There was a problem hiding this comment.
'r' is the default, I would drop it here
soundfile.py
Outdated
There was a problem hiding this comment.
What about some kind of a HH:MM:SS.x display?
27e1589 to
9a59fec
Compare
|
I have implemented most of your suggestions: To be honest, I still prefer the original, indented style. But this is a workable compromise, and it doesn't hint at an actual I don't want I also experimented with different styles for the duration. Lastly, I experimented with |
Then go ahead an use it!
Fair enough, I don't know any strong argument either way.
Cool! Is there a reason why you use exactly 2 digits after the decimal point? I think it would be easier to differentiate between HH:MM:SS and MM:SS.ss with 3 digits, i.e. MM:SS.sss
OK, I see now that this gets quite complicated because of the presence of the Given your example from above, let me show how I would "improve" it: This is what I changed:
I don't like the spaces before colons nor the initial capital letters, but probably we should use them for consistency? |
There was a problem hiding this comment.
Now that I'm reading this it seems strange to me that verbose only affects the __repr__.
But I guess that's the price we have to pay for combining human- and machine-readability, right?
Hmmm ...
Probably verbose should also affect the attributes of the _SoundFileInfo instance?
I guess this would be more consistent ...
I like the slight bookending by the file name. Just a plain list with no "header" looks strange to me.
The triple quotes (and to a lesser extent, the indentation of extra_info) serve a purpose: They make it clear that this is not "parametric" metadata, but just a string. I think that this is quite useful, especially since we really don't have any control over the contents of that string. I would prefer to keep it the way it is now. Can we merge? |
There was a problem hiding this comment.
There's a newline missing before the endian line!
I don't. I find it very inconsistent and somewhat confusing.
It doesn't to me, but I see your point.
In my suggestion, this part is done by the separation line.
If find the indentation and the triple quotes butt-ugly, but that's only my unfounded personal subjective opinion. So sure, go ahead and merge it, you have the last say on subjective decisions. Except for the missing newline before |
|
Now that I'm seeing my previous example, I see a possible header: But in this case we would have to make sure that those are actually properties of the And we should go back to small letters (like the actual property names) and more And then we might as well get rid of the spaces before colons again: BTW, why not add |
|
We might even have a |
|
My priority right now is to get the next release out the door. I am still interested in a better way though. Maybe the idea with "SoundFile properties" is a good one, and we should add Feel free to continue this discussion in either a pull request to that effect, or here. |
|
The right thing to do now would be:
I'm not a fan of pushing half-baked stuff into a release in a hurry. |
It is often desirable to get information about a sound file without reading all its data.