@@ -485,10 +485,6 @@ Dictionary AudioStreamWAV::get_tags() const {
485485 return tags;
486486}
487487
488- HashMap<String, String>::ConstIterator AudioStreamWAV::remap_tag_id (const String &p_tag_id) {
489- return tag_id_remaps.find (p_tag_id);
490- }
491-
492488double AudioStreamWAV::get_length () const {
493489 int len = data_bytes;
494490 switch (format) {
@@ -1146,16 +1142,37 @@ Ref<AudioStreamWAV> AudioStreamWAV::load_from_buffer(const Vector<uint8_t> &p_st
11461142 sample->set_loop_end (loop_end);
11471143 sample->set_stereo (format_channels == 2 );
11481144
1149- Dictionary tag_dictionary;
1150- for (const KeyValue<String, String> &E : tag_map) {
1151- HashMap<String, String>::ConstIterator remap = sample->remap_tag_id (E.key );
1152- if (remap) {
1153- tag_map.replace_key (E.key , remap->value );
1154- }
1145+ if (!tag_map.is_empty ()) {
1146+ // Used to make the metadata tags more unified across different AudioStreams.
1147+ // See https://www.recordingblogs.com/wiki/list-chunk-of-a-wave-file
1148+ HashMap<String, String> tag_id_remaps;
1149+ tag_id_remaps.reserve (15 );
1150+ tag_id_remaps[" IARL" ] = " location" ;
1151+ tag_id_remaps[" IART" ] = " artist" ;
1152+ tag_id_remaps[" ICMS" ] = " organization" ;
1153+ tag_id_remaps[" ICMT" ] = " comments" ;
1154+ tag_id_remaps[" ICOP" ] = " copyright" ;
1155+ tag_id_remaps[" ICRD" ] = " date" ;
1156+ tag_id_remaps[" IGNR" ] = " genre" ;
1157+ tag_id_remaps[" IKEY" ] = " keywords" ;
1158+ tag_id_remaps[" IMED" ] = " medium" ;
1159+ tag_id_remaps[" INAM" ] = " title" ;
1160+ tag_id_remaps[" IPRD" ] = " album" ;
1161+ tag_id_remaps[" ISBJ" ] = " description" ;
1162+ tag_id_remaps[" ISFT" ] = " software" ;
1163+ tag_id_remaps[" ITRK" ] = " tracknumber" ;
1164+ Dictionary tag_dictionary;
1165+ for (const KeyValue<String, String> &E : tag_map) {
1166+ HashMap<String, String>::ConstIterator remap = tag_id_remaps.find (E.key );
1167+ String tag_key = E.key ;
1168+ if (remap) {
1169+ tag_key = remap->value ;
1170+ }
11551171
1156- tag_dictionary[E.key ] = E.value ;
1172+ tag_dictionary[tag_key] = E.value ;
1173+ }
1174+ sample->set_tags (tag_dictionary);
11571175 }
1158- sample->set_tags (tag_dictionary);
11591176
11601177 return sample;
11611178}
@@ -1215,22 +1232,3 @@ void AudioStreamWAV::_bind_methods() {
12151232 BIND_ENUM_CONSTANT (LOOP_PINGPONG);
12161233 BIND_ENUM_CONSTANT (LOOP_BACKWARD);
12171234}
1218-
1219- AudioStreamWAV::AudioStreamWAV () {
1220- // Used to make the metadata tags more unified across different AudioStreams.
1221- // See https://www.recordingblogs.com/wiki/list-chunk-of-a-wave-file
1222- tag_id_remaps[" IARL" ] = " location" ;
1223- tag_id_remaps[" IART" ] = " artist" ;
1224- tag_id_remaps[" ICMS" ] = " organization" ;
1225- tag_id_remaps[" ICMT" ] = " comments" ;
1226- tag_id_remaps[" ICOP" ] = " copyright" ;
1227- tag_id_remaps[" ICRD" ] = " date" ;
1228- tag_id_remaps[" IGNR" ] = " genre" ;
1229- tag_id_remaps[" IKEY" ] = " keywords" ;
1230- tag_id_remaps[" IMED" ] = " medium" ;
1231- tag_id_remaps[" INAM" ] = " title" ;
1232- tag_id_remaps[" IPRD" ] = " album" ;
1233- tag_id_remaps[" ISBJ" ] = " description" ;
1234- tag_id_remaps[" ISFT" ] = " software" ;
1235- tag_id_remaps[" ITRK" ] = " tracknumber" ;
1236- }
0 commit comments