mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 03:09:18 +02:00
build 180429. vorbis ogg audio data format support, minor bug fixes
This commit is contained in:
@@ -6402,7 +6402,7 @@ void TMoverParameters::dizel_Heat( double const dt ) {
|
||||
&& ( dizel_heat.temperatura2 > dizel_heat.water_aux.config.temp_cooling - ( dizel_heat.water_aux.is_warm ? 8 : 0 ) ) ) );
|
||||
auto const PTC2 { ( dizel_heat.water_aux.is_warm /*or PTC2p*/ ? 1 : 0 ) };
|
||||
dizel_heat.rpmwz2 = PTC2 * 80 * rpm / ( ( 0.5 * rpm ) + 500 );
|
||||
dizel_heat.zaluzje2 = ( dizel_heat.water_aux.config.shutters ? PTC2 : true ); // no shutters is an equivalent to having them open
|
||||
dizel_heat.zaluzje2 = ( dizel_heat.water_aux.config.shutters ? ( PTC2 == 1 ) : true ); // no shutters is an equivalent to having them open
|
||||
auto const zaluzje2 { ( dizel_heat.zaluzje2 ? 1 : 0 ) };
|
||||
// auxiliary water circuit heat transfer values
|
||||
auto const kf2 { kurek07 * ( ( dizel_heat.kw * ( 0.3 + 0.7 * zaluzje2 ) ) * dizel_heat.rpmw2 + ( dizel_heat.kv * ( 0.3 + 0.7 * zaluzje2 ) * Vel / 3.6 ) ) + 2 };
|
||||
@@ -6430,7 +6430,7 @@ void TMoverParameters::dizel_Heat( double const dt ) {
|
||||
&& ( dizel_heat.temperatura1 > dizel_heat.water.config.temp_cooling - ( dizel_heat.water.is_warm ? 8 : 0 ) ) ) );
|
||||
auto const PTC1 { ( dizel_heat.water.is_warm /*or PTC1p*/ ? 1 : 0 ) };
|
||||
dizel_heat.rpmwz = PTC1 * 80 * rpm / ( ( 0.5 * rpm ) + 500 );
|
||||
dizel_heat.zaluzje1 = ( dizel_heat.water.config.shutters ? PTC1 : true ); // no shutters is an equivalent to having them open
|
||||
dizel_heat.zaluzje1 = ( dizel_heat.water.config.shutters ? ( PTC1 == 1 ) : true ); // no shutters is an equivalent to having them open
|
||||
auto const zaluzje1 { ( dizel_heat.zaluzje1 ? 1 : 0 ) };
|
||||
// primary water circuit heat transfer values
|
||||
auto const kf { obieg * kurek07 * ( ( dizel_heat.kw * ( 0.3 + 0.7 * zaluzje1 ) ) * dizel_heat.rpmw + ( dizel_heat.kv * ( 0.3 + 0.7 * zaluzje1 ) * Vel / 3.6 ) + 3 ) + 2 };
|
||||
|
||||
32
audio.cpp
32
audio.cpp
@@ -15,6 +15,8 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "logs.h"
|
||||
#include "resourcemanager.h"
|
||||
|
||||
#define STB_VORBIS_HEADER_ONLY
|
||||
#include "stb_vorbis.c"
|
||||
#define DR_WAV_IMPLEMENTATION
|
||||
#include "dr_wav.h"
|
||||
#define DR_FLAC_IMPLEMENTATION
|
||||
@@ -27,8 +29,28 @@ openal_buffer::openal_buffer( std::string const &Filename ) :
|
||||
|
||||
::alGenBuffers( 1, &id );
|
||||
// fetch audio data
|
||||
if( Filename.substr( Filename.rfind( '.' ) ) == ".wav" ) {
|
||||
// .wav file
|
||||
if( Filename.substr( Filename.rfind( '.' ) ) == ".ogg" ) {
|
||||
// vorbis .ogg audio data file
|
||||
// TBD, TODO: customized vorbis_decode to avoid unnecessary shuffling around of the decoded data
|
||||
int channels, samplerate;
|
||||
std::int16_t *filedata { nullptr };
|
||||
auto const samplecount{ stb_vorbis_decode_filename( Filename.c_str(), &channels, &samplerate, &filedata ) };
|
||||
if( samplecount > 0 ) {
|
||||
rate = samplerate;
|
||||
data.resize( samplecount );
|
||||
std::copy( filedata, filedata + samplecount, std::begin( data ) );
|
||||
free( filedata );
|
||||
if( channels > 1 ) {
|
||||
narrow_to_mono( channels );
|
||||
data.resize( samplecount / channels );
|
||||
}
|
||||
}
|
||||
else {
|
||||
ErrorLog( "Bad file: failed do load audio file \"" + Filename + "\"", logtype::file );
|
||||
}
|
||||
}
|
||||
else if( Filename.substr( Filename.rfind( '.' ) ) == ".wav" ) {
|
||||
// .wav audio data file
|
||||
auto *file { drwav_open_file( Filename.c_str() ) };
|
||||
if( file != nullptr ) {
|
||||
rate = file->sampleRate;
|
||||
@@ -49,8 +71,8 @@ openal_buffer::openal_buffer( std::string const &Filename ) :
|
||||
// we're done with the disk data
|
||||
drwav_close( file );
|
||||
}
|
||||
else {
|
||||
// .flac or .ogg file
|
||||
else if( Filename.substr( Filename.rfind( '.' ) ) == ".flac" ) {
|
||||
// .flac audio data file
|
||||
auto *file { drflac_open_file( Filename.c_str() ) };
|
||||
if( file != nullptr ) {
|
||||
rate = file->sampleRate;
|
||||
@@ -209,7 +231,7 @@ buffer_manager::find_buffer( std::string const &Buffername ) const {
|
||||
std::string
|
||||
buffer_manager::find_file( std::string const &Filename ) const {
|
||||
|
||||
std::vector<std::string> const extensions { ".wav", ".flac", ".ogg" };
|
||||
std::vector<std::string> const extensions { ".ogg", ".flac", ".wav" };
|
||||
|
||||
for( auto const &extension : extensions ) {
|
||||
if( FileExists( Filename + extension ) ) {
|
||||
|
||||
5462
stb_vorbis.c
Normal file
5462
stb_vorbis.c
Normal file
File diff suppressed because it is too large
Load Diff
2
uart.cpp
2
uart.cpp
@@ -160,7 +160,7 @@ void uart_input::poll()
|
||||
auto const bit { std::get<std::size_t>( entry ) % 8 };
|
||||
|
||||
bool const state { ( ( buffer[ byte ] & ( 1 << bit ) ) != 0 ) };
|
||||
bool const changed { ( ( old_packet[ byte ] & ( 1 << bit ) ) != state ) };
|
||||
bool const changed { ( ( ( old_packet[ byte ] & ( 1 << bit ) ) != 0 ) != state ) };
|
||||
|
||||
if( false == changed ) { continue; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user