Initial Commit
This commit is contained in:
64 files changed
+14785
No files matched your search
@@ -0,0 +1,24 @@
|
||||
#! Contains what the tests of `audio` share: whether a result failed as it
|
||||
#! should, and how far one run of samples strays from another. The Ogg Vorbis
|
||||
#! streams they decode are made in `streams.sakura`.
|
||||
|
||||
import std::math;
|
||||
import malunal::audio;
|
||||
|
||||
# Whether a result failed with an error.
|
||||
def fails<T>(made: result<T, audio_error>, why: audio_error): bool {
|
||||
if made is error(e) {
|
||||
return e == why;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
# How far one run of samples strays from another at most, or 1000 where they're
|
||||
# of other lengths.
|
||||
def apart(a: span<f32>, b: span<f32>): f32 {
|
||||
return 1000 if a.length != b.length;
|
||||
var most: f32 = 0;
|
||||
for i in 0..a.length {
|
||||
most = math::max(most, math::abs(a[i] - b[i]));
|
||||
}
|
||||
return most;
|
||||
}
|
||||
Reference in new issue
Block a user