Archived

This topic is now archived and is closed to further replies.

dragonflightdesign

DXSound Tutorial for FS9 ?

Recommended Posts

Is there one ? I have downloaded the SDK, and have found a switch which uses DXSound for the click, but it was not made for the beginner as the files are everywhere. I have sorted the code to make the click in FS I think, but can not get it to compile, as I am obviously not including something, but after looking at the switch sample I can not work out what it is.any help will be greatly appreaciated.

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Ok still get errorsthe sample switch compiles if I open it in Visual C++ 2008, with a couple of warning and shows up in FS, so have gone through every file to see what includes there are, and wrote them down. Then made sure I include them when I compile my switch, I get 120 errors.windows.h, stdio.h, stdlib.h string.h are all in fs9gauges.hsound.cpp and waveread.cpp are in Visual C++ include folder along with fs9 gauges. All includes from the DXSound SDK are in there, and the library files are in the Visual C++ lib folder.I then tell the compiler where they are in the source like this#include "..includefs9gauges.h"#include "..includesound.cpp"#include "..includewaveread.cpp"#include "beacon.h"#include "Sound.h" - added this on last compile, as the sample switch had this in the header file in the compiler. Still 120 errors.where am I going wrong ?

Share this post


Link to post
Share on other sites

Are you linking to the following libraries?dsound.libuser32.libwinmm.libDoug

Share this post


Link to post
Share on other sites

Hi DougI am linking the following librariesdsound.libuser32.libwinmm.libjust in case I not linking them correctly, In Visual C++ 2008, I go to the propities of my project, linker, input, then in additional dependencies I have added dsound.lib winmm.lib. user32.lib is in the inherited values.

Share this post


Link to post
Share on other sites

Russell:Give me a few days. I've got all of this working for both FS9 and FSX but I'm currently intermittantly losing control of the DirectSound secondary buffers. Has to be a b*llsup in my code. I intend to release the code as a gauge that can be included in anyone's project. The play command data is to be passed by a simple globally-shared string variable; no buggering about with creating and destroying variables to be shared between separate guages.-Dai

Share this post


Link to post
Share on other sites

Hi DaiYou gauge sounds good, but one of the main reason I started learning C++ is to do sounds. I have an idea for a project which uses a lot of sounds, but if I can not get the basics to work then I might as well give up, and the last three months I have spend learning C++ I might have as well spend down the pub.My problem with this seems to be sound.cpp and waveread.cpp, if I do not include these files the dam thing compiles, but include them and the compiler chucks out a shed load of errors.The sample switch I downloaded includes some of your work, panswitch. Which if I open as a project/solution compiles with a couple of errors, but works ok in FS, but for the life of me I can not see why that compiles and and mine does not. I have added all the libraries, plus the ones that came with the sample switch, which are not in the directsoundsdk, dxsoundDebug.lib and dxsoundrelease.lib, but still the same errors.Been at this for hours and will call it a night, as my eyes hurt and my brain has turned to mush, will start again tomorrow though. Not beat yet :)

Share this post


Link to post
Share on other sites

Sounds like you're using Jose Olivera's work as a base. I can't for the life of me remember why it doesn't work correctly in FS9/FSX; I do remember looking at it, deciding I didn't understand enough to update it and then throwing it away to start again with the DirectX SDK. Guess what? The end result looks remarkably like Jose's original... no surprise there.Now, Jose's original only allows for one DirectSound buffer. Try to play more than one sound simultaneously and FS will blackscreen. I fixed that problem in my version, then occasionally got engine failure trying to keep track of the secondary buffers.Did I say that I'll be giving away the code? I meant to imply that: by 'gauge' I mean giving the developers the code to incorporate within their own gauges and not have to call to an external, standalone gauge. If anyone wants to convert my code to do that, they'll be welcome.-Dai

Share this post


Link to post
Share on other sites

DaiWhen you said "I intend to release the code as a gauge" I thought you ment like the one Doug did for XML where you would have to include the gauge in the panel, and then add the sounds via a ini file. Understood the second explaination better :)The template switch I am using is by Jose Olivera, could not rememember his name when I posted I was to lazy to look. After looking at this again this morning I have decide to do what you have done and throw it away and start with the SDK. If I am understanding this correctly Jose created the Sound.cpp and Waveread.cpp, so it could be included in anyones gauge, to play single sounds. Your code could be included the same way but will play more than one sound simultaneously. I think I will have a go at the one direct sound buffer first, can always add later.I am currently printing out the DirectSoundSDK, so will see how it goes

Share this post


Link to post
Share on other sites

sound.cpp and waveread.cpp (and their corresponding .h files) come with the DirectSound SDK. Which version of the SDK are you using? IIRC the current one (June 2008) illustrates managed code only; one h

Share this post


Link to post
Share on other sites

>sound.cpp and waveread.cpp (and their corresponding .h files) come with the DirectSound SDK. sound.cpp and waveread.cppI have downloaded the latest Direct X SDK (June 2008). The reason I thought sound.cpp and waveread.cpp where something Jose coded was due to this in the SDK "Projects need to include the Dsound.h header file. If you are using the DirectSound API directly and want to be able to use helper functions such as DirectSoundCreate8, be sure to link to Dsound.lib and include the appropriate folder in the library search path." I have not had time to read through the SDK yet, due to other things, but am planning to sit down and read it shortly, maybe be I will understand a bit more then, or then again I might be even more confused :)which version of the SDK are you using ?

Share this post


Link to post
Share on other sites

>which version of the SDK are you using ?Good question :). Dunno. Not that it matters for unmanaged code because in true Microsoft fashion, sound.cpp and waveread.cpp have not changed since the original release when the filename was simply called 'directxsdk' - sometime in spring 2002 IIRC. I can verify that because a couple of days ago, just out of interest, I compared the original files against the current ones. I think I've got the August 2007 DirectX9 version installed on this PC, but as I said, it doesn't really matter.I'll give you clue as to one real nasty :( tracking the buffers that have been allocated a looping sound so that you can stop them correctly. Fixed the bl**dy secondary sound buffer allocation tracking BTW. Enough's enough for today - I've got some monsters to kill (in a CRPG, I hasten to add!).-Dai

Share this post


Link to post
Share on other sites

An update for anyone who is following this thread...I fully expect to have the initial release of the DirectSound code by the end of the week. It will form part of the next release of sd2gau.-Dai

Share this post


Link to post
Share on other sites