mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 22:09:19 +02:00
sound fixed
This commit is contained in:
@@ -4711,7 +4711,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
for( int i = 0; i < iAxles; i++ ) {
|
for( int i = 0; i < iAxles; i++ ) {
|
||||||
parser.getTokens( 1, false );
|
parser.getTokens( 1, false );
|
||||||
parser >> dWheelsPosition[ i ];
|
parser >> dWheelsPosition[ i ];
|
||||||
parser.getTokens();
|
parser.getTokens(1, false);
|
||||||
parser >> token;
|
parser >> token;
|
||||||
if( token != "end" ) {
|
if( token != "end" ) {
|
||||||
rsStukot[i] = sound_man->create_sound(token);
|
rsStukot[i] = sound_man->create_sound(token);
|
||||||
|
|||||||
33
Train.cpp
33
Train.cpp
@@ -6528,102 +6528,135 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
|||||||
// hamowanie zwykle:
|
// hamowanie zwykle:
|
||||||
rsBrake = sound_man->create_sound(parser.getToken<std::string>());
|
rsBrake = sound_man->create_sound(parser.getToken<std::string>());
|
||||||
parser.getTokens(4, false);
|
parser.getTokens(4, false);
|
||||||
|
if (rsBrake)
|
||||||
|
{
|
||||||
parser >> rsBrake->gain_mul >> rsBrake->gain_off >> rsBrake->pitch_mul >> rsBrake->pitch_off;
|
parser >> rsBrake->gain_mul >> rsBrake->gain_off >> rsBrake->pitch_mul >> rsBrake->pitch_off;
|
||||||
rsBrake->gain_mul /= (1 + mvOccupied->MaxBrakeForce * 1000);
|
rsBrake->gain_mul /= (1 + mvOccupied->MaxBrakeForce * 1000);
|
||||||
rsBrake->pitch_mul /= (1 + mvOccupied->Vmax);
|
rsBrake->pitch_mul /= (1 + mvOccupied->Vmax);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (token == "slipperysound:")
|
else if (token == "slipperysound:")
|
||||||
{
|
{
|
||||||
// sanie:
|
// sanie:
|
||||||
rsSlippery = sound_man->create_sound(parser.getToken<std::string>());
|
rsSlippery = sound_man->create_sound(parser.getToken<std::string>());
|
||||||
parser.getTokens(2, false);
|
parser.getTokens(2, false);
|
||||||
|
if (rsSlippery)
|
||||||
|
{
|
||||||
parser >> rsSlippery->gain_mul >> rsSlippery->gain_off;
|
parser >> rsSlippery->gain_mul >> rsSlippery->gain_off;
|
||||||
rsSlippery->pitch_mul = 0.0;
|
rsSlippery->pitch_mul = 0.0;
|
||||||
rsSlippery->pitch_off = 1.0;
|
rsSlippery->pitch_off = 1.0;
|
||||||
rsSlippery->gain_mul /= (1 + mvOccupied->Vmax);
|
rsSlippery->gain_mul /= (1 + mvOccupied->Vmax);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (token == "airsound:")
|
else if (token == "airsound:")
|
||||||
{
|
{
|
||||||
// syk:
|
// syk:
|
||||||
rsHiss = sound_man->create_sound(parser.getToken<std::string>());
|
rsHiss = sound_man->create_sound(parser.getToken<std::string>());
|
||||||
parser.getTokens(2, false);
|
parser.getTokens(2, false);
|
||||||
|
if (rsHiss)
|
||||||
|
{
|
||||||
parser >> rsHiss->gain_mul >> rsHiss->gain_off;
|
parser >> rsHiss->gain_mul >> rsHiss->gain_off;
|
||||||
rsHiss->pitch_mul = 0.0;
|
rsHiss->pitch_mul = 0.0;
|
||||||
rsHiss->pitch_off = 1.0;
|
rsHiss->pitch_off = 1.0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (token == "airsound2:")
|
else if (token == "airsound2:")
|
||||||
{
|
{
|
||||||
// syk:
|
// syk:
|
||||||
rsHissU = sound_man->create_sound(parser.getToken<std::string>());
|
rsHissU = sound_man->create_sound(parser.getToken<std::string>());
|
||||||
parser.getTokens(2, false);
|
parser.getTokens(2, false);
|
||||||
|
if (rsHissU)
|
||||||
|
{
|
||||||
parser >> rsHissU->gain_mul >> rsHissU->gain_off;
|
parser >> rsHissU->gain_mul >> rsHissU->gain_off;
|
||||||
rsHissU->pitch_mul = 0.0;
|
rsHissU->pitch_mul = 0.0;
|
||||||
rsHissU->pitch_off = 1.0;
|
rsHissU->pitch_off = 1.0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (token == "airsound3:")
|
else if (token == "airsound3:")
|
||||||
{
|
{
|
||||||
// syk:
|
// syk:
|
||||||
rsHissE = sound_man->create_sound(parser.getToken<std::string>());
|
rsHissE = sound_man->create_sound(parser.getToken<std::string>());
|
||||||
parser.getTokens(2, false);
|
parser.getTokens(2, false);
|
||||||
|
if (rsHissE)
|
||||||
|
{
|
||||||
parser >> rsHissE->gain_mul >> rsHissE->gain_off;
|
parser >> rsHissE->gain_mul >> rsHissE->gain_off;
|
||||||
rsHissE->pitch_mul = 0.0;
|
rsHissE->pitch_mul = 0.0;
|
||||||
rsHissE->pitch_off = 1.0;
|
rsHissE->pitch_off = 1.0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (token == "airsound4:")
|
else if (token == "airsound4:")
|
||||||
{
|
{
|
||||||
// syk:
|
// syk:
|
||||||
rsHissX = sound_man->create_sound(parser.getToken<std::string>());
|
rsHissX = sound_man->create_sound(parser.getToken<std::string>());
|
||||||
parser.getTokens(2, false);
|
parser.getTokens(2, false);
|
||||||
|
if (rsHissX)
|
||||||
|
{
|
||||||
parser >> rsHissX->gain_mul >> rsHissX->gain_off;
|
parser >> rsHissX->gain_mul >> rsHissX->gain_off;
|
||||||
rsHissX->pitch_mul = 0.0;
|
rsHissX->pitch_mul = 0.0;
|
||||||
rsHissX->pitch_off = 1.0;
|
rsHissX->pitch_off = 1.0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (token == "airsound5:")
|
else if (token == "airsound5:")
|
||||||
{
|
{
|
||||||
// syk:
|
// syk:
|
||||||
rsHissT = sound_man->create_sound(parser.getToken<std::string>());
|
rsHissT = sound_man->create_sound(parser.getToken<std::string>());
|
||||||
parser.getTokens(2, false);
|
parser.getTokens(2, false);
|
||||||
|
if (rsHissT)
|
||||||
|
{
|
||||||
parser >> rsHissT->gain_mul >> rsHissT->gain_off;
|
parser >> rsHissT->gain_mul >> rsHissT->gain_off;
|
||||||
rsHissT->pitch_mul = 0.0;
|
rsHissT->pitch_mul = 0.0;
|
||||||
rsHissT->pitch_off = 1.0;
|
rsHissT->pitch_off = 1.0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (token == "fadesound:")
|
else if (token == "fadesound:")
|
||||||
{
|
{
|
||||||
// syk:
|
// syk:
|
||||||
rsFadeSound = sound_man->create_sound(parser.getToken<std::string>());
|
rsFadeSound = sound_man->create_sound(parser.getToken<std::string>());
|
||||||
|
if (rsFadeSound)
|
||||||
|
{
|
||||||
rsFadeSound->gain_mul = 1.0;
|
rsFadeSound->gain_mul = 1.0;
|
||||||
rsFadeSound->gain_off = 1.0;
|
rsFadeSound->gain_off = 1.0;
|
||||||
rsFadeSound->pitch_mul = 1.0;
|
rsFadeSound->pitch_mul = 1.0;
|
||||||
rsFadeSound->pitch_off = 1.0;
|
rsFadeSound->pitch_off = 1.0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (token == "localbrakesound:")
|
else if (token == "localbrakesound:")
|
||||||
{
|
{
|
||||||
// syk:
|
// syk:
|
||||||
rsSBHiss = sound_man->create_sound(parser.getToken<std::string>());
|
rsSBHiss = sound_man->create_sound(parser.getToken<std::string>());
|
||||||
parser.getTokens(2, false);
|
parser.getTokens(2, false);
|
||||||
|
if (rsSBHiss)
|
||||||
|
{
|
||||||
parser >> rsSBHiss->gain_mul >> rsSBHiss->gain_off;
|
parser >> rsSBHiss->gain_mul >> rsSBHiss->gain_off;
|
||||||
rsSBHiss->pitch_mul = 0.0;
|
rsSBHiss->pitch_mul = 0.0;
|
||||||
rsSBHiss->pitch_off = 1.0;
|
rsSBHiss->pitch_off = 1.0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (token == "runningnoise:")
|
else if (token == "runningnoise:")
|
||||||
{
|
{
|
||||||
// szum podczas jazdy:
|
// szum podczas jazdy:
|
||||||
rsRunningNoise = sound_man->create_sound(parser.getToken<std::string>());
|
rsRunningNoise = sound_man->create_sound(parser.getToken<std::string>());
|
||||||
parser.getTokens(4, false);
|
parser.getTokens(4, false);
|
||||||
|
if (rsRunningNoise)
|
||||||
|
{
|
||||||
parser >> rsRunningNoise->gain_mul >> rsRunningNoise->gain_off >> rsRunningNoise->pitch_mul >>
|
parser >> rsRunningNoise->gain_mul >> rsRunningNoise->gain_off >> rsRunningNoise->pitch_mul >>
|
||||||
rsRunningNoise->pitch_off;
|
rsRunningNoise->pitch_off;
|
||||||
rsRunningNoise->gain_mul /= (1 + mvOccupied->Vmax);
|
rsRunningNoise->gain_mul /= (1 + mvOccupied->Vmax);
|
||||||
rsRunningNoise->pitch_mul /= (1 + mvOccupied->Vmax);
|
rsRunningNoise->pitch_mul /= (1 + mvOccupied->Vmax);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (token == "engageslippery:")
|
else if (token == "engageslippery:")
|
||||||
{
|
{
|
||||||
// tarcie tarcz sprzegla:
|
// tarcie tarcz sprzegla:
|
||||||
rsEngageSlippery = sound_man->create_sound(parser.getToken<std::string>());
|
rsEngageSlippery = sound_man->create_sound(parser.getToken<std::string>());
|
||||||
parser.getTokens(4, false);
|
parser.getTokens(4, false);
|
||||||
|
if (rsEngageSlippery)
|
||||||
|
{
|
||||||
parser >> rsEngageSlippery->gain_mul >> rsEngageSlippery->gain_off >> rsEngageSlippery->pitch_mul >>
|
parser >> rsEngageSlippery->gain_mul >> rsEngageSlippery->gain_off >> rsEngageSlippery->pitch_mul >>
|
||||||
rsEngageSlippery->pitch_off;
|
rsEngageSlippery->pitch_off;
|
||||||
rsEngageSlippery->pitch_mul /= (1 + mvOccupied->nmax);
|
rsEngageSlippery->pitch_mul /= (1 + mvOccupied->nmax);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (token == "mechspring:")
|
else if (token == "mechspring:")
|
||||||
{
|
{
|
||||||
// parametry bujania kamery:
|
// parametry bujania kamery:
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ std::string sound_manager::find_file(std::string name)
|
|||||||
return name;
|
return name;
|
||||||
|
|
||||||
name.erase(name.rfind('.'));
|
name.erase(name.rfind('.'));
|
||||||
std::vector<std::string> exts { ".wav", ".flac", ".ogg" };
|
std::vector<std::string> exts { ".wav", ".WAV", ".flac", ".ogg" };
|
||||||
for (auto const &ext : exts)
|
for (auto const &ext : exts)
|
||||||
if (FileExists(name + ext))
|
if (FileExists(name + ext))
|
||||||
return name + ext;
|
return name + ext;
|
||||||
@@ -243,6 +243,7 @@ sound::sound()
|
|||||||
gain_mul = 1.0f;
|
gain_mul = 1.0f;
|
||||||
pitch_off = 0.0f;
|
pitch_off = 0.0f;
|
||||||
pitch_mul = 1.0f;
|
pitch_mul = 1.0f;
|
||||||
|
dt_sum = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
simple_sound::simple_sound(sound_buffer *buf) : sound::sound()
|
simple_sound::simple_sound(sound_buffer *buf) : sound::sound()
|
||||||
@@ -317,12 +318,15 @@ void simple_sound::stop()
|
|||||||
|
|
||||||
void sound::update(float dt)
|
void sound::update(float dt)
|
||||||
{
|
{
|
||||||
|
if (spatial)
|
||||||
|
dt_sum += dt;
|
||||||
if (spatial && pos_dirty)
|
if (spatial && pos_dirty)
|
||||||
{
|
{
|
||||||
glm::vec3 velocity = (pos - last_pos) / dt; // m/s
|
glm::vec3 velocity = (pos - last_pos) / dt_sum; // m/s
|
||||||
alSourcefv(id, AL_VELOCITY, glm::value_ptr(velocity));
|
alSourcefv(id, AL_VELOCITY, glm::value_ptr(velocity));
|
||||||
last_pos = pos;
|
last_pos = pos;
|
||||||
pos_dirty = false;
|
pos_dirty = false;
|
||||||
|
dt_sum = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
sound.h
1
sound.h
@@ -41,6 +41,7 @@ class sound
|
|||||||
{
|
{
|
||||||
bool pos_dirty;
|
bool pos_dirty;
|
||||||
glm::vec3 last_pos;
|
glm::vec3 last_pos;
|
||||||
|
float dt_sum;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float max_dist;
|
float max_dist;
|
||||||
|
|||||||
3
stdafx.h
3
stdafx.h
@@ -77,7 +77,7 @@
|
|||||||
#include "GL/wglew.h"
|
#include "GL/wglew.h"
|
||||||
#endif
|
#endif
|
||||||
#define GLFW_INCLUDE_GLU
|
#define GLFW_INCLUDE_GLU
|
||||||
//m7todo: jest tu bo nie chcia³o mi siê wpychaæ do wszystkich plików
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
@@ -86,6 +86,7 @@
|
|||||||
#include <glm/gtc/epsilon.hpp>
|
#include <glm/gtc/epsilon.hpp>
|
||||||
#include <glm/gtx/rotate_vector.hpp>
|
#include <glm/gtx/rotate_vector.hpp>
|
||||||
#include <glm/gtx/norm.hpp>
|
#include <glm/gtx/norm.hpp>
|
||||||
|
#include <glm/gtx/string_cast.hpp>
|
||||||
|
|
||||||
#include "openglmatrixstack.h"
|
#include "openglmatrixstack.h"
|
||||||
#define STRINGIZE_DETAIL(x) #x
|
#define STRINGIZE_DETAIL(x) #x
|
||||||
|
|||||||
Reference in New Issue
Block a user