Computer Science Canada

Turing Piano Program

Author:  ashkie [ Wed Jun 08, 2011 8:15 pm ]
Post subject:  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.




Turing:


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 ( "><2a" )
       end if
    if chars ('l') then
        Music.Play ( "><2b" )
      end if
    if chars (';') 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

Author:  Insectoid [ Wed Jun 08, 2011 8:26 pm ]
Post subject:  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.

Author:  klutzedufus [ Sat Jul 02, 2011 5:13 pm ]
Post subject:  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<" )
end if

Author:  Raknarg [ Mon Jul 04, 2011 10:36 am ]
Post subject:  RE:Turing Piano Program

if you want to simplify it, you could have it play an mp3 for the notes instead.


: