Category Archives: Uncategorized

Some good parts, kind of integrated

We are packing up, so I’m done for now. Progress has been pretty good. The core parts of the posting module are done, though they are not yet managed by a “topic manager” or some similar. I have YUI talking via PHP to MySQL, sending objects that contain data that will be needed in a structured way. That turned out to be much harder than I thought, simply because I couldn’t make the debugger in IntelleJ work in the PHP server file in such a way that I could watch an HTTP request come in. In olden days, I would have RTFM about the process and worked from that, but now with OpenSource, I’ve become very dependent on the debugger to tell me what’s actually going on. Many times things don’t correspond with (often stale) documentation. So in the end, I put together a light PHP class that pretty much echoed POST calls back at me so that I could look at them in the JavaScript debugger. That burned a day. Sigh.

The last (new) thing to do is to make the database access robust. I did my code based on Learning PHP, MySQL, and JavaScript, a generally fine book, but it still uses the deprecated “mysql_*” calls. I need to update that and have some generalized data return structures built. Then that part should be reasonably static from here on out.

Version 1!

  • Writing out files – done with CSV, not sure if we need the xml yet. Here’s what a session result looks like:
  • Trying to copy the executable over to another machine. First, the app failed to launch until I installed the end-user directX package. Now, it fails to start the XAudio2 engine. Trying the full install.
  • Built a release version. That may be better?
  • Well, it was either the full SDK install or the release build, but it works. I’m betting that it was the release build, since the debug dlls aren’t included in the DirectX end user package and I may have been referencing those.
  • Everything is now on the laptop for tomorrow’s meeting 🙂
  • Oh yeah, and I need to change the versionversion1

Building the Audio Library

  • Making sure that the release version of the code runs as well – it does. And a massive 19kb of executable. Of course, it’s not statically linked… That makes it 6,234kb
    • C/C++
      • General
        • Additional Include Directories: $(DXSDK_DIR)\Include
      • Language
        • Treat WChar_t as Built in Type: Yes (/Zc:wchar_t)
    • Linker
      • General
        • Additional Library Directories: C:\Program Files %28Ă—86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86
      • Input
        • Additional Dependencies:
          • winmm.lib
          • dxerr.lib
          • X3DAudio.lib (only needed for DLL compilation)
  • Making library
    • Following directions here:
    • For a DLL library, you *must* select the when creating your console application’s (that is actually not a console application, but never mind that…) “export variables” checkbox option. Still figuring out how to use this.
    • For my first attempt in accessing the DLL, I’ve created the following method (The #defines are generated, I’ve included them for all to marvel at):
        #define DXAUDIOINTERFACEDLL_API __declspec(dllexport)
        #define DXAUDIOINTERFACEDLL_API __declspec(dllimport)
        DXAUDIOINTERFACEDLL_API BasicAudio* getBasicAudio(void);
      • I think this produces an exported method that returns a pointer to the BasicAudio class. Not sure though. It may, though now I’m getting the following link errors:
        • 1>DynamicLibConsoleTest.obj : error LNK2019: unresolved external symbol “public: void __thiscall BasicAudio::destroy(void)” (?destroy@BasicAudio@@QAEXXZ) referenced in function _wmain
        • etc…
        • 1>C:\Phil\MSVC Dev\MultichannelOr3dAudio\DxAudioInterfaceLibrary\Debug\DynamicLibConsoleTest.exe : fatal error LNK1120: 6 unresolved externals
      • Which means the public inner methods are not available. Maybe the answer is to make a wrapper class for all the methods? Ugly, but something to try..
      • Building wrapper class DXAUDIOINTERFACEDLL_API CDxAudioInterfaceDLL
      • Done. Compiles and links now, but doesn’t run. Ah. I was declaring a local pointer to the internal BasicAudio class. Not pretty, but it does seem to work…
  • Testing against Static console app – check
  • Testing against Dynamic console app – check
  • Switching to Release build
  • Testing against Static console app – check
  • Testing against Dynamic console app – check
  • Checked everything into Subversion. Calling it a day.

A working console app!

Good progress today

Looks like everything is working in the proof of concept! Here’s the code:

#include "stdafx.h"
#include <Windows.h>
#include <conio.h>
#include "audio.h"

int _tmain(int argc, _TCHAR* argv[])
	int keyIn;
	HRESULT hr;                 // standard return type
	LPTSTR buf;
	LPTSTR targetDir = "C:\\Programming 2D Games in DirectX 11\\Chapter 7 - Sound\\ConsoleSound\\ConsoleSound\\ConsoleSound";
	Audio *audio = new Audio();

	buf = (LPTSTR)calloc(256, sizeof(char));
	GetCurrentDirectory(256, buf);
	printf("Current dir: '%s'\n", buf);
	if (*WAVE_BANK != '' && *SOUND_BANK != '')  // if sound files defined
		if( FAILED( hr = audio->initialize() ) )
				printf("Failed to initialize sound system because media file not found.\n");
				printf("hit return to exit\n");
				return -1;
				printf("Failed to initialize sound system.\n");
				printf("hit return to exit\n");
				return -1;

	printf("Type 'x' to quit, 1, 2, or 3 for sounds.\n");
	bool doit = true;
			keyIn = getch();

			printf("key = %c\n", keyIn);
			case 'x' : doit = false; 
			case '1' : audio->playCue(BEEP1);                  // play sound
			case '2' : audio->playCue(BEEP2);                  // play sound
			case '3' : audio->playCue(BEEP3);                  // play sound
		audio->run();                       // perform periodic sound engine tasks

	printf("hit return to exit");
	return 0;

Tomorrow, we’ll try to add positional sound.

When does surround not equal surround?

Apparently when you’re using OpenAL.

There is a multichannel test binary that you can run. (C:\Program Files (x86)\OpenAL 1.1 SDK\samples\bin\win64\PlayMultiChannelWin64.exe). It should run

front left, center, front right, rear right, rear left, and subwoofer.

Instead, it’s running

front left, front right, and center.

I’ve verified that all eight speakers are working in the test app that comes with the drivers. I’ve also verified that the sound is correctly sent using the Control Panel Sound->configure tool. So I’m not sure if it’s OpenAl or something else. Ah well. That’s for tomorrow.

Now, where was I?

Not a good week for development.

The headgear is done, the divers are in, and I was ready to start doing a serious dive into the Java3D sound capabilities (as per Section 2 of the plan “Develop codebase for testing haptic rendering”). Then my father got sick and landed in the hospital for a week. Which kinda shot productivity to hell.

Anyway, I’m picking up the pieces. The (official) site was down for most of yesterday, so I’ve only just connected to it again. So far I’ve downloaded and installed the AMD64 version of the jar files, hooked up my Eclipse IDE to the J3d-examples subversion repository (

The downloaded code compiles and runs as an ant file, but the structure doesn’t accommodate Eclipse’s code navigation for some reason. To fix this, I created a new Java project and copied the entire “resources” tree over and the tree that starts under “classes” in the original file. Here’s a screenshot:

J3D project layout

J3D project layout

This still didn’t compile though. I got an “Access restriction on class due to restriction on required library“, which I’ve never seen before. Poking around led me to StackOverflow, where there was this suggestion:

“go to java build path and under Library tab, remove JRE System Library. Then again Add Library –> JRE System Library”

Well, that makes no sense. It is just deleting and re-adding the system library. On the other hand, that’s exactly the kind of senseless thing that fixes weird errors, so I gave it a shot. Worked like a charm.

Anyway, now I’m having problems locating files that are right where the code says they are, but the loader’s can’t find them. Regardless, it’s time to go take care of Dad.