thsno02 / StarGANv2-VC

StarGANv2-VC 训练 + 实时转化
MIT License
6 stars 1 forks source link

Why `sounddevice` has `status` flag in `callback` function? #28

Closed thsno02 closed 2 years ago

thsno02 commented 2 years ago

sounddeivce.get_status() gets info about over-/underflows in play()/rec()/playrec(), returns CallbackFlags – A CallbackFlags object that holds information about the last invocation of play(), rec() or playrec().

thsno02 commented 2 years ago

Over-/underflow

The Definition of Overflow and Underflow

In another works, overflow refers to the data feed exceeds the capacity of the volumn, and underflow means the date feed does not fill the volumn and rest some space.

The Definition in Buffer Overflow and Buffer Underflow

The definitions are similar to the original linguistics meaning, both buffer overflow and buffer underflow can be counted as errors. 1

The former arises while the flow of data from the original data scource, typically the hard driver, was too large to store in the buffer memory, and the buffer memory tends to empty itself. This error leads to the terminatation of the data feeding process and device cannot handle the successive data feed.

The latter occurs while the data flow does not meet the threshold of the buffer memory. It's noteworthy that the threshold is not the capacity of the buffer memory, but a reading rate or processing rate that promises a continuous data transformation. This error leads to the buffer is always empty dynamically and may yield a discontinuous output.

For example, in audio playback scenario, buffer underflow leads to stuttering audio and buffe overflow may cause program breaking. 2

Footnotes

[1]: https://www.techtarget.com/searchsecurity/definition/buffer-underflow

[2]: https://stackoverflow.com/questions/26257639/c-what-is-a-example-of-a-buffer-underflow

thsno02 commented 2 years ago

The flags are used to tolerate errors.