Pārlūkot izejas kodu

add additional params to SoundResource

mikymod 12 gadi atpakaļ
vecāks
revīzija
f4aea53be1

+ 6 - 2
engine/compilers/sound/SoundCompiler.cpp

@@ -109,8 +109,10 @@ size_t SoundCompiler::compile_if_wav(Filesystem& fs, const char* resource_path)
 	m_sound_header.version = SOUND_VERSION;
 	m_sound_header.size = header.data_size;
 	m_sound_header.sample_rate = header.fmt_sample_rate;
+	m_sound_header.avg_bytes_ps = header.fmt_avarage;
 	m_sound_header.channels = header.fmt_channels;
-	m_sound_header.bits_per_sample = header.fmt_bits_per_sample;
+	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_data_size = header.data_size;
@@ -164,8 +166,10 @@ 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.channels = channels;
-	m_sound_header.bits_per_sample = 16;
+	m_sound_header.block_size = -1;
+	m_sound_header.bits_ps = 16;
 	m_sound_header.sound_type = ST_OGG;
 
 	m_sound_data_size = size;

+ 2 - 2
engine/compilers/sound/SoundCompiler.h

@@ -46,9 +46,9 @@ struct WAVHeader
 	int16_t			fmt_tag;				// Identifies way data is stored, 1 means no compression
 	int16_t			fmt_channels;			// Channel, 1 means mono, 2 means stereo
 	int32_t			fmt_sample_rate;		// Sample per second
-	int32_t			fmt_avarage;			// Not needed, here for completness
+	int32_t			fmt_avarage;			// Avarage bytes per sample
 	int16_t			fmt_block_align;		// Block alignment
-	int16_t			fmt_bits_per_sample;	// Number of bits per sample
+	int16_t			fmt_bits_ps;			// Number of bits per sample
 	char 			data[4];				// Should contains 'data'
 	int32_t			data_size;				// Data dimension
 };

+ 8 - 2
engine/resource/SoundResource.h

@@ -50,8 +50,10 @@ struct SoundHeader
 	uint32_t	version;	// Sound file version
 	uint32_t	size;
 	uint32_t	sample_rate;
+	uint32_t	avg_bytes_ps;
 	uint32_t	channels;
-	uint32_t 	bits_per_sample;
+	uint16_t	block_size;
+	uint16_t 	bits_ps;
 	uint8_t		sound_type;
 };
 
@@ -105,9 +107,13 @@ public:
 
 	uint32_t 			size() const { return m_header.size; }
 	uint32_t			sample_rate() const { return m_header.sample_rate; }
+	uint32_t			avg_bytes_ps() const { return m_header.avg_bytes_ps; }
 	uint32_t			channels() const { return m_header.channels; }
-	uint32_t			bits_per_sample() const { return m_header.bits_per_sample; }
+	uint16_t			block_size() const { return m_header.block_size; }
+	uint16_t			bits_ps() const { return m_header.bits_ps; }
+
 	uint8_t				sound_type() const { return m_header.sound_type; }
+
 	const uint8_t*		data() const { return m_data; }
 
 private: