Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update pitchHertz/currentPitch arg blocks #2545

Merged
merged 1 commit into from
Aug 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions js/logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class Logo {

this.temperamentSelected = [];
this.customTemperamentDefined = false;
this.specialArgs = [];

if (_THIS_IS_MUSIC_BLOCKS_) {
// Load the default synthesizer
Expand Down Expand Up @@ -1521,6 +1522,10 @@ class Logo {
)
);
}
if (logo.turtles.ithTurtle(turtle).singer.inNoteBlock.length > 0 &&
["pitchinhertz","currentpitch"].indexOf(logo.blocks.blockList[logo.blocks.blockList[blk].connections[i]].name) !== -1) {
logo.specialArgs.push([args, logo, turtle, blk, receivedArg, null, isflow]); //redo after noteBlock Ends
}
}
}

Expand Down
41 changes: 41 additions & 0 deletions js/turtle-singer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,47 @@ class Singer {

if (last(tur.singer.inNoteBlock) !== null) {
__playnote();

if (logo.specialArgs.length > 0) {
let runAgainBlockParam = logo.specialArgs.pop()
let _ar = runAgainBlockParam
let blockN = _ar[3];

//update args for pitch in hertz and current pitch and then redo the flow block they are attatched to(print/storein etc).

let args = [];
for (let i = 1; i <= logo.blocks.blockList[blockN].protoblock.args; i++) {
if (logo.blocks.blockList[blockN].protoblock.dockTypes[i] === "in") {
if (logo.blocks.blockList[blockN].connections[i] == null) {
console.debug("skipping inflow args");
} else {
args.push(logo.blocks.blockList[blockN].connections[i]);
}
} else {
args.push(
logo.parseArg(
logo,
_ar[2],
logo.blocks.blockList[blockN].connections[i],
blockN,
_ar[4]
)
);
}
}
//args, logo, turtle, blk, receivedArg, null, isflow
if (typeof logo.blocks.blockList[blockN].protoblock.flow === "function") {
logo.blocks.blockList[blockN].protoblock.flow(
args,
_ar[1],
_ar[2],
_ar[3],
_ar[4],
_ar[5],
_ar[6]
);
}
}
}
}

Expand Down