After a couple months of work, it has just been published on CNet’s Download.com my newest program: SRTEd, a visual and portable editor to SRT files for Windows.
Basically, I decided to write this program because I had to edit some subtitles a while ago, in SRT format, and the available editors were quite tedious and painful to use. I somewhat got this insight of a more visual editor, and some time later I began writing it. The most important thing to “get the feel” is the use of the keyboard arrow keys to sync the subs. Left/right arrows move them, and when holding Shift key, change the duration. This makes the sync incredibly easy to do, visual.
Technically, the program is pure C-like C++ (that’s how I define my own C++ style) and native Win32, so it’s really light and fast. To video playback, it uses DirectX infrastructure. Moreover, SRTEd uses my own Win32 object-oriented library, which I plan to release as open source some day.
Here’s a getting started video:
CNet download link: SRTEd - SRT Subtitles Editor.
Update: I just received an e-mail from Softpedia, they published SRTEd on their site too.
Friday, March 15, 2013
Wednesday, February 20, 2013
KRK VXT frequency charts
As looking for a pair of studio monitors, I wanted to have a comparison between the three KRK VXT series models: VXT4, VXT6 and VXT8 – cones being respectively 4, 6 and 8 inches. I got the individual charts from KRK website, and I just made a collage with the three. This is what I ended up with:
It’s easy to spot how the low end increases with the cone size. Many people recommend a subwoofer, but not everyone has an appropriated room to fit everything. Indeed, in my case, I can hardly fit anything larger than the VXT4 on my desk, so I’ll probably have to stick with the VXT4 or other monitor with similar size, like the Yamaha HS50M – although I found these too bright and lacking in lows, rather unpleasant.
And the quest for my new home studio monitors goes on.
Update: after a lot of research and some listenings, I ended up picking up the KRK VXT4, which not only sounds really good, but also fits my desk. I’ve got a new pair for a good price, and I’m pretty satisfied so far.
It’s easy to spot how the low end increases with the cone size. Many people recommend a subwoofer, but not everyone has an appropriated room to fit everything. Indeed, in my case, I can hardly fit anything larger than the VXT4 on my desk, so I’ll probably have to stick with the VXT4 or other monitor with similar size, like the Yamaha HS50M – although I found these too bright and lacking in lows, rather unpleasant.
And the quest for my new home studio monitors goes on.
Update: after a lot of research and some listenings, I ended up picking up the KRK VXT4, which not only sounds really good, but also fits my desk. I’ve got a new pair for a good price, and I’m pretty satisfied so far.
Thursday, February 14, 2013
Reading version from EXE and DLL files
Here’s a C++ and Win32 class to read version information from the resource section within EXE and DLL Windows binaries. The key functions are GetFileVersionInfo and VerQueryValue. The object will provide public pointers to the strings; these pointers should not be deleted, since they point straight into the allocated data block. If version information can’t be read – for example, if it’s a file with no version information – the load method will simply return
There’s room for more improvements, like tighter error checking, but it’s pretty usable:
false
.There’s room for more improvements, like tighter error checking, but it’s pretty usable:
#include <Windows.h> #pragma comment(lib, "Version.lib") class VersionInfo { public: const wchar_t *pComments, *pCompanyName, *pLegalCopyright, *pProductVersion; VersionInfo() : _data(NULL), pComments(NULL), pCompanyName(NULL), pLegalCopyright(NULL), pProductVersion(NULL) { } ~VersionInfo() { if(_data) free(_data); } bool load(const wchar_t *path) { DWORD szVer = 0; if(!(szVer = GetFileVersionInfoSize(path, &szVer))) return false; _data = (BYTE*)malloc(sizeof(BYTE) * szVer); if(!GetFileVersionInfo(path, 0, szVer, _data)) return false; UINT len = 0; VerQueryValue(_data, L"\\StringFileInfo\\040904b0\\Comments", (void**)&pComments, &len); VerQueryValue(_data, L"\\StringFileInfo\\040904b0\\CompanyName", (void**)&pCompanyName, &len); VerQueryValue(_data, L"\\StringFileInfo\\040904b0\\LegalCopyright", (void**)&pLegalCopyright, &len); VerQueryValue(_data, L"\\StringFileInfo\\040904b0\\ProductVersion", (void**)&pProductVersion, &len); return true; } private: BYTE *_data; };Usage example:
{ VersionInfo vi; if(vi.load(L"C:\\Program.exe")) { OutputDebugString(vi.pProductVersion); OutputDebugString(vi.pComments); } }Can’t be simpler than that.
Like Firefox? Try Pale Moon
When it comes to internet browsers, overall, I prefer Firefox behavior over Chrome’s. But when using Firefox 18.0.2 on Windows 7 x64, I started to become increasingly angry with its memory usage. Even with only 4 tabs opened, Firefox peaked 800 MB of RAM easily, like not releasing memory at all. This was making Firefox really slow, a pain to use.
Searching around, I found Pale Moon. Basically it’s Firefox compiled specifically for Windows, letting out compatibility with older processors, all compiler optimization switches on, and also some minor changes done by the Pale Moon mantainer, which follows Firefox with some gap, waiting for the bugs to be fixed. Pale Moon seems to release memory faster, and on my tests, the RAM usage floats around 300 MB, compared to 800 MB on Firefox. On the use, it’s noticeably faster, a joy.
I’m testing a portable version of Pale Moon 15.4.1, and so far I’m very pleased. All my add-ons worked fine. I totally recommend it as an alternative to Firefox itself.
Searching around, I found Pale Moon. Basically it’s Firefox compiled specifically for Windows, letting out compatibility with older processors, all compiler optimization switches on, and also some minor changes done by the Pale Moon mantainer, which follows Firefox with some gap, waiting for the bugs to be fixed. Pale Moon seems to release memory faster, and on my tests, the RAM usage floats around 300 MB, compared to 800 MB on Firefox. On the use, it’s noticeably faster, a joy.
I’m testing a portable version of Pale Moon 15.4.1, and so far I’m very pleased. All my add-ons worked fine. I totally recommend it as an alternative to Firefox itself.
Sunday, January 20, 2013
Adobe Source Code Pro font
I’ve just downloaded the new open source monospaced font from Adobe: Source Code Pro. I’m using it at 9pt size on Windows, and it has the same vertical and horizontal size of Microsoft's acclaimed Consolas font at 10pt – it means each character occupies the exact same square of pixels. Coincidence? Maybe not. Consolas is a great coding font praised by thousands of programmers around the world, so it’s natural that it could have been used as parameter.
My impression so far is that Source Code Pro looks lighter than Consolas, with less cluttering. It looks like a crossover between Consolas and Inconsolata, a font which looks absolutely great on Linux, but bad on Windows.
On Linux, Source Code Pro at 9pt renders as good as in Windows. It occupies the same horizontal spacing of Inconsolata at 10pt, but more vertical spacing. Too much vertical space, in my opinion; at 8pt, the font is too small if compared to the line height it has. It would be a lot better if this vertical space could be cut down. And the bold is too bold.
Source Code Pro can be downloaded at SourceForge, and the project is hosted on GitHub, which is a great initiative.
I’m really picky about the font I code with – in fact, I’m absolutely paranoid about it, I often change the font I use –, and I consider Source Code Pro worth trying on Windows, I can stare at it for hours without getting tired. Definitely added to my monospaced fonts collection, and from now on, the default monospaced font on this blog!
My impression so far is that Source Code Pro looks lighter than Consolas, with less cluttering. It looks like a crossover between Consolas and Inconsolata, a font which looks absolutely great on Linux, but bad on Windows.
On Linux, Source Code Pro at 9pt renders as good as in Windows. It occupies the same horizontal spacing of Inconsolata at 10pt, but more vertical spacing. Too much vertical space, in my opinion; at 8pt, the font is too small if compared to the line height it has. It would be a lot better if this vertical space could be cut down. And the bold is too bold.
Source Code Pro can be downloaded at SourceForge, and the project is hosted on GitHub, which is a great initiative.
I’m really picky about the font I code with – in fact, I’m absolutely paranoid about it, I often change the font I use –, and I consider Source Code Pro worth trying on Windows, I can stare at it for hours without getting tired. Definitely added to my monospaced fonts collection, and from now on, the default monospaced font on this blog!
Wednesday, January 16, 2013
jQuery with requestAnimationFrame
The requestAnimationFrame specification is being cooked to replace the over-used setTimeout call when doing JavaScript animations. By specifically targeting animations, it’s highly optimized for this purpose. And since JavaScript animations are becoming more and more widespread, I believe it’s a great initiative, aiming to smooth all moving things inside your browser window. Concept and usage are well explained on this article.
If you use jQuery, however, you are not taking benefit of this new specification. It was used on a previous version, but it was dropped since then. I believe it should have been kept, misuse of the animation features shouldn’t have guided this decision. Anyway, when I was developing a jQuery plugin to embed requestAnimationFrame inside jQuery animation again, I just found out that someone had already done that. It’s available on GitHub and it works very well. The author has also made some claims on jQuery forums to make it default inside the library, with no success so far.
So, this is what you need to do (the file you need is within dist directory):
If you use jQuery, however, you are not taking benefit of this new specification. It was used on a previous version, but it was dropped since then. I believe it should have been kept, misuse of the animation features shouldn’t have guided this decision. Anyway, when I was developing a jQuery plugin to embed requestAnimationFrame inside jQuery animation again, I just found out that someone had already done that. It’s available on GitHub and it works very well. The author has also made some claims on jQuery forums to make it default inside the library, with no success so far.
So, this is what you need to do (the file you need is within dist directory):
<script type="text/javascript" src="jquery-1.8.3.min.js"></script> <script type="text/javascript" src="jquery.requestAnimationFrame.min.js"></script>Animations instantly became smoother on Firefox on Linux. Highly recommended.
Saturday, January 12, 2013
R.I.P. victims of the loudness wars
Terribly mixed, brickwalled, clipped everywhere, static noise, ears bleeding, the horror... loudness wars victims. As an audiophile, it deeply saddens me when I find a good album ruined by a horrible mixing. I think this disease began spreading towards the end of the 1990’s, and from now on, most of the albums are simply unlistenable. Producers responsible by these atrocities should die slowly and in great pain, by having all their blood drained away from their perforated eardrums.
Here it follows a list of some ruined albums which I particularly mourn over, because I cannot listen to:
There you have something that makes me really sad about.
Here it follows a list of some ruined albums which I particularly mourn over, because I cannot listen to:
Slayer Undisputed Attitude 1996 -10.54 dB Red Hot Chili Peppers Californication 1999 -12.42 dB Children of Bodom Follow the Reaper 2000 -12.63 dB Pantera Reinventing the Steel 2000 -11.42 dB Stratovarius Infinite 2000 -11.47 dB |
Rage Against the Machine Renegades 2000 -11.98 dB Velvet Revolver Contraband 2004 -10.45 dB Franz Ferdinand You Could Have It So Much Better 2005 -11.02 dB Audioslave Revelations 2006 -11.14 dB Joey Ramone Ya Know? 2012 -10.12 dB |
There you have something that makes me really sad about.
Wednesday, January 9, 2013
Blurry fonts on Firefox 18
Firefox is the browser which behavior I like most, but it’s seriously becoming a pain to use, version after version. I’ve just upgraded my Firefox to the ridiculous version number 18, and on some specific sites the fonts look terribly blurry. Seriously, they hurt my eyes. It’s specially noticeable on Google sites, like Gmail, Blogger, YouTube, Groups and Docs – and the font in Docs looks particularly bad.
I’ve run through some fixes from previous versions (though I never had this problem before), like this, this and this. Nothing seems to work. I’m using both Windows XP and Windows 7 to perform all these tests. At first, I thought it would be a problem of GPU rendering overriding ClearType settings, but the fonts are also blurry on Linux!
There’s a thread at Mozilla’s board with some people complaining about this since v17, where the solution was to disable hardware acceleration – what I did already, to fix other rendering problems at that time. On v18, however, no one could find a fix yet, it looks like they really messed it up. So if you have this problem, go make some noise at that thread!
Congratulations to Mozilla for dropping the ball again, with its moronic and Chrome-wannabe release cycling which is introducing more and more bugs. If I wanted Chrome, I would have downloaded Chrome.
I’ve run through some fixes from previous versions (though I never had this problem before), like this, this and this. Nothing seems to work. I’m using both Windows XP and Windows 7 to perform all these tests. At first, I thought it would be a problem of GPU rendering overriding ClearType settings, but the fonts are also blurry on Linux!
There’s a thread at Mozilla’s board with some people complaining about this since v17, where the solution was to disable hardware acceleration – what I did already, to fix other rendering problems at that time. On v18, however, no one could find a fix yet, it looks like they really messed it up. So if you have this problem, go make some noise at that thread!
Congratulations to Mozilla for dropping the ball again, with its moronic and Chrome-wannabe release cycling which is introducing more and more bugs. If I wanted Chrome, I would have downloaded Chrome.
Sunday, December 2, 2012
Automation for C++ COM pointers
This week I was working on a C++ program which used a lot of COM pointers. I remembered I’ve seen an automation class somewhere, and after some searching I found it, it’s Microsoft’s ComPtr template class. Although I liked the concept, it had too much fuss to me, so I was displeased in using it.
Oh well, here we go again: I wrote my own COM pointer automation class. Here it goes the full code of it, which I now share with the world:
Oh well, here we go again: I wrote my own COM pointer automation class. Here it goes the full code of it, which I now share with the world:
#pragma once #include <Windows.h> #include <ObjBase.h> template<typename T> class ComPtr { public: ComPtr() : _ptr(NULL) { } ComPtr(const ComPtr& other) : _ptr(NULL) { operator=(other); } ~ComPtr() { this->release(); } ComPtr& operator=(const ComPtr& other) { if(this != &other) { this->~ComPtr(); _ptr = other._ptr; if(_ptr) _ptr->AddRef(); } return *this; } void release() { if(_ptr) { _ptr->Release(); _ptr = NULL; } } bool coCreateInstance(REFCLSID rclsid) { return _ptr ? false : SUCCEEDED(::CoCreateInstance(rclsid, 0, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&_ptr))); } bool coCreateInstance(REFCLSID rclsid, REFIID riid) { return _ptr ? false : SUCCEEDED(::CoCreateInstance(rclsid, 0, CLSCTX_INPROC_SERVER, riid, (void**)&_ptr)); } template<typename COM_INTERFACE> bool queryInterface(REFIID riid, COM_INTERFACE **comPtr) { return !_ptr ? false : SUCCEEDED(_ptr->QueryInterface(riid, (void**)comPtr)); } bool isNull() const { return _ptr == NULL; } T& operator*() { return *_ptr; } T* operator->() { return _ptr; } T** operator&() { return &_ptr; } operator T*() const { return _ptr; } private: T *_ptr; };Basically, by using this class I don’t have to worry about calling the Release method. Most interestingly, I added two shorhand methods to ease my life,
coCreateInstance
and queryInterface
. Here are an example illustrating the use of the ComPtr class, along with the cited methods:{ ComPtr<IGraphBuilder> graph; if(!graph.coCreateInstance(CLSID_FilterGraph)) OutputDebugString(L"Failed!"); ComPtr<IMediaControl> mediaCtrl; if(!graph.queryInterface(IID_IMediaControl, &mediaCtrl)) OutputDebugString(L"Failed!"); graph->RenderFile(L"foo.avi", NULL); // sweet! }If you’re wondering about the usefulness of this ComPtr class, try to write the code above without it.
Tuesday, November 27, 2012
HTML DTD: strict vs loose
I’ve been writing some HTML5 code lately, and at some point I faced some miscalculations of dimensions through CSS. After some research, I discovered I had my page being rendered in quirks mode. I’ve heard this expression before, but never really bothered much. What happens is that standards compliant pages should have a doctype declaration, which tells the browser the page should be rendered that way, otherwise the HTML will be rendered in a Neanderthal form, the so-called “quirks mode”. I never bothered using a doctype, because I didn’t know the real meaning of it. Until now.
Then, convinced to use a doctype, I faced another problem. There were two types for me:
Good references here and here.
Then, convinced to use a doctype, I faced another problem. There were two types for me:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">The first is called “strict”, the second is “transitional”. The strict cuts away all the deprecated tags, while the transitional is the same strict plus some stuff like iframe, which I’m using at my project. So, my page is a transitional one, and I finally found my DTD.
Good references here and here.
Friday, November 23, 2012
A JavaScript and HTML5 tree graph
Following the previous post, I needed a graphical representation of a tree graph to put on an HTML page. I thought it would be a great opportunity to learn this HTML5 thingy, which everyone is talking about these days. I ended up writing a full implementation of a tree graph using only HTML5 and pure JavaScript, thus avoiding any third-party JavaScript libraries.
However, I faced some problems. I had to plot more than 2,000 nodes, although not all at the same time, sometimes I had hundreds of them being shown. So I had to run into a series of optimizations of the algorithm, not only to speed up the internal calculations, but also the page rendering itself. On my first implementation, each node was a DIV, and the lines were drawn upon a canvas. Then at some point I decided to purely draw the whole monster on canvas, and I rewrote everything, taking the opportunity to add animation effects.
Since I consider it to be good and clean code, and believing that it could be useful to someone else, I published the whole code on GitHub at rodrigocfd/html5-tree-graph, along with an example file.
A hard work and a great experience, indeed.
However, I faced some problems. I had to plot more than 2,000 nodes, although not all at the same time, sometimes I had hundreds of them being shown. So I had to run into a series of optimizations of the algorithm, not only to speed up the internal calculations, but also the page rendering itself. On my first implementation, each node was a DIV, and the lines were drawn upon a canvas. Then at some point I decided to purely draw the whole monster on canvas, and I rewrote everything, taking the opportunity to add animation effects.
Since I consider it to be good and clean code, and believing that it could be useful to someone else, I published the whole code on GitHub at rodrigocfd/html5-tree-graph, along with an example file.
A hard work and a great experience, indeed.
Monday, November 12, 2012
A jQuery popup modal dialog
These days I needed to display a form in HTML. The simplest way to do this would be just go to another page, where the form would be displayed, then go back to the previous page after the submit. But the form had only a couple fields to use a whole page, and also it felt too cumbersome to go back and forth with the pages. Or I could use an ordinary window popup, but since it’s a modeless window, problems would easily arise.
So, with the aid of jQuery, I wrote a small jQuery plugin to use an ordinary hidden DIV as a popup modal dialog, so that I’d just have to keep the form into a DIV, and it would be shown without leave the current page. At some point, it saw that the OK and Cancel buttons could be automated themselves, so my form would need just the fields.
I also took the opportunity and used the same engine to generate automatic OK and OK/Cancel dialogs, thus beautifying the alert and confirm JavaScript stock functions. Worth mentioning that the popup can be stacked, that is, a modal popup can open another modal popup, and so on.
It ended up helping me a lot, so I published it on GitHub at rodrigocfd/jquery-modalForm, along with an example file.
So, with the aid of jQuery, I wrote a small jQuery plugin to use an ordinary hidden DIV as a popup modal dialog, so that I’d just have to keep the form into a DIV, and it would be shown without leave the current page. At some point, it saw that the OK and Cancel buttons could be automated themselves, so my form would need just the fields.
I also took the opportunity and used the same engine to generate automatic OK and OK/Cancel dialogs, thus beautifying the alert and confirm JavaScript stock functions. Worth mentioning that the popup can be stacked, that is, a modal popup can open another modal popup, and so on.
It ended up helping me a lot, so I published it on GitHub at rodrigocfd/jquery-modalForm, along with an example file.
Subscribe to:
Posts (Atom)