
-----------------------------------
ashkie
Wed Jun 08, 2011 8:15 pm

Turing Piano Program
-----------------------------------
What is it you are trying to achieve?
What I am trying to do is make a one octave piano from a lower c to an upper c. 


What is the problem you are having?
Once you get to the notes where you need to increase an octave (2a>, etc.) and you try pressing a lower octave key again, the lower octave key is in a higher octave than it previously was. I want this to stop, as I want the program to simulate a real piano.






var chars: array char of boolean 
            loop
                     Input.KeyDown (chars) 
    
    if chars ('a') then 
         Music.Play ( "2c" ) 
    end if 
    if chars ('d') then 
        Music.Play ( "2d" ) 
       end if 
    if chars ('f') then 
        Music.Play ( "2e" ) 
      end if 
    if chars ('h') then 
        Music.Play ( "2f" ) 
        end if
      if chars ('j') then 
         Music.Play ( "2g" ) 
    end if 
    if chars ('k') then 
        Music.Play ( ">2c" ) 
    end if 
      if chars ('w') then 
        Music.Play ( "2c+" ) 
        end if
      if chars ('r') then 
         Music.Play ( "2d+" ) 
    end if 
    if chars ('u') then 
        Music.Play ( "2f+" ) 
       end if 
    if chars ('i') then 
        Music.Play ( "2g+" ) 
      end if 
    if chars ('o') then 
        Music.Play ( "2a+" ) 
        end if
    end loop





Please specify what version of Turing you are using
4.1.1

-----------------------------------
Insectoid
Wed Jun 08, 2011 8:26 pm

RE:Turing Piano Program
-----------------------------------
You'll probably need a variable to keep track of which octave you're at. If you want a low-C, and you're currently at a high octave, reduce the octave, then play the note. If you're at a low octave and want a high-C, increase the octave and play the note.

The important bit is storing which octave you're at.

-----------------------------------
klutzedufus
Sat Jul 02, 2011 5:13 pm

Re: Turing Piano Program
-----------------------------------
if chars (';') then
        Music.Play ( ">2c" )
    end if 

The problem with this is that it's raising the octave, and not lowering it again after. I had a similar problem when I was trying to make a song playing program. It should look like:

    if chars (';') then
        Music.Play ( ">2c