Mobsya / aseba-target-thymio2

Thymio 2 firmware
8 stars 8 forks source link

New native function to retrieve the duration of a recorded sound #21

Closed stephanemagnenat closed 7 years ago

stephanemagnenat commented 7 years ago

To make sounds available in VPL, it would be useful to have a native function, for instance sound.duration, that returns the duration of a given sound stored on the SD card.

mbonani commented 7 years ago

is the actual event sound.finished not sufficient?

stephanemagnenat commented 7 years ago

is the actual event sound.finished not sufficient?

Not really, because you would like to show the duration in the editor, without having to play the sound.

mbonani commented 7 years ago

when we record sounds we store in the .wav header the size of the sample counter. So I propose to read only to the recordet sound files rN.wav sizes. The problem is that its is in long format 32 bits

stephanemagnenat commented 7 years ago

We could easily have a native function that parses the header, and transforms the duration into 10th of seconds.

mbonani commented 7 years ago

sound.duration(N, ds) Give sound duration in 1/10 sec of rN.wav

stephanemagnenat commented 7 years ago

Yes, that would be great!

mbonani commented 7 years ago

implement in d2be7683a437f20433fd88efc28a1011781be30f

mbonani commented 7 years ago

thanks for comments new implementation here ebf4bf656daeb1dd2b64cc6c43859a841a43f813