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

Addition of lyrics through phase maker #4174

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Commanderk3
Copy link
Contributor

@Commanderk3 Commanderk3 commented Dec 22, 2024

#3842

I was able to figure out how we can add print blocks to the block stack. But addition of a "true" print block in the phase maker widget and detecting it in the matrix is challenging. I spent almost 2 days on this problem but no results were produced.
Hence I am making it a draft PR for the interested one. They can continue my work and also I am ready to collab.

Things we can focus on :-

  1. Modifying print block code. Orginally the phase maker only identifies notes and instruments like drum. No such implementation
    for other blocks.
  2. Removal of keyboard shorcuts while typing in the cell.
  3. Here I have used an array to store lyrics. Is there any better option ?

@walterbender @pikurasa Sir please check this PR.

lyric.mp4

@walterbender
Copy link
Member

Generally seems to work well. Not sure why the blocks are created when you add lyrics. But export is correct.
One small detail: it would be good to make the lyric block the same width as the other blocks in their columns.

@Commanderk3
Copy link
Contributor Author

Generally seems to work well. Not sure why the blocks are created when you add lyrics. But export is correct.
One small detail: it would be good to make the lyric block the same width as the other blocks in their columns.

Blocks are probably added because of keyboard shortcuts, just have to disable it like typing in the search box.

Originally Mr. Devin asked to initiate the lyrics row when print block is added to phrase maker widget. But in this PR their is no such implementation. Lyrics row will generate any way. I have to understand more deeply how it works.

Although I have added a Boolean lyricsON, if you think that initiating lyrics row in Matrix by adding a print block is not necessary then we can just use the Boolean to add print blocks in the generated action block.

@Commanderk3 Commanderk3 marked this pull request as ready for review December 23, 2024 07:53
@Commanderk3 Commanderk3 marked this pull request as draft December 23, 2024 07:57
@haroon10725
Copy link
Contributor

@Commanderk3 I would like to continue it.

@walterbender
Copy link
Member

I realized after I typed my comment that the extra note blocks must be generated (as you had mentioned) by keyboard short cuts. We should probably disable keyboard shortcuts whenever any of the widgets are open.

I agree that the Lyrics row should not be a default. It should be driven by the presense of a print block. The glue for doing that is a bit messy, but you can follow the example for any of the graphics blocks.

@Commanderk3
Copy link
Contributor Author

@Commanderk3 I would like to continue it.

Sure, go ahead.

@Commanderk3
Copy link
Contributor Author

I realized after I typed my comment that the extra note blocks must be generated (as you had mentioned) by keyboard short cuts. We should probably disable keyboard shortcuts whenever any of the widgets are open.

I agree that the Lyrics row should not be a default. It should be driven by the presense of a print block. The glue for doing that is a bit messy, but you can follow the example for any of the graphics blocks.

Yes, I will look into it. The generation of cells excluding the first two is a bit tricky part. I will take my time on this one.

@Commanderk3
Copy link
Contributor Author

Commanderk3 commented Dec 26, 2024

i wont say the commit "update 3" is perfect. A bit hardcoded. Just sharing my idea, still have some issues.
Cell width is now matching with others.

@haroon10725
Copy link
Contributor

@Commanderk3 I am working on those issues.

@Commanderk3
Copy link
Contributor Author

@walterbender

Okay I am satisfied with the recent commit. Everything is working fine.
What I did ?

Instead of pushing "print" into rowLabels it will now mark lyricsON true. Irrespective of print block position the lyrics row will be generated at the end.
And because it is not in rowLabels, no need to modify existing implemented functions like "Add notes" and "make clickable".

Also removed keyboard shortcuts while typing.

I have to make the formatting correct. I will update it after sometime and also will attach a video.

@haroon10725
Copy link
Contributor

Screenshot 2024-12-27 at 11 58 39 AM

@Commanderk3 Shouldn’t we add to rowLabels and rowArgs. Your implementation is not adding them in rowLabels and rowArgs array.

@Commanderk3
Copy link
Contributor Author

Commanderk3 commented Dec 27, 2024

No problem. It works. Adding it to rowLabels means modifying existing functions. This approach is much simpler. And the lyrics row is anyway going to be at last.

If @walterbender and @pikurasa agree I shall make it a PR.

@haroon10725
Copy link
Contributor

haroon10725 commented Dec 27, 2024

But it can be confusing because in phrase maker we have print block, but it doesn't shows in rowArgs and rowLabels.

@walterbender What do you think about it?

@Commanderk3
Copy link
Contributor Author

Commanderk3 commented Dec 27, 2024

But it can be confusing because in phrase maker we have print block, but it doesn't shows in rowArgs and rowLabels.

@walterbender What do you think about it?

Hmm...maybe. I actually prefer this one because of its simplicity. And everything works fine.

@haroon10725
Copy link
Contributor

I am working on this issue, and will come with a solution soon.

@@ -534,6 +534,8 @@ function setupExtrasBlocks(activity) {
}
}
}
} else if (logo.inMatrix) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not move this else if above the previous one so you don't need the && !logo.inMatrix ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i will do it. 👍

@@ -210,7 +210,7 @@ class PhraseMaker {

// This array keeps track of the position of the rows after sorting.
/**
* Map of row positions after sorting.
* Map of row positions after sorting.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove trailing space

lastConnection = null;
} else {
lastConnection = thisBlock + 3;
lastConnection = thisBlock + 3;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove trailing space

ptmTableRow.insertCell().append(tempTable);

console.log(tempTable2.outerHTML);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove console log in final PR (and extra new lines)

this._tupletValueRow = tempTable.insertRow();
this._noteValueRow = tempTable.insertRow();
this._noteValueRow = tempTable.insertRow();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove trailing space

*/
this._lyrics = [];

this._lyricsON = false;
Copy link
Member

@walterbender walterbender Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use _ for fields that are accessed externally

@walterbender
Copy link
Member

I am somewhat on the fence. Sidestepping the rowBlocks mechanism is simpler but I wonder if it doesn't add a different kind of complexity in that now there are two different mechanism for managing rows. That said, I think we can live with this implementation and perhaps make the change at some point in a different PR.

But we should add a comment in the code explaining that the lyrics are handled differently. Also a comment about disabling keyboard shortcuts and why.

@Commanderk3
Copy link
Contributor Author

Roger that. Formatting I will fix now and other changes that you said.

@Commanderk3
Copy link
Contributor Author

@walterbender I have fixed the issues you mentioned.

@Commanderk3 Commanderk3 marked this pull request as ready for review December 27, 2024 14:05
@@ -1430,6 +1430,7 @@ function setupWidgetBlocks(activity) {
logo.phraseMaker.rowArgs = [];
logo.phraseMaker.graphicsBlocks = [];
logo.phraseMaker.clearBlocks();
logo.phraseMaker._lyricsON = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to change to logo.phraseMaker.lyricsOn = false;

(Did you test after your updates?)

@@ -508,6 +508,8 @@ function setupExtrasBlocks(activity) {
logo.oscilloscopeTurtles.indexOf(activity.turtles.turtleList[turtleIndex]) < 0
)
logo.oscilloscopeTurtles.push(activity.turtles.turtleList[turtleIndex]);
} else if (logo.inMatrix) {
logo.phraseMaker._lyricsON = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to change (remove the _)

@@ -911,8 +926,78 @@ class PhraseMaker {
this._rows[j] = ptmRow;

j += 1;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove trailing spaces


const lyricsInput = document.createElement("input");
lyricsInput.type = "text";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the extra newline

@@ -5036,7 +5122,7 @@ class PhraseMaker {
if (obj === null) {
// add a hertz block
// The last connection in last pitch block is null.
if (note[0].length === 1 || j === note[0].length - 1) {
if (!this._lyricsON && (note[0].length === 1 || j === note[0].length - 1)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no _

@@ -5061,7 +5147,7 @@ class PhraseMaker {
} else if (drumName != null) {
// add a playdrum block
// The last connection in last pitch block is null.
if (note[0].length === 1 || j === note[0].length - 1) {
if (!this._lyricsON && (note[0].length === 1 || j === note[0].length - 1)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no _

@@ -5086,7 +5172,7 @@ class PhraseMaker {
} else if (note[0][j].slice(0, 4) === "http") {
// add a playdrum block with URL
// The last connection in last pitch block is null.
if (note[0].length === 1 || j === note[0].length - 1) {
if (!this._lyricsON && (note[0].length === 1 || j === note[0].length - 1)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no _

@@ -5111,7 +5197,7 @@ class PhraseMaker {
} else if (obj.length > 2) {
// add a 2-arg graphics block
// The last connection in last pitch block is null.
if (note[0].length === 1 || j === note[0].length - 1) {
if (!this._lyricsON && (note[0].length === 1 || j === note[0].length - 1)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_

@@ -5143,7 +5229,7 @@ class PhraseMaker {
} else if (obj.length > 1) {
// add a 1-arg graphics block
// The last connection in last pitch block is null.
if (note[0].length === 1 || j === note[0].length - 1) {
if (!this._lyricsON && (note[0].length === 1 || j === note[0].length - 1)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_

@@ -5168,7 +5254,7 @@ class PhraseMaker {
} else {
// add a pitch block
// The last connection in last pitch block is null.
if (note[0].length === 1 || j === note[0].length - 1) {
if (!this._lyricsON && (note[0].length === 1 || j === note[0].length - 1)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_

}
}
}
if (this._lyricsON) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_

@walterbender
Copy link
Member

Please test before pushing your changes to the PR.

@Commanderk3
Copy link
Contributor Author

Please test before pushing your changes to the PR.

My apologies sir. I did test, somehow it worked. I will take some time, right now I am traveling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants