Capture Console display
-
[Solved] I am currently working on a project to convert wav files to mp3's using lame.
I note that lame's output on the console window displays its information in the same position on the screen. It also shows a 'running' progress display.
Two questions:- How does this display of data in the same position work?
- Can i 'capture' the progress and display it as a progress bar or a number graphically in my program?
Any help would be much appreciated.
Thank you
Graham
-
[quote author="graham1941" date="1398586809"]1. How does this display of data in the same position work?[/quote]
It simply prints it to the console using printf() or probably fprintf(stderr, ...).
Note: You can print "\r" (carriage return), instead of "\n" (line feed) in order to go back to the beginning of the line - and then you can simply overwrite the "old" line content. You can also go back an arbitrary number positions in the console by printing the proper number of "\b" (backspace) characters.
For even more detailed control of the cursor positions use:
"SetConsoleCursorPosition":http://goo.gl/V60QRv[quote author="graham1941" date="1398586809"]2. Can i 'capture' the progress and display it as a progress bar or a number graphically in my program?[/quote]
Yes!
See here how to do it:
https://github.com/lordmulder/LameXP/tree/master/src(Especially "Encoder_MP3.cpp")
-
Thank you very much!
Cheers
G