Author Topic: Music Keyboard  (Read 137 times)

Rick3137

  • Sr. Member
  • ****
  • Posts: 341
  • May the Force be with You
    • View Profile
    • Rick's Programs
Music Keyboard
« on: July 22, 2017 »
   I have recently been working on sound files . I have finished a set of notes with Audacity and created a keyboard to play them on.
   The files would not fit on this forum, so you need to go to my website to find them.
   
     http://rb23.yolasite.com/musickeyboard.php
   


Code: [Select]
visible:
 
 
 event = 1; Sound = 0 ; button = 0 ; mzone = 0
  mx; my; z1 = 0 ; z2 = 0 ; z3 = 0
 
ky[] = [ 0,1,2,1,2,1,1,2,1,2,1,2,1,1,2,1,2,1,1,2,1,2,1,2,1,1,2,1,2,1,1,2,1,2,1,2,1,1,2,1,2,1,1,2,1,2,1,2,1 ]
 
randomize time()
hidden:
set redraw off
procedure start()
 ThisIsAPlaceHolder = 1
endproc
set window 0, 0, 1350, 700
proc HowToPlay
proc Setup
proc SetupPieces
proc SetupPieces2
'proc SetupBlackKeys

proc SetupSound
proc SetupZones

   set color 0,0,0
   cls
   set color 255,255,255

    do
         wait 100
   
         set color 0,0,0
         cls;
         set color 255,255,255
                mx= mousex()
                my= mousey()
              z2 = z1
              z1 = zone(mx,my)
              if z1 <> z2 and z1 > 0
                 Sound = z1
                 play sound Sound
                 mzone = z1
              endif
 
         proc DrawBoard

         proc DisplayPieces
         proc PrintText
     
        redraw
    until event = 2
 
  end

procedure SetupZones()
       
           create zone 1,110,380,40,70
           create zone 3,150,380,40,70
           create zone 5,190,380,40,70
           create zone 6,230,380,40,70
           create zone 8,270,380,40,70
           create zone 10,310,380,40,70
           create zone 12,350,380,40,70
           create zone 13,390,380,40,70
           create zone 15,430,380,40,70
           create zone 17,470,380,40,70
           create zone 18,510,380,40,70
           create zone 20,550,380,40,70
           create zone 22,590,380,40,70
           create zone 24,630,380,40,70

           create zone 25,670,380,40,70
           create zone 27,710,380,40,70
           create zone 29,750,380,40,70
           create zone 30,790,380,40,70
           create zone 32,830,380,40,70
           create zone 34,870,380,40,70
           create zone 36,910,380,40,70
           create zone 37,950,380,40,70
           create zone 39,990,380,40,70
           create zone 41,1030,380,40,70
           create zone 42,1070,380,40,70
           create zone 44,1110,380,40,70
           create zone 46,1150,380,40,70
           create zone 48,1190,380,40,70

           create zone  2,140,300,20,80
           create zone  4,180,300,20,80

           create zone  7,260,300,20,80
           create zone  9,300,300,20,80
           create zone  11,340,300,20,80

           create zone  14,420,300,20,80
           create zone  16,460,300,20,80

           create zone  19,540,300,20,80
           create zone  21,580,300,20,80
           create zone  23,620,300,20,80

           create zone  26,140 + 560,300,20,80
           create zone  28,180 + 560,300,20,80

           create zone  31,260 + 560,300,20,80
           create zone  33,300 + 560,300,20,80
           create zone  35,340 + 560,300,20,80

           create zone  38,420 + 560,300,20,80
           create zone  40,460 + 560,300,20,80

           create zone  43,540 + 560,300,20,80
           create zone  45,580 + 560,300,20,80
           create zone  47,620 + 560,300,20,80


endproc

procedure SetupPieces()
      for a = 1 to 48
           
         if ky[a] = 1
            create image a,38,150
            set color 250,250,255
            set image a
            draw rect 0,0,38,150,1
         endif
         if ky[a] = 2
            create image a,18,80
            set color 5,10,15
            set image a
            draw rect 0,0,18,80,1
         endif

      next

  set image primary
  set color 255,255,255

endproc

procedure SetupBlackKeys()
      for a = 51 to 99
         create image a,18,80
      next
  for a = 51 to 99
     set color 10,20,30
     set image a
     draw rect 0,0,18,80,1
  next
  set image primary
  set color 255,255,255

endproc

procedure SetupPieces2()
   for a = 1 to 50
       set image a
     set color 0,0,0

     draw line 0,0,38,0
     draw line 0,0,0,150

     draw line 37,0,37,150
     draw line 0,149,38,149

    next
  set image primary
  set color 255,255,255

endproc

 

procedure Setup()
   rem Setup Variables and other things here.
   gameover = 0
   event = 1
endproc

procedure SetupSound()
     load sound 1,"data\c3.wav"
     load sound 2,"data\c3s.wav"
     load sound 3,"data\d3.wav"
     load sound 4,"data\d3s.wav"
     load sound 5,"data\e3.wav"
     load sound 6,"data\f3.wav"
     load sound 7,"data\f3s.wav"
     load sound 8,"data\g3.wav"
     load sound 9,"data\g3s.wav"
     load sound 10,"data\a3.wav"
     load sound 11,"data\a3s.wav"
     load sound 12,"data\b3.wav"
     load sound 13,"data\c4.wav"
     load sound 14,"data\c4s.wav"
     load sound 15,"data\d4.wav"
     load sound 16,"data\d4s.wav"
     load sound 17,"data\e4.wav"
     load sound 18,"data\f4.wav"
     load sound 19,"data\f4s.wav"
     load sound 20,"data\g4.wav"
     load sound 21,"data\g4s.wav"
     load sound 22,"data\a4.wav"
     load sound 23,"data\a4s.wav"
     load sound 24,"data\b4.wav"
     load sound 25,"data\c5.wav"
     load sound 26,"data\c5s.wav"
     load sound 27,"data\d5.wav"
     load sound 28,"data\d5s.wav"
     load sound 29,"data\e5.wav"
     load sound 30,"data\f5.wav"
     load sound 31,"data\f5s.wav"
     load sound 32,"data\g5.wav"
     load sound 33,"data\g5s.wav"
     load sound 34,"data\a5.wav"
     load sound 35,"data\a5s.wav"
     load sound 36,"data\b5.wav"
     load sound 37,"data\c6.wav"
     load sound 38,"data\c6s.wav"
     load sound 39,"data\d6.wav"
     load sound 40,"data\d6s.wav"
     load sound 41,"data\e6.wav"
     load sound 42,"data\f6.wav"
     load sound 43,"data\f6s.wav"
     load sound 44,"data\g6.wav"
     load sound 45,"data\g6s.wav"
     load sound 46,"data\a6.wav"
     load sound 47,"data\a6s.wav"
     load sound 48,"data\b6.wav"

     
endproc

procedure DrawBoard()
 
  rem cls
  set color 200,200,255
    draw rect 20,20,1300,665,1


endproc

procedure DisplayPieces()
   set color 255,255,255
  ' OK I may have too many images. I needed 2.  My bad habits keep me from getting confused. When I try the "right" way, confused is what I get.
           draw image 1,110,300
           draw image 3,150,300
           draw image 5,190,300
           draw image 6,230,300
           draw image 8,270,300
           draw image 10,310,300
           draw image 12,350,300
           draw image 13,390,300
           draw image 15,430,300
           draw image 17,470,300
           draw image 18,510,300
           draw image 20,550,300
           draw image 22,590,300
           draw image 24,630,300

           draw image 25,670,300
           draw image 27,710,300
           draw image 29,750,300
           draw image 30,790,300
           draw image 32,830,300
           draw image 34,870,300
           draw image 36,910,300
           draw image 37,950,300
           draw image 39,990,300
           draw image 41,1030,300
           draw image 42,1070,300
           draw image 44,1110,300
           draw image 46,1150,300
           draw image 48,1190,300

           draw image 2,140,300
           draw image 4,180,300

           draw image 7,260,300
           draw image 9,300,300
           draw image 11,340,300

           draw image 14,420,300
           draw image 16,460,300

           draw image 19,540,300
           draw image 21,580,300
           draw image 23,620,300

           draw image 26,140 + 560,300
           draw image 28,180 + 560,300

           draw image 31,260 + 560,300
           draw image 33,300 + 560,300
           draw image 35,340 + 560,300

           draw image 38,420 + 560,300
           draw image 40,460 + 560,300

           draw image 43,540 + 560,300
           draw image 45,580 + 560,300
           draw image 47,620 + 560,300

endproc

procedure PrintText()
      set caret 30,50
      write " MouseX = " ; wln str$(mx)
      write " MouseY = " ; wln str$(my)
      write " Zone = " ; wln str$( mzone )

endproc


procedure HowToPlay()
  a = 1
  create font 0, "arial", 24

  set color 255,255,255
  set caret 200,100
  wln "  The object of this puzzle is : "
  wln " to move all of the pieces from the Right Side Board to the Left Side Board."
  wln " "
  wln "  Each piece has 4 colors and when you place the piece on the left side board,  "
  wln " each color should match the color of the piece that it touches. "
  wln " "
  wln " "
  wln "  "
  wln "  "
  wln "  "
  wln "  "
  wln "  "
  wln "  "
  wln "  "
  wln "  "
  wln " Hit any key to continue. "

  wln
  wln " http://rb23.yolasite.com "
 
     redraw
   wait keydown
 

endproc

procedure AfterGame()
   play sound 2
   'set color 0,0,0
   'cls
   create font 0, "arial", 48

   set caret 300,40
   set color 255,255,255
   wln "PUZZLE SOLVED !"
   create font 0, "arial", 16
   set caret 20,300
   wln "  "
   wln "  "
   wln "  My Web Sites: "
   wln " http://rb23.yolasite.com "
   wln " http://rb27.synthasite.com "
   wln " http://scratch2.yolasite.com "
   wln " http://rb26.synthasite.com "
   wln " http://rb29.yolasite.com "
   wln;wln
   set caret 300,630
   wln " Hit any key to play again "
   event = 2
   redraw
   wait keydown


endproc


procedure SetColor( a )
     if a = 1 then   set color 60,255,50
     if a = 2 then   set color 20,20,255
     if a = 3 then   set color 250,50,50
     if a = 4 then   set color 50,250,250
     if a = 5 then   set color 250,50,250
     if a = 6 then   set color 250,250,50
     if a = 7 then   set color 150,20,180
     if a = 8 then   set color 20,130,130
     if a = 9 then   set color 20,130,130
     sqrcolor = a
     quadColor = a
endproc




« Last Edit: July 22, 2017 by Rick3137 »

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 542
    • View Profile
Re: Music Keyboard
« Reply #1 on: July 24, 2017 »
I'm going to the No-Internet land for a week, but hopefully I'll be able to download it through my phone, looks interesting!
.\\\opz

Rick3137

  • Sr. Member
  • ****
  • Posts: 341
  • May the Force be with You
    • View Profile
    • Rick's Programs
Re: Music Keyboard V2
« Reply #2 on: July 29, 2017 »
   With this version, I use NaaLaa to make the notes before using them.
Code: [Select]
visible:
  SampleRate = 44100

  data#[ 44110 ]
  aa$ = "c4.wav"
  freq1# = 261.63

 
 event = 1; Sound = 0 ; button = 0 ; mzone = 0
  mx; my; z1 = 0 ; z2 = 0 ; z3 = 0
 
ky[] = [ 0,1,2,1,2,1,1,2,1,2,1,2,1,1,2,1,2,1,1,2,1,2,1,2,1,1,2,1,2,1,1,2,1,2,1,2,1,1,2,1,2,1,1,2,1,2,1,2,1 ]
 
randomize time()
hidden:
set redraw off
procedure start()
 ThisIsAPlaceHolder = 1
endproc
set window 0, 0, 1350, 700
proc HowToPlay
proc MakeKeys

proc Setup
proc SetupPieces
proc SetupPieces2
'proc SetupBlackKeys

proc SetupSound
proc SetupZones

   set color 0,0,0
   cls
   set color 255,255,255

    do
         wait 100
   
         set color 0,0,0
         cls;
         set color 255,255,255
                mx= mousex()
                my= mousey()
              z2 = z1
              z1 = zone(mx,my)
              if z1 <> z2 and z1 > 0
                 Sound = z1
                 play sound Sound
                 mzone = z1
              endif
 
         proc DrawBoard

         proc DisplayPieces
         proc PrintText
     
        redraw
    until event = 2
 
  end

procedure MakeKeys()

 for cnt = 1 to 48
     if cnt = 1
         aa = "data\c3.wav"
         freq1 = 130.81
     endif
     if cnt = 2
         aa = "data\c3Sharp.wav"
         freq1 = 138.59
     endif
     if cnt = 3
         aa = "data\d3.wav"
         freq1 = 146.83
     endif
     if cnt = 4
         aa = "data\d3Sharp.wav"
         freq1 = 155.56
     endif
     if cnt = 5
         aa = "data\e3.wav"
         freq1 = 164.81
     endif
     if cnt = 6
         aa = "data\f3.wav"
         freq1 = 174.61
     endif
     if cnt = 7
         aa = "data\f3Sharp.wav"
         freq1 = 185.0
     endif
     if cnt = 8
         aa = "data\g3.wav"
         freq1 = 196.0
     endif
     if cnt = 9
         aa = "data\g3Sharp.wav"
         freq1 = 207.65
     endif
     if cnt = 10
         aa = "data\a3.wav"
         freq1 = 220.0
     endif
     if cnt = 11
         aa = "data\a3Sharp.wav"
         freq1 = 233.08
     endif
     if cnt = 12
         aa = "data\b3.wav"
         freq1 = 246.94
     endif

     if cnt = 13
         aa = "data\c4.wav"
         freq1 = 261.63
     endif
     if cnt = 14
         aa = "data\c4Sharp.wav"
         freq1 = 277.18
     endif
     if cnt = 15
         aa = "data\d4.wav"
         freq1 = 293.66
     endif
     if cnt = 16
         aa = "data\d4Sharp.wav"
         freq1 = 311.13
     endif
     if cnt = 17
         aa = "data\e4.wav"
         freq1 = 329.63
     endif
     if cnt = 18
         aa = "data\f4.wav"
         freq1 = 349.23
     endif
     if cnt = 19
         aa = "data\f4Sharp.wav"
         freq1 = 369.99
     endif
     if cnt = 20
         aa = "data\g4.wav"
         freq1 = 392.0
     endif
     if cnt = 21
         aa = "data\g4Sharp.wav"
         freq1 = 415.30
     endif
     if cnt = 22
         aa = "data\a4.wav"
         freq1 = 440.0
     endif
     if cnt = 23
         aa = "data\a4Sharp.wav"
         freq1 = 466.16
     endif
     if cnt = 24
         aa = "data\b4.wav"
         freq1 = 493.88
     endif

     if cnt = 25
         aa = "data\c5.wav"
         freq1 = 523.26
     endif
     if cnt = 26
         aa = "data\c5Sharp.wav"
         freq1 = 554.36
     endif
     if cnt = 27
         aa = "data\d5.wav"
         freq1 = 587.32
     endif
     if cnt = 28
         aa = "data\d5Sharp.wav"
         freq1 = 622.26
     endif
     if cnt = 29
         aa = "data\e5.wav"
         freq1 = 659.26
     endif
     if cnt = 30
         aa = "data\f5.wav"
         freq1 = 698.46
     endif
     if cnt = 31
         aa = "data\f5Sharp.wav"
         freq1 = 739.98
     endif
     if cnt = 32
         aa = "data\g5.wav"
         freq1 = 784.0
     endif
     if cnt = 33
         aa = "data\g5Sharp.wav"
         freq1 = 830.6
     endif
     if cnt = 34
         aa = "data\a5.wav"
         freq1 = 880.0
     endif
     if cnt = 35
         aa = "data\a5Sharp.wav"
         freq1 = 932.32
     endif
     if cnt = 36
         aa = "data\b5.wav"
         freq1 = 987.76
     endif

     if cnt = 37
         aa = "data\c6.wav"
         freq1 = 1046.52
     endif
     if cnt = 38
         aa = "data\c6Sharp.wav"
         freq1 = 1108.72
     endif
     if cnt = 39
         aa = "data\d6.wav"
         freq1 = 1174.64
     endif
     if cnt = 40
         aa = "data\d6Sharp.wav"
         freq1 = 1244.52
     endif
     if cnt = 41
         aa = "data\e6.wav"
         freq1 = 1318.52
     endif
     if cnt = 42
         aa = "data\f6.wav"
         freq1 = 1396.92
     endif
     if cnt = 43
         aa = "data\f6Sharp.wav"
         freq1 = 1479.96
     endif
     if cnt = 44
         aa = "data\g6.wav"
         freq1 = 1568.0
     endif
     if cnt = 45
         aa = "data\g6Sharp.wav"
         freq1 = 1661.2
     endif
     if cnt = 46
         aa = "data\a6.wav"
         freq1 = 1760.0
     endif
     if cnt = 47
         aa = "data\a6Sharp.wav"
         freq1 = 1864.64
     endif
     if cnt = 48
         aa = "data\b6.wav"
         freq1 = 1975.52
     endif
      proc MakeNotes aa$, freq1
next

endproc

procedure MakeNotes( note$,freq# )
   
  ' freq# = 261.63 for c4
   ' period is the number of samples per cycle
   period# = 44100.0 / freq
   ' interval is the time between samples, measured in degrees.
   interval# = 360.0/period
   a# = 0.0
   vol# = 1.0
   for i = 0 to 44099
      value# = sin(a)
    data[i] = value * vol
    a = a + interval
    ' Fade out.
    vol = vol - 1.0/44100.0
   next
   ' Write file
   _WriteWave note, 44100
endproc




procedure SetupZones()
       
           create zone 1,110,380,40,70
           create zone 3,150,380,40,70
           create zone 5,190,380,40,70
           create zone 6,230,380,40,70
           create zone 8,270,380,40,70
           create zone 10,310,380,40,70
           create zone 12,350,380,40,70
           create zone 13,390,380,40,70
           create zone 15,430,380,40,70
           create zone 17,470,380,40,70
           create zone 18,510,380,40,70
           create zone 20,550,380,40,70
           create zone 22,590,380,40,70
           create zone 24,630,380,40,70

           create zone 25,670,380,40,70
           create zone 27,710,380,40,70
           create zone 29,750,380,40,70
           create zone 30,790,380,40,70
           create zone 32,830,380,40,70
           create zone 34,870,380,40,70
           create zone 36,910,380,40,70
           create zone 37,950,380,40,70
           create zone 39,990,380,40,70
           create zone 41,1030,380,40,70
           create zone 42,1070,380,40,70
           create zone 44,1110,380,40,70
           create zone 46,1150,380,40,70
           create zone 48,1190,380,40,70

           create zone  2,140,300,20,80
           create zone  4,180,300,20,80

           create zone  7,260,300,20,80
           create zone  9,300,300,20,80
           create zone  11,340,300,20,80

           create zone  14,420,300,20,80
           create zone  16,460,300,20,80

           create zone  19,540,300,20,80
           create zone  21,580,300,20,80
           create zone  23,620,300,20,80

           create zone  26,140 + 560,300,20,80
           create zone  28,180 + 560,300,20,80

           create zone  31,260 + 560,300,20,80
           create zone  33,300 + 560,300,20,80
           create zone  35,340 + 560,300,20,80

           create zone  38,420 + 560,300,20,80
           create zone  40,460 + 560,300,20,80

           create zone  43,540 + 560,300,20,80
           create zone  45,580 + 560,300,20,80
           create zone  47,620 + 560,300,20,80


endproc

procedure SetupPieces()
      for a = 1 to 48
           
         if ky[a] = 1
            create image a,38,150
            set color 250,250,255
            set image a
            draw rect 0,0,38,150,1
         endif
         if ky[a] = 2
            create image a,18,80
            set color 5,10,15
            set image a
            draw rect 0,0,18,80,1
         endif

      next

  set image primary
  set color 255,255,255

endproc

procedure SetupBlackKeys()
      for a = 51 to 99
         create image a,18,80
      next
  for a = 51 to 99
     set color 10,20,30
     set image a
     draw rect 0,0,18,80,1
  next
  set image primary
  set color 255,255,255

endproc

procedure SetupPieces2()
   for a = 1 to 50
       set image a
     set color 0,0,0

     draw line 0,0,38,0
     draw line 0,0,0,150

     draw line 37,0,37,150
     draw line 0,149,38,149

    next
  set image primary
  set color 255,255,255

endproc

 

procedure Setup()
   rem Setup Variables and other things here.
   gameover = 0
   event = 1
endproc

procedure SetupSound()
     load sound 1,"data\c3.wav"
     load sound 2,"data\c3Sharp.wav"
     load sound 3,"data\d3.wav"
     load sound 4,"data\d3Sharp.wav"
     load sound 5,"data\e3.wav"
     load sound 6,"data\f3.wav"
     load sound 7,"data\f3Sharp.wav"
     load sound 8,"data\g3.wav"
     load sound 9,"data\g3Sharp.wav"
     load sound 10,"data\a3.wav"
     load sound 11,"data\a3Sharp.wav"
     load sound 12,"data\b3.wav"
     load sound 13,"data\c4.wav"
     load sound 14,"data\c4Sharp.wav"
     load sound 15,"data\d4.wav"
     load sound 16,"data\d4Sharp.wav"
     load sound 17,"data\e4.wav"
     load sound 18,"data\f4.wav"
     load sound 19,"data\f4Sharp.wav"
     load sound 20,"data\g4.wav"
     load sound 21,"data\g4Sharp.wav"
     load sound 22,"data\a4.wav"
     load sound 23,"data\a4Sharp.wav"
     load sound 24,"data\b4.wav"
     load sound 25,"data\c5.wav"
     load sound 26,"data\c5Sharp.wav"
     load sound 27,"data\d5.wav"
     load sound 28,"data\d5Sharp.wav"
     load sound 29,"data\e5.wav"
     load sound 30,"data\f5.wav"
     load sound 31,"data\f5Sharp.wav"
     load sound 32,"data\g5.wav"
     load sound 33,"data\g5Sharp.wav"
     load sound 34,"data\a5.wav"
     load sound 35,"data\a5Sharp.wav"
     load sound 36,"data\b5.wav"
     load sound 37,"data\c6.wav"
     load sound 38,"data\c6Sharp.wav"
     load sound 39,"data\d6.wav"
     load sound 40,"data\d6Sharp.wav"
     load sound 41,"data\e6.wav"
     load sound 42,"data\f6.wav"
     load sound 43,"data\f6Sharp.wav"
     load sound 44,"data\g6.wav"
     load sound 45,"data\g6Sharp.wav"
     load sound 46,"data\a6.wav"
     load sound 47,"data\a6Sharp.wav"
     load sound 48,"data\b6.wav"

     
endproc

procedure DrawBoard()
 
  rem cls
  set color 200,200,255
    draw rect 20,20,1300,665,1


endproc

procedure DisplayPieces()
   set color 255,255,255
  ' OK I may have too many images. I needed 2.  My bad habits keep me from getting confused. When I try the "right" way, confused is what I get.
           draw image 1,110,300
           draw image 3,150,300
           draw image 5,190,300
           draw image 6,230,300
           draw image 8,270,300
           draw image 10,310,300
           draw image 12,350,300
           draw image 13,390,300
           draw image 15,430,300
           draw image 17,470,300
           draw image 18,510,300
           draw image 20,550,300
           draw image 22,590,300
           draw image 24,630,300

           draw image 25,670,300
           draw image 27,710,300
           draw image 29,750,300
           draw image 30,790,300
           draw image 32,830,300
           draw image 34,870,300
           draw image 36,910,300
           draw image 37,950,300
           draw image 39,990,300
           draw image 41,1030,300
           draw image 42,1070,300
           draw image 44,1110,300
           draw image 46,1150,300
           draw image 48,1190,300

           draw image 2,140,300
           draw image 4,180,300

           draw image 7,260,300
           draw image 9,300,300
           draw image 11,340,300

           draw image 14,420,300
           draw image 16,460,300

           draw image 19,540,300
           draw image 21,580,300
           draw image 23,620,300

           draw image 26,140 + 560,300
           draw image 28,180 + 560,300

           draw image 31,260 + 560,300
           draw image 33,300 + 560,300
           draw image 35,340 + 560,300

           draw image 38,420 + 560,300
           draw image 40,460 + 560,300

           draw image 43,540 + 560,300
           draw image 45,580 + 560,300
           draw image 47,620 + 560,300

endproc

procedure PrintText()
      set caret 30,50
      write " MouseX = " ; wln str$(mx)
      write " MouseY = " ; wln str$(my)
      write " Zone = " ; wln str$(Sound)

endproc


procedure HowToPlay()
  a = 1
  create font 0, "arial", 24

  set color 255,255,255
  set caret 200,100
  wln "  The object of this puzzle is : "
  wln " to move all of the pieces from the Right Side Board to the Left Side Board."
  wln " "
  wln "  Each piece has 4 colors and when you place the piece on the left side board,  "
  wln " each color should match the color of the piece that it touches. "
  wln " "
  wln " "
  wln "  "
  wln "  "
  wln "  "
  wln "  "
  wln "  "
  wln "  "
  wln "  "
  wln "  "
  wln " Hit any key to continue. "

  wln
  wln " http://rb23.yolasite.com "
 
     redraw
   wait keydown
 

endproc

procedure AfterGame()
   play sound 2
   'set color 0,0,0
   'cls
   create font 0, "arial", 48

   set caret 300,40
   set color 255,255,255
   wln "PUZZLE SOLVED !"
   create font 0, "arial", 16
   set caret 20,300
   wln "  "
   wln "  "
   wln "  My Web Sites: "
   wln " http://rb23.yolasite.com "
   wln " http://rb27.synthasite.com "
   wln " http://scratch2.yolasite.com "
   wln " http://rb26.synthasite.com "
   wln " http://rb29.yolasite.com "
   wln;wln
   set caret 300,630
   wln " Hit any key to play again "
   event = 2
   redraw
   wait keydown


endproc


procedure SetColor( a )
     if a = 1 then   set color 60,255,50
     if a = 2 then   set color 20,20,255
     if a = 3 then   set color 250,50,50
     if a = 4 then   set color 50,250,250
     if a = 5 then   set color 250,50,250
     if a = 6 then   set color 250,250,50
     if a = 7 then   set color 150,20,180
     if a = 8 then   set color 20,130,130
     if a = 9 then   set color 20,130,130
     sqrcolor = a
     quadColor = a
endproc

   ' This section written by Marcus Johansson
' ===============================================================================
' Write wave file from float data.
'   filename - name of output file (wav)
'   fmt      - BITS_8 or BITS_16
'   rate     - sample rate (11025, 22050, 44100 ...)
'   data     - sound data as float array, values in range [-1 .. 1]
' ===============================================================================
procedure WriteWave(filename$, rate)
rate = rate
  fmt = 16
create file 0, filename$, true
' Write header.
_WriteBytes 0, "RIFF"
if fmt = 16 then write32 0, 36 + sizeof(data)*2

_WriteBytes 0, "WAVE"
_WriteBytes 0, "fmt "
write32 0, 16
write16 0, 1
write16 0, 1
' Sampe rate.
write32 0, rate
' Byte rate.
if fmt = 16
      write32 0, rate*2
  write16 0, 2
  write16 0, 16
    _WriteBytes 0, "data"
    write32 0, sizeof(data)*2
  ' Write data.
  for i = 0 to sizeof(data) - 1
  write16 0, int(data[i]*32000.0)
  next
endif
free file 0
endproc

' ===============================================================================
' Write string as bytes.
' ===============================================================================
procedure WriteBytes(f, bytes$)
for i = 0 to len(bytes) - 1
write8 f, asc(mid(bytes, i))
next
endproc



« Last Edit: July 29, 2017 by Rick3137 »