bitluni / ESP32AMRadioTransmitter

127 stars 33 forks source link

[q] only why 2048 in send but buff is 1024 #1

Closed ESP32DE closed 6 years ago

ESP32DE commented 6 years ago

https://github.com/bitluni/ESP32AMRadioTransmitter/blob/d0e4267865050062405c8882f1945496a09c06a4/AMTransmitterI2SButton/AMTransmitterI2SButton.ino#L80

same here https://github.com/bitluni/ESP32AMRadioTransmitter/blob/d0e4267865050062405c8882f1945496a09c06a4/AMTransmitterI2S/AMTransmitterI2S.ino#L69

cause buff is 1024 or https://github.com/bitluni/ESP32AMRadioTransmitter/blob/d0e4267865050062405c8882f1945496a09c06a4/AMTransmitterI2S/AMTransmitterI2S.ino#L39

bitluni commented 6 years ago

hardcoding the buffer size might be misleading but i2s_write_bytes expects the size of the buffer in bytes while the actual buff array (and the i2s samples) is 1024 short integers of 16 bit (=2048 bytes)

ESP32DE commented 6 years ago

@bitluni Thank you Not everyone dares ask if you do not know it; so I just asked, so that people sometimes even think about why this is so - and just ask even with such a great learning project.

Thank you for the friendly and objectively flawless explanation. (suggestion: hint a line for this in code )

keep it up! great work you do.

bitluni commented 6 years ago

I'll change it to sizeof(buff), thanks for the hint