How to use writeIndex method in Appium

Best JavaScript code snippet using appium

webaudioapi.js

Source:webaudioapi.js Github

copy

Full Screen

1(function(T) {2 "use strict";3 if (T.env !== "webkit") {4 return;5 }6 var fn = T.fn;7 var context = fn._audioContext;8 var BUFFERSIZE = 1024;9 function WebAudioAPINode(_args) {10 T.Object.call(this, 2, _args);11 fn.fixAR(this);12 var _ = this._;13 _.mode = "";14 _.bufferL = new fn.SignalArray(BUFFERSIZE << 2);15 _.bufferR = new fn.SignalArray(BUFFERSIZE << 2);16 _.buffermask = _.bufferL.length - 1;17 _.node = null;18 _.script = context.createScriptProcessor(BUFFERSIZE, 2, 2);19 _.writeIndex = 0;20 _.readIndex = 0;21 _.totalRead = 0;22 _.totalWrite = 0;23 }24 fn.extend(WebAudioAPINode);25 var $ = WebAudioAPINode.prototype;26 Object.defineProperties($, {27 context: {28 get: function() {29 return context;30 }31 },32 mode: {33 get: function() {34 return this._.mode;35 }36 }37 });38 $.cancel = function() {39 var _ = this._;40 var cell = this.cells[0];41 for (var i = 0, imax = cell.length; i < imax; ++i) {42 cell[i] = 0;43 }44 _.node = null;45 };46 (function() {47 function WebAudioAPIRecvNode(_args) {48 WebAudioAPINode.call(this, _args);49 var _ = this._;50 _.mode = "recv";51 _.script.onaudioprocess = make_recv_process(this);52 _.gain = context.createGain();53 _.gain.gain.value = 0;54 _.script.connect(_.gain);55 }56 fn.extend(WebAudioAPIRecvNode, WebAudioAPINode);57 var make_recv_process = function(self) {58 return function(e) {59 var _ = self._;60 var ins = e.inputBuffer;61 var inputL = ins.getChannelData(0);62 var inputR = ins.getChannelData(1);63 var length = ins.length;64 var writeIndex = _.writeIndex;65 _.bufferL.set(inputL, writeIndex);66 _.bufferR.set(inputR, writeIndex);67 _.writeIndex = (writeIndex + length) & _.buffermask;68 _.totalWrite += length;69 };70 };71 var $ = WebAudioAPIRecvNode.prototype;72 $.cancel = function() {73 WebAudioAPINode.prototype.cancel.call(this);74 this._.gain.disconnect();75 if(this._.node) {76 this._.node.disconnect();77 }78 };79 $.recv = function(node) {80 var _ = this._;81 try {82 _.node = node;83 _.node.connect(_.script);84 _.gain.connect(context.destination);85 } catch(e) {86 _.node = null;87 }88 _.writeIndex = 0;89 _.readIndex = 0;90 _.totalWrite = 0;91 _.totalRead = 0;92 return this;93 };94 $.process = function(tickID) {95 var _ = this._;96 if (_.node === null) {97 return this;98 }99 if (this.tickID !== tickID) {100 this.tickID = tickID;101 var cellsize = _.cellsize;102 var bufferL = _.bufferL;103 var bufferR = _.bufferR;104 if (_.totalWrite > _.totalRead + cellsize) {105 var begin = _.readIndex;106 var end = begin + cellsize;107 this.cells[1].set(bufferL.subarray(begin, end));108 this.cells[2].set(bufferR.subarray(begin, end));109 _.readIndex = end & _.buffermask;110 _.totalRead += cellsize;111 }112 fn.outputSignalAR(this);113 }114 return this;115 };116 fn.register("WebAudioAPI:recv", WebAudioAPIRecvNode);117 })();118 (function() {119 function WebAudioAPISendNode(_args) {120 WebAudioAPINode.call(this, _args);121 fn.listener(this);122 var _ = this._;123 _.mode = "send";124 _.script.onaudioprocess = make_send_process(this);125 _.connectIndex = null;126 }127 fn.extend(WebAudioAPISendNode, WebAudioAPINode);128 var make_send_process = function(self) {129 return function(e) {130 var _ = self._;131 var outs = e.outputBuffer;132 var length = outs.length;133 if (_.totalWrite > _.totalRead + length) {134 var begin = _.readIndex;135 var end = begin + length;136 outs.getChannelData(0).set(_.bufferL.subarray(begin, end));137 outs.getChannelData(1).set(_.bufferR.subarray(begin, end));138 _.readIndex = end & _.buffermask;139 _.totalRead += length;140 }141 };142 };143 var $ = WebAudioAPISendNode.prototype;144 $.cancel = function() {145 WebAudioAPINode.prototype.cancel.call(this);146 var _ = this._;147 if (_.connectIndex !== null) {148 _.script.disconnect(_.connectIndex);149 } else {150 _.script.disconnect();151 }152 this.unlisten();153 };154 $.send = function(node, index) {155 var _ = this._;156 try {157 _.node = node;158 if (typeof index === "number") {159 _.script.connect(_.node, index);160 _.connectIndex = index;161 } else {162 _.script.connect(_.node);163 _.connectIndex = null;164 }165 this.listen();166 } catch(e) {167 _.node = null;168 }169 _.writeIndex = 0;170 _.readIndex = 0;171 _.totalWrite = 0;172 _.totalRead = 0;173 return this;174 };175 $.process = function(tickID) {176 var _ = this._;177 if (_.script === null) {178 return this;179 }180 if (this.tickID !== tickID) {181 this.tickID = tickID;182 var cellL = this.cells[1];183 var cellR = this.cells[2];184 var cellsize = _.cellsize;185 var writeIndex = _.writeIndex;186 fn.inputSignalAR(this);187 _.bufferL.set(cellL, writeIndex);188 _.bufferR.set(cellR, writeIndex);189 _.writeIndex = (writeIndex + cellsize) & _.buffermask;190 _.totalWrite += cellsize;191 fn.outputSignalAR(this);192 }193 return this;194 };195 fn.register("WebAudioAPI:send", WebAudioAPISendNode);196 })();...

Full Screen

Full Screen

mediastream.js

Source:mediastream.js Github

copy

Full Screen

1(function(T) {2 "use strict";3 if (T.envtype !== "browser") {4 return;5 }6 var fn = T.fn;7 var BUFFER_SIZE = 4096;8 var BUFFER_MASK = BUFFER_SIZE - 1;9 function MediaStreamNode(_args) {10 T.Object.call(this, 2, _args);11 fn.fixAR(this);12 var _ = this._;13 _.src = _.func = null;14 _.bufferL = new fn.SignalArray(BUFFER_SIZE);15 _.bufferR = new fn.SignalArray(BUFFER_SIZE);16 _.readIndex = 0;17 _.writeIndex = 0;18 _.totalRead = 0;19 _.totalWrite = 0;20 }21 fn.extend(MediaStreamNode);22 var $ = MediaStreamNode.prototype;23 $.listen = function(audio) {24 var _impl = impl[T.env];25 if (_impl) {26 _impl.set.call(this, audio);27 _impl.listen.call(this);28 }29 };30 $.unlisten = function() {31 var _impl = impl[T.env];32 if (_impl) {33 _impl.unlisten.call(this);34 }35 this.cells[0].set(fn.emptycell);36 this.cells[1].set(fn.emptycell);37 this.cells[2].set(fn.emptycell);38 var _ = this._;39 var bufferL = _.bufferL, bufferR = _.bufferR;40 for (var i = 0, imax = bufferL.length; i < imax; ++i) {41 bufferL[i] = bufferR[i] = 0;42 }43 };44 $.process = function(tickID) {45 var _ = this._;46 if (_.src === null) {47 return this;48 }49 if (this.tickID !== tickID) {50 this.tickID = tickID;51 var cellsize = _.cellsize;52 if (_.totalWrite > _.totalRead + cellsize) {53 var begin = _.readIndex;54 var end = begin + cellsize;55 this.cells[1].set(_.bufferL.subarray(begin, end));56 this.cells[2].set(_.bufferR.subarray(begin, end));57 _.readIndex = end & BUFFER_MASK;58 _.totalRead += cellsize;59 }60 fn.outputSignalAR(this);61 }62 return this;63 };64 var impl = {};65 impl.webkit = {66 set: function(src) {67 var _ = this._;68 /*global HTMLMediaElement:true */69 if (src instanceof HTMLMediaElement) {70 var context = fn._audioContext;71 _.src = context.createMediaElementSource(src);72 }73 /*global HTMLMediaElement:false */74 },75 listen: function() {76 var _ = this._;77 var context = fn._audioContext;78 _.gain = context.createGain();79 _.gain.gain.value = 0;80 _.node = context.createScriptProcessorNode(1024, 2, 2);81 _.node.onaudioprocess = onaudioprocess(this);82 _.src.connect(_.node);83 _.node.connect(_.gain);84 _.gain.connect(context.destination);85 },86 unlisten: function() {87 var _ = this._;88 if (_.src) {89 _.src.disconnect();90 }91 if (_.gain) {92 _.gain.disconnect();93 }94 if (_.node) {95 _.node.disconnect();96 }97 }98 };99 var onaudioprocess = function(self) {100 return function(e) {101 var _ = self._;102 var ins = e.inputBuffer;103 var length = ins.length;104 var writeIndex = _.writeIndex;105 _.bufferL.set(ins.getChannelData(0), writeIndex);106 _.bufferR.set(ins.getChannelData(1), writeIndex);107 _.writeIndex = (writeIndex + length) & BUFFER_MASK;108 _.totalWrite += length;109 };110 };111 impl.moz = {112 set: function(src) {113 var _ = this._;114 /*global HTMLAudioElement:true */115 if (src instanceof HTMLAudioElement) {116 _.src = src;117 _.istep = _.samplerate / src.mozSampleRate;118 }119 /*global HTMLAudioElement:false */120 },121 listen: function() {122 var _ = this._;123 var o0 = _.bufferL;124 var o1 = _.bufferR;125 var prev0 = 0, prev1 = 0;126 if (_.src.mozChannels === 2) {127 _.x = 0;128 _.func = function(e) {129 var writeIndex = _.writeIndex;130 var totalWrite = _.totalWrite;131 var samples = e.frameBuffer;132 var x, istep = _.istep;133 var i, imax = samples.length;134 x = _.x;135 for (i = 0; i < imax; i+= 2) {136 x += istep;137 while (x > 0) {138 o0[writeIndex] = (samples[i ] + prev0) * 0.5;139 o1[writeIndex] = (samples[i+1] + prev1) * 0.5;140 writeIndex = (writeIndex + 1) & BUFFER_MASK;141 ++totalWrite;142 x -= 1;143 }144 prev0 = samples[i ];145 prev1 = samples[i+1];146 }147 _.x = x;148 _.writeIndex = writeIndex;149 _.totalWrite = totalWrite;150 };151 } else {152 _.x = 0;153 _.func = function(e) {154 var writeIndex = _.writeIndex;155 var totalWrite = _.totalWrite;156 var samples = e.frameBuffer;157 var x, istep = _.istep;158 var i, imax = samples.length;159 x = _.x;160 for (i = 0; i < imax; ++i) {161 x += istep;162 while (x >= 0) {163 o0[writeIndex] = o1[writeIndex] = (samples[i] + prev0) * 0.5;164 writeIndex = (writeIndex + 1) & BUFFER_MASK;165 ++totalWrite;166 x -= 1;167 }168 prev0 = samples[i];169 }170 _.x = x;171 _.writeIndex = writeIndex;172 _.totalWrite = totalWrite;173 };174 }175 _.src.addEventListener("MozAudioAvailable", _.func);176 },177 unlisten: function() {178 var _ = this._;179 if (_.func) {180 _.src.removeEventListener("MozAudioAvailable", _.func);181 _.func = null;182 }183 }184 };185 fn.register("mediastream", MediaStreamNode);...

Full Screen

Full Screen

OscillatorNode.js

Source:OscillatorNode.js Github

copy

Full Screen

1'use strict';2import { SINE } from '../../constants/OscillatorType';3const OscillatorNodeDSP = {4 dspInit() {5 this._phase = 0;6 },7 dspProcess() {8 const blockSize = this.blockSize;9 const quantumStartFrame = this.context.currentSampleFrame;10 const quantumEndFrame = quantumStartFrame + blockSize;11 const sampleOffset = Math.max(0, this._startFrame - quantumStartFrame);12 const fillToSample =13 Math.min(quantumEndFrame, this._stopFrame) - quantumStartFrame;14 const output = this.outputs[0].bus.getMutableData()[0];15 let writeIndex = 0;16 if (this._type === SINE) {17 writeIndex = this.dspSine(18 output,19 sampleOffset,20 fillToSample,21 this.sampleRate,22 );23 } else {24 writeIndex = this.dspWave(25 output,26 sampleOffset,27 fillToSample,28 this.sampleRate,29 );30 }31 // timeline32 // |----------------|-------*--------|----------------|----------------|33 // ^ ^ ^34 // |------>| quantumEndFrame35 // | wrote |36 // | stopFrame37 // quantumStartFrame38 if (this._stopFrame <= quantumStartFrame + writeIndex) {39 // rest samples fill zero40 while (writeIndex < blockSize) {41 output[writeIndex++] = 0;42 }43 this.context.addPostProcess(() => {44 this.outputs[0].bus.zeros();45 this.outputs[0].disable();46 this.dispatchEvent({ type: 'ended' });47 });48 }49 },50 dspSine(output, writeIndex, blockSize, sampleRate) {51 const frequency = this._frequency;52 const detune = this._detune;53 const algorithm =54 frequency.hasSampleAccurateValues() * 2 +55 detune.hasSampleAccurateValues();56 const frequencyToPhaseIncr = (2 * Math.PI) / sampleRate;57 let phase = this._phase;58 if (algorithm === 0) {59 const frequencyValue = frequency.getValue();60 const detuneValue = detune.getValue();61 const computedFrequency =62 frequencyValue * Math.pow(2, detuneValue / 1200);63 const phaseIncr = frequencyToPhaseIncr * computedFrequency;64 while (writeIndex < blockSize) {65 output[writeIndex++] = Math.sin(phase);66 phase += phaseIncr;67 }68 } else {69 const frequencyValues = frequency.getSampleAccurateValues();70 const detuneValues = detune.getSampleAccurateValues();71 while (writeIndex < blockSize) {72 const frequencyValue = frequencyValues[writeIndex];73 const detuneValue = detuneValues[writeIndex];74 const computedFrequency =75 frequencyValue * Math.pow(2, detuneValue / 1200);76 output[writeIndex++] = Math.sin(phase);77 phase += frequencyToPhaseIncr * computedFrequency;78 }79 }80 this._phase = phase;81 return writeIndex;82 },83 dspWave(output, writeIndex, blockSize, sampleRate) {84 const frequency = this._frequency;85 const detune = this._detune;86 const algorithm =87 frequency.hasSampleAccurateValues() * 2 +88 detune.hasSampleAccurateValues();89 const waveTable = this._waveTable;90 const waveTableLength = waveTable.length - 1;91 const frequencyToPhaseIncr = 1 / sampleRate;92 let phase = this._phase;93 if (algorithm === 0) {94 const frequencyValue = frequency.getValue();95 const detuneValue = detune.getValue();96 const computedFrequency =97 frequencyValue * Math.pow(2, detuneValue / 1200);98 const phaseIncr = frequencyToPhaseIncr * computedFrequency;99 while (writeIndex < blockSize) {100 const idx = (phase * waveTableLength) % waveTableLength;101 const v0 = waveTable[idx | 0];102 const v1 = waveTable[(idx | 0) + 1];103 output[writeIndex++] = v0 + (idx % 1) * (v1 - v0);104 phase += phaseIncr;105 }106 } else {107 const frequencyValues = frequency.getSampleAccurateValues();108 const detuneValues = detune.getSampleAccurateValues();109 while (writeIndex < blockSize) {110 const frequencyValue = frequencyValues[writeIndex];111 const detuneValue = detuneValues[writeIndex];112 const computedFrequency =113 frequencyValue * Math.pow(2, detuneValue / 1200);114 const idx = (phase * waveTableLength) % waveTableLength;115 const v0 = waveTable[idx | 0];116 const v1 = waveTable[(idx | 0) + 1];117 output[writeIndex++] = v0 + (idx % 1) * (v1 - v0);118 phase += frequencyToPhaseIncr * computedFrequency;119 }120 }121 this._phase = phase;122 return writeIndex;123 },124};...

Full Screen

Full Screen

AudioBufferSourceNode.js

Source:AudioBufferSourceNode.js Github

copy

Full Screen

1'use strict';2const AudioBufferSourceNodeDSP = {3 dspInit() {4 this._phase = 0;5 },6 dspStart() {7 if (this._audioData) {8 const bufferSampleRate = this._audioData.sampleRate;9 const bufferDuration = this._audioData.length / bufferSampleRate;10 this._phase =11 Math.max(0, Math.min(this._offset, bufferDuration)) * bufferSampleRate;12 }13 },14 dspProcess() {15 if (this._audioData === null) {16 return this.dspEmitEnded();17 }18 const blockSize = this.blockSize;19 const quantumStartFrame = this.context.currentSampleFrame;20 const quantumEndFrame = quantumStartFrame + blockSize;21 const sampleOffset = Math.max(0, this._startFrame - quantumStartFrame);22 const fillToSample =23 Math.min(quantumEndFrame, this._stopFrame) - quantumStartFrame;24 const outputs = this.outputs[0].bus.getMutableData();25 let writeIndex = 0;26 writeIndex = this.dspBufferRendering(27 outputs,28 sampleOffset,29 fillToSample,30 this.sampleRate,31 );32 // timeline33 // |----------------|-------*--------|----------------|----------------|34 // ^ ^ ^35 // |------>| quantumEndFrame36 // | wrote |37 // | stopFrame38 // quantumStartFrame39 if (this._stopFrame <= quantumStartFrame + writeIndex) {40 // rest samples fill zero41 const numberOfChannels = outputs.length;42 while (writeIndex < blockSize) {43 for (let ch = 0; ch < numberOfChannels; ch++) {44 outputs[ch][writeIndex] = 0;45 }46 writeIndex += 1;47 }48 this.dspEmitEnded();49 }50 },51 dspBufferRendering(outputs, writeIndex, inNumSamples, sampleRate) {52 const playbackRateValues = this._playbackRate.getSampleAccurateValues();53 const detuneValues = this._detune.getSampleAccurateValues();54 const numberOfChannels = this._audioData.numberOfChannels;55 const bufferLength = this._audioData.length;56 const bufferSampleRate = this._audioData.sampleRate;57 const bufferChannelData = this._audioData.channelData;58 const playbackRateToPhaseIncr = bufferSampleRate / sampleRate;59 let phase = this._phase;60 while (writeIndex < inNumSamples) {61 const playbackRateValue = playbackRateValues[writeIndex];62 const detuneValue = detuneValues[writeIndex];63 const computedPlaybackRate =64 playbackRateValue * Math.pow(2, detuneValue / 1200);65 for (let ch = 0; ch < numberOfChannels; ch++) {66 const v0 = bufferChannelData[ch][phase | 0] || 0;67 const v1 = bufferChannelData[ch][(phase | 0) + 1] || 0;68 outputs[ch][writeIndex] = v0 + (phase % 1) * (v1 - v0);69 }70 writeIndex += 1;71 phase += playbackRateToPhaseIncr * Math.max(0, computedPlaybackRate);72 if (this._loop) {73 if (0 <= this._loopStart && this._loopStart < this._loopEnd) {74 const loopEndSamples = this._loopEnd * bufferSampleRate;75 if (loopEndSamples <= phase) {76 phase = this._loopStart * bufferSampleRate;77 }78 } else {79 if (bufferLength <= phase) {80 phase = 0;81 }82 }83 } else {84 if (bufferLength <= phase) {85 this.dspEmitEnded();86 break;87 }88 }89 }90 this._phase = phase;91 return writeIndex;92 },93 dspEmitEnded() {94 this._done = true;95 this.context.addPostProcess(() => {96 this.outputs[0].bus.zeros();97 this.outputs[0].disable();98 this.dispatchEvent({ type: 'ended' });99 });100 },101};...

Full Screen

Full Screen

format-number.js

Source:format-number.js Github

copy

Full Screen

1const formatNumber = (_x, precision = null) => {2 const x = precision !== null3 ? parseFloat(_x.toPrecision(precision))4 : _x5 const chars = Array.from(x.toExponential())6 let wholeStart7 let wholeEnd8 if (chars[0] === '-' || chars[0] === '+') {9 wholeStart = 110 wholeEnd = 211 } else {12 wholeStart = 013 wholeEnd = 114 }15 if (chars[wholeStart] === '0') { wholeStart = wholeEnd }16 let fracStart17 let fracEnd18 if (chars[wholeEnd] === '.') {19 fracStart = wholeEnd + 120 fracEnd = chars.lastIndexOf('e')21 } else {22 fracStart = wholeEnd23 fracEnd = wholeEnd24 }25 const exp = parseInt(chars.slice(fracEnd + 1).join(''), 10)26 const signLength = wholeStart27 const wholeLength = wholeEnd - wholeStart28 const fracLength = fracEnd - fracStart29 let leadingZeros = 030 let trailingZeros = 031 if (exp > fracLength) {32 trailingZeros = exp - fracLength33 } else if (-exp >= wholeLength) {34 leadingZeros = Math.max(0, (-exp + 1) - wholeLength)35 }36 const totalLength = 037 + signLength38 + leadingZeros39 + wholeLength40 + fracLength41 + trailingZeros42 const res = new Array(totalLength)43 let writeIndex = 044 const wholeDigits = leadingZeros ? 1 : wholeLength + exp45 let commaPosition = wholeDigits46 if (wholeStart) {47 res[writeIndex++] = chars[0]48 commaPosition++49 }50 let dotStepper = 3 - (wholeDigits % 3)51 if (dotStepper === 3) { dotStepper = 0 }52 for (let i = 1; i < leadingZeros; i++) {53 if (writeIndex === commaPosition) {54 res[writeIndex++] = ','55 dotStepper = 056 } else if (dotStepper === 3) {57 res[writeIndex++] = '.'58 dotStepper = 059 commaPosition++60 }61 res[writeIndex++] = '0'62 ++dotStepper63 }64 for (let i = wholeStart; i < wholeEnd; i++) {65 if (writeIndex === commaPosition) {66 res[writeIndex++] = ','67 dotStepper = 068 } else if (dotStepper === 3) {69 res[writeIndex++] = '.'70 dotStepper = 071 commaPosition++72 }73 res[writeIndex++] = chars[i]74 ++dotStepper75 }76 for (let i = fracStart; i < fracEnd; i++) {77 if (writeIndex === commaPosition) {78 res[writeIndex++] = ','79 dotStepper = 080 } else if (dotStepper === 3) {81 res[writeIndex++] = '.'82 dotStepper = 083 commaPosition++84 }85 res[writeIndex++] = chars[i]86 ++dotStepper87 }88 for (let i = 0; i < trailingZeros; i++) {89 if (writeIndex === commaPosition) {90 res[writeIndex++] = ','91 dotStepper = 092 } else if (dotStepper === 3) {93 res[writeIndex++] = '.'94 dotStepper = 095 commaPosition++96 }97 res[writeIndex++] = '0'98 ++dotStepper99 }100 // console.log({101 // chars: chars.join(''),102 // sign: chars.slice(0, wholeStart).join(''),103 // whole: chars.slice(wholeStart, wholeEnd).join(''),104 // frac: chars.slice(fracStart, fracEnd).join(''),105 // exp,106 // res: res.join(''),107 // })108 return res.join('')109}...

Full Screen

Full Screen

AtmelRegisters.js

Source:AtmelRegisters.js Github

copy

Full Screen

1$(function () {23 // these classes are accessors for specialty AVR registers i.e. those with different read/write values and/or addresses4 PortRegister = Class.create({56 ctor: function(readIndex, writeIndex, dirIndex)7 {8 var self = this;9 this.ReadIndex = readIndex;10 this.WriteIndex = writeIndex;11 this.DirIndex = dirIndex;1213 this.ReadRegister =14 {15 get: function() { return AtmelContext.RAM[self.ReadIndex]; },16 set: function(value) { }17 }1819 this.WriteRegister =20 {21 get: function() { return AtmelContext.RAM[self.WriteIndex]; },22 set: function(value) { }23 }2425 AtmelContext.RAM[writeIndex].OnRegisterChanged.push(26 function (oldVal, newVal) { self.PortRegister_OnRegisterChanged(oldVal, newVal); }27 );2829 },3031 PortRegister_OnRegisterChanged: function(oldVal, newVal)32 {33 // if a pin is set as an output then writing to its write register sets the input value on it's read register as well34 var readVal = AtmelContext.RAM[this.ReadIndex].get();35 var direction = AtmelContext.RAM[this.DirIndex].get();36 readVal = readVal & ~direction;37 readVal = readVal | (direction & newVal);38 AtmelContext.RAM[this.ReadIndex].set(readVal);39 },4041 get: function()42 {43 return AtmelContext.RAM[this.ReadIndex].get();44 },4546 set: function(value)47 {48 AtmelContext.RAM[this.WriteIndex].set(value);49 },5051 get_bit: function(index)52 {53 return ((AtmelContext.RAM[this.ReadIndex].get() >> index) & 1);54 },5556 set_bit: function(index, value)57 {58 if (value == 0)59 AtmelContext.RAM[this.WriteIndex].set(AtmelContext.RAM[this.WriteIndex].get() & ~(1 << index));60 else61 AtmelContext.RAM[this.WriteIndex].set(AtmelContext.RAM[this.WriteIndex].get() | (1 << index));62 },6364 Reset: function()65 {66 AtmelContext.RAM[this.WriteIndex].Reset();67 AtmelContext.RAM[this.ReadIndex].Reset();68 }69 });7071 IndirectAddressRegister = Class.create({7273 ctor: function(index)74 {75 this.Index = index;76 },7778 Reset: function()79 {80 this.set(0);81 },8283 get: function()84 {85 var lo = AtmelContext.RAM[this.Index].get();86 var hi = AtmelContext.RAM[(this.Index + 1)].get();87 return lo | (hi << 8);88 },8990 set: function(value)91 {92 AtmelContext.RAM[this.Index].set(value & 0xff);93 AtmelContext.RAM[this.Index + 1].set(value >> 8);94 },9596 get_bit: function(index)97 {98 return ((this.get() >> index) & 1);99 },100101 set_bit: function(index, value)102 {103 if (value == 0)104 set((get() & ~(1 << index)));105 else106 set((get() | (1 << index)));107 }108109 });110 ...

Full Screen

Full Screen

server.js

Source:server.js Github

copy

Full Screen

1var express = require('express');2var serveStatic = require('serve-static');3var bodyParser = require('body-parser');4var fs = require("fs");5var writeIndex = 0;6var maxImageCount = 10;7var dataSaved = false;8var statistics = null;9var faces = null;10loadData();11var urlencodedParser = bodyParser.urlencoded({ extended: true, limit: '1mb' });12var app = express ();13app.use(serveStatic(__dirname + '\\quiz\\'));14app.get('/getFace', function (req, res) {15 if(faces.length == 0){16 res.writeHead(200, {'Content-Type': 'text/plain'});17 res.end(JSON.stringify({18 "file": "img/noImage.png",19 "archetype": Math.floor(Math.random() * 4)20 })); 21 }22 else {23 var keys = Object.keys(faces);24 var index = keys[Math.floor(keys.length * Math.random())];25 res.writeHead(200, {'Content-Type': 'text/plain'});26 res.end(JSON.stringify({27 "file": "faces/" + index + ".png",28 "archetype": faces[index]29 })); 30 }31})32app.post('/upload', urlencodedParser, function (req, res) {33 if(req.body.noWebcam){34 statistics[req.body.archetype] += 1;35 }36 else{37 var base64Data = req.body.image.replace(/^data:image\/png;base64,/, "");38 var path = "quiz/faces/" + writeIndex + ".png";39 if (fs.existsSync(path)) {40 fs.unlink(path, function(err) {41 writeFace(base64Data, path, req.body.archetype);42 });43 }44 else {45 writeFace(base64Data, path, req.body.archetype);46 }47 }48 res.writeHead(200, {'Content-Type': 'text/plain'});49 res.end(JSON.stringify(statistics));50})51app.listen(8000)52function writeFace(base64Data, path, archetype)53{54 fs.writeFile(path, base64Data, 'base64', function(err) {55 if(err)56 return;57 faces[writeIndex] = archetype;58 statistics[archetype] += 1;59 console.log("face " + writeIndex + " written -> " + JSON.stringify(statistics));60 writeIndex ++;61 writeIndex = writeIndex % 10;62 saveData();63 });64}65function loadData()66{67 fs.readFile('data.json', 'utf8', function (err, data) {68 if(err)69 {70 statistics = [0, 0, 0, 0];71 faces = [];72 writeIndex = 0;73 }74 else75 {76 data = JSON.parse(data);77 faces = data.faces;78 statistics = data.statistics;79 writeIndex = data.writeIndex;80 }81 });82}83function saveData(){84 if(faces != null && statistics != null)85 {86 fs.writeFile("data.json", JSON.stringify({87 "faces":faces,88 "statistics": statistics,89 "writeIndex": writeIndex90 }), function(err){91 if(err)92 console.log(err);93 else94 console.log("data saved");95 });96 }...

Full Screen

Full Screen

lag.js

Source:lag.js Github

copy

Full Screen

1(function(T) {2 "use strict";3 var fn = T.fn;4 var timevalue = T.timevalue;5 function LagNode(_args) {6 T.Object.call(this, 1, _args);7 fn.fixAR(this);8 var _ = this._;9 var bits = Math.ceil(Math.log(_.samplerate) * Math.LOG2E);10 _.buffersize = 1 << bits;11 _.buffermask = _.buffersize - 1;12 _.buffer = new fn.SignalArray(_.buffersize);13 _.time = 0;14 _.readIndex = 0;15 _.writeIndex = 0;16 }17 fn.extend(LagNode);18 var $ = LagNode.prototype;19 Object.defineProperties($, {20 time: {21 set: function(value) {22 if (typeof value === "string") {23 value = timevalue(value);24 }25 if (typeof value === "number" && value > 0) {26 var _ = this._;27 _.time = value;28 var offset = (value * 0.001 * _.samplerate)|0;29 if (offset > _.buffermask) {30 offset = _.buffermask;31 }32 _.writeIndex = (_.readIndex + offset) & _.buffermask;33 }34 },35 get: function() {36 return this._.time;37 }38 }39 });40 $.process = function(tickID) {41 var _ = this._;42 if (this.tickID !== tickID) {43 this.tickID = tickID;44 fn.inputSignalAR(this);45 var cell = this.cells[0];46 var buffer = _.buffer;47 var mask = _.buffermask;48 var readIndex = _.readIndex;49 var writeIndex = _.writeIndex;50 var i, imax = cell.length;51 for (i = 0; i < imax; ++i) {52 buffer[writeIndex] = cell[i];53 cell[i] = buffer[readIndex];54 readIndex += 1;55 writeIndex = (writeIndex + 1) & mask;56 }57 _.readIndex = readIndex & mask;58 _.writeIndex = writeIndex;59 fn.outputSignalAR(this);60 }61 return this;62 };63 fn.register("lag", LagNode);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7client.init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end();12var webdriverio = require('webdriverio');13var options = {14 desiredCapabilities: {15 }16};17var client = webdriverio.remote(options);18client.init()19 .getTitle().then(function(title) {20 console.log('Title was: ' + title);21 })22 .end();23var webdriverio = require('webdriverio');24var options = {25 desiredCapabilities: {26 }27};28var client = webdriverio.remote(options);29client.init()30 .getTitle().then(function(title) {31 console.log('Title was: ' + title);32 })33 .end();34var webdriverio = require('webdriverio');35var options = {36 desiredCapabilities: {37 }38};39var client = webdriverio.remote(options);40client.init()41 .getTitle().then(function(title) {42 console.log('Title was: ' + title);43 })44 .end();45var webdriverio = require('webdriverio');46var options = {47 desiredCapabilities: {48 }49};50var client = webdriverio.remote(options);51client.init()52 .getTitle().then(function(title) {53 console.log('Title was: ' + title);54 })55 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var index = 1;4var desired = {5};6var browser = wd.remote('localhost', 4723);7browser.init(desired, function() {8 browser.writeIndex('q', index, 'Appium', function() {9 browser.elementByCssSelector('#tsf > div.tsf-p > div.jsb > center > input[type="submit"]:nth-child(1)', function(err, el) {10 browser.clickElement(el, function() {11 browser.waitForElementByCss('#ires > ol > div > h3 > a', function() {12 browser.title(function(err, title) {13 assert.ok(~title.indexOf('Appium'), 'Wrong title!');14 browser.quit();15 });16 });17 });18 });19 });20 });21});22writeElement(locator, text, cb)23var wd = require('wd');24var assert = require('assert');25var desired = {26};27var browser = wd.remote('localhost', 4723);28browser.init(desired, function() {29 browser.writeElement('name', 'q', 'Appium', function() {30 browser.elementByCssSelector('#tsf > div.tsf-p > div.jsb > center > input[type="submit"]:nth-child(1)', function(err, el) {31 browser.clickElement(el, function() {32 browser.waitForElementByCss('#ires > ol > div > h3 > a', function() {33 browser.title(function(err, title)

Full Screen

Using AI Code Generation

copy

Full Screen

1var appium = require('appium');2var wd = require('wd');3var assert = require('assert');4var should = require('should');5var fs = require('fs');6var path = require('path');7var _ = require('underscore');8var desiredCaps = {9};10var driver = wd.promiseChainRemote("localhost", 4723);11driver.init(desiredCaps).then(function() {12 return driver.sleep(10000);13}).then(function() {14 return driver.elementById('io.appium.android.apis:id/edit');15}).then(function(el) {16 return el.sendKeys("Hello World");17}).fin(function() {18 return driver.quit();19}).done();20I have tried to use appium.writeIndex() method with the following code but it is not working. I am getting the following error21I have tried to use appium.writeIndex() method with the following code but it is not working. I am getting the following error22appium.writeIndex(4723, desiredCaps, function(err, res) {23 if (err) {24 console.log("Error: " + err);25 } else {26 console.log("Response: " + res);27 }28});29Your name to display (optional):30Your name to display (optional):

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd'),2 path = require('path'),3 fs = require('fs'),4 assert = require('assert'),5 _ = require('underscore'),6 serverConfigs = require('./helpers/appium-servers');7var serverConfig = serverConfigs.local;8var driver = wd.promiseChainRemote(serverConfig);9var desired = {10 app: path.resolve(__dirname, "apps", "TestApp.app.zip"),11};12 .init(desired)13 .then(function() {14 .writeIndex()15 .then(function() {16 .source()17 .then(function(src) {18 assert(src.indexOf('<html') !== -1);19 });20 });21 })22 .fin(function() { return driver.quit(); })23 .done();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful