Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Turing Piano
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Il Lupo




PostPosted: Mon Jun 13, 2011 5:04 pm   Post subject: Turing Piano

Task:
I am trying to make a Turing program that will allow me to play a simulator piano.

Problem:
The problem that I am experiencing with my program is that whenever I play
a note, all of the other notes on the keyboard start to sound similar. Also,
if I were to continuously tap on a key, the sound of that key will sound either
lower or higher - depending on what note it plays.

------------------------------------------------------------------------------------------------
Program:
(The program is incomplete.)

%Program: Piano

%Setscreen:
setscreen ("graphics:700,550")

%Variable(s) (Declared & Assigned):
%Font Vaiable(s):
var chars : array char of boolean

var PrestigeEliteStd : int

var PrestigeEliteStd_2 : int

var PrestigeEliteStd_3 : int

var BatangChe : int

var BatangChe_2 : int

var BatangChe_3 : int

var GungsuhChe : int

var MingLiU : int

var MingLiU_2 : int

PrestigeEliteStd := Font.New ("Prestige Elite Std:45:bold")

PrestigeEliteStd_2 := Font.New ("Prestige Elite Std:40:bold")

PrestigeEliteStd_3 := Font.New ("Prestige Elite Std:25:bold")

BatangChe := Font.New ("@BatangChe:35:bold")

BatangChe_2 := Font.New ("@BatangChe:35:bold")

BatangChe_3 := Font.New ("@BatangChe:27:bold")

GungsuhChe := Font.New ("@GungsuhChe:40")

MingLiU := Font.New ("MingLiU:20")

MingLiU_2 := Font.New ("MingLiU:35")

%Keyboard:
Draw.Box (1, 1, 697, 275, black)

Draw.Box (1, 55, 697, 55, black)

Draw.Box (1, 110, 697, 110, black)

Draw.Box (1, 165, 697, 165, black)

Draw.Box (1, 220, 697, 220, black)

%Keyboard (1st Row):
Font.Draw ("Turing Piano", 185, 10, GungsuhChe, black)

Draw.Line (126, 1, 126, 55, black)

Draw.Line (567, 1, 567, 55, black)

%Keyboard (Fill 1st Row):
Draw.Fill (10, 10, grey, black)

Draw.Fill (666, 10, grey, black)

%Keyboard (2nd Row):
Font.Draw ("C", 20, 67, BatangChe, black)

Font.Draw ("D", 83, 67, BatangChe, black)

Font.Draw ("E", 145, 67, BatangChe, black)

Font.Draw ("F", 210, 67, BatangChe, black)

Font.Draw ("G", 270, 67, BatangChe, black)

Font.Draw ("A", 337, 67, BatangChe, black)

Font.Draw ("B", 400, 67, BatangChe, black)

Font.Draw ("C1", 449, 67, BatangChe, black)

Font.Draw ("D1", 512, 67, BatangChe, black)

Font.Draw ("E1", 575, 67, BatangChe, black)

Font.Draw ("F1", 642, 67, BatangChe, black)

Draw.Line (63, 110, 63, 165, black)

Draw.Line (126, 110, 126, 165, black)

Draw.Line (189, 110, 189, 165, black)

Draw.Line (252, 110, 252, 165, black)

Draw.Line (315, 110, 315, 165, black)

Draw.Line (378, 110, 378, 165, black)

Draw.Line (441, 110, 441, 165, black)

Draw.Line (504, 110, 504, 165, black)

Draw.Line (567, 110, 567, 165, black)

Draw.Line (630, 110, 630, 165, black)

%Keyboard (3rd Row):
Font.Draw ("A", 15, 120, PrestigeEliteStd_2, black)

Font.Draw ("S", 79, 120, PrestigeEliteStd_2, black)

Font.Draw ("D", 142, 120, PrestigeEliteStd_2, black)

Font.Draw ("F", 205, 120, PrestigeEliteStd_2, black)

Font.Draw ("G", 267, 120, PrestigeEliteStd_2, black)

Font.Draw ("H", 332, 120, PrestigeEliteStd_2, black)

Font.Draw ("J", 392, 120, PrestigeEliteStd_2, black)

Font.Draw ("K", 455, 120, PrestigeEliteStd_2, black)

Font.Draw ("L", 520, 120, PrestigeEliteStd_2, black)

Font.Draw (":", 587, 144, PrestigeEliteStd_3, black)

Font.Draw (";", 586, 120, PrestigeEliteStd_3, black)

Font.Draw ("'", 648, 120, PrestigeEliteStd_2, black)

Draw.Line (63, 55, 63, 110, black)

Draw.Line (126, 55, 126, 110, black)

Draw.Line (189, 55, 189, 110, black)

Draw.Line (252, 55, 252, 110, black)

Draw.Line (315, 55, 315, 110, black)

Draw.Line (378, 55, 378, 110, black)

Draw.Line (441, 55, 441, 110, black)

Draw.Line (504, 55, 504, 110, black)

Draw.Line (567, 55, 567, 110, black)

Draw.Line (630, 55, 630, 110, black)

%Keyboard (4th Row):
Font.Draw ("Q", 60, 175, PrestigeEliteStd, black)

Font.Draw ("W", 137, 175, PrestigeEliteStd, black)

Font.Draw ("E", 215, 175, PrestigeEliteStd, black)

Font.Draw ("T", 290, 175, PrestigeEliteStd, black)

Font.Draw ("Y", 368, 175, PrestigeEliteStd, black)

Font.Draw ("U", 444, 175, PrestigeEliteStd, black)

Font.Draw ("O", 522, 175, PrestigeEliteStd, black)

Font.Draw ("P", 600, 175, PrestigeEliteStd, black)

Draw.Line (39, 165, 39, 220, black)

Draw.Line (116, 165, 116, 220, black)

Draw.Line (193, 165, 193, 220, black)

Draw.Line (270, 165, 270, 220, black)

Draw.Line (347, 165, 347, 220, black)

Draw.Line (424, 165, 424, 220, black)

Draw.Line (501, 165, 501, 220, black)

Draw.Line (578, 165, 578, 220, black)

Draw.Line (655, 165, 655, 220, black)

%Keyboard (Fill 4th Row):
Draw.Fill (10, 168, grey, black)

Draw.Fill (695, 168, grey, black)

%Keyboard (5th Row):
Font.Draw ("Quit", 43, 235, BatangChe_3, black)

Font.Draw ("C#", 133, 230, BatangChe_2, black)

Font.Draw ("D#", 210, 230, BatangChe_2, black)

Font.Draw ("F#", 283, 230, BatangChe_2, black)

Font.Draw ("G#", 362, 230, BatangChe_2, black)

Font.Draw ("Bb", 439, 230, BatangChe_2, black)

Font.Draw ("C#1", 503, 230, BatangChe_2, black)

Font.Draw ("D#1", 580, 230, BatangChe_2, black)

Draw.Line (39, 220, 39, 275, black)

Draw.Line (116, 220, 116, 275, black)

Draw.Line (193, 220, 193, 275, black)

Draw.Line (270, 220, 270, 275, black)

Draw.Line (347, 220, 347, 275, black)

Draw.Line (424, 220, 424, 275, black)

Draw.Line (501, 220, 501, 275, black)

Draw.Line (578, 220, 578, 275, black)

Draw.Line (655, 220, 655, 275, black)

%Keyboard (Fill 5th Row):
Draw.Fill (10, 225, grey, black)

Draw.Fill (666, 225, grey, black)

%Piano (White Keys):
Draw.Box (1, 277, 697, 547, black)

Draw.Line (63, 277, 63, 420, black)

Draw.Line (126, 277, 126, 420, black)

Draw.Line (189, 277, 189, 547, black)

Draw.Line (252, 277, 252, 420, black)

Draw.Line (315, 277, 315, 420, black)

Draw.Line (378, 277, 378, 420, black)

Draw.Line (441, 277, 441, 547, black)

Draw.Line (504, 277, 504, 420, black)

Draw.Line (567, 277, 567, 420, black)

Draw.Line (630, 277, 630, 547, black)

Font.Draw ("C", 18, 289, MingLiU_2, black)

Font.Draw ("D", 82, 289, MingLiU_2, black)

Font.Draw ("E", 145, 289, MingLiU_2, black)

Font.Draw ("F", 210, 289, MingLiU_2, black)

Font.Draw ("G", 273, 289, MingLiU_2, black)

Font.Draw ("A", 335, 289, MingLiU_2, black)

Font.Draw ("B", 398, 289, MingLiU_2, black)

Font.Draw ("C1", 451, 289, MingLiU_2, black)

Font.Draw ("D1", 515, 289, MingLiU_2, black)

Font.Draw ("E1", 579, 289, MingLiU_2, black)

Font.Draw ("F1", 645, 289, MingLiU_2, black)

%Piano (Black Keys):
Draw.Box (40, 420, 87, 547, black)

Draw.Box (105, 420, 150, 547, black)

Draw.Box (227, 420, 275, 547, black)

Draw.Box (290, 420, 340, 547, black)

Draw.Box (355, 420, 400, 547, black)

Draw.Box (480, 420, 525, 547, black)

Draw.Box (547, 420, 592, 547, black)

%Piano (Fill Black Keys):
Draw.Fill (45, 430, black, black)

Draw.Fill (110, 430, black, black)

Draw.Fill (232, 430, black, black)

Draw.Fill (295, 430, black, black)

Draw.Fill (360, 430, black, black)

Draw.Fill (485, 430, black, black)

Draw.Fill (552, 430, black, black)

Font.Draw ("C#", 50, 430, MingLiU, white)

Font.Draw ("D#", 115, 430, MingLiU, white)

Font.Draw ("F#", 237, 430, MingLiU, white)

Font.Draw ("G#", 303, 430, MingLiU, white)

Font.Draw ("Bb", 363, 430, MingLiU, white)

Font.Draw ("C#1", 485, 430, MingLiU, white)

Font.Draw ("D#1", 552, 430, MingLiU, white)

%Play Piano:
loop

Input.KeyDown (chars)

if chars ('a') then

Music.Play (">c")

elsif chars ('s') then

Music.Play (">d")

elsif chars ('d') then

Music.Play (">e")

elsif chars ('f') then

Music.Play (">f")

elsif chars ('g') then

Music.Play (">g")

elsif chars ('h') then

Music.Play (">a")

elsif chars ('j') then

Music.Play (">b")

elsif chars ('k') then

Music.Play ("<c")

elsif chars ('l') then

Music.Play ("<d")

elsif chars (';') then

Music.Play ("<e")

elsif chars ('"') then

Music.Play ("<f")

end if

end loop
------------------------------------------------------------------------------------------------

Extra:
Also if anyone knows what all the Music.Play notes are in Turing, can
you be able to give me a list of what it is or show how each types of notes
can be played. Thanks.

In the end, I will like to thank you for taking your time to read my
request.

------------------------------------------------------------------------------------------------
UPDATE:
(Because I put this on the wrong section, I am going to put the reply from the topic
at the other section and place it here. Sorry for the mistake.)

From Insectoid:
Using '<' in a Music.Play call changes the octave. If you hit the same key 5 times,
you'll go up 5 octaves. Try Music.Play ("<f>"). This should reduce the octave after
playing the f.
------------------------------------------------------------------------------------------------
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Jun 13, 2011 5:26 pm   Post subject: RE:Turing Piano

As for "all the notes" that there are, see documentation -- Music.Play
Quote:

The Music.Play procedure takes strings containing characters that specify notes, rests, sharps, flats and duration. The notes are the letters a to g (or A to G). A rest is p (for pause). A sharp is + and a flat is -. The durations are 1 (whole note), 2 (half note), 4 (quarter note), 8 (eight note) and 6 (sixteenth note). The character > raises to the next octave and < lowers.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Il Lupo




PostPosted: Fri Jun 17, 2011 5:58 pm   Post subject: Re: Turing Piano

Oh, okay. Now I understand how to do this. Also, thanks for the link that showed me the instructions to Music.Play,
for that really helped me.
PS. Sorry for the late reply, I wasn't online for a while.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: