How to use requireInstruments method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

playback.js

Source:playback.js Github

copy

Full Screen

1import * as Tonal from 'tonal';2var events = null;3var playback = {};4// Boilerplate to connect this to a Notochord.5playback.attachEvents = function(ev) {6 events = ev;7};8playback.ready = false;9playback.tonal = Tonal;10playback.measureNumber = 0;11playback.measure = null;12playback.beat = 1;13playback.repeatStack = [];14playback.playing = false;15playback.tempo = 120; // Player should set these 3 before playing.16playback.song = null;17playback.beatLength = 500;18playback.AudioContext = new AudioContext();19// an array containing data about all scheduled tasks yet to come.20var scheduled = [];21// @todo docs22// this one is absolute timing in the measure23playback.schedule = function(func, durations, force) {24 if (typeof durations == 'number') durations = [durations];25 if(playback.style.swing) durations = durations.map(playback.swing);26 var relativeDurations = durations.map(d => d - playback.beat);27 playback.scheduleRelative(func, relativeDurations, force);28};29/**30 * Perform an action in a certain number of beats.31 * @param {Function} func Function to run.32 * @param {Number|Number[]} durations Array of numbers of beats to wait to33 * run func.34 * @param {Boolean} [force=false] By default, won't run if playback.playing35 * is false at the specified time. Setting this to true ignres that.36 */37playback.scheduleRelative = function(func, durations, force) {38 if (typeof durations == 'number') durations = [durations];39 for(let dur of durations) {40 if(dur === 0) { // if duration is 0, run immediately.41 if(playback.playing || force) func();42 } else {43 let timeoutObj;44 let timeout = setTimeout(() => {45 if(playback.playing || force) func();46 47 let index = scheduled.indexOf(timeoutObj);48 if(index != -1) scheduled.splice(index, 1);49 }, dur * playback.beatLength);50 timeoutObj = {51 timeout: timeout,52 func: func,53 force: force54 };55 scheduled.push(timeoutObj);56 // @todo swing?57 }58 }59};60/**61 * Resets all counters and things as if sarting from beginning of song.62 */63playback.reset = function() {64 playback.measureNumber = 0;65 playback.measureInPhrase = 0;66 playback.beat = 1;67 playback.measure = playback.song.measures[0];68 playback.repeatStack = [69 {70 repeatCount: 0,71 maxRepeats: 1,72 startMeasure: playback.measure73 }74 ];75};76/**77 * Stops playback.78 * @public79 */80playback.stop = function() {81 playback.playing = false;82 83 // Cancel (or in some cases immediately run) all scheduled tasks.84 while(scheduled.length) {85 let timeoutObj = scheduled.pop();86 clearTimeout(timeoutObj.timeout);87 if(timeoutObj.force) timeoutObj.func();88 }89};90/**91 * Fills playback.beats with an array of beat array-like objects, which92 * consist of a "name" property for the original chord name, and numbered93 * entires for the nites in the chord.94 * @private95 */96var getBeats = function() { // @todo docs97 playback.beats = [ null ]; // First item is null so it can be 1-indexed.98 for(let i = 0; i < playback.measure.length; i++) {99 let beat = playback.measure.getBeat(i);100 if(beat) {101 let beatObj = playback.tonal.Chord.notes(beat).slice();102 beatObj['name'] = beat;103 playback.beats.push(beatObj);104 } else {105 playback.beats.push(null);106 }107 }108};109playback.play = function() {110 playback.playing = true;111 playback.beatLength = (60 * 1000) / playback.tempo;112 var signature = playback.song.timeSignature[0];113 var sigArray = Array(signature - 1).fill().map((x,i)=>i + 1);114 var onMeasure = function() {115 if(!playback.measure) playback.playing = false;116 if(!playback.playing) return;117 118 playback.beat = 1;119 getBeats();120 if(playback.style.onMeasure) playback.style.onMeasure();121 122 var onBeat = function() {123 if(!playback.playing) return;124 playback.restsAfter = playback.getRestsAfter(playback.beat);125 playback.highlightCurrentBeat();126 if(playback.style.onBeat) playback.style.onBeat();127 };128 onBeat();129 playback.scheduleRelative(() => {130 playback.nextBeat();131 onBeat();132 }, sigArray);133 playback.scheduleRelative(() => {134 playback.nextMeasure();135 onMeasure();136 }, signature);137 };138 onMeasure();139};140/**141 * If there's a beat in the viewer, highlight it for its duration.142 * @private143 */144playback.highlightCurrentBeat = function() {145 if(events) {146 var args = {147 measure: playback.measureNumber,148 beat: playback.beat - 1149 };150 events.dispatch('Player.playBeat', args);151 playback.scheduleRelative(() => {152 events.dispatch('Player.stopBeat', args);153 }, playback.restsAfter, true); // force unhighlight after playback stops154 }155};156playback.instruments = new Map();157/**158 * Load the required instruments for a given style.159 * @param {Object} style A playback style object.160 * @private161 */162playback.setStyle = function(style) {163 // Avoid loading the same plugin twice.164 let loadingInstruments = style.requireInstruments165 .filter(name => !playback.instruments.has(name))166 .map(name => {167 if(name == 'percussion') {168 // eslint-disable-next-line max-len169 let url = 'https://notochord.github.io/percussion-soundfont.js/percussion-mp3.js';170 return Soundfont.instrument(playback.AudioContext, name, {171 // Soundfont has a bug where you can't just pass it a URL like the172 // docs say you can. :/173 // @TODO: open an issue there174 isSoundfontUrl: () => true,175 nameToUrl: () => url176 });177 } else {178 return Soundfont.instrument(playback.AudioContext, name);179 }180 });181 Promise182 .all(loadingInstruments)183 .then(instrumentObjects => {184 instrumentObjects.forEach(instrument => {185 playback.instruments.set(instrument.name, instrument);186 });187 playback.style = style;188 playback.ready = true;189 events && events.dispatch('Player.loadStyle', {});190 });191};192playback.drumNames = new Map();193fetch('https://notochord.github.io/percussion-soundfont.js/drums.json')194 .then(res => res.json())195 .then(drums => {196 // flip it inside-out197 for(let id in drums) {198 playback.drumNames.set(drums[id], id);199 }200 });201/* @TODO: docs */202playback.drum = function(drumName, gain = 0.5) {203 if(playback.drumNames.has(drumName)) {204 let drumID = playback.drumNames.get(drumName);205 if(playback.instruments.has('percussion')) {206 playback.instruments.get('percussion').play(drumID, 0, {gain: gain});207 } else {208 throw new ReferenceError('Instrument "percussion" not loaded.');209 /* @TODO: schedule drums if they're not available yet? This should210 * never happen since styles can't run until their instruments are211 * all loaded */212 213 /* unless the client calls this manually, which I don't want */214 }215 } else {216 // eslint-disable-next-line max-len217 throw new ReferenceError(`No drum with name ${drumName}. See https://notochord.github.io/percussion-soundfont.js/drums.json for available names.`);218 }219};220{221 playback.swingRatio = (2/3);222 let swingRatio1 = playback.swingRatio / 0.5;223 let swingRatio2 = (1 - playback.swingRatio) / 0.5;224 playback.swing = function(origTime) {225 var wholeBeats = Math.floor(origTime);226 var remainder = origTime - wholeBeats;227 var out = wholeBeats;228 if(remainder >= 0.5) {229 out += playback.swingRatio;230 let whatsLeft = remainder - 0.5;231 out += whatsLeft * swingRatio2;232 if(remainder > 0.5) out -= 0.01; 233 } else {234 out += remainder * swingRatio1;235 }236 return out;237 };238}239/**240 * Put a note, array of notes, or beat object into a specific octave.241 * @param {String|Array} beat A note, array of notes, or beat object to put242 * into the selected octave.243 * @param {Number} octave to put the notes in.244 * @param {Boolean} [pianist = false] If true, potentially drop below the245 * given octave to duplicate how a pianist might invert the chord.246 * @returns {Array} Notes in the given octave.247 */248playback.octave = function(beat, octave, pianist = false) {249 if(typeof beat == 'string') beat = [beat];250 if(pianist) {251 let root = beat[0];252 var key = playback.song.getTransposedKey();253 var semitonesFromKey = playback.tonal.Distance.semitones(key, root);254 var down = (semitonesFromKey >= 6);255 if(down) octave -= 1;256 var cToRoot = playback.tonal.Distance.semitones('C', root);257 var cToKey = playback.tonal.Distance.semitones('C', key);258 if(cToRoot < cToKey) octave++;259 }260 261 var prevSemitones = Infinity;262 var notesInOctaves = beat.map(note => {263 let semitones = playback.tonal.Distance.semitones(note, 'C');264 if(semitones == 0) semitones = 12;265 if(semitones > prevSemitones) {266 octave++;267 }268 prevSemitones = semitones;269 return note + octave;270 });271 return notesInOctaves;272 273};274/**275 * Get the number of beats of rest left in the measure after (and including)276 * a given beat.277 * @param {Number} current Current beat.278 * @returns {Number} Number of beats of rest left, plus one.279 * @private280 */281playback.getRestsAfter = function(current) {282 var measure = playback.song.measures[playback.measureNumber];283 if(measure) {284 let count = 1;285 for(let i = current + 1; i < measure.length; i++) {286 if(measure.getBeat(i - 1)) {287 return count;288 } else {289 count++;290 }291 }292 return measure.length - current + 1;293 } else {294 return 0;295 }296};297// Which measure it is in a phrase of four measures.298playback.measureInPhrase = 0;299/**300 * Update playback.measure object to next measure.301 * @private302 */303playback.nextMeasure = function() {304 var skipToEnding = false;305 var repeatData = playback.repeatStack[playback.repeatStack.length - 1];306 if(repeatData && playback.measure.attributes['ending'] !== null) {307 let ending = playback.measure.attributes['ending'];308 if(repeatData.repeatCount != ending - 1) {309 skipToEnding = true;310 playback.measure = repeatData.endMeasure.getNextMeasure();311 }312 }313 if(!skipToEnding) {314 if(repeatData && playback.measure.attributes['repeatEnd']) {315 if(repeatData.repeatCount < repeatData.maxRepeats) {316 repeatData.endMeasure = playback.measure;317 playback.measure = repeatData.startMeasure;318 repeatData.repeatCount++;319 } else {320 playback.repeatStack.pop();321 playback.measure = playback.measure.getNextMeasure();322 }323 } else {324 playback.measure = playback.measure.getNextMeasure();325 326 if(playback.measure && playback.measure.attributes['repeatStart']) {327 playback.repeatStack.push({328 repeatCount: 0,329 maxRepeats: playback.measure.attributes['maxRepeats'],330 startMeasure: playback.measure,331 endMeasure: null332 });333 }334 }335 }336 337 if(playback.measure) {338 playback.measureNumber = playback.measure.getIndex();339 340 playback.measureInPhrase++;341 if(playback.measureInPhrase == 4) playback.measureInPhrase = 0;342 } else {343 playback.playing = false;344 playback.measureInPhrase = 0;345 }346};347/**348 * 349 */350playback.nextBeat = function() {351 playback.beat++;352 if(playback.beat > playback.measure.length) {353 playback.beat = 1;354 }355};356// @TODO: docs357playback.beatsToSecs = function(beats) {358 return (60 / playback.tempo) * beats;359};360/**361 * Play a note or notes for a number of beats.362 * @param {Object} data Object with data about what to play.363 * @param {String|String[]} data.notes Note name[s] to play.364 * @param {String} data.instrument Instrument name to play notes on.365 * @param {Number} data.dur Number of beats to play the note for.366 * @param {Number} [data.velocity=100] Velocity (volume) 0-127.367 * @param {Boolean} [data.roll=false] If true, roll/arpeggiate notes.368 * @param {Number} [data.delay=0] Number of beats to wait before playing.369 */370playback.playNotes = function(data) {371 if(typeof data.notes == 'string') data.notes = [data.notes];372 var notesAsNums = data.notes.map(playback.tonal.Note.midi);373 374 if(!data.velocity) data.velocity = 100;375 let gain = data.velocity / 127;376 377 let durSecs = playback.beatsToSecs(data.dur);378 379 var instrument = playback.instruments.get(data.instrument);380 if(!instrument) {381 // eslint-disable-next-line max-len382 throw new ReferenceError(`Instrument "${data.instrument}" not loaded. Put it in your requireInstruments.`);383 }384 let rollIncr = data.roll ? playback.beatsToSecs(0.05) : 0;385 let totalDelay = data.delay || 0;386 for(let note of notesAsNums) {387 instrument.play(note, totalDelay, {388 gain: gain,389 duration: durSecs - totalDelay390 });391 totalDelay += rollIncr;392 }393};394/**395 * Schedule an array of note data.396 * @param {Object} input Object to pass in actual parameters.397 * @param {String} input.instrument Instrument to use.398 * @param {Number} [data.velocity] Velocity (volume) 0-127.399 * @param {Object[]} input.data Array of objects describing notes to play at400 * different times.401 * @param {Number|Number[]} input.data[].times What beat[s] to play on.402 * @param {Number} input.data[].dur How many beats to play the notes for.403 * @param {String|String[]} input.data[].notes Note name[s] to play.404 */405playback.scheduleNotes = function(input) {406 for(let set of input.data) {407 playback.schedule(() => {408 playback.playNotes({409 notes: set.notes,410 instrument: input.instrument,411 dur: set.dur412 });413 }, set.times);414 }415};416/**417 * Takes an array and returns a random item from it.418 * @param {Array} arr Items to choose from.419 * @returns {*} One of the items of the array.420 */421playback.randomFrom = function(arr) {422 var idx = Math.floor(Math.random() * arr.length);423 return arr[idx];424};425// https://stackoverflow.com/a/2450976/1784306426playback.shuffle = function(array) {427 var currentIndex = array.length, temporaryValue, randomIndex;428 while (0 !== currentIndex) {429 randomIndex = Math.floor(Math.random() * currentIndex);430 currentIndex -= 1;431 temporaryValue = array[currentIndex];432 array[currentIndex] = array[randomIndex];433 array[randomIndex] = temporaryValue;434 }435 return array;436};...

Full Screen

Full Screen

performance.js

Source:performance.js Github

copy

Full Screen

...114 binaryPath = await requireXctrace();115 } catch (e) {116 log.debug(e.message);117 log.info(`Defaulting to ${INSTRUMENTS} usage`);118 binaryPath = await requireInstruments();119 }120 const args = [];121 const toolName = path.basename(binaryPath) === XCRUN ? XCTRACE : INSTRUMENTS;122 if (toolName === XCTRACE) {123 args.push(124 XCTRACE, 'record',125 '--device', this._udid,126 '--template', this._profileName,127 '--output', this._reportPath,128 '--time-limit', `${this._timeout}ms`,129 );130 if (this._pid) {131 args.push('--attach', `${this._pid}`);132 } else {...

Full Screen

Full Screen

swing.js

Source:swing.js Github

copy

Full Screen

1export default function style_swing(playback) {2 var style = {};3 4 style.swing = true;5 6 style.requireInstruments = [7 'percussion',8 'acoustic_grand_piano',9 'acoustic_bass'10 ];11 12 var drums = function() {13 playback.schedule(14 () => playback.drum('Open Hi-Hat', 0.1),15 [1,2,2.5,3,4,4.5]16 );17 playback.schedule(() => playback.drum('Bass Drum', 0.2), [1,2,3,4]);18 playback.schedule(() => playback.drum('Closed Hi Hat', 0.1), [2,4]);19 20 if(Math.random() < 0.3) {21 let snarePattern = playback.randomFrom([22 [4],23 [2.5],24 [2.5,3.5,4.5]25 ]);26 playback.schedule(27 () => playback.drum('Acoustic Snare', 0.1),28 snarePattern29 );30 }31 };32 33 var fourthTrick = false;34 var bass = function() {35 var octv = function(chord) {36 return playback.octave(chord, 2, true);37 };38 var transpose = function(note, intvl) {39 return playback.tonal.transpose(note + 4, intvl).replace(/\d/, '');40 };41 var note1, note2, note3, note4;42 {43 let key = playback.song.getTransposedKey();44 var keyscale = playback.tonal.Scale.notes(key + ' major');45 }46 47 if(playback.beats[2] || playback.beats[4]) {48 note1 = playback.beats[1] && playback.beats[1][0];49 note2 = playback.beats[2] && playback.beats[2][0];50 note3 = playback.beats[3] && playback.beats[3][0];51 note4 = playback.beats[4] && playback.beats[4][0];52 } else {53 // loosely based on https://music.stackexchange.com/a/22174/556354 let beat3 = playback.beats[3] || playback.beats[1];55 let nextMeasure = playback.measure.getNextMeasure();56 let doFourthTrick = false;57 let lookahead = null, interval31 = null;58 if(nextMeasure) {59 lookahead = nextMeasure.getBeat(0);60 interval31 = playback.tonal.Distance.subtract(61 lookahead[0],62 beat3[0]);63 doFourthTrick = interval31 == '4P' && (Math.random() < 0.2);64 }65 66 if(fourthTrick) {67 let beat1 = playback.beats[1];68 if(beat1.quality == 'Major' || beat1.quality == 'Augmented') {69 note1 = transpose(beat1[0], '3M');70 } else { // chord is m/dim71 note1 = transpose(beat1[0], '3m');72 }73 } else {74 note1 = playback.beats[1][0];75 }76 77 if(doFourthTrick) {78 fourthTrick = true;79 note4 = transpose(beat3[0], '7m');80 } else {81 fourthTrick = false;82 let next5 = lookahead[3];83 if(keyscale.includes(next5) && Math.random() < 0.3) {84 note4 = next5;85 } else if(lookahead) {86 let scale3;87 if(beat3.quality == 'Major' || beat3.quality == 'Augmented') {88 scale3 = playback.tonal.Scale.notes(beat3[0] + ' major');89 // @todo that's actually wrong? #5 for aug????90 } else {91 scale3 = playback.tonal.Scale.notes(beat3[0] + ' minor');92 // @todo likewise for dim93 }94 let intervals = playback.shuffle(['-2m', '-2M','2m', '2M']);95 for(let int of intervals) {96 note4 = transpose(lookahead[0], int);97 if(scale3.includes(note4) && keyscale.includes(note4)) break;98 }99 if(!note4) note4 = beat3[2];100 } else {101 note4 = beat3[2];102 }103 }104 105 let rootChanges = (beat3[0] != playback.beats[1][0]);106 let chord1 = playback.tonal.Chord.notes(playback.beats[0]).slice();107 chord1.splice(0,1);108 if(rootChanges) {109 note3 = beat3[0];110 if(chord1.includes(note4)) {111 let idx = chord1.indexOf(note4);112 chord1.splice(idx, 1);113 }114 note2 = playback.randomFrom(chord1);115 } else {116 let rand = Math.floor(Math.random() * chord1.length);117 note2 = chord1.splice(rand,1);118 note3 = playback.randomFrom(chord1);119 }120 }121 playback.scheduleNotes({122 instrument: 'acoustic_bass',123 velocity: 127,124 data: [125 {126 times: 1,127 notes: octv(note1),128 dur: 1129 },130 {131 times: 2,132 notes: note2 ? octv(note2) : [],133 dur: 1134 },135 {136 times: 3,137 notes: note3 ? octv(note3) : [],138 dur: 1139 },140 {141 times: 4,142 notes: note4 ? octv(note4) : [],143 dur: 1144 }145 ]146 });147 };148 149 var piano = function() {150 if(playback.beats[2] || playback.beats[4]) {151 for(let i = 1; i < playback.beats.length; i++) {152 let beat = playback.beats[i];153 if(beat) {154 playback.schedule(() => {155 playback.playNotes({156 notes: playback.octave(beat, 4, true),157 instrument: 'acoustic_grand_piano',158 dur: 2159 });160 }, i);161 }162 }163 } else {164 var patterns = [165 {166 t: [1.5,2,3.5],167 l: [0.5,1.5,1]168 },169 {170 t: [1,2.5,3.5],171 l: [1.5, 0.5, 1]172 },173 {174 t: [1,2.5,3.5,4.5],175 l: [1.5,1.5,0.5,0.5]176 }177 ];178 if(!playback.beats[3]) patterns.push({179 t: [1,2.5],180 l: [1.5,1.5]181 });182 var pianoPattern = playback.randomFrom(patterns);183 var item = 0;184 playback.schedule(() => {185 var beat = playback.beats[1];186 if(playback.beat >= 3) {187 if(playback.beats[3]) beat = playback.beats[3];188 }189 var length = pianoPattern.l[item++];190 playback.playNotes({191 notes: playback.octave(beat, 4, true),192 instrument: 'acoustic_grand_piano',193 dur: length,194 roll: (length > 1)195 });196 }, pianoPattern.t);197 }198 };199 200 /*201 * Style should have either an onBeat function or an onMeasure function.202 * Here we have both.203 */204 style.onMeasure = function() {205 drums();206 bass();207 piano();208 };209 210 return style;...

Full Screen

Full Screen

samba.js

Source:samba.js Github

copy

Full Screen

1export default function style_samba(playback) {2 var style = {};3 4 style.requireInstruments = [5 'percussion',6 'acoustic_grand_piano',7 'acoustic_bass'8 ];9 10 var drums = function() {11 var hatPattern;12 if(playback.measureInPhrase % 2 === 0) {13 hatPattern = playback.randomFrom([14 [2,3,3.5,4.5],15 [1,2,3,3.5,4,4.5]16 ]);17 } else {18 hatPattern = playback.randomFrom([19 [1.5,2,3,4,4.5],20 [1.5,2,3,3.5,4.5]21 ]);22 }23 // not my fault that the GM standard doesn't hyphenate consistently24 // https://www.midi.org/specifications-old/item/gm-level-1-sound-set25 playback.schedule(() => playback.drum('Open Hi-Hat', 0.1), hatPattern);26 27 playback.schedule(() => playback.drum('Bass Drum', 0.2), [1,2.5]);28 playback.schedule(() => playback.drum('Closed Hi Hat', 0.1), [2,4]);29 };30 31 var bass = function() {32 if(playback.beats[2] || playback.beats[4]) {33 for(let i = 1; i < playback.beats.length; i++) {34 let beat = playback.beats[i];35 if(beat) {36 playback.schedule(() => {37 playback.playNotes({38 notes: beat[0] + 2,39 instrument: 'acoustic_bass',40 dur: 1,41 velocity: 12742 });43 }, i);44 }45 }46 } else {47 if(playback.beats[3]48 && playback.beats[3][0] != playback.beats[1][0]) {49 playback.scheduleNotes({50 instrument: 'acoustic_bass',51 velocity: 127,52 data: [53 {54 times: 1,55 notes: playback.beats[1][0] + 2,56 dur: 1.557 },58 {59 times: 2.5,60 notes: playback.beats[1][0] + 2,61 dur: 0.562 },63 {64 times: 3,65 notes: playback.beats[3][0] + 2,66 dur: 1.567 },68 {69 times: 4.5,70 notes: playback.beats[3][0] + 2,71 dur: 0.572 }73 ]74 });75 } else {76 // @todo dim?77 let low5 = playback.tonal.transpose(playback.beats[1][0] + 1, 'P5');78 let coinFlip = Math.random() < 0.5;79 if(coinFlip) {80 playback.scheduleNotes({81 instrument: 'acoustic_bass',82 velocity: 127,83 data: [84 {85 times: 1,86 notes: playback.beats[1][0] + 2,87 dur: 1.588 },89 {90 times: 2.5,91 notes: low5,92 dur: 2.593 }94 ]95 });96 } else {97 playback.scheduleNotes({98 instrument: 'acoustic_bass',99 velocity: 127,100 data: [101 {102 times: 1,103 notes: playback.beats[1][0] + 2,104 dur: 1.5105 },106 {107 times: 2.5,108 notes: low5,109 dur: 1.5110 },111 {112 times: 4,113 notes: playback.beats[1][0] + 2,114 dur: 1115 },116 ]117 });118 }119 }120 }121 };122 123 var piano = function() {124 if(playback.beats[2] || playback.beats[4]) {125 for(let i = 1; i < playback.beats.length; i++) {126 let beat = playback.beats[i];127 if(beat) {128 playback.schedule(() => {129 playback.playNotes({130 notes: playback.octave(beat, 4, true),131 instrument: 'acoustic_grand_piano',132 dur: 2133 });134 }, i);135 }136 }137 } else {138 var patterns = [139 {140 t: [1.5,2,3.5],141 l: [0.5,1.5,1]142 },143 {144 t: [1,2.5,3.5],145 l: [1.5, 0.5, 1]146 },147 {148 t: [1,2.5,4,4.5],149 l: [1.5,1.5,0.5,0.5]150 }151 ];152 if(!playback.beats[3]) patterns.push({153 t: [1,2.5],154 l: [1.5,1.5]155 });156 var pianoPattern = playback.randomFrom(patterns);157 var item = 0;158 playback.schedule(() => {159 var beat = playback.beats[1];160 if(playback.beat >= 3) {161 if(playback.beats[3]) beat = playback.beats[3];162 }163 var length = pianoPattern.l[item++];164 playback.playNotes({165 notes: playback.octave(beat, 4, true),166 instrument: 'acoustic_grand_piano',167 dur: length,168 roll: (length > 1)169 });170 }, pianoPattern.t);171 }172 };173 174 style.onMeasure = function() {175 drums();176 bass();177 piano();178 };179 180 return style;...

Full Screen

Full Screen

basic.js

Source:basic.js Github

copy

Full Screen

1/*2 * A style is expected to take one parameter, the player's playback object.3 * The playback object has all of the functionality a style needs to get chord4 * data from the current measure, and play notes.5 *6 * A style should have a requireInstruments array, which can include7 * "General MIDI" instrument names as well as the string 'percussion'.8 * A style should return 1-2 functions: onBeat or onMeasure.9 */10export default function style_basic(playback) {11 var style = {};12 13 /*14 * The load function could be no-op if you really wanted, but it has to15 * exist. You can use it to load instruments required by the style.16 */17 style.requireInstruments = [18 'percussion',19 'acoustic_grand_piano',20 'acoustic_bass'21 ];22 23 /*24 * Style should have either an onBeat function or an onMeasure function.25 * Here we have both.26 */27 style.onMeasure = function() {28 // Play metronome.29 playback.drum('Bass Drum');30 31 // This isn't the best way to do this, but for the sake of example,32 // here's how the scheduler works:33 playback.schedule(() => playback.drum('Hi Wood Block'), [2, 3, 4]);34 };35 style.onBeat = function() {36 var chord = playback.beats[playback.beat];37 // If there's no chord returned by getBeat, there's no chord on this beat.38 if(chord) {39 40 // This turns a beat object into an array of note names.41 // the second argument decides whether to go up or down the octave.42 var notes = playback.octave(chord, 4, true);43 playback.playNotes({44 notes: notes, // Note name or array of note names.45 instrument: 'acoustic_grand_piano',46 dur: playback.restsAfter // Number of beats to play the note.47 // Optionally: 'velocity' which is a number 0-127 representing volume.48 // Well, technically it represents how hard you play an instrument49 // but it corresponds to volume so.50 });51 52 playback.playNotes({53 notes: chord[0] + 2,54 instrument: 'acoustic_bass',55 dur: playback.restsAfter56 });57 }58 };59 60 return style;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { AppiumDriver } = require('appium-base-driver');2const { XCUITestDriver } = require('appium-xcuitest-driver');3const { XCUITestDriverExtensions } = require('appium-xcuitest-driver/lib/commands/extension');4const driver = new XCUITestDriver();5const extensions = new XCUITestDriverExtensions({driver});6(async () => {7 await driver.createSession({8 });9 await extensions.requireInstruments({10 });11 await driver.deleteSession();12})();13const { AppiumDriver } = require('appium-base-driver');14const { XCUITestDriver } = require('appium-xcuitest-driver');15const { XCUITestDriverExtensions } = require('appium-xcuitest-driver/lib/commands/extension');16const driver = new XCUITestDriver();17const extensions = new XCUITestDriverExtensions({driver});18(async () => {19 await driver.createSession({20 });21 await extensions.requireInstruments({22 });23 await driver.deleteSession();24})();25const { AppiumDriver } = require('appium-base-driver');26const { XCUITestDriver } = require('appium-xcuitest-driver');27const { XCUITestDriverExtensions } = require('appium-xcuitest-driver/lib/commands/extension');28const driver = new XCUITestDriver();29const extensions = new XCUITestDriverExtensions({driver});30(async () => {31 await driver.createSession({

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require("wd");2driver.init({3}).then(function() {4 return driver.requireInstruments("/Users/...../instruments-without-delay.dylib");5}).then(function() {6 return driver.execute("mobile: launchApp", {bundleId: "com.apple.mobilesafari"});7}).then(function() {8}).then(function() {9 return driver.sleep(5000);10}).then(function() {11 return driver.quit();12}).done();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {requireInstruments} = require('appium-xcuitest-driver');2const instruments = requireInstruments();3const {requireInstruments} = require('appium-xcuitest-driver');4const instruments = requireInstruments();5const {requireInstruments} = require('appium-xcuitest-driver');6const instruments = requireInstruments();7const {requireInstruments} = require('appium-xcuitest-driver');8const instruments = requireInstruments();9const {requireInstruments} = require('appium-xcuitest-driver');10const instruments = requireInstruments();11const {requireInstruments} = require('appium-xcuitest-driver');12const instruments = requireInstruments();13const {requireInstruments} = require('appium-xcuitest-driver');14const instruments = requireInstruments();15const {requireInstruments} = require('appium-xcuitest-driver');16const instruments = requireInstruments();17const {requireInstruments} = require('appium-xcuitest-driver');18const instruments = requireInstruments();19const {requireInstruments} = require('appium-xcuitest-driver');20const instruments = requireInstruments();21const {requireInstruments} = require('appium-xcuitest-driver');22const instruments = requireInstruments();23const {requireInstruments} = require('appium-xcuitest-driver');24const instruments = requireInstruments();25const {requireInstruments}

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = require('appium-xcuitest-driver');2var instruments = driver.requireInstruments();3var driver = require('appium-xcuitest-driver');4var instruments = driver.requireInstruments();5var driver = require('appium-xcuitest-driver');6var instruments = driver.requireInstruments();7var driver = require('appium-xcuitest-driver');8var instruments = driver.requireInstruments();9var driver = require('appium-xcuitest-driver');10var instruments = driver.requireInstruments();11var driver = require('appium-xcuitest-driver');12var instruments = driver.requireInstruments();13var driver = require('appium-xcuitest-driver');14var instruments = driver.requireInstruments();15var driver = require('appium-xcuitest-driver');16var instruments = driver.requireInstruments();17var driver = require('appium-xcuitest-driver');18var instruments = driver.requireInstruments();19var driver = require('appium-xcuitest-driver');20var instruments = driver.requireInstruments();21var driver = require('appium-xcuitest-driver');22var instruments = driver.requireInstruments();23var driver = require('appium-xcuitest-driver');24var instruments = driver.requireInstruments();25var driver = require('app

Full Screen

Using AI Code Generation

copy

Full Screen

1var path = require('path');2var assert = require('assert');3var wd = require('wd');4var chai = require('chai');5var chaiAsPromised = require('chai-as-promised');6var chaiSubset = require('chai-subset');7chai.use(chaiAsPromised);8chai.use(chaiSubset);9chai.should();10var app = path.resolve(__dirname, 'TestApp.app.zip');11var instruments = path.resolve(__dirname, 'instruments');12var driver = wd.promiseChainRemote('localhost', 4723);13driver.init({14}).then(function () {15 return driver.elementByAccessibilityId('ComputeSumButton');16}).then(function (el) {17 return el.click();18}).then(function () {19 return driver.elementByAccessibilityId('Answer');20}).then(function (el) {21 return el.text();22}).then(function (text) {23 console.log(text);24 assert.equal(text, '42');25}).fin(function () {26 return driver.quit();27}).done();28{29 {30 "buildSettings" : {31 "DYLD_FRAMEWORK_PATH" : "$(PLATFORM_DIR)/Developer/Library/Frameworks",32 "DYLD_LIBRARY_PATH" : "$(inherited)",33 "LD_RUNPATH_SEARCH_PATHS" : "$(inherited) @executable_path/Frameworks",

Full Screen

Using AI Code Generation

copy

Full Screen

1const { XCUITestDriver } = require('appium-xcuitest-driver');2const { withSafariOptions } = require('appium-safari-driver');3const driver = new XCUITestDriver();4driver.requireInstruments(withSafariOptions);5const { XCUITestDriver } = require('appium-xcuitest-driver');6const { withSafariOptions } = require('appium-safari-driver');7const driver = new XCUITestDriver();8driver.requireInstruments(withSafariOptions);9driver.createSession({10 capabilities: {11 }12});13driver.getTitle().then(function(title) {14 console.log('Title is: ' + title);15});16driver.quit();17const { XCUITestDriver } = require('appium-xcuitest-driver');18const { withSafariOptions } = require('appium-safari-driver');19const driver = new XCUITestDriver();20driver.requireInstruments(withSafariOptions);21driver.createSession({22 capabilities: {23 }24});25driver.getTitle().then(function(title) {26 console.log('Title is: ' + title);27});28driver.quit();29const { XCUITestDriver } = require('appium-xcuitest-driver');30const { withSafariOptions } = require('appium-safari-driver');31const driver = new XCUITestDriver();32driver.requireInstruments(withSafariOptions);33driver.createSession({34 capabilities: {

Full Screen

Using AI Code Generation

copy

Full Screen

1const {requireInstruments} = require('appium-xcuitest-driver');2const instruments = requireInstruments('appium-xcuitest-driver');3const {startInstrumentsSession} = instruments;4const {requireInstruments} = require('appium-xcuitest-driver');5const instruments = requireInstruments('appium-xcuitest-driver');6const {startInstrumentsSession} = instruments;7const {requireInstruments} = require('appium-xcuitest-driver');8const instruments = requireInstruments('appium-xcuitest-driver');9const {startInstrumentsSession} = instruments;10const {requireInstruments} = require('appium-xcuitest-driver');11const instruments = requireInstruments('appium-xcuitest-driver');12const {startInstrumentsSession} = instruments;13const {requireInstruments} = require('appium-xcuitest-driver');14const instruments = requireInstruments('appium-xcuitest-driver');15const {startInstrumentsSession} = instruments;16const {requireInstruments} = require('appium-xcuitest-driver');17const instruments = requireInstruments('appium-xcuitest-driver');18const {startInstrumentsSession} = instruments;19const {requireInstruments} = require('appium-xcuitest-driver');20const instruments = requireInstruments('appium-xcuitest-driver');21const {startInstrumentsSession} = instruments;22const {requireInstruments} = require('appium-xcuitest-driver');23const instruments = requireInstruments('appium-xcuitest-driver');24const {startInstrumentsSession} = instruments;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var xcode = require('appium-xcode');4var path = require('path');5var fs = require('fs');6var os = require('os');7var rimraf = require('rimraf');8var mkdirp = require('mkdirp');9var _ = require('lodash');10var logger = require('appium-logger').get('appium-xcuitest-driver');11var log = logger.log.bind(logger);12var exec = require('teen_process').exec;13var async = require('async');14var ncp = require('ncp');15var p = path.posix;16var mv = require('mv');17var NodeZip = require('node-zip');18var bplistCreate = require('bplist-creator');19var bplistParse = require('bplist-parser');20var xcodeVersion = xcode.getVersion(true);21var xcodeVersionFloat = parseFloat(xcodeVersion);22var xcode7 = xcodeVersionFloat >= 7.0 && xcodeVersionFloat < 8.0;23var xcode8 = xcodeVersionFloat >= 8.0;24var xcode9 = xcodeVersionFloat >= 9.0;25var xcode10 = xcodeVersionFloat >= 10.0;26var xcode11 = xcodeVersionFloat >= 11.0;27var xcode11_2 = xcodeVersionFloat >= 11.2;28var xcode11_3 = xcodeVersionFloat >= 11.3;29var xcode12 = xcodeVersionFloat >= 12.0;30var xcode12_2 = xcodeVersionFloat >= 12.2;31var xcode12_3 = xcodeVersionFloat >= 12.3;32var xcode12_4 = xcodeVersionFloat >= 12.4;33var xcode12_5 = xcodeVersionFloat >= 12.5;34var xcode12_5_1 = xcodeVersionFloat >= 12.5.1;35var xcode13 = xcodeVersionFloat >= 13.0;36var xcode13_1 = xcodeVersionFloat >= 13.1;37var xcode13_2 = xcodeVersionFloat >= 13.2;

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 Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful