|
@@ -485,10 +485,6 @@ Dictionary AudioStreamWAV::get_tags() const {
|
|
return tags;
|
|
return tags;
|
|
}
|
|
}
|
|
|
|
|
|
-HashMap<String, String>::ConstIterator AudioStreamWAV::remap_tag_id(const String &p_tag_id) {
|
|
|
|
- return tag_id_remaps.find(p_tag_id);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
double AudioStreamWAV::get_length() const {
|
|
double AudioStreamWAV::get_length() const {
|
|
int len = data_bytes;
|
|
int len = data_bytes;
|
|
switch (format) {
|
|
switch (format) {
|
|
@@ -1146,16 +1142,37 @@ Ref<AudioStreamWAV> AudioStreamWAV::load_from_buffer(const Vector<uint8_t> &p_st
|
|
sample->set_loop_end(loop_end);
|
|
sample->set_loop_end(loop_end);
|
|
sample->set_stereo(format_channels == 2);
|
|
sample->set_stereo(format_channels == 2);
|
|
|
|
|
|
- Dictionary tag_dictionary;
|
|
|
|
- for (const KeyValue<String, String> &E : tag_map) {
|
|
|
|
- HashMap<String, String>::ConstIterator remap = sample->remap_tag_id(E.key);
|
|
|
|
- if (remap) {
|
|
|
|
- tag_map.replace_key(E.key, remap->value);
|
|
|
|
- }
|
|
|
|
|
|
+ if (!tag_map.is_empty()) {
|
|
|
|
+ // Used to make the metadata tags more unified across different AudioStreams.
|
|
|
|
+ // See https://www.recordingblogs.com/wiki/list-chunk-of-a-wave-file
|
|
|
|
+ HashMap<String, String> tag_id_remaps;
|
|
|
|
+ tag_id_remaps.reserve(15);
|
|
|
|
+ tag_id_remaps["IARL"] = "location";
|
|
|
|
+ tag_id_remaps["IART"] = "artist";
|
|
|
|
+ tag_id_remaps["ICMS"] = "organization";
|
|
|
|
+ tag_id_remaps["ICMT"] = "comments";
|
|
|
|
+ tag_id_remaps["ICOP"] = "copyright";
|
|
|
|
+ tag_id_remaps["ICRD"] = "date";
|
|
|
|
+ tag_id_remaps["IGNR"] = "genre";
|
|
|
|
+ tag_id_remaps["IKEY"] = "keywords";
|
|
|
|
+ tag_id_remaps["IMED"] = "medium";
|
|
|
|
+ tag_id_remaps["INAM"] = "title";
|
|
|
|
+ tag_id_remaps["IPRD"] = "album";
|
|
|
|
+ tag_id_remaps["ISBJ"] = "description";
|
|
|
|
+ tag_id_remaps["ISFT"] = "software";
|
|
|
|
+ tag_id_remaps["ITRK"] = "tracknumber";
|
|
|
|
+ Dictionary tag_dictionary;
|
|
|
|
+ for (const KeyValue<String, String> &E : tag_map) {
|
|
|
|
+ HashMap<String, String>::ConstIterator remap = tag_id_remaps.find(E.key);
|
|
|
|
+ String tag_key = E.key;
|
|
|
|
+ if (remap) {
|
|
|
|
+ tag_key = remap->value;
|
|
|
|
+ }
|
|
|
|
|
|
- tag_dictionary[E.key] = E.value;
|
|
|
|
|
|
+ tag_dictionary[tag_key] = E.value;
|
|
|
|
+ }
|
|
|
|
+ sample->set_tags(tag_dictionary);
|
|
}
|
|
}
|
|
- sample->set_tags(tag_dictionary);
|
|
|
|
|
|
|
|
return sample;
|
|
return sample;
|
|
}
|
|
}
|
|
@@ -1215,22 +1232,3 @@ void AudioStreamWAV::_bind_methods() {
|
|
BIND_ENUM_CONSTANT(LOOP_PINGPONG);
|
|
BIND_ENUM_CONSTANT(LOOP_PINGPONG);
|
|
BIND_ENUM_CONSTANT(LOOP_BACKWARD);
|
|
BIND_ENUM_CONSTANT(LOOP_BACKWARD);
|
|
}
|
|
}
|
|
-
|
|
|
|
-AudioStreamWAV::AudioStreamWAV() {
|
|
|
|
- // Used to make the metadata tags more unified across different AudioStreams.
|
|
|
|
- // See https://www.recordingblogs.com/wiki/list-chunk-of-a-wave-file
|
|
|
|
- tag_id_remaps["IARL"] = "location";
|
|
|
|
- tag_id_remaps["IART"] = "artist";
|
|
|
|
- tag_id_remaps["ICMS"] = "organization";
|
|
|
|
- tag_id_remaps["ICMT"] = "comments";
|
|
|
|
- tag_id_remaps["ICOP"] = "copyright";
|
|
|
|
- tag_id_remaps["ICRD"] = "date";
|
|
|
|
- tag_id_remaps["IGNR"] = "genre";
|
|
|
|
- tag_id_remaps["IKEY"] = "keywords";
|
|
|
|
- tag_id_remaps["IMED"] = "medium";
|
|
|
|
- tag_id_remaps["INAM"] = "title";
|
|
|
|
- tag_id_remaps["IPRD"] = "album";
|
|
|
|
- tag_id_remaps["ISBJ"] = "description";
|
|
|
|
- tag_id_remaps["ISFT"] = "software";
|
|
|
|
- tag_id_remaps["ITRK"] = "tracknumber";
|
|
|
|
-}
|
|
|