Help! - Simulating a piano key being pressed


hello,

i'd simulate piano key being pressed have problem.

i use musical instrument shield defines functions noteon(byte channel, byte note, byte attack_velocity) , noteoff(byte channel, byte note, byte release_velocity)
but problem not come shield, it's programming issue:

i want note played once when press key, , played time release , press key again.

but if use this:

code: [select]
if (digitalread(key1)== high)
         {
            noteon(0, 59, 60)
         }


then note loop fast, want played once.


i thought of using delay this:

code: [select]
if (digitalread(key1)== high)
         {
            noteon(0, 59, 60)
            delay (10000)
         }

 
but way can't play key (or one) during 10sec...


to sum up: want noteon activated once in if loop, , re-activated when if goes false true.

any ideas?

thank you.


code: [select]

int key1_val = digitalread(key1);

if (key1_val== high)
{
     noteon(0, 59, 60)
    key1_val=low; //once low, wont high till key pressed again
 }



Arduino Forum > Using Arduino > Programming Questions > Help! - Simulating a piano key being pressed


arduino

Comments