Closed timoffenhaeusser closed 1 year ago
Float64List
is the internal representation that Wav
uses. Taking a List<Float64List>
in the constructor is nice because it avoids having to copy the data to a new list. This means the constructor is O(1) rather than O(n). These lists can be very large in a typical wav file (n can be really big), so this efficiency is important.
I could certainly add a constructor that takes a List<Float32List>
but all it would do is convert the Float32List
s to Float64List
s, so would lose that efficiency.
Besides, it's really easy to do that conversion yourself:
// Convert a Float32List to a Float64List:
final float64List = Float64List.fromList(float32List);
// Convert a List<Float32List> to a List<Float64List>:
final float64Channels = float32Channels.map(Float64List.fromList).toList();
// You can even do it during Wav construction:
final wav = Wav(float32Channels.map(Float64List.fromList).toList(), 44100);
Thank you for the ideas. You're right, I can just convert it before calling the constructor.
Hi, I just want to ask if it is possible to pass a list of samples of type Float32List to the Wav() constructor. Currently it only allows Float64List. Is there a way to change this?
Thanks, Tim