I2S init() to support multiple files sample_rate/bit_widths? #9139
-
Hi, By its name, it looks like Should I create an i2s object once in the lifetime of my program with the desired output parameters (sample_rate, bit_width) and convert whatever file I read to those? Is there any existing micropython package to help me with resample of WAV samples? Is there any existing implementation for decoding other formats? (mp3, ogg, aac) I'll happily save some space on the SDCard, I'm currently dealing with ~400-500MBs just to keep a few songs... Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The i2s constructor and i2s.init() share all parameters beside the id argument of the constructor. Calling either of them does a full reconfiguration of the I2S device. If you call the constructor for an ID that has already been used, the existing object will be re-used and the same will happen as calling i2s.init(). So - there is no difference whether you create the i2s object once and run i2s.init() afterwards or if you call the constructor every time. I do not know of any implementation for decoding. A python implementation may be too slow. |
Beta Was this translation helpful? Give feedback.
The i2s constructor and i2s.init() share all parameters beside the id argument of the constructor. Calling either of them does a full reconfiguration of the I2S device. If you call the constructor for an ID that has already been used, the existing object will be re-used and the same will happen as calling i2s.init(). So - there is no difference whether you create the i2s object once and run i2s.init() afterwards or if you call the constructor every time.
I do not know of any implementation for decoding. A python implementation may be too slow.