octive problems?
Author |
Message |
facultyofmusic
|
Posted: Tue Dec 23, 2008 1:51 pm Post subject: octive problems? |
|
|
this is a program which i made for y isp for a musical keyboard. I made one here with seven white keys. when I press them, they'll give me the correct sound. now i added two octive buttons (goes higher or lower key). and what I expected it to do was when I press the key, the keyboard's notes go one octive higher. however, after I press the octive button, i press the key, it will go up by one octive (nothing wrong there) but if i press one of the keys again ,it will go a higher octive, not staying in one octive. So it goes up everytime i press a keyboard key. how can i fix this? do i have to put 3 if commands under every other if?
Turing: | import GUI
var mainScreen : int := Window.Open ("position:65;50,graphics:900;600")
var octiveUp, octiveDown, exitButton, picID : int
var playTarget, addToPlayTarget1, addToPlayTarget2 : string
var blackKeyPlayButton : string
var octiveCh : string(1) := ""
var wTT : string
procedure rulers
drawline (0, 580, 1000, 580, 1)
end rulers
proc title
cls
locate (1, 50)
put "Wave Studio"
put ""
end title
proc octive
locate (3, 1)
if GUI.GetEventWidgetID = octiveUp then
put "octive up"
octiveCh := ">"
GUI.Enable (exitButton )
else
if GUI.GetEventWidgetID = octiveDown then
put "Octive Down"
octiveCh := "<"
GUI.Enable (exitButton )
end if
end if
end octive
%white key response play
proc playwTT
play (wTT )
wTT := " "
end playwTT
proc drawB
%KEY BOARD BOTTONS
%the white keys (starting fron the left)
drawbox (100, 350, 400, 550, 7)
drawline (143, 350, 143, 550, 7)
drawline (186, 350, 186, 550, 7)
drawline (229, 350, 229, 550, 7)
drawline (273, 350, 273, 550, 7)
drawline (315, 350, 315, 550, 7)
drawline (358, 350, 358, 550, 7)
%the black keys
end drawB
proc keyBoard
var mX, mY, mB : int
var testNoteTarget : string
drawB
%KEY BOARD BUTTON RESPONSE
mousewhere (mX, mY, mB )
if mB = 1 then
if (mX > 100 and mX < 143 and mY > 350 and mY < 420) or (mX > 100 and mX < 127 and mY > 420 and mY < 550) then
wTT := "2c" + octiveCh
playwTT
elsif (mX > 143 and mX < 180 and mY > 350 and mY < 420) or (mX > 157 and mX < 172 and mY > 420 and mY < 550) then
wTT := "2d" + octiveCh
playwTT
elsif (mX > 180 and mX < 229 and mY > 350 and mY < 420) or (mX > 202 and mX < 229 and mY > 420 and mY < 550) then
wTT := "2e" + octiveCh
playwTT
elsif (mX > 229 and mX < 273 and mY > 350 and mY < 420) or (mX > 229 and mX < 255 and mY > 420 and mY < 550) then
wTT := "2f" + octiveCh
playwTT
elsif (mX > 273 and mX < 315 and mY > 350 and mY < 420) or (mX > 285 and mX < 300 and mY > 420 and mY < 550) then
wTT := "2g" + octiveCh
playwTT
elsif (mX > 315 and mX < 358 and mY > 350 and mY < 420) or (mX > 330 and mX < 343 and mY > 420 and mY < 550) then
wTT := "2a" + octiveCh
playwTT
elsif (mX > 358 and mX < 400 and mY > 350 and mY < 420) or (mX > 373 and mX < 400 and mY > 420 and mY < 550) then
wTT := "2b" + octiveCh
playwTT
end if
end if
end keyBoard
title
%Octive buttons
octiveUp := GUI.CreateButton (420, 400, 100, "Octive Up", octive )
octiveDown := GUI.CreateButton (420, 450, 100, "Octive Down", octive )
exitButton := GUI.CreateButton (420, 350, 100, "EXIT", GUI.Quit)
%GUI.Disable (exitButton)
rulers
loop
keyBoard
exit when GUI.ProcessEvent
end loop
Window.Close (mainScreen )
|
Mod Edit: Remember to use syntax tags! Thanks code: | [syntax="turing"]Code Here[/syntax] |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Homer_simpson
|
Posted: Tue Dec 23, 2008 3:15 pm Post subject: Re: octive problems? |
|
|
note the line in the play function
Quote: import GUI
var mainScreen : int := Window.Open ("position:65;50,graphics:900;600")
var octiveUp, octiveDown, exitButton, picID : int
var playTarget, addToPlayTarget1, addToPlayTarget2 : string
var blackKeyPlayButton : string
var octiveCh : string (1) := ""
var wTT : string
procedure rulers
drawline (0, 580, 1000, 580, 1)
end rulers
proc title
cls
locate (1, 50)
put "Wave Studio"
put ""
end title
proc octive
locate (3, 1)
if GUI.GetEventWidgetID = octiveUp then
put "octive up"
octiveCh := ">"
GUI.Enable (exitButton)
else
if GUI.GetEventWidgetID = octiveDown then
put "Octive Down"
octiveCh := "<"
GUI.Enable (exitButton)
end if
end if
end octive
%white key response play
proc playwTT
play (wTT)
octiveCh := ""
wTT := " "
end playwTT
proc drawB
%KEY BOARD BOTTONS
%the white keys (starting fron the left)
drawbox (100, 350, 400, 550, 7)
drawline (143, 350, 143, 550, 7)
drawline (186, 350, 186, 550, 7)
drawline (229, 350, 229, 550, 7)
drawline (273, 350, 273, 550, 7)
drawline (315, 350, 315, 550, 7)
drawline (358, 350, 358, 550, 7)
%the black keys
end drawB
proc keyBoard
var mX, mY, mB : int
var testNoteTarget : string
drawB
%KEY BOARD BUTTON RESPONSE
mousewhere (mX, mY, mB)
if mB = 1 then
if (mX > 100 and mX < 143 and mY > 350 and mY < 420) or (mX > 100 and mX < 127 and mY > 420 and mY < 550) then
wTT := "2c" + octiveCh
playwTT
elsif (mX > 143 and mX < 180 and mY > 350 and mY < 420) or (mX > 157 and mX < 172 and mY > 420 and mY < 550) then
wTT := "2d" + octiveCh
playwTT
elsif (mX > 180 and mX < 229 and mY > 350 and mY < 420) or (mX > 202 and mX < 229 and mY > 420 and mY < 550) then
wTT := "2e" + octiveCh
playwTT
elsif (mX > 229 and mX < 273 and mY > 350 and mY < 420) or (mX > 229 and mX < 255 and mY > 420 and mY < 550) then
wTT := "2f" + octiveCh
playwTT
elsif (mX > 273 and mX < 315 and mY > 350 and mY < 420) or (mX > 285 and mX < 300 and mY > 420 and mY < 550) then
wTT := "2g" + octiveCh
playwTT
elsif (mX > 315 and mX < 358 and mY > 350 and mY < 420) or (mX > 330 and mX < 343 and mY > 420 and mY < 550) then
wTT := "2a" + octiveCh
playwTT
elsif (mX > 358 and mX < 400 and mY > 350 and mY < 420) or (mX > 373 and mX < 400 and mY > 420 and mY < 550) then
wTT := "2b" + octiveCh
playwTT
end if
end if
end keyBoard
title
%Octive buttons
octiveUp := GUI.CreateButton (420, 400, 100, "Octive Up", octive)
octiveDown := GUI.CreateButton (420, 450, 100, "Octive Down", octive)
exitButton := GUI.CreateButton (420, 350, 100, "EXIT", GUI.Quit)
%GUI.Disable (exitButton)
rulers
loop
keyBoard
exit when GUI.ProcessEvent
end loop
Window.Close (mainScreen)
|
|
|
|
|
|
|
|