diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index 6d3d474cee48..f3aa67103012 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -458,6 +458,8 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s AudioStreamWAV::Format dst_format; if (compression == 1) { +#ifndef DISABLE_DEPRECATED + WARN_DEPRECATED_MSG("IMA ADPCM compression is deprecated. Consider using Quite OK Audio instead."); dst_format = AudioStreamWAV::FORMAT_IMA_ADPCM; if (format_channels == 1) { _compress_ima_adpcm(data, pcm_data); @@ -493,7 +495,9 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s w[i * 2 + 1] = rr[i]; } } - +#else + ERR_FAIL_V_MSG(ERR_UNAVAILABLE, "This engine build was compiled without deprecated features. IMA ADPCM is not available."); +#endif // DISABLE_DEPRECATED } else { dst_format = is16 ? AudioStreamWAV::FORMAT_16_BITS : AudioStreamWAV::FORMAT_8_BITS; bool enforce16 = is16 || compression == 2; diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h index 47af37ba41dd..503637dd8cb0 100644 --- a/editor/import/resource_importer_wav.h +++ b/editor/import/resource_importer_wav.h @@ -49,6 +49,7 @@ class ResourceImporterWAV : public ResourceImporter { virtual void get_import_options(const String &p_path, List *r_options, int p_preset = 0) const override; virtual bool get_option_visibility(const String &p_path, const String &p_option, const HashMap &p_options) const override; +#ifndef DISABLE_DEPRECATED static void _compress_ima_adpcm(const Vector &p_data, Vector &dst_data) { static const int16_t _ima_adpcm_step_table[89] = { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, @@ -139,6 +140,7 @@ class ResourceImporterWAV : public ResourceImporter { } } } +#endif // DISABLE_DEPRECATED virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap &p_options, List *r_platform_variants, List *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; diff --git a/scene/resources/audio_stream_wav.cpp b/scene/resources/audio_stream_wav.cpp index ba5dad088f81..ee680918fcb3 100644 --- a/scene/resources/audio_stream_wav.cpp +++ b/scene/resources/audio_stream_wav.cpp @@ -34,6 +34,7 @@ #include "core/io/marshalls.h" void AudioStreamPlaybackWAV::start(double p_from_pos) { +#ifndef DISABLE_DEPRECATED if (base->format == AudioStreamWAV::FORMAT_IMA_ADPCM) { //no seeking in IMA_ADPCM for (int i = 0; i < 2; i++) { @@ -48,8 +49,11 @@ void AudioStreamPlaybackWAV::start(double p_from_pos) { offset = 0; } else { +#endif seek(p_from_pos); +#ifndef DISABLE_DEPRECATED } +#endif sign = 1; active = true; @@ -72,9 +76,11 @@ double AudioStreamPlaybackWAV::get_playback_position() const { } void AudioStreamPlaybackWAV::seek(double p_time) { +#ifndef DISABLE_DEPRECATED if (base->format == AudioStreamWAV::FORMAT_IMA_ADPCM) { return; //no seeking in ima-adpcm } +#endif double max = base->get_length(); if (p_time < 0) { @@ -98,6 +104,7 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, pos <<= 1; } +#ifndef DISABLE_DEPRECATED if (is_ima_adpcm) { int64_t sample_pos = pos + p_ima_adpcm[0].window_ofs; @@ -175,6 +182,7 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, } } else { +#endif // DISABLE_DEPRECATED if (is_qoa) { if (pos != p_qoa->cache_pos) { // Prevents triple decoding on lower mix rates. for (int i = 0; i < 2; i++) { @@ -252,7 +260,9 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, if (is_stereo) { final_r = final_r + ((next_r - final_r) * frac >> MIX_FRAC_BITS); } +#ifndef DISABLE_DEPRECATED } +#endif if (!is_stereo) { final_r = final; //copy to right channel if stereo @@ -328,6 +338,7 @@ int AudioStreamPlaybackWAV::mix(AudioFrame *p_buffer, float p_rate_scale, int p_ const void *data = dataptr + AudioStreamWAV::DATA_PAD; AudioFrame *dst_buff = p_buffer; +#ifndef DISABLE_DEPRECATED if (format == AudioStreamWAV::FORMAT_IMA_ADPCM) { if (loop_format != AudioStreamWAV::LOOP_DISABLED) { ima_adpcm[0].loop_pos = loop_begin_fp >> MIX_FRAC_BITS; @@ -335,6 +346,7 @@ int AudioStreamPlaybackWAV::mix(AudioFrame *p_buffer, float p_rate_scale, int p_ loop_format = AudioStreamWAV::LOOP_FORWARD; } } +#endif while (todo > 0) { int64_t limit = 0; @@ -375,7 +387,7 @@ int AudioStreamPlaybackWAV::mix(AudioFrame *p_buffer, float p_rate_scale, int p_ sign *= -1; } else { /* go to loop-begin */ - +#ifndef DISABLE_DEPRECATED if (format == AudioStreamWAV::FORMAT_IMA_ADPCM) { for (int i = 0; i < 2; i++) { ima_adpcm[i].step_index = ima_adpcm[i].loop_step_index; @@ -384,8 +396,11 @@ int AudioStreamPlaybackWAV::mix(AudioFrame *p_buffer, float p_rate_scale, int p_ } offset = loop_begin_fp; } else { +#endif offset = loop_begin_fp + (offset - loop_end_fp); +#ifndef DISABLE_DEPRECATED } +#endif } } else { /* no loop, check for end of sample */ @@ -413,7 +428,7 @@ int AudioStreamPlaybackWAV::mix(AudioFrame *p_buffer, float p_rate_scale, int p_ todo -= target; - switch (base->format) { + switch (format) { case AudioStreamWAV::FORMAT_8_BITS: { if (is_stereo) { do_resample((int8_t *)data, dst_buff, offset, increment, target, ima_adpcm, &qoa); diff --git a/servers/audio/effects/audio_effect_record.cpp b/servers/audio/effects/audio_effect_record.cpp index e30a8fa99e31..1e116ca1632d 100644 --- a/servers/audio/effects/audio_effect_record.cpp +++ b/servers/audio/effects/audio_effect_record.cpp @@ -224,7 +224,10 @@ Ref AudioEffectRecord::get_recording() const { int16_t v = CLAMP(current_instance->recording_data[i] * 32768, -32768, 32767); encode_uint16(v, &w[i * 2]); } - } else if (dst_format == AudioStreamWAV::FORMAT_IMA_ADPCM) { + } +#ifndef DISABLE_DEPRECATED + else if (dst_format == AudioStreamWAV::FORMAT_IMA_ADPCM) { + //byte interleave Vector left; Vector right; @@ -259,7 +262,9 @@ Ref AudioEffectRecord::get_recording() const { w[i * 2 + 0] = rl[i]; w[i * 2 + 1] = rr[i]; } - } else { + } +#endif + else { ERR_PRINT("Format not implemented."); }