• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FS2004 VC doesn't build project

Messages
10
Country
belarus
Good day. I need your help. Compiler doesn't build project with error in stdexcept file.

I'm using VS2010.

This my code:
File ref_sound.h:
Code:
#pragma once

enum id_sounds {
	SND_TUMBLER,
	SND_GALETNIK,

	SOUNDS_COUNT
};

void initialization_play_sounds();
void update_play_sounds();
void deinitialization_play_sounds();

bool MFSSoundIsPlaying(int sound_type);
void MFSSoundFilePlay(int sound_type, bool flag_looping=false, DWORD pos=0);
void MFSSoundStop(int sound_type);

void play_sound_tumbler();
void play_sound_galetnik();

and ref_sound.cpp:
Code:
#include <gauges.h>
#include "DXUTsound.h"
#include "ref_sound.h"

CSoundManager* p_sound_manager = NULL;

struct stru_sound {
	CSound *p_sound;
	SINT32 volume;
	char name_wav_file[MAX_PATH];
	char name_volume_parameter[30];
	UINT32 defult_volume;
} sounds[SOUNDS_COUNT] = {

	{NULL, 0, "Tumb_no_fix.wav", "", 70},			// SOUND_SWITCH_NOFIX	0
	{NULL, 0, "Galetn.wav", "", 70},					// SOUND_WAFER_SWITCH	1
};

void initialization_play_sounds()
{
	p_sound_manager = new CSoundManager();
	if (!p_sound_manager) return;

	HRESULT hr;
	HWND hWnd = FindWindow((LPCWSTR) "FS98MAIN", NULL);
	hr = p_sound_manager->Initialize(hWnd, DSSCL_NORMAL);
	if (hr != S_OK) 
	{	SAFE_DELETE(p_sound_manager);
	return;
	}

	hr = p_sound_manager->SetPrimaryBufferFormat( 2, 22050, 16 );

	char path_to_sim[MAX_PATH];
	DWORD result;
	int i;
	ZeroMemory(path_to_sim, MAX_PATH);
	result = GetModuleFileName(NULL, (LPWSTR) path_to_sim, MAX_PATH);
	if (result) {
		for (i = MAX_PATH; i > 0; i--) 
		{
			if (*(path_to_sim + i) == '\\')
				break;
			*(path_to_sim + i) = 0;
		}
	}

	char path_to_sound[MAX_PATH];
	char path_to_vaw_file[MAX_PATH];

	if (strlen(path_to_sim) > 0) {
		ZeroMemory(path_to_sound, MAX_PATH);
		sprintf_s(path_to_sound, MAX_PATH, "%s%s", path_to_sim, "Gauges\\Tu154_cfg\\SOUND\\");

		for (int i = 0; i < SOUNDS_COUNT; i++)
		{
			ZeroMemory(path_to_vaw_file, MAX_PATH);
			sprintf_s(path_to_vaw_file, MAX_PATH, "%s%s", (LPTSTR) path_to_sound, sounds[i].name_wav_file); 

			if (sounds[i].defult_volume < 0)
				sounds[i].volume = 1;
			else {
				if (strlen(sounds[i].name_volume_parameter) > 0) {
					SINT32 value = -2000 + 20 * 30;
					if(value > 0)
						value = 0;
					else if(value < -2000)
						value = -2000;
					sounds[i].volume = value;
				}
			}

			hr = p_sound_manager->Create(&sounds[i].p_sound, (LPTSTR) path_to_vaw_file, DSBCAPS_CTRLVOLUME, GUID_NULL);
			if (sounds[i].p_sound != NULL)
				sounds[i].p_sound->SetVolume(sounds[i].volume);
		}
	}
}

void update_play_sounds()
{
	for (int i = 0; i < SOUNDS_COUNT; i++)
		if (sounds[i].p_sound != NULL)
			sounds[i].p_sound->SetVolume(sounds[i].volume);
}


void deinitialization_play_sounds()
{
	for (int i = 0; i < SOUNDS_COUNT; i++)
		SAFE_DELETE(sounds[i].p_sound);
	SAFE_DELETE(p_sound_manager);
}

DWORD bufsz_sound_by_type(int sound_type)
{
	if (sound_type < 0 || sound_type > SOUNDS_COUNT-1)
		return 1;
	if (sounds[sound_type].p_sound == NULL)
		return 1;
	return sounds[sound_type].p_sound->GetBufferSize();
}

bool MFSSoundIsPlaying(int sound_type) {
	if (sound_type < 0 || sound_type > SOUNDS_COUNT-1)
		return false;
	if (sounds[sound_type].p_sound == NULL)
		return false;
	return sounds[sound_type].p_sound->IsSoundPlaying();
}


void MFSSoundFilePlay(int sound_type, BOOL flag_looping, DWORD pos)
{
	if (sound_type < 0 || sound_type > SOUNDS_COUNT-1)
		return;
	if (sounds[sound_type].p_sound == NULL)
		return;	
	if (sounds[sound_type].p_sound->IsSoundPlaying())
	{
		sounds[sound_type].p_sound->Stop();
		sounds[sound_type].p_sound->Reset();
	}
	if (pos > 0)
		sounds[sound_type].p_sound->SetCurPos(pos);
	DWORD flag;
	if (flag_looping)
		flag = DSBPLAY_LOOPING;
	else
		flag = 0;
	sounds[sound_type].p_sound->Play(0, flag);
}


void MFSSoundStop(int sound_type)
{
	if (sound_type < 0 || sound_type > SOUNDS_COUNT-1)
		return;
	if (sounds[sound_type].p_sound == NULL)
		return;
	if (sounds[sound_type].p_sound->IsSoundPlaying()) 
	{
		sounds[sound_type].p_sound->Stop();
		sounds[sound_type].p_sound->Reset();
	}
}

void play_sound_tumbler() {MFSSoundFilePlay(SND_TUMBLER);}
void play_sound_galetnik() {MFSSoundFilePlay(SND_GALETNIK);}
 
Last edited:
Back
Top