-
Notifications
You must be signed in to change notification settings - Fork 121
Miscellaneous small changes #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I don't think that's possible, because OTOH, the admittedly strange order or arguments in the other functions has the reason that sf.write(myarray, 'myfile.wav', 44100, 'FLOAT')I hope that's reason enough to have this strange order. If not, we could change the order everywhere to
I'm not quite sure about this. I think I can live with either option. Another argument comes up with for block in sf.blocks('myfile.raw', 48000, 44100, 2, 'PCM_16'):
do_something(block)vs. for block in sf.blocks('myfile.raw', 44100, 2, 'PCM_16', blocksize=48000):
do_something(block)Now that I see it, this is really a weak point ...
I agree that sounds better. |
|
Regarding the second point, I was thinking that for block in sf.blocks('myfile.wav', 1024):
do_something(block)is probably the most common use case. For RAW files, I would probably either do raw_format = {
'samplerate': 48000,
'channels': 2,
'format': 'PCM_16'
}
for block in sf.blocks('myfile.raw', 1024, **raw_format):
do_something(block)or for block in sf.blocks('myfile.raw', 1024, samplerate=48000, channels=2, format='PCM_16'):
do_something(block)But then, I have never actually used a RAW file anyway :-). |
I agree. This makes no sense. RAW files require a subtype, but no format or endian. Thus, subtype should be first. f = SoundFile('myfile.raw', 44100, 2, 'PCM_16')I was thinking of unnamed things like streams and file descriptors, where subtype and endian can be deduced from the format, thus format should come first. However, these don't require a samplerate or channels, so format has to be given as keyword argument anyway: f = SoundFile(stream, format='wav')TL;DR: I agree on with you on the first point. |
|
Does this look ok to you? |
|
Yes, except that you seem to have forgotten the examples in the docstring ... |
I forgot these two instances in the last commit
|
Great, let's merge! |
The arguments which are forwarded to the SoundFile constructor, are moved to the back (because they are very seldomly used). See also #78.
format,subtypeandendianfunction arguments informat_check, to be consistent withSoundFile.__init__etc.blocksso thatblocksizecomes before the__init__arguments. This would make the typical usage of this function easier.format_checktocheck_format.