Commit 4dd91ce1 authored by Dr-Dan's avatar Dr-Dan
Browse files

working with safari now

parent 2cafb6fe
......@@ -10,7 +10,7 @@ SOURCE=src/cpp/maxi_emscr.cpp
# destination .js file
OUTPUT=maxiLib/maxiLib.js
EXP_FUNCS=-s EXPORTED_FUNCTIONS="['_sumArray']"
# EXP_FUNCS=-s EXPORTED_FUNCTIONS="['_sumArray']"
# https://kripken.github.io/emscripten-site/docs/tools_reference/emcc.html
CFLAGS=-O2 $(EXP_FUNCS) -s DISABLE_EXCEPTION_CATCHING=0 -s ALLOW_MEMORY_GROWTH=1 --memory-init-file 0 --profiling
......
......@@ -50827,29 +50827,6 @@ function __ZNSt3__16locale2id5__getEv(i1) {
return (HEAP32[i1 + 4 >> 2] | 0) + -1 | 0;
}
 
function _sumArray(i1, i2) {
i1 = i1 | 0;
i2 = i2 | 0;
var i3 = 0, d4 = 0.0, i5 = 0, d6 = 0.0, d7 = 0.0;
if ((i2 | 0) > 0) {
i3 = 0;
d4 = 0.0;
} else {
i5 = 0;
return i5 | 0;
}
while (1) {
d6 = d4 + +HEAPF64[i1 + (i3 << 3) >> 3];
i3 = i3 + 1 | 0;
if ((i3 | 0) == (i2 | 0)) {
d7 = d6;
break;
} else d4 = d6;
}
i5 = ~~d7;
return i5 | 0;
}
function __ZNSt3__111make_sharedI13maxiDelaylineJEEENS_9enable_ifIXntsr8is_arrayIT_EE5valueENS_10shared_ptrIS3_EEE4typeEDpOT0_(i1) {
i1 = i1 | 0;
var i2 = 0;
......@@ -51792,15 +51769,6 @@ function __ZN10emscripten8internal14raw_destructorINSt3__110shared_ptrI20maxiEnv
return;
}
 
function _newlocale(i1, i2, i3) {
i1 = i1 | 0;
i2 = i2 | 0;
i3 = i3 | 0;
var i4 = 0;
if (((HEAP8[i2 >> 0] | 0) != 0 ? (_strcmp(i2, 47548) | 0) != 0 : 0) ? (_strcmp(i2, 42852) | 0) != 0 : 0) i4 = 0; else if (!i3) i4 = _calloc(1, 4) | 0; else i4 = i3;
return i4 | 0;
}
function __ZNKSt3__15ctypeIcE10do_toupperEc(i1, i2) {
i1 = i1 | 0;
i2 = i2 | 0;
......@@ -51811,6 +51779,14 @@ function __ZNKSt3__15ctypeIcE10do_toupperEc(i1, i2) {
} else i3 = i2;
return i3 | 0;
}
function _newlocale(i1, i2, i3) {
i1 = i1 | 0;
i2 = i2 | 0;
i3 = i3 | 0;
var i4 = 0;
if (((HEAP8[i2 >> 0] | 0) != 0 ? (_strcmp(i2, 47548) | 0) != 0 : 0) ? (_strcmp(i2, 42852) | 0) != 0 : 0) i4 = 0; else if (!i3) i4 = _calloc(1, 4) | 0; else i4 = i3;
return i4 | 0;
}
 
function __ZNKSt3__16locale5__imp9has_facetEl(i1, i2) {
i1 = i1 | 0;
......@@ -55769,6 +55745,12 @@ function __ZN10__cxxabiv123__fundamental_type_infoD0Ev(i1) {
return;
}
 
function _isdigit_l(i1, i2) {
i1 = i1 | 0;
i2 = i2 | 0;
return (i1 + -48 | 0) >>> 0 < 10 | 0;
}
function __ZNKSt3__17codecvtIwc11__mbstate_tE16do_always_noconvEv(i1) {
i1 = i1 | 0;
return 0;
......@@ -55792,11 +55774,6 @@ function b50(i1, i2, i3, d4) {
d4 = +d4;
abort(50);
}
function _isdigit_l(i1, i2) {
i1 = i1 | 0;
i2 = i2 | 0;
return (i1 + -48 | 0) >>> 0 < 10 | 0;
}
 
function __ZN10__cxxabiv121__vmi_class_type_infoD0Ev(i1) {
i1 = i1 | 0;
......@@ -56530,7 +56507,7 @@ var FUNCTION_TABLE_iiiid = [b57,__ZN10emscripten8internal15FunctionInvokerIPFbRN
var FUNCTION_TABLE_viiii = [b58,__ZNK10__cxxabiv117__class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi,__ZNK10__cxxabiv120__si_class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi,__ZNK10__cxxabiv121__vmi_class_type_info27has_unambiguous_public_baseEPNS_19__dynamic_cast_infoEPvi,__ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7seekposENS_4fposI11__mbstate_tEEj,__ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7seekposENS_4fposI11__mbstate_tEEj,__ZNKSt3__17collateIcE12do_transformEPKcS3_,__ZNKSt3__17collateIwE12do_transformEPKwS3_,__ZN10emscripten8internal7InvokerIvJiiiEE6invokeEPFviiiEiii,__ZN10emscripten8internal13MethodInvokerIMNSt3__16vectorIiNS2_9allocatorIiEEEEFvjRKiEvPS6_JjS8_EE6invokeERKSA_SB_ji,__ZNSt3__110shared_ptrI8maxiTestEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI7maxiOscEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI12maxiEnvelopeEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI13maxiDelaylineEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI10maxiFilterEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI7maxiMixEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI10maxiLagExpIdEEC2IS2_N10emscripten15smart_ptr_traitIS3_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleISA_PS2_EE5valueENS3_5__natEE4typeE,__ZNSt3__110shared_ptrI10maxiSampleEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI7maxiMapEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI7maxiDynEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI7maxiEnvEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI7convertEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI14maxiDistortionEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI11maxiFlangerEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI10maxiChorusEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,__ZNSt3__110shared_ptrI20maxiEnvelopeFollowerEC2IS1_N10emscripten15smart_ptr_traitIS2_E11val_deleterEEEPT_T0_NS_9enable_ifIXsr14is_convertibleIS9_PS1_EE5valueENS2_5__natEE4typeE,b58,b58,b58
,b58,b58,b58];
 
return { ___cxa_can_catch: ___cxa_can_catch, _fflush: _fflush, _sumArray: _sumArray, ___cxa_is_pointer_type: ___cxa_is_pointer_type, _i64Add: _i64Add, _memmove: _memmove, _i64Subtract: _i64Subtract, _memset: _memset, _malloc: _malloc, _memcpy: _memcpy, ___getTypeName: ___getTypeName, _bitshift64Lshr: _bitshift64Lshr, _free: _free, ___errno_location: ___errno_location, _bitshift64Shl: _bitshift64Shl, __GLOBAL__I_000101: __GLOBAL__I_000101, __GLOBAL__sub_I_maxi_emscr_cpp: __GLOBAL__sub_I_maxi_emscr_cpp, __GLOBAL__sub_I_bind_cpp: __GLOBAL__sub_I_bind_cpp, __GLOBAL__sub_I_iostream_cpp: __GLOBAL__sub_I_iostream_cpp, runPostSets: runPostSets, _emscripten_replace_memory: _emscripten_replace_memory, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, establishStackSpace: establishStackSpace, setThrew: setThrew, setTempRet0: setTempRet0, getTempRet0: getTempRet0, dynCall_iiiiiiii: dynCall_iiiiiiii, dynCall_diddidd: dynCall_diddidd, dynCall_vid: dynCall_vid, dynCall_diididi: dynCall_diididi, dynCall_vi: dynCall_vi, dynCall_vii: dynCall_vii, dynCall_iiiiiii: dynCall_iiiiiii, dynCall_diididdd: dynCall_diididdd, dynCall_diddd: dynCall_diddd, dynCall_ii: dynCall_ii, dynCall_vididdd: dynCall_vididdd, dynCall_vidid: dynCall_vidid, dynCall_iiiiiid: dynCall_iiiiiid, dynCall_viidd: dynCall_viidd, dynCall_didddddii: dynCall_didddddii, dynCall_viiiii: dynCall_viiiii, dynCall_vididd: dynCall_vididd, dynCall_iiiiii: dynCall_iiiiii, dynCall_viiiiiiiiii: dynCall_viiiiiiiiii, dynCall_i: dynCall_i, dynCall_diddddd: dynCall_diddddd, dynCall_vidd: dynCall_vidd, dynCall_iiii: dynCall_iiii, dynCall_diiddidd: dynCall_diiddidd, dynCall_dddddd: dynCall_dddddd, dynCall_viiiiii: dynCall_viiiiii, dynCall_diiii: dynCall_diiii, dynCall_viii: dynCall_viii, dynCall_di: dynCall_di, dynCall_diiddd: dynCall_diiddd, dynCall_viid: dynCall_viid, dynCall_diid: dynCall_diid, dynCall_diidid: dynCall_diidid, dynCall_viiiiiii: dynCall_viiiiiii, dynCall_iiiiiiiiiiii: dynCall_iiiiiiiiiiii, dynCall_didid: dynCall_didid, dynCall_viididdd: dynCall_viididdd, dynCall_iii: dynCall_iii, dynCall_diiddddd: dynCall_diiddddd, dynCall_diii: dynCall_diii, dynCall_diidddii: dynCall_diidddii, dynCall_didd: dynCall_didd, dynCall_diidddddii: dynCall_diidddddii, dynCall_diidd: dynCall_diidd, dynCall_dii: dynCall_dii, dynCall_did: dynCall_did, dynCall_viiiiiiiiiiiiiii: dynCall_viiiiiiiiiiiiiii, dynCall_iiiiid: dynCall_iiiiid, dynCall_iiiii: dynCall_iiiii, dynCall_dididdd: dynCall_dididdd, dynCall_viiid: dynCall_viiid, dynCall_viidid: dynCall_viidid, dynCall_didddii: dynCall_didddii, dynCall_v: dynCall_v, dynCall_iiiiiiiii: dynCall_iiiiiiiii, dynCall_viididd: dynCall_viididd, dynCall_dididi: dynCall_dididi, dynCall_iiiid: dynCall_iiiid, dynCall_viiii: dynCall_viiii };
return { ___cxa_can_catch: ___cxa_can_catch, _fflush: _fflush, ___cxa_is_pointer_type: ___cxa_is_pointer_type, _i64Add: _i64Add, _memmove: _memmove, _i64Subtract: _i64Subtract, _memset: _memset, _malloc: _malloc, _memcpy: _memcpy, ___getTypeName: ___getTypeName, _bitshift64Lshr: _bitshift64Lshr, _free: _free, ___errno_location: ___errno_location, _bitshift64Shl: _bitshift64Shl, __GLOBAL__I_000101: __GLOBAL__I_000101, __GLOBAL__sub_I_maxi_emscr_cpp: __GLOBAL__sub_I_maxi_emscr_cpp, __GLOBAL__sub_I_bind_cpp: __GLOBAL__sub_I_bind_cpp, __GLOBAL__sub_I_iostream_cpp: __GLOBAL__sub_I_iostream_cpp, runPostSets: runPostSets, _emscripten_replace_memory: _emscripten_replace_memory, stackAlloc: stackAlloc, stackSave: stackSave, stackRestore: stackRestore, establishStackSpace: establishStackSpace, setThrew: setThrew, setTempRet0: setTempRet0, getTempRet0: getTempRet0, dynCall_iiiiiiii: dynCall_iiiiiiii, dynCall_diddidd: dynCall_diddidd, dynCall_vid: dynCall_vid, dynCall_diididi: dynCall_diididi, dynCall_vi: dynCall_vi, dynCall_vii: dynCall_vii, dynCall_iiiiiii: dynCall_iiiiiii, dynCall_diididdd: dynCall_diididdd, dynCall_diddd: dynCall_diddd, dynCall_ii: dynCall_ii, dynCall_vididdd: dynCall_vididdd, dynCall_vidid: dynCall_vidid, dynCall_iiiiiid: dynCall_iiiiiid, dynCall_viidd: dynCall_viidd, dynCall_didddddii: dynCall_didddddii, dynCall_viiiii: dynCall_viiiii, dynCall_vididd: dynCall_vididd, dynCall_iiiiii: dynCall_iiiiii, dynCall_viiiiiiiiii: dynCall_viiiiiiiiii, dynCall_i: dynCall_i, dynCall_diddddd: dynCall_diddddd, dynCall_vidd: dynCall_vidd, dynCall_iiii: dynCall_iiii, dynCall_diiddidd: dynCall_diiddidd, dynCall_dddddd: dynCall_dddddd, dynCall_viiiiii: dynCall_viiiiii, dynCall_diiii: dynCall_diiii, dynCall_viii: dynCall_viii, dynCall_di: dynCall_di, dynCall_diiddd: dynCall_diiddd, dynCall_viid: dynCall_viid, dynCall_diid: dynCall_diid, dynCall_diidid: dynCall_diidid, dynCall_viiiiiii: dynCall_viiiiiii, dynCall_iiiiiiiiiiii: dynCall_iiiiiiiiiiii, dynCall_didid: dynCall_didid, dynCall_viididdd: dynCall_viididdd, dynCall_iii: dynCall_iii, dynCall_diiddddd: dynCall_diiddddd, dynCall_diii: dynCall_diii, dynCall_diidddii: dynCall_diidddii, dynCall_didd: dynCall_didd, dynCall_diidddddii: dynCall_diidddddii, dynCall_diidd: dynCall_diidd, dynCall_dii: dynCall_dii, dynCall_did: dynCall_did, dynCall_viiiiiiiiiiiiiii: dynCall_viiiiiiiiiiiiiii, dynCall_iiiiid: dynCall_iiiiid, dynCall_iiiii: dynCall_iiiii, dynCall_dididdd: dynCall_dididdd, dynCall_viiid: dynCall_viiid, dynCall_viidid: dynCall_viidid, dynCall_didddii: dynCall_didddii, dynCall_v: dynCall_v, dynCall_iiiiiiiii: dynCall_iiiiiiiii, dynCall_viididd: dynCall_viididd, dynCall_dididi: dynCall_dididi, dynCall_iiiid: dynCall_iiiid, dynCall_viiii: dynCall_viiii };
})
// EMSCRIPTEN_END_ASM
(Module.asmGlobalArg, Module.asmLibraryArg, buffer);
......@@ -56538,7 +56515,6 @@ var ___cxa_can_catch = Module["___cxa_can_catch"] = asm["___cxa_can_catch"];
var __GLOBAL__sub_I_bind_cpp = Module["__GLOBAL__sub_I_bind_cpp"] = asm["__GLOBAL__sub_I_bind_cpp"];
var _fflush = Module["_fflush"] = asm["_fflush"];
var runPostSets = Module["runPostSets"] = asm["runPostSets"];
var _sumArray = Module["_sumArray"] = asm["_sumArray"];
var ___cxa_is_pointer_type = Module["___cxa_is_pointer_type"] = asm["___cxa_is_pointer_type"];
var _i64Add = Module["_i64Add"] = asm["_i64Add"];
var _memmove = Module["_memmove"] = asm["_memmove"];
......@@ -56759,6 +56735,7 @@ if (Module["noInitialRun"]) {
shouldRunNow = false;
}
run();
var maximTools = {};
var maximJs = {};
maximJs.maxiSettings = Module.maxiSettings;
maximJs.maxiOsc = Module.maxiOsc;
......@@ -56778,33 +56755,45 @@ maximJs.maxiChorus = Module.maxiChorus;
maximJs.maxiEnvelopeFollower = Module.maxiEnvelopeFollower;
maximJs.maxiArray = function maxiArray() {
this.length = 0;
this.vec = new Module.VectorDouble;
this.set = (function(arrayIn) {
this.clear();
this.vec = GetArrayAsVectorDbl(arrayIn);
this.length = this.vec.size();
});
this.SetSqBrackets = (function(useSq) {
for (var i = 0; i < this.length; i++) {
if (useSq) {
this[i] = this.vec.get(i);
} else {
delete this[i];
}
}
});
this.clear = (function(useSq) {
for (var i = 0; i < this.length; i++) {
var vec = new Module.VectorDouble;
};
maximJs.maxiArray.prototype.asVector = (function(arrayIn) {
return this.vec;
});
maximJs.maxiArray.prototype.asJsArray = (function(arrayIn) {
var arrayOut = [];
for (var i = 0; i < this.length; i++) {
array.push(this.vec.get(i));
}
return arrayOut;
});
maximJs.maxiArray.prototype.set = (function(arrayIn) {
this.clear();
this.vec = GetArrayAsVectorDbl(arrayIn);
this.length = this.vec.size();
this.SetSqBrackets(true);
});
maximJs.maxiArray.prototype.push = (function(num) {
this.vec.push_back(num);
this[this.length] = num;
this.length++;
});
maximJs.maxiArray.prototype.SetSqBrackets = (function(useSq) {
for (var i = 0; i < this.length; i++) {
if (useSq) {
this[i] = this.vec.get(i);
} else {
delete this[i];
}
Module.vectorTools.clearVectorDbl(this.vec);
this.length = 0;
});
this.push = (function(num) {
this.vec.push_back(num);
this.length++;
});
};
}
});
maximJs.maxiArray.prototype.clear = (function(useSq) {
for (var i = 0; i < this.length; i++) {
delete this[i];
}
Module.vectorTools.clearVectorDbl(this.vec);
this.length = 0;
});
function GetArrayAsVectorDbl(arrayIn) {
var vecOut = new Module.VectorDouble;
for (var i = 0; i < arrayIn.length; i++) {
......@@ -56812,8 +56801,7 @@ function GetArrayAsVectorDbl(arrayIn) {
}
return vecOut;
}
AudioContext = AudioContext || webkitAudioContext;
var context = new AudioContext;
var context = new webkitAudioContext || new AudioContext;
var source;
var jsProcessor = 0;
var analyser;
......@@ -63,14 +63,14 @@ public:
int sumArray(uintptr_t input, size_t len) {
const int* ptr = reinterpret_cast<int*>(input);
// double n = 0;
// for(int i = 0; i < len; i++){
// n+=ptr[i];
// }
// double n = 0;
// for(int i = 0; i < len; i++){
// n+=ptr[i];
// }
return ptr[0];
}
};
class maxiSettings {
public:
......@@ -127,7 +127,7 @@ class maxiEnvelope {
public:
// maxiEnvelope(){}
double line(int numberofsegments, std::vector<double>& segments);
// double line(int numberofsegments , double segments[1000]);
// double line(int numberofsegments , double segments[1000]);
void trigger(int index,double amp);
int valindex;
......@@ -194,7 +194,7 @@ class maxiMix {
// double two[2];
// double four[4];
// double eight[8];
public:
// double x;
// double y;
......@@ -204,7 +204,7 @@ public:
currently using non-pointer version for embind, need to sort out pointer stuff though
embind has no support for pointers to primitives!
*/
// double *stereo(double input,double two[2],double x);
// double *stereo(double input,double two[2],double x);
// double *quad(double input,double four[4], double x,double y);
// double *ambisonic(double input,double eight[8],double x,double y, double z);
......@@ -215,37 +215,37 @@ public:
};
//lagging with an exponential moving average
//a lower alpha value gives a slower lag
template <class T>
class maxiLagExp {
public:
//lagging with an exponential moving average
//a lower alpha value gives a slower lag
template <class T>
class maxiLagExp {
public:
T alpha, alphaReciprocal;
T val;
maxiLagExp() {
init(0.5, 0.0);
init(0.5, 0.0);
};
// haven't worked out how to do this (override) with smart_ptr_constructor?!
// maxiLagExp(T initAlpha, T initVal) {
// init(initAlpha, initVal);
// }
// haven't worked out how to do this (override) with smart_ptr_constructor?!
// maxiLagExp(T initAlpha, T initVal) {
// init(initAlpha, initVal);
// }
void init(T initAlpha, T initVal) {
alpha = initAlpha;
alphaReciprocal = 1.0 - alpha;
val = initVal;
alpha = initAlpha;
alphaReciprocal = 1.0 - alpha;
val = initVal;
}
// no need for inline if declared/defined in .h file
// no need for inline if declared/defined in .h file
void addSample(T newVal) {
val = (alpha * newVal) + (alphaReciprocal * val);
val = (alpha * newVal) + (alphaReciprocal * val);
}
T value() {
return val;
return val;
}
};
};
//lagging with an exponential moving average
......@@ -255,16 +255,16 @@ public:
//public:
// double alpha, alphaReciprocal;
// double val;
//
//
// maxiLagExp() {
// init(0.5, 0.0);
// };
//
//
//
//
// maxiLagExp(double initAlpha, double initVal) {
// init(initAlpha, initVal);
// }
//
//
// void init(double initAlpha, double initVal) {
// alpha = initAlpha;
// alphaReciprocal = 1.0 - alpha;
......@@ -274,7 +274,7 @@ public:
// void addSample(double newVal) {
// val = (alpha * newVal) + (alphaReciprocal * val);
// }
//
//
// double value() {
// return val;
// }
......@@ -364,7 +364,7 @@ public:
double play();
void clear(){tempVec.clear();}
double playOnce();
double playOnce();
//
double playOnce(double speed);
//
......@@ -379,7 +379,7 @@ public:
//
double play4(double frequency, double start, double end);
//
double bufferPlay(unsigned char &bufferin,long length);
double bufferPlay(unsigned char &bufferin,long length);
//
// double bufferPlay(unsigned char &bufferin,double speed,long length);
//
......
// might adopt some strange functions from Module?
// var maximJs = Module;
var maximTools = {};
// alternatively...
// probably better this way
// no inheritance of Module stuff...
......@@ -27,42 +29,14 @@ maximJs.maxiChorus = Module.maxiChorus;
maximJs.maxiEnvelopeFollower = Module.maxiEnvelopeFollower;
// alternative array method to avoid mixing vector terminology with arrays
// seems like bad practice though and needs some testing...
// how to stop people messing with vec and its effects on object
// ------------------------------------------------
// maxiArray - could extend Array object?
// cheaty array method to avoid mixing vector terminology with arrays
// but have to copy everything?!
// better to use GetArrayAsVectorDbl function ???
maximJs.maxiArray = function maxiArray(){
this.length = 0;
this.vec = new Module.VectorDouble();
this.set = function(arrayIn){
this.clear();
this.vec = GetArrayAsVectorDbl(arrayIn);
this.length = this.vec.size();
};
// set object properties to mimic array
this.SetSqBrackets = function(useSq){
for(var i = 0; i < this.length; i++){
if(useSq){
this[i] = this.vec.get(i);
} else{
delete this[i];
}
}
};
this.clear = function(useSq){
for(var i = 0; i < this.length; i++){
delete this[i];
}
Module.vectorTools.clearVectorDbl(this.vec);
this.length = 0;
};
this.push = function(num){
this.vec.push_back(num);
this.length++;
};
var vec = new Module.VectorDouble();
// this.update = function(){
// var lengthsMatch = this.length !== this.vec.size();
......@@ -83,6 +57,54 @@ this.push = function(num){
// };
};
maximJs.maxiArray.prototype.asVector = function(arrayIn){
return this.vec;
};
maximJs.maxiArray.prototype.asJsArray = function(arrayIn){
var arrayOut = [];
for(var i = 0; i < this.length; i++){
array.push(this.vec.get(i));
}
return arrayOut;
};
maximJs.maxiArray.prototype.set = function(arrayIn){
this.clear();
this.vec = GetArrayAsVectorDbl(arrayIn);
this.length = this.vec.size();
this.SetSqBrackets(true);
};
maximJs.maxiArray.prototype.push = function(num){
this.vec.push_back(num);
this[this.length] = num;
this.length++;
};
// set object properties to mimic array
// this doesn't seem particularly efficient or smart
maximJs.maxiArray.prototype.SetSqBrackets = function(useSq){
for(var i = 0; i < this.length; i++){
if(useSq){
this[i] = this.vec.get(i);
} else{
delete this[i];
}
}
};
maximJs.maxiArray.prototype.clear = function(useSq){
for(var i = 0; i < this.length; i++){
delete this[i];
}
Module.vectorTools.clearVectorDbl(this.vec);
this.length = 0;
};
function GetArrayAsVectorDbl(arrayIn){
var vecOut = new Module.VectorDouble();
for(var i = 0; i < arrayIn.length; i++){
......@@ -92,13 +114,15 @@ function GetArrayAsVectorDbl(arrayIn){
return vecOut;
}
// ------------------------------------------------
// would be nice to put this (all below) in function/class of some sort
// Temporary patch until all browsers support unprefixed context.
AudioContext = AudioContext || webkitAudioContext;
// AudioContext = AudioContext || webkitAudioContext;
// var context;
var context = new AudioContext();
// var context = new AudioContext();
var context = new webkitAudioContext() || new AudioContext();
// context = new (window.AudioContext || window.webkitAudioContext)();
var source;
......@@ -175,7 +199,7 @@ function process(event) {
}
else
{
for (var channel = 0; channel < numChannels; channel++) {
for (var channel = 0; channel < numChannels; channel++) {
event.outputBuffer.getChannelData(channel)[i] = output;
}
}
......@@ -205,22 +229,6 @@ function init() {
setup();
}
// function loadSampleBuffers(url){
// bufferLoader = new BufferLoader(
// context,
// [url],
// finishedLoading
// );
// bufferLoader.load();
// // var sources = [];
// // for(var i = 0; i < urls.length; i++){
// // var sourceI = context.createBufferSource();
// // sourceI.buffer = bufferList[i];
// // }
// }
function loadSample(url, samplePlayer) {
var data = [];
......@@ -269,11 +277,3 @@ function loadSample(url, samplePlayer) {
function transferComplete(evt) {
console.log("The transfer is complete.");
}
// function playSound(buffer) {
// var source = context.createBufferSource(); // creates a sound source
// source.buffer = buffer; // tell the source which sound to play
// source.connect(context.destination); // connect the source to the context's destination (the speakers)
// source.start(0); // play the source now
// // note: on older systems, may have to use deprecated noteOn(time);
// }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment