mikymod 12 лет назад
Родитель
Сommit
31defd34c8
2 измененных файлов с 10 добавлено и 7 удалено
  1. 4 4
      engine/compilers/sound/SoundCompiler.cpp
  2. 6 3
      engine/resource/SoundResource.h

+ 4 - 4
engine/compilers/sound/SoundCompiler.cpp

@@ -110,7 +110,7 @@ size_t SoundCompiler::compile_if_wav(Filesystem& fs, const char* resource_path)
 	m_sound_header.channels = header.fmt_channels;
 	m_sound_header.block_size = header.fmt_block_align;
 	m_sound_header.bits_ps = header.fmt_bits_ps;
-	m_sound_header.sound_type = ST_WAV;
+	m_sound_header.sound_type = SoundType::WAV;
 
 	m_sound_data_size = header.data_size;
 	m_sound_data = (uint8_t*)default_allocator().allocate(m_sound_data_size);
@@ -152,11 +152,11 @@ size_t SoundCompiler::compile_if_ogg(Filesystem& fs, const char* resource_path)
 	m_sound_header.version = SOUND_VERSION;
 	m_sound_header.size = size;
 	m_sound_header.sample_rate = rate;
-	m_sound_header.avg_bytes_ps = -1;
+	m_sound_header.block_size = (channels * 16) / 8;
+	m_sound_header.avg_bytes_ps = rate * ((channels * 16) / 8);
 	m_sound_header.channels = channels;
-	m_sound_header.block_size = -1;
 	m_sound_header.bits_ps = 16;
-	m_sound_header.sound_type = ST_OGG;
+	m_sound_header.sound_type = SoundType::OGG;
 
 	m_sound_data_size = size;
 	m_sound_data = (uint8_t*)default_allocator().allocate(m_sound_data_size);

+ 6 - 3
engine/resource/SoundResource.h

@@ -36,10 +36,13 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-enum SoundType
+struct SoundType
 {
-	ST_WAV = 0,
-	ST_OGG
+	enum Enum
+	{
+		WAV = 0,
+		OGG = 1
+	};
 };
 
 const uint32_t SOUND_VERSION = 1;