spatialaudio / python-sounddevice

:sound: Play and Record Sound with Python :snake:
https://python-sounddevice.readthedocs.io/
MIT License
1.02k stars 149 forks source link

Question: return array index order #319

Closed StuartIanNaylor closed 3 years ago

StuartIanNaylor commented 3 years ago

Hi,

I am recording from mic in 20ms secs and the array shape returned is 320,1 being mono. Is there anyway to define the array shape so that I don't need to run np.reshape(1,320)

?

Lols not sure from memory if I got those the right way round but however can you specify a return shape for the indexes? :)

mgeier commented 3 years ago

No, there is no option for selecting the return shape.

Why is it a problem for you to reshape the result?

BTW, what exact function/method are you talking about?

StuartIanNaylor commented 3 years ago

Doesn't matter but any instruction less is an instruction less.

Its been a puzzle to me as with tensorflow the indexes seem to be in reverse.

mgeier commented 3 years ago

Doesn't matter but any instruction less is an instruction less.

That's true, but to switch between different index orders you would still have to write something, maybe a keyword argument?

It would be possible to implement such a keyword argument, and I'm open for discussions about such a thing, but I have the feeling that the disadvantages would outweigh the advantages.

I've had a similar discussion in https://github.com/bastibe/python-soundfile/issues/16, and we decided not to do it, partly because we couldn't come up with a good name for such a keyword argument.

What API would you suggest for this?

Its been a puzzle to me as with tensorflow the indexes seem to be in reverse.

Valid arguments can be made for both ways.

My arguments for deciding the order in the sounddevice module:

I'm sure the TensorFlow people have their own valid arguments for their choice.

People coming from Matlab (which uses Fortran-ordering) would probably expect the channels to be stored in rows?

StuartIanNaylor commented 3 years ago

Thanks for the reply though