piano icon indicating copy to clipboard operation
piano copied to clipboard

¿Can I touch key from any function or instruction?

Open developez opened this issue 7 years ago • 12 comments

I would to ask if I can touch key programatically.

developez avatar Dec 20 '17 10:12 developez

Uhmmmm

Maybe you can create a triggers to simulate click on keys...

felipefialho avatar Dec 20 '17 15:12 felipefialho

i am thinking to make chords programatically, do you think that is possible??

developez avatar Dec 20 '17 15:12 developez

I think yes.

But I don't have imagined it when I've created this project.

felipefialho avatar Dec 20 '17 15:12 felipefialho

By the momento firing click does not work:

$($("li.key")[1]).click();

I suppose that to fire the event that plays the sound will be enough

developez avatar Dec 20 '17 15:12 developez

The correct approach is

$("li.key:nth-child(2) > .black-key").trigger('click'); or $("li.key:nth-child(2) > .white-key").trigger('click');

felipefialho avatar Dec 20 '17 15:12 felipefialho

that sounds on you machine???

developez avatar Dec 20 '17 16:12 developez

Not, it's weird.

I need to test again later.

felipefialho avatar Dec 20 '17 16:12 felipefialho

Hello from France :) You think about making chords, like this ? http://www.pianochord.org/

I would be very interested to. And I would be interested to contribute to it. The other day, I just made a simple keyboard on my Codepen, but it isn't as good as yours.

aureliet avatar Jan 21 '18 15:01 aureliet

Hi @aureliet. This is an old project (since 2013), but I want to update it.

I like any suggestion to improve piano and I am open to PR's accepts 😹

Thanks!

felipefialho avatar Jan 22 '18 11:01 felipefialho

Hello @LFeh !

My code can be better, I think, but now we can have the chords.

Can I propose the app to a music school? They won't pay me for it. Maybe one free piano lesson but that's all. They would be interested to use it on their website for their students.

dev.zip

Edit : in the index.html : Now we have data-number on the spans. From this, we can calculate the chords. And we have two selects, to get the different chords variations.

in the _general.js : The js I added to make chords

And... we will have to add notes, because from the A# to the end, we don't have enough...

aureliet avatar Jan 24 '18 13:01 aureliet

For the problem I mentionned before, problem solved . Just change theses cases :

case "Add2" :
           note2 = note1+2;
           note3 = note1+4;
           note4 = note1+7;
           break;

       case "Addm2" :
           note2 = note1+1;
           note3 = note1+4;
           note4 = note1+7;
           break;

       case "Addm3" :
           note2 = note1+3;
           note3 = note1+4;
           note4 = note1+7;
           break;

aureliet avatar Jan 24 '18 16:01 aureliet

Hey @developez, check if it works now?

felipefialho avatar Apr 17 '18 13:04 felipefialho