Installer Steam
log på
|
sprog
简体中文 (forenklet kinesisk)
繁體中文 (traditionelt kinesisk)
日本語 (japansk)
한국어 (koreansk)
ไทย (thai)
Български (bulgarsk)
Čeština (tjekkisk)
Deutsch (tysk)
English (engelsk)
Español – España (spansk – Spanien)
Español – Latinoamérica (spansk – Latinamerika)
Ελληνικά (græsk)
Français (fransk)
Italiano (italiensk)
Bahasa indonesia (indonesisk)
Magyar (ungarsk)
Nederlands (hollandsk)
Norsk
Polski (polsk)
Português (portugisisk – Portugal)
Português – Brasil (portugisisk – Brasilien)
Română (rumænsk)
Русский (russisk)
Suomi (finsk)
Svenska (svensk)
Türkçe (tyrkisk)
Tiếng Việt (Vietnamesisk)
Українська (ukrainsk)
Rapporter et oversættelsesproblem
so let's say we have the values:
[1,9,5,3] (=> this represents the audio data)
but instead of 4 points, we want 7 points (that's the easiest example)
then it becomes:
[1, 5, 9, 7, 5, 4, 3] ( we just averaged the numbers in between the existing data set, to calculate the numbers in between )
Now, if you would like to create a data set from 64 to 65, you can just put in into a formula, where it would take something like where the second value would be between the first and second, at 64/65*100% value etc.
var newData = [];
var data = array;
// If the Smooth library is available, use it instead for better results
if (!!Smooth) {
var s = Smooth(data, { method: Smooth.METHOD_CUBIC, scaleTo: newLength });
for (var i = 0; i < newLength; i++) {
newData = s(i);
}
} else {
var linearInterpolate = function(before, after, atPoint) {
return before + (after - before) * atPoint;
};
var springFactor = Number((data.length - 1) / (newLength - 1));
// assign first value
newData[0] = data[0];
for (var i = 1; i < newLength - 1; i++) {
var tmp = i * springFactor;
var before = Number(Math.floor(tmp)).toFixed();
var after = Number(Math.ceil(tmp)).toFixed();
var atPoint = tmp - before;
newData = linearInterpolate(data[before], data[after], atPoint);
}
// assign last value
newData[newLength - 1] = data[data.length - 1];
}
// Return the new array
return newData;
}
This is how it's impemented in JavaScript in the Wallpaper :P The ''Smooth'' Library, will also take the difference between the numbers into account, and 'smooths' it out using the Qubic Quadratic method. ( the fallback would be like I described in my first post )
Thanks for the reply, have a good day