Music.Play and different versions of turing
Author |
Message |
PianoGirl
|
Posted: Mon Jan 17, 2005 8:58 am Post subject: Music.Play and different versions of turing |
|
|
I previously posted about a problem with Musi.Play and I would first like to thank all of you for your help with the program.
However, I am having a problem. The program works fine with Turing 4.0.1, but not with Turing 4.0.5.
I could use Turing 4.0.1 for the program, but here are my problems:
- Pic.Scale does not work
- jpegs are not supported, and I have many pictures so bmps would slow down the program tremendously
- the forking is not working so I cannot play chords.
For 4.0.5:
- I cannot play the bass clef notes and the treble clef notes at the same time
Here is my code:
** Please note that the code below is only for playing the music, none of my picture files and other routines are included.
code: |
% Routines and Procedures
function checkNote (x : string (1)) : string
% Purpose: Tells the program which note is associated with each key on the keyboard
% Down 1 octave:
if x = " " then % space - C
result "<c"
elsif x = chr (122) then % z - D
result "<d"
elsif x = chr (120) then % x - E
result "<e"
elsif x = chr (99) then % c - F
result "<f"
elsif x = chr (118) then % v - G
result "<g"
elsif x = chr (98) then % b - A
result "<a"
elsif x = chr (110) then % n - B
result "<b"
elsif x = chr (97) then % a - C#
result "<c+"
elsif x = chr (115) then % s - D#
result "<d+"
elsif x = chr (102) then % f - F#
result "<f+"
elsif x = chr (103) then % g - G#
result "<g+"
elsif x = chr (104) then % h - A#
result "<a+"
% Up 1 octave:
elsif x = chr (106) then % j - C
result "c"
elsif x = chr (107) then % k - D
result "d"
elsif x = chr (108) then % l - E
result "e"
elsif x = chr (59) then % ; - F
result "f"
elsif x = chr (39) then % ' - G
result "g"
elsif x = chr (10) then % enter - A
result "a"
elsif x = chr (211) then % delete - B
result "b"
elsif x = chr (105) then % i - C#
result "c+"
elsif x = chr (111) then % o - D#
result "d+"
elsif x = chr (91) then % [ - F#
result "f+"
elsif x = chr (93) then % ] - G#
result "g+"
elsif x = chr (92) then % \ - A#
result "a+"
% Down 2 octaves:
elsif x = chr (96) then % ` - C
result "<<c"
elsif x = chr (49) then % 1 - D
result "<<d"
elsif x = chr (50) then % 2 - E
result "<<e"
elsif x = chr (51) then % 3 - F
result "<<f"
elsif x = chr (52) then % 4 - G
result "<<g"
elsif x = chr (53) then % 5 - A
result "<<a"
elsif x = chr (54) then % 6 - B
result "<<b"
elsif x = chr (187) then % F1 - #C
result "<<c+"
elsif x = chr (188) then % F2 - #D
result "<<d+"
elsif x = chr (189) then % F3 - #F
result "<<f+"
elsif x = chr (190) then % F4 - #G
result "<<g+"
elsif x = chr (191) then % F5 - #A
result "<<a+"
% Up 2 octaves:
elsif x = chr (55) then % 7 - C
result ">c"
elsif x = chr (56) then % 8 - D
result ">d"
elsif x = chr (57) then % 9 - E
result ">e"
elsif x = chr (48) then % 0 - F
result ">f"
elsif x = chr (45) then % - - G
result ">g"
elsif x = chr (61) then % = - A
result ">a"
elsif x = chr (8) then % backspace - B
result ">b"
elsif x = chr (192) then % F6 - #C
result ">c+"
elsif x = chr (193) then % F7 - #D
result ">d+"
elsif x = chr (195) then % F9 - #F
result ">f+"
elsif x = chr (196) then % F10 - #G
result ">g+"
elsif x = chr (197) then % F11 - #A
result ">a+"
% Down 3 octaves:
elsif x = chr (90) then % Z - C
result "<<<c"
elsif x = chr (88) then % X - D
result "<<<d"
elsif x = chr (67) then % C - E
result "<<<e"
elsif x = chr (86) then % V - F
result "<<<f"
elsif x = chr (66) then % B - G
result "<<<g"
elsif x = chr (78) then % N - A
result "<<<a"
elsif x = chr (77) then % M - B
result "<<<b"
elsif x = chr (83) then % S - #C
result "<<<c+"
elsif x = chr (68) then % D - #D
result "<<<d+"
elsif x = chr (71) then % G - #F
result "<<<f+"
elsif x = chr (72) then % H - #G
result "<<<g+"
elsif x = chr (74) then % J - #A
result "<<<a+"
% Up 3 octaves:
elsif x = chr (81) then % Q - C
result ">>c"
elsif x = chr (87) then % W - D
result ">>d"
elsif x = chr (69) then % E - E
result ">>e"
elsif x = chr (82) then % R - F
result ">>f"
elsif x = chr (84) then % T - G
result ">>g"
elsif x = chr (89) then % Y - A
result ">>a"
elsif x = chr (85) then % U - B
result ">>b"
elsif x = chr (64) then % @ - #C
result ">>c+"
elsif x = chr (35) then % # - #D
result ">>d+"
elsif x = chr (37) then % % - #F
result ">>f+"
elsif x = chr (94) then % ^ - #G
result ">>g+"
elsif x = chr (38) then % & - #A
result ">>a+"
elsif x = chr (27) then % Esc - Exit
result "exit"
else
result "x" % No note will be played
end if
end checkNote
process doNote (note : string, duration : int)
var timeBegin := Time.Elapsed
loop
Music.Play (note)
exit when Time.Elapsed - timeBegin >= duration
end loop
end doNote
% Driver Program
loop
var x : string (1) % Memory reserved for the key that is pressed
getch (x) % Get the pressed key
fork doNote (checkNote (x), 125)
fork doNote (checkNote (x), 125)
fork doNote (checkNote (x), 125)
end loop |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|