diff options
Diffstat (limited to 'intern/audaspace/FX/AUD_FaderReader.cpp')
-rw-r--r-- | intern/audaspace/FX/AUD_FaderReader.cpp | 59 |
1 files changed, 14 insertions, 45 deletions
diff --git a/intern/audaspace/FX/AUD_FaderReader.cpp b/intern/audaspace/FX/AUD_FaderReader.cpp index d5096e7fae1..6c7ea6e0a01 100644 --- a/intern/audaspace/FX/AUD_FaderReader.cpp +++ b/intern/audaspace/FX/AUD_FaderReader.cpp @@ -35,35 +35,6 @@ AUD_FaderReader::AUD_FaderReader(AUD_IReader* reader, AUD_FadeType type, m_start(start), m_length(length) { - int bigendian = 1; - bigendian = (((char*)&bigendian)[0]) ? 0: 1; // 1 if Big Endian - - switch(m_reader->getSpecs().format) - { - case AUD_FORMAT_S16: - m_adjust = AUD_volume_adjust<int16_t>; - break; - case AUD_FORMAT_S32: - m_adjust = AUD_volume_adjust<int32_t>; - break; - case AUD_FORMAT_FLOAT32: - m_adjust = AUD_volume_adjust<float>; - break; - case AUD_FORMAT_FLOAT64: - m_adjust = AUD_volume_adjust<double>; - break; - case AUD_FORMAT_U8: - m_adjust = AUD_volume_adjust_u8; - break; - case AUD_FORMAT_S24: - m_adjust = bigendian ? AUD_volume_adjust_s24_be : - AUD_volume_adjust_s24_le; - break; - default: - delete m_reader; - AUD_THROW(AUD_ERROR_READER); - } - m_buffer = new AUD_Buffer(); AUD_NEW("buffer") } @@ -93,9 +64,7 @@ void AUD_FaderReader::read(int & length, sample_t* & buffer) if(m_type != AUD_FADE_OUT) { buffer = m_buffer->getBuffer(); - memset(buffer, - specs.format == AUD_FORMAT_U8 ? 0x80 : 0, - length * samplesize); + memset(buffer, 0, length * samplesize); } } else if(position / (float)specs.rate >= m_start+m_length) @@ -103,9 +72,7 @@ void AUD_FaderReader::read(int & length, sample_t* & buffer) if(m_type == AUD_FADE_OUT) { buffer = m_buffer->getBuffer(); - memset(buffer, - specs.format == AUD_FORMAT_U8 ? 0x80 : 0, - length * samplesize); + memset(buffer, 0, length * samplesize); } } else @@ -113,19 +80,21 @@ void AUD_FaderReader::read(int & length, sample_t* & buffer) sample_t* buf = m_buffer->getBuffer(); float volume; - for(int i = 0; i < length; i++) + for(int i = 0; i < length * specs.channels; i++) { - volume = (((position+i)/(float)specs.rate)-m_start) / m_length; - if(volume > 1.0f) - volume = 1.0f; - else if(volume < 0.0f) - volume = 0.0f; + if(i % specs.channels == 0) + { + volume = (((position+i)/(float)specs.rate)-m_start) / m_length; + if(volume > 1.0f) + volume = 1.0f; + else if(volume < 0.0f) + volume = 0.0f; - if(m_type == AUD_FADE_OUT) - volume = 1.0f - volume; + if(m_type == AUD_FADE_OUT) + volume = 1.0f - volume; + } - m_adjust(buf + i * samplesize, buffer + i * samplesize, - specs.channels, volume); + buf[i] = buffer[i] * volume; } buffer = buf; |