Skip to content

Commit

Permalink
merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
ricknjacky committed Jan 31, 2021
2 parents 29cb58f + ba69769 commit 3dbb048
Show file tree
Hide file tree
Showing 3 changed files with 359 additions and 688 deletions.
83 changes: 43 additions & 40 deletions js/blocks/WidgetBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function setupWidgetBlocks() {
}

flow(args, logo, turtle, blk) {
let tur = logo.turtles.ithTurtle(turtle);
const tur = logo.turtles.ithTurtle(turtle);

if (args.length === 4 && typeof args[0] === "number") {
if (args[0] < 0 || args[0] > 100) {
Expand Down Expand Up @@ -103,7 +103,7 @@ function setupWidgetBlocks() {
let rollOff;

if (args.length === 3 && typeof args[1] === "number") {
for (let ftype in FILTERTYPES) {
for (const ftype in FILTERTYPES) {
if (FILTERTYPES[ftype][0] === args[0]) {
filtertype = FILTERTYPES[ftype][1];
} else if (FILTERTYPES[ftype][1] === args[0]) {
Expand Down Expand Up @@ -187,31 +187,31 @@ function setupWidgetBlocks() {

logo.insideTemperament = true;
logo.temperament.inTemperament = args[0];
let scale = [];
const scale = [];

if (
logo.blocks.blockList[logo.blocks.blockList[blk].connections[2]]
.name === "pitch"
) {
let pitchBlock =
const pitchBlock =
logo.blocks.blockList[
logo.blocks.blockList[blk].connections[2]
];
let note =
const note =
logo.blocks.blockList[pitchBlock.connections[1]].value;
let octave =
const octave =
logo.blocks.blockList[pitchBlock.connections[2]].value;
let setKey = logo.blocks.blockList[pitchBlock.connections[3]];
const setKey = logo.blocks.blockList[pitchBlock.connections[3]];
scale[0] = logo.blocks.blockList[setKey.connections[1]].value;
scale[1] = logo.blocks.blockList[setKey.connections[2]].value;
logo.synth.startingPitch = note + octave;
logo.temperament.scale = scale;
}

let listenerName = "_temperament_" + turtle;
const listenerName = "_temperament_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {
const __listener = function(event) {
logo.temperament.init();
};

Expand Down Expand Up @@ -324,10 +324,10 @@ function setupWidgetBlocks() {
logo.timbre.duoSynthParams = [];
logo.timbre.notesToPlay = [];

let listenerName = "_timbre_" + turtle;
const listenerName = "_timbre_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {
const __listener = function(event) {
logo.timbre.init();
};

Expand Down Expand Up @@ -365,10 +365,10 @@ function setupWidgetBlocks() {
flow(args, logo, turtle, blk) {
logo.insideMeterWidget = true;

let listenerName = "_meterwidget_" + turtle;
const listenerName = "_meterwidget_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {
const __listener = function(event) {
logo.meterWidget = new MeterWidget(blk);

logo.insideMeterWidget = false;
Expand All @@ -393,18 +393,19 @@ function setupWidgetBlocks() {
"oscilloscope"
]);
this.formBlock({ name: _("oscilloscope"), canCollapse: true });
let addPrintTurtle = (blocks,turtle,prev,last) => {
let len = blocks.length;
let next = last ? null : len+2
const addPrintTurtle = (blocks,turtle,prev,last) => {
const len = blocks.length;
const next = last ? null : len+2;
blocks.push([len, "print", 0, 0, [prev, len + 1, next]]);
blocks.push([len + 1, ["text", { value: turtle.name}], 0, 0, [len, null]]);
return blocks;
}
};

this.makeMacro((x, y) => {
let blocks = [[0,"oscilloscope", x, y, [null, 1, null]]];
for (let turtle of turtles.turtleList) {
for (const turtle of turtles.turtleList) {
if (!turtle.inTrash)
// eslint-disable-next-line max-len
blocks = addPrintTurtle(blocks, turtle, Math.max(0, blocks.length - 2), turtle == last(turtles.turtleList));
}
blocks[0][4][2]=blocks.length;
Expand All @@ -417,10 +418,10 @@ function setupWidgetBlocks() {
logo.oscilloscopeTurtles = [];
logo.inOscilloscope = true;

let listenerName = "_oscilloscope_" + turtle;
const listenerName = "_oscilloscope_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {
const __listener = function(event) {
logo.Oscilloscope = new Oscilloscope(logo);
logo.inOscilloscope = false;
};
Expand Down Expand Up @@ -459,10 +460,10 @@ function setupWidgetBlocks() {
flow(args, logo, turtle, blk) {
logo.insideModeWidget = true;

let listenerName = "_modewidget_" + turtle;
const listenerName = "_modewidget_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {
const __listener = function(event) {
logo.modeWidget = new ModeWidget();
logo.insideModeWidget = false;
};
Expand Down Expand Up @@ -509,10 +510,10 @@ function setupWidgetBlocks() {
logo.tempo.BPMBlocks = [];
logo.tempo.BPMs = [];

let listenerName = "_tempo_" + turtle;
const listenerName = "_tempo_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {
const __listener = function(event) {
logo.tempo.init();
};

Expand Down Expand Up @@ -567,10 +568,10 @@ function setupWidgetBlocks() {
logo.pitchDrumMatrix.drums = [];
logo.pitchDrumMatrix.clearBlocks();

let listenerName = "_pitchdrummatrix_" + turtle;
const listenerName = "_pitchdrummatrix_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {
const __listener = function(event) {
if (
logo.pitchDrumMatrix.drums.length === 0 ||
logo.pitchDrumMatrix.rowLabels.length === 0
Expand Down Expand Up @@ -624,10 +625,10 @@ function setupWidgetBlocks() {
logo.inPitchSlider = true;
logo.pitchSlider.frequencies = [];

let listenerName = "_pitchslider_" + turtle;
const listenerName = "_pitchslider_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {
const __listener = function(event) {
logo.pitchSlider.init(logo);
logo.inPitchSlider = false;
};
Expand Down Expand Up @@ -756,10 +757,11 @@ function setupWidgetBlocks() {
logo.musicKeyboard.octaves = [];
logo.musicKeyboard._rowBlocks = [];

let listenerName = "_musickeyboard_" + turtle;
const listenerName = "_musickeyboard_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {

const __listener = function(event) {
logo.musicKeyboard.init();
};

Expand Down Expand Up @@ -805,10 +807,10 @@ function setupWidgetBlocks() {

logo.inPitchStaircase = true;

let listenerName = "_pitchstaircase_" + turtle;
const listenerName = "_pitchstaircase_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {
const __listener = function(event) {
logo.pitchStaircase.init(logo);
logo.inPitchStaircase = false;
};
Expand Down Expand Up @@ -892,11 +894,11 @@ function setupWidgetBlocks() {
logo.rhythmRuler.Drums = [];
logo.inRhythmRuler = true;

let listenerName = "_rhythmruler_" + turtle;
const listenerName = "_rhythmruler_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {
logo.rhythmRuler = new RhythmRuler();
const __listener = function(event) {
logo.rhythmRuler.init();
};

logo.setTurtleListener(turtle, listenerName, __listener);
Expand Down Expand Up @@ -1035,10 +1037,10 @@ function setupWidgetBlocks() {
logo.tupletParams = [];
logo.addingNotesToTuplet = false;

let listenerName = "_matrix_" + turtle;
const listenerName = "_matrix_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {
const __listener = function(event) {
if (
logo.tupletRhythms.length === 0 ||
logo.phraseMaker.rowLabels.length === 0
Expand All @@ -1063,7 +1065,8 @@ function setupWidgetBlocks() {
switch (logo.tupletRhythms[i][0]) {
case "notes":
case "simple":
let tupletParam = [logo.tupletParams[logo.tupletRhythms[i][1]]];
// eslint-disable-next-line no-case-declarations
const tupletParam = [logo.tupletParams[logo.tupletRhythms[i][1]]];
tupletParam.push([]);
for (
let j = 2;
Expand Down Expand Up @@ -1140,10 +1143,10 @@ function setupWidgetBlocks() {

logo.inStatusMatrix = true;

let listenerName = "_status_" + turtle;
const listenerName = "_status_" + turtle;
logo.setDispatchBlock(blk, turtle, listenerName);

let __listener = function(event) {
const __listener = function(event) {
logo.statusMatrix.init(logo);
logo.inStatusMatrix = false;
};
Expand Down
25 changes: 24 additions & 1 deletion js/widgets/pitchslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,40 @@
// from given frequency to nextoctave frequency(two times the given frequency)
// in continuous manner.

/* global _, Tone, logo */

/*
Global locations
js/activity.js
logo, Tone
js/utils/utils.js
_
*/

/* exported PitchSlider */
class PitchSlider {
static ICONSIZE = 32;
static SEMITONE = Math.pow(2, 1 / 12);

/**
* @constructor
*/
constructor() {
this._delta = 0;
this.sliders = {};
this._cellScale = 0;
}

/**
* Intializes the pitch/slider
* @returns {void}
*/
init() {
if (window.widgetWindows.openWindows["slider"]) return;
if (!this.frequencies || !this.frequencies.length) this.frequencies = [392];

const oscillators = [];
for (const _ in this.frequencies) {
for (let i = 0; i < this.frequencies.length; i++) {
const osc = new Tone.AMSynth().toDestination();
oscillators.push(osc);
}
Expand Down Expand Up @@ -120,6 +138,11 @@ class PitchSlider {
setTimeout(this.widgetWindow.sendToCenter, 0);
}

/**
* @private
* @param {number} frequency
* @returns {void}
*/
_save(frequency) {
for (const name in logo.blocks.palettes.dict) {
logo.blocks.palettes.dict[name].hideMenu(true);
Expand Down
Loading

0 comments on commit 3dbb048

Please sign in to comment.