I have to admit that the title of this article is misleading, but I didn’t find a better one. It’s not about DirectSound under Delphi – these two just happen to be the topics I was busy with today.
The Delphi part was about a bug report I received for MPUI: If Windows XP styles are activated, the menu bar would have the wrong color. To fix this, the bug reporter said, it would suffice to recompile MPUI with Delphi 7. Sadly, I don’t have Delphi 7 Personal Edition here and it’s nowhere to be found on the web, so I had to download Delphi 2005 Personal Edition, which is about three times as big as Delphi 6 personal.
The new IDE is »Microsoftish«, i.e. it resembles Visual Studio. This means that the user interface is complex and confusing, for example it’s really hard to find something in the coponents palette. Another major flaw in the IDE’s GUI design is the location of tabs: Above the main edit window, there is a tab bar with all opened units. Good. But the tab bar to switch between the Code Editor and Form Designer is below the main window. Bad.
But the worst thing about the modern Delphi incarnation is the help system. Prior versions offered a well-structured, clear, context-sensitive help. All this stuff was sacrificed and replaced by the utterly unusable Microsoft Document Viewer that displays HTML-rendered content in a completely unstructured manner. Sigh. I’m glad that I really only need Delphi 2005 for compiling, not developing stuff.
The other thing I did today was some delving into DirectSound, this time in C. For the 4k intro that is (hopefully!) upcoming for Breakpoint 2006, I need a simple player for samples at varying pitch, with some polyphony. This is exactly what DirectSoundBuffers offer, so DirectSound was the API of my choice. Unfortunately, it’s quite hard to find documentation for IDirectSound (the original DirectSound interface), MSDN seems to have ditched erverything but IDirectSound8 (but I’m not an MSDN expert, so maybe I just have searched in the wrong places). Thus, all I had was the Windows CE DirectSound documentation and a bunch of tutorials.
By and large, the API is OK. But there is one note in the documentation that really sounds like bad API design: »Check if the buffer is lost, and if so, restore it.« Well, isn’t it the task of a hardware-abstracting library like DirectSound to care about buffers that get lost due to context switches, DMA memory shortage or other common situations? Why does the user (i.e. the application programmer) have to deal with these intricate details?
Another stange issue was
IDirectSound::SetCooperativeLevel constantly failing without any apparent reason. After nearly half an hour of debugging, I found the reason: I set the default (and recommended)
DSSCL_NORMAL cooperative level – but only the much less polite
DSSCL_PRIORITY worked. Sigh again.
Finally, I want to mention a funny compiler warning complaining about an additional and superfluous level of pointer indirection:
Warning dstest.c: 35 assignment of pointer to pointer to pointer to void to pointer to pointer to void
In sound programming, even the warning messages seem to have some kind of rhythm :)