aboutsummaryrefslogtreecommitdiff
path: root/scene/io/resource_format_wav.cpp
diff options
context:
space:
mode:
authorJuan Linietsky2015-05-21 15:02:49 -0300
committerJuan Linietsky2015-05-21 15:02:49 -0300
commitbb5d46bb113bca3204db7678eb69900f159e8087 (patch)
treecd34e10d67a196d217559ab8d4973b8f5bc4ccde /scene/io/resource_format_wav.cpp
parent4b8745ad63409cf14b02735981ee35d2f794421c (diff)
parent6049479a99f66b620d59498a76ed9f2c3891f4c8 (diff)
downloadgodot-bb5d46bb113bca3204db7678eb69900f159e8087.tar.gz
godot-bb5d46bb113bca3204db7678eb69900f159e8087.tar.zst
godot-bb5d46bb113bca3204db7678eb69900f159e8087.zip
Merge branch 'master' of https://github.com/okamstudio/godot
Diffstat (limited to 'scene/io/resource_format_wav.cpp')
-rw-r--r--scene/io/resource_format_wav.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/scene/io/resource_format_wav.cpp b/scene/io/resource_format_wav.cpp
index a37d3b063..b246eb66f 100644
--- a/scene/io/resource_format_wav.cpp
+++ b/scene/io/resource_format_wav.cpp
@@ -146,9 +146,13 @@ RES ResourceFormatLoaderWAV::load(const String &p_path,const String& p_original_
}
int frames=chunksize;
+
frames/=format_channels;
frames/=(format_bits>>3);
+ print_line("chunksize: "+itos(chunksize));
+ print_line("channels: "+itos(format_channels));
+ print_line("bits: "+itos(format_bits));
sample->create(
(format_bits==8) ? Sample::FORMAT_PCM8 : Sample::FORMAT_PCM16,
@@ -156,8 +160,14 @@ RES ResourceFormatLoaderWAV::load(const String &p_path,const String& p_original_
frames );
sample->set_mix_rate( format_freq );
+ int len=frames;
+ if (format_channels==2)
+ len*=2;
+ if (format_bits>8)
+ len*=2;
+
DVector<uint8_t> data;
- data.resize(chunksize);
+ data.resize(len);
DVector<uint8_t>::Write dataw = data.write();
void * data_ptr = dataw.ptr();