Skip to content

Commit

Permalink
ResourceImporterWAV: Enable QOA compression by default
Browse files Browse the repository at this point in the history
  • Loading branch information
DeeJayLSP committed Aug 31, 2024
1 parent 61598c5 commit 5930c4a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions doc/classes/ResourceImporterWAV.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
Imports a WAV audio file for playback.
</brief_description>
<description>
WAV is an uncompressed format, which can provide higher quality compared to Ogg Vorbis and MP3. It also has the lowest CPU cost to decode. This means high numbers of WAV sounds can be played at the same time, even on low-end deviceS.
WAV is an uncompressed format, which can provide higher quality compared to Ogg Vorbis and MP3. It also has the lowest CPU cost to decode. This means high numbers of WAV sounds can be played at the same time, even on low-end devices.
By default, Godot imports WAV files using the lossy QOA compression. You may change this by setting the [member compress/mode] property.
</description>
<tutorials>
<link title="Importing audio samples">$DOCS_URL/tutorials/assets_pipeline/importing_audio_samples.html</link>
</tutorials>
<members>
<member name="compress/mode" type="int" setter="" getter="" default="0">
<member name="compress/mode" type="int" setter="" getter="" default="2">
The compression mode to use on import.
- [b]PCM (Uncompressed):[/b] Imports audio data without any form of compression, preserving the highest possible quality. It has the lowest CPU cost, but the highest memory usage.
- [b]IMA ADPCM:[/b] Applies fast, lossy compression during import, noticeably decreasing the quality, but with low CPU cost and memory usage. Does not support seeking and only Forward loop mode is supported.
Expand Down
3 changes: 2 additions & 1 deletion editor/import/resource_importer_wav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ void ResourceImporterWAV::get_import_options(const String &p_path, List<ImportOp
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "edit/loop_mode", PROPERTY_HINT_ENUM, "Detect From WAV,Disabled,Forward,Ping-Pong,Backward", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "edit/loop_begin"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "edit/loop_end"), -1));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "PCM (Uncompressed),IMA ADPCM,Quite OK Audio"), 0));
// Quite OK Audio is lightweight enough and supports virtually every significant AudioStreamWAV feature.
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "PCM (Uncompressed),IMA ADPCM,Quite OK Audio"), 2));
}

Error ResourceImporterWAV::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
Expand Down
2 changes: 2 additions & 0 deletions tests/scene/test_audio_stream_wav.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ void run_test(String file_name, AudioStreamWAV::Format data_format, bool stereo,
for (const ResourceImporter::ImportOption &E : options_list) {
options_map[E.option.name] = E.default_value;
}
// Compressed streams can't be saved, disable compression.
options_map["compress/mode"] = 0;

REQUIRE(wav_importer->import(save_path, save_path, options_map, nullptr) == OK);

Expand Down

0 comments on commit 5930c4a

Please sign in to comment.