Only a couple of hours to do things today

  • Working on getting reacquainted with FLTK, callbacks, etc. Got some of the framework up:

FltkFramework

Advertisements

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: http://msdn.microsoft.com/en-us/library/vstudio/ms235627.aspx
    • 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):
      • #ifdef DXAUDIOINTERFACEDLL_EXPORTS
        #define DXAUDIOINTERFACEDLL_API __declspec(dllexport)
        #else
        #define DXAUDIOINTERFACEDLL_API __declspec(dllimport)
        #endif
        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();

	SetCurrentDirectory(targetDir);
	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() ) )
		{
			if( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ) ){
				printf("Failed to initialize sound system because media file not found.\n");
				printf("hit return to exit\n");
				getchar();
				return -1;
			}
			else{
				printf("Failed to initialize sound system.\n");
				printf("hit return to exit\n");
				getchar();
				return -1;
			}
		}
	}

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

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

	printf("hit return to exit");
	getchar();
	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) java3d.java.net 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 (https://svn.java.net/svn/j3d-examples~svn).

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.