See site in english Voir le site en francais
Website skin:
home  download  forum  link  contact

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

Author Topic: How to make OrbiterSound load an different sound file for RCS  (Read 2660 times)

0 Members and 1 Guest are viewing this topic.

Offline Orbiter Fan

  • Full Member
  • ***
  • Posts: 162
  • Karma: 0
18 February 2004, 13:47:24
Hello.

Does someone know how to make OrbiterSound load an different sound file for the RCS? I want to
know this since I don't really like hearing the RCS thruster sound when I make my MER move. I
want to have an more appropriate sound file for that. Any help is appriciated!


Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15410
  • Karma: 264
  • Hein, quoi !?
    • FsPassengers
Reply #1 - 18 February 2004, 14:00:47
It's only for you or to be installed on user's computer ?

If it's only for you you can replace "attfire.wav" and "attsustain.wav"
in the folder "sound/vessel" by your how sound.

If it's for other I suggest you program this yourself with two
custom sound (or only one)

That's easy if you write the module (but impossible with
vinka dll)

Let me know

Dan


Offline Orbiter Fan

  • Full Member
  • ***
  • Posts: 162
  • Karma: 0
Reply #2 - 18 February 2004, 14:35:16
DanSteph wrote:

> If it's for other I suggest you program this yourself with two
> custom sound (or only one)

Could you please show me how to accomplish this?


Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15410
  • Karma: 264
  • Hein, quoi !?
    • FsPassengers
Reply #3 - 18 February 2004, 15:38:22
no problem here is how OrbiterSound do it:
(it's a bit more complicated in fact but it will be too long
 and you will not understand the point, so this is a basic custom code specially for you.
Tune it until satisfaction)

// PUT THIS BELOW IN .H FILE
-------------------------------------
#define RCS 50

// PUT THIS BELOW IN OVCINIT
---------------------------------------
ConnectToOrbiterSoundDLL();
RequestLoadVesselWave(RCS,"Sound\\yourfolder\\rcs.wav");
SoundOptionOnOff(PLAYATTITUDETHRUST,FALSE);


// PUT THIS BELOW IN OVCTIMESTEP
//---------------------------------------------
// here we record a value to see if one thruster is active
double ThrusterActive = GetThrusterGroupLevel(THGROUP_ATT_PITCHUP) +
GetThrusterGroupLevel(THGROUP_ATT_PITCHDOWN) +
GetThrusterGroupLevel(THGROUP_ATT_YAWLEFT) +
GetThrusterGroupLevel(THGROUP_ATT_YAWRIGHT) +
GetThrusterGroupLevel(THGROUP_ATT_BANKLEFT) +
GetThrusterGroupLevel(THGROUP_ATT_BANKRIGHT) +
GetThrusterGroupLevel(THGROUP_ATT_RIGHT) +
GetThrusterGroupLevel(THGROUP_ATT_LEFT) +
GetThrusterGroupLevel(THGROUP_ATT_UP) +
GetThrusterGroupLevel(THGROUP_ATT_DOWN) +
GetThrusterGroupLevel(THGROUP_ATT_FORWARD) +
GetThrusterGroupLevel(THGROUP_ATT_BACK);
if(ThrusterActive>1.0f)
ThrusterActive=1.0f;

// execute only if a thruster is active
if(ThrusterActive>0.0f)
{
// we calculate the volume at wich it must be played
double volume=110+(145*ThrusterActive);
PlayVesselWave(RCS,LOOP,Volume);   // play the sound
}
else if(IsPlayingVesselWave(RCS)
{
// else shut down the sound if it's playing
StopVesselWave(RCS);
}

That's it, take care that for now the option will shut down the rcs of all the vessel
in the scenario, I'll rewrite OrbiterSound so each vessel will be independent
but later.

Dan


Offline Orbiter Fan

  • Full Member
  • ***
  • Posts: 162
  • Karma: 0
Reply #4 - 19 February 2004, 09:46:25
Thanks for the code Dan. But when I compile I get these errors:

-------Configuration: NASA_MER - Win32 Release--------------------
Compiling...
NASA_MER.cpp
C:\orbiter_040128\Orbitersdk\samples\NASA_MER\NASA_MER.cpp(75) : error
C2065: 'GetThrusterGroupLevel' : undeclared identifier
C:\orbiter_040128\Orbitersdk\samples\NASA_MER\NASA_MER.cpp(95) : error C2065: 'Volume' :
undeclared identifier
C:\orbiter_040128\Orbitersdk\samples\NASA_MER\NASA_MER.cpp(97) : error
C2065: 'IsPlayingVesselWave' : undeclared identifier
C:\orbiter_040128\Orbitersdk\samples\NASA_MER\NASA_MER.cpp(98 ) : error C2143: syntax
error : missing ')' before '{'
Error executing cl.exe.

NASA_MER.dll - 4 error(s), 0 warning(s)

And here's the code:

// Vessel initialisation
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
   ConnectToOrbiterSoundDLL();
    RequestLoadVesselWave(RCS,"Sound\\Saturn1B\\LRover.wav" );
    SoundOptionOnOff(PLAYATTITUDETHRUST,FALSE);
   return new NASA_MER (hvessel, flightmodel);
}

// Frame update
DLLCLBK void ovcTimestep (VESSEL *vessel, double simt)
{
   // here we record a value to see if one thruster is active
double ThrusterActive = GetThrusterGroupLevel(THGROUP_ATT_PITCHUP) +
GetThrusterGroupLevel(THGROUP_ATT_PITCHDOWN) +
GetThrusterGroupLevel(THGROUP_ATT_YAWLEFT) +
GetThrusterGroupLevel(THGROUP_ATT_YAWRIGHT) +
GetThrusterGroupLevel(THGROUP_ATT_BANKLEFT) +
GetThrusterGroupLevel(THGROUP_ATT_BANKRIGHT) +
GetThrusterGroupLevel(THGROUP_ATT_RIGHT) +
GetThrusterGroupLevel(THGROUP_ATT_LEFT) +
GetThrusterGroupLevel(THGROUP_ATT_UP) +
GetThrusterGroupLevel(THGROUP_ATT_DOWN) +
GetThrusterGroupLevel(THGROUP_ATT_FORWARD) +
GetThrusterGroupLevel(THGROUP_ATT_BACK);
if(ThrusterActive>1.0f)
ThrusterActive=1.0f;

// execute only if a thruster is active
if(ThrusterActive>0.0f)
{
// we calculate the volume at wich it must be played
double volume=110+(145*ThrusterActive);
PlayVesselWave(RCS,LOOP,Volume); // play the sound
}
else if(IsPlayingVesselWave(RCS)
{
// else shut down the sound if it's playing
StopVesselWave(RCS);
}

   ((NASA_MER*)vessel)->Timestep (simt);
}

Do you see any errors?


Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15410
  • Karma: 264
  • Hein, quoi !?
    • FsPassengers
Reply #5 - 19 February 2004, 13:22:27
Yes , you are not in your vessel's class.

So either you deplace your whole code to your CLASS timestep
(Timestep (simt);)  (search about : "TimeStep") you must find a
NASA_MER::TimeStep(double simt) function.

Either you add the vessel pointer to each vessel function
(ie: vessel->GetThrusterGroupLevel(THGROUP_ATT_PITCHUP) +
vessel->GetThrusterGroupLevel(THGROUP_ATT_PITCHDOWN) + )


But the first methode is the right one.

Dan


Offline Orbiter Fan

  • Full Member
  • ***
  • Posts: 162
  • Karma: 0
Reply #6 - 19 February 2004, 14:15:06
I can't get it to compile. Dan, it would make me very happy if you could modify the source code
below to make the custom RCS sound work!
The source code I'm using is based on the ShuttlePB source code:

// ==============================================================
//              ORBITER MODULE: NASA_MER Rover
//          Copyright (C) 2004 David Sundstrom
//     Based on ShuttlePB source code by Dr. Martin Schweiger
//                   All rights reserved
//
// NASA_MER.cpp
// Control module for NASA_MER vessel class
// ==============================================================

#include "orbitersdk.h"
#include "OrbiterSoundSDK.h"
#define RCS 1

const double NASA_MER_FUELMASS = 50;
const double NASA_MER_ISP = 5e4;
const double NASA_MER_MAXRCSTH = 0;
const double NASA_MER_MAXLINTH = 2e2;
const double NASA_MER_MAXROTTH = 5e1;


// ==============================================================
// API interface
// ==============================================================

// Initialisation
DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
   ConnectToOrbiterSoundDLL();
    RequestLoadVesselWave(RCS,"Sound\\Saturn1B\\LRover.wav");
    SoundOptionOnOff(PLAYATTITUDETHRUST,FALSE);

   return new VESSEL (hvessel, flightmodel);
}

// Cleanup
DLLCLBK void ovcExit (VESSEL *vessel)
{
   if (vessel) delete vessel;
}

// Set the capabilities of the vessel class
DLLCLBK void ovcSetClassCaps (VESSEL *vessel, FILEHANDLE cfg)
{
   THRUSTER_HANDLE th_rcs[14], th_group[4];

   // physical specs
   vessel->SetSize (3.5);
   vessel->SetEmptyMass (174);
   vessel->SetCW (0.3, 0.3, 0.6, 0.9);
   vessel->SetCrossSections (_V(10.5,15.0,5.8));
   vessel->SetRotDrag (_V(0.6,0.6,0.35));
   vessel->SetPMI (_V(2.28,2.31,0.79));
   vessel->SetCameraOffset (_V(0,0.8,0));
   vessel->SetTouchdownPoints (_V(0,-0.63,2), _V(-1,-0.63,-1.5), _V(1,-0.63,-1.5));

   // propellant resources
   PROPELLANT_HANDLE hpr = vessel->CreatePropellantResource (NASA_MER_FUELMASS);

   // *********************** thruster definitions
********************************

   th_rcs[ 0] = vessel->CreateThruster (_V( 1,0, 3), _V(0, 1,0), NASA_MER_MAXRCSTH, hpr,
NASA_MER_ISP);
   th_rcs[ 1] = vessel->CreateThruster (_V( 1,0, 3), _V(0,-1,0), NASA_MER_MAXRCSTH, hpr,
NASA_MER_ISP);
   th_rcs[ 2] = vessel->CreateThruster (_V(-1,0, 3), _V(0, 1,0), NASA_MER_MAXRCSTH, hpr,
NASA_MER_ISP);
   th_rcs[ 3] = vessel->CreateThruster (_V(-1,0, 3), _V(0,-1,0), NASA_MER_MAXRCSTH, hpr,
NASA_MER_ISP);
   th_rcs[ 4] = vessel->CreateThruster (_V( 1,0,-3), _V(0, 1,0), NASA_MER_MAXRCSTH, hpr,
NASA_MER_ISP);
   th_rcs[ 5] = vessel->CreateThruster (_V( 1,0,-3), _V(0,-1,0), NASA_MER_MAXRCSTH, hpr,
NASA_MER_ISP);
   th_rcs[ 6] = vessel->CreateThruster (_V(-1,0,-3), _V(0, 1,0), NASA_MER_MAXRCSTH, hpr,
NASA_MER_ISP);
   th_rcs[ 7] = vessel->CreateThruster (_V(-1,0,-3), _V(0,-1,0), NASA_MER_MAXRCSTH, hpr,
NASA_MER_ISP);
   th_rcs[ 8] = vessel->CreateThruster (_V( 1,0, 3), _V(-1,0,0), NASA_MER_MAXROTTH, hpr,
NASA_MER_ISP);
   th_rcs[ 9] = vessel->CreateThruster (_V(-1,0, 3), _V( 1,0,0), NASA_MER_MAXROTTH, hpr,
NASA_MER_ISP);
   th_rcs[10] = vessel->CreateThruster (_V( 1,0,-3), _V(-1,0,0), NASA_MER_MAXROTTH,
hpr, NASA_MER_ISP);
   th_rcs[11] = vessel->CreateThruster (_V(-1,0,-3), _V( 1,0,0), NASA_MER_MAXROTTH,
hpr, NASA_MER_ISP);
   th_rcs[12] = vessel->CreateThruster (_V( 0,0,-3), _V(0,0, 1), NASA_MER_MAXLINTH, hpr,
NASA_MER_ISP);
   th_rcs[13] = vessel->CreateThruster (_V( 0,0, 3), _V(0,0,-1), NASA_MER_MAXLINTH, hpr,
NASA_MER_ISP);


   th_group[0] = th_rcs[8];
   th_group[1] = th_rcs[11];
   vessel->CreateThrusterGroup (th_group, 2, THGROUP_ATT_YAWLEFT);

   th_group[0] = th_rcs[9];
   th_group[1] = th_rcs[10];
   vessel->CreateThrusterGroup (th_group, 2, THGROUP_ATT_YAWRIGHT);

   vessel->CreateThrusterGroup (th_rcs+12, 1, THGROUP_ATT_FORWARD);
   vessel->CreateThrusterGroup (th_rcs+13, 1, THGROUP_ATT_BACK);

   // visual specs
   vessel->AddMesh ("NASA_MER_Rover");
}


Offline Orbiter Fan

  • Full Member
  • ***
  • Posts: 162
  • Karma: 0
Reply #7 - 20 February 2004, 14:33:35
*bump*

« Last Edit: 20 February 2004, 14:33:35 by Orbiter Fan »