Igranje na inštrumente


to midi
   show midiopen
   (keyboardon [tipkaDol] [tipkaGor])
   make "snemam "false
   make "skladba []

   windowcreate "root "main "MIDI 0 0 185 203 []

   groupboxcreate "main "gr1 5 3 173 60
   staticcreate "main "t1 "Snemanje: 10 12 50 10
   buttoncreate "main "brec "Začni 50 10 40 12 [recordstart]
   buttoncreate "main "bstop "Ustavi 95 10 40 12 [recordstop]
   staticcreate "main "t2 "Oktava: 10 30 40 10
   staticcreate "main "t3 "Kanal: 10 40 40 10
   staticcreate "main "t4 "Jakost: 10 50 40 10
   scrollbarcreate "main "bar1 40 30 100 10 [oktava]
   scrollbarcreate "main "bar2 40 40 100 10 [kanal]
   scrollbarcreate "main "bar3 40 50 100 10 [jakost]
   staticcreate "main "t5 [] 145 30 15 10
   staticcreate "main "t6 [] 145 40 15 10
   staticcreate "main "t7 [] 145 50 15 10

   groupboxcreate "main "gr2 5 65 173 40
   buttoncreate "main "k01 "G# 20 75 11 11 [nota -4]
   buttoncreate "main "k02 "A# 32 75 11 11 [nota -2]
   buttoncreate "main "k03 "C# 56 75 11 11 [nota 1]
   buttoncreate "main "k04 "D# 68 75 11 11 [nota 3]
   buttoncreate "main "k05 "E# 92 75 11 11 [nota 6]
   buttoncreate "main "k06 "G# 104 75 11 11 [nota 8]
   buttoncreate "main "k07 "A# 116 75 11 11 [nota 10]
   buttoncreate "main "k08 "C# 140 75 11 11 [nota 13]
   buttoncreate "main "k09 "A 26 87 11 11 [nota -3]
   buttoncreate "main "k10 "B 38 87 11 11 [nota -1]
   buttoncreate "main "k11 "C 50 87 11 11 [nota 0]
   buttoncreate "main "k12 "D 62 87 11 11 [nota 2]
   buttoncreate "main "k13 "E 74 87 11 11 [nota 4]
   buttoncreate "main "k14 "F 86 87 11 11 [nota 5]
   buttoncreate "main "k15 "G 98 87 11 11 [nota 7]
   buttoncreate "main "k16 "A 110 87 11 11 [nota 9]
   buttoncreate "main "k17 "B 122 87 11 11 [nota 11]
   buttoncreate "main "k18 "C 134 87 11 11 [nota 12]

   groupboxcreate "main "gr3 5 107 173 63
   staticcreate "main "t8 "Predvajanje: 10 116 50 10
   buttoncreate "main "bplay "Začni 55 114 40 12 [recordplay]
   staticcreate "main "t9 "Hitrost: 10 134 50 10
   staticcreate "main "t10 "Glasnost: 10 144 50 10
   staticcreate "main "t11 "Inštrument: 10 157 50 10
   scrollbarcreate "main "bar4 50 134 90 10 [hitrost]
   scrollbarcreate "main "bar5 50 144 90 10 [glasnost]
   staticcreate "main "t12 [] 145 134 15 10
   staticcreate "main "t13 [] 145 144 15 10
   listboxcreate "main "foo 50 156 90 12
   buttoncreate "main "bins "Izberi 142 155 30 12 [inštrument]

   buttoncreate "main "bload "Odpri 10 175 45 12 [odpri]
   buttoncreate "main "bsave "Shrani 60 175 45 12 [shrani]
   buttoncreate "main "bend "Končaj 126 175 45 12 [midiclose keyboardoff windowdelete "main]

   listboxaddstring "foo [000 Acoustic Grand Piano]
   listboxaddstring "foo [001 Bright Acoustic Piano]
   listboxaddstring "foo [002 Electric Grand Piano]
   listboxaddstring "foo [003 Honky-tonk Piano]
   listboxaddstring "foo [004 Rhodes Piano]
   listboxaddstring "foo [005 Chorused Piano]
   listboxaddstring "foo [006 Harpsichord]
   listboxaddstring "foo [007 Clavinet]
   listboxaddstring "foo [008 Celesta]
   listboxaddstring "foo [009 Glockenspiel]
   listboxaddstring "foo [010 Music box]
   listboxaddstring "foo [011 Vibraphone]
   listboxaddstring "foo [012 Marimba]
   listboxaddstring "foo [013 Xylophone]
   listboxaddstring "foo [014 Tubular Bells]
   listboxaddstring "foo [015 Dulcimer]
   listboxaddstring "foo [016 Hammond Organ]
   listboxaddstring "foo [017 Percussive Organ]
   listboxaddstring "foo [018 Rock Organ]
   listboxaddstring "foo [019 Church Organ]
   listboxaddstring "foo [020 Reed Organ]
   listboxaddstring "foo [021 Accordian]
   listboxaddstring "foo [022 Harmonica]
   listboxaddstring "foo [023 Tango Accordian]
   listboxaddstring "foo [024 Acoustic Guitar (nylon)]
   listboxaddstring "foo [025 Acoustic Guitar (steel)]
   listboxaddstring "foo [026 Electric Guitar (jazz)]
   listboxaddstring "foo [027 Electric Guitar (clean)]
   listboxaddstring "foo [028 Electric Guitar (muted)]
   listboxaddstring "foo [029 Overdriven Guitar]
   listboxaddstring "foo [030 Distortion Guitar]
   listboxaddstring "foo [031 Guitar Harmonics]
   listboxaddstring "foo [032 Acoustic Bass]
   listboxaddstring "foo [033 Electric Bass (finger)]
   listboxaddstring "foo [034 Electric Bass (pick)]
   listboxaddstring "foo [035 Fretless Bass]
   listboxaddstring "foo [036 Slap Bass 1]
   listboxaddstring "foo [037 Slap Bass 2]
   listboxaddstring "foo [038 Synth Bass 1]
   listboxaddstring "foo [039 Synth Bass 2]
   listboxaddstring "foo [040 Violin]
   listboxaddstring "foo [041 Viola]
   listboxaddstring "foo [042 Cello]
   listboxaddstring "foo [043 Contrabass]
   listboxaddstring "foo [044 Tremolo Strings]
   listboxaddstring "foo [045 Pizzicato Strings]
   listboxaddstring "foo [046 Orchestral Harp]
   listboxaddstring "foo [047 Timpani]
   listboxaddstring "foo [048 String Ensemble 1]
   listboxaddstring "foo [049 String Ensemble 2]
   listboxaddstring "foo [050 Synth Strings 1]
   listboxaddstring "foo [051 Synth Strings 2]
   listboxaddstring "foo [052 Choir Aahs]
   listboxaddstring "foo [053 Voice Oohs]
   listboxaddstring "foo [054 Synth Voice]
   listboxaddstring "foo [055 Orchestra Hit]
   listboxaddstring "foo [056 Trumpet]
   listboxaddstring "foo [057 Trombone]
   listboxaddstring "foo [058 Tuba]
   listboxaddstring "foo [059 Muted Trumpet]
   listboxaddstring "foo [060 French Horn]
   listboxaddstring "foo [061 Brass Section]
   listboxaddstring "foo [062 Synth Brass 1]
   listboxaddstring "foo [063 Synth Brass 2]
   listboxaddstring "foo [064 Soprano Sax]
   listboxaddstring "foo [065 Alto Sax]
   listboxaddstring "foo [066 Tenor Sax]
   listboxaddstring "foo [067 Baritone Sax]
   listboxaddstring "foo [068 Oboe]
   listboxaddstring "foo [069 English Horn]
   listboxaddstring "foo [070 Bassoon]
   listboxaddstring "foo [071 Clarinet]
   listboxaddstring "foo [072 Piccolo]
   listboxaddstring "foo [073 Flute]
   listboxaddstring "foo [074 Recorder]
   listboxaddstring "foo [075 Pan Flute]
   listboxaddstring "foo [076 Bottle Blow]
   listboxaddstring "foo [077 Shakuhachi]
   listboxaddstring "foo [078 Whistle]
   listboxaddstring "foo [079 Ocarina]
   listboxaddstring "foo [080 Lead 1 (square)]
   listboxaddstring "foo [081 Lead 2 (sawtooth)]
   listboxaddstring "foo [082 Lead 3 (caliope lead)]
   listboxaddstring "foo [083 Lead 4 (chiff lead)]
   listboxaddstring "foo [084 Lead 5 (charang)]
   listboxaddstring "foo [085 Lead 6 (voice)]
   listboxaddstring "foo [086 Lead 7 (fifths)]
   listboxaddstring "foo [087 Lead 8 (brass + lead)]
   listboxaddstring "foo [088 Pad 1 (new age)]
   listboxaddstring "foo [089 Pad 2 (warm)]
   listboxaddstring "foo [090 Pad 3 (polysynth)]
   listboxaddstring "foo [091 Pad 4 (choir)]
   listboxaddstring "foo [092 Pad 5 (bowed)]
   listboxaddstring "foo [093 Pad 6 (metallic)]
   listboxaddstring "foo [094 Pad 7 (halo)]
   listboxaddstring "foo [095 Pad 8 (sweep)]
   listboxaddstring "foo [096 FX 1 (rain)]
   listboxaddstring "foo [097 FX 2 (soundtrack)]
   listboxaddstring "foo [098 FX 3 (crystal)]
   listboxaddstring "foo [099 FX 4 (atmosphere)]
   listboxaddstring "foo [100 FX 5 (brightness)]
   listboxaddstring "foo [101 FX 6 (goblins)]
   listboxaddstring "foo [102 FX 7 (echoes)]
   listboxaddstring "foo [103 FX 8 (sci-fi)]
   listboxaddstring "foo [104 Sitar]
   listboxaddstring "foo [105 Banjo]
   listboxaddstring "foo [106 Shamisen]
   listboxaddstring "foo [107 Koto]
   listboxaddstring "foo [108 Kalimba]
   listboxaddstring "foo [109 Bagpipe]
   listboxaddstring "foo [110 Fiddle]
   listboxaddstring "foo [111 Shanai]
   listboxaddstring "foo [112 Tinkle Bell]
   listboxaddstring "foo [113 Agogo]
   listboxaddstring "foo [114 Steel Drums]
   listboxaddstring "foo [115 Woodblock]
   listboxaddstring "foo [116 Taiko Drum]
   listboxaddstring "foo [117 Melodic Tom]
   listboxaddstring "foo [118 Synth Drum]
   listboxaddstring "foo [119 Reverse Cymbal]
   listboxaddstring "foo [120 Guitar Fret Noise]
   listboxaddstring "foo [121 Breath Noise]
   listboxaddstring "foo [122 Seashore]
   listboxaddstring "foo [123 Bird Tweet]
   listboxaddstring "foo [124 Telephone Ring]
   listboxaddstring "foo [125 Helicopter]
   listboxaddstring "foo [126 Applause]
   listboxaddstring "foo [127 Gunshot]

   scrollbarset "bar1 1 11 6
   scrollbarset "bar2 1 16 8
   scrollbarset "bar3 1 127 127
   scrollbarset "bar4 1 60 50
   scrollbarset "bar5 1 127 127

   oktava
   kanal
   jakost
   hitrost
   glasnost
   inštrument

   make "tabela array 256
   repeat 256 [setitem repcount :tabela -10]
   setitem 65  :tabela -4
   setitem 90  :tabela -3
   setitem 83  :tabela -2
   setitem 88  :tabela -1
   setitem 67  :tabela 0
   setitem 70  :tabela 1
   setitem 86  :tabela 2
   setitem 71  :tabela 3
   setitem 66  :tabela 4
   setitem 78  :tabela 5
   setitem 74  :tabela 6
   setitem 77  :tabela 7
   setitem 75  :tabela 8
   setitem 188 :tabela 9
   setitem 76  :tabela 10
   setitem 190 :tabela 11
   setitem 191 :tabela 12
   setitem 222 :tabela 13
   fokus
end

to oktava
   make "oktava scrollbarget "bar1
   staticupdate "t5 :oktava - 3
   make "oktava 12 * (:oktava - 1)
   fokus
end

to kanal
   make "kanal scrollbarget "bar2
   staticupdate "t6 :kanal
   fokus
end

to jakost
   make "jakost scrollbarget "bar3
   staticupdate "t7 :jakost
   fokus
end

to hitrost
   make "hitrost scrollbarget "bar4
   staticupdate "t12 :hitrost
   make "hitrost 60 - :hitrost
   fokus
end

to glasnost
   local "glasnost
   make "glasnost scrollbarget "bar5
   staticupdate "t13 :glasnost
   midimessage (list 176 + :kanal 7 :glasnost)
   fokus
end

to inštrument
   local "inštrument
   make "inštrument listboxgetselect "foo
   midimessage (list 192 + :kanal first :inštrument 0)
   fokus
end

to tipkaDol
   local "tipka make "tipka keyboardvalue
   local "nota make "nota item :tipka :tabela
   if not equalp :nota -10 [
      local "opis make "opis (list 144 + :kanal :oktava + :nota :jakost)
      midimessage :opis
      if :snemam [recordmessage :opis]
   ]
end

to tipkaGor
   local "tipka make "tipka keyboardvalue
   local "nota make "nota item :tipka :tabela
   if not equalp :nota -10 [
      local "opis make "opis (list 128 + :kanal :oktava + :nota :jakost)
      midimessage :opis
      if :snemam [recordmessage :opis]
   ]
end

to nota :n
   local "opis
   make "opis (list 144 + :kanal :oktava + :n :jakost)
   midimessage :opis
   if :snemam [recordmessage :opis]
   wait 10
   make "opis (list 128 + :kanal :oktava + :n :jakost)
   midimessage :opis
   if :snemam [recordmessage :opis]
   fokus
end

to recordmessage :opis
   make "skladba lput :opis :skladba
end

to recordstart
   if :snemam [messagebox "Napaka [Že snemam!] stop]
   make "snemam "true
   make "skladba []
   fokus
end

to recordstop
   if not :snemam [messagebox "Napaka [Saj nič ne smemam!] stop]
   make "snemam "false
   fokus
end

to recordplay
   if :snemam [messagebox "Napaka [Še vedno snemam!] stop]
   if emptyp :skladba [messagebox "Napaka [Nič ni posneto!] stop]
   repeat count :skladba [
      midimessage item repcount :skladba
      wait :hitrost
   ]
   fokus
end

to fokus
   setfocus [MSWLogo Screen]
end

to odpri
   local "datoteka make "datoteka dialogfileopen "*.midi
   if not emptyp :datoteka [
      make "datoteka first :datoteka
      openread :datoteka
      setread :datoteka
      make "skladba readlist
      setread []
      close :datoteka
   ]
end

to shrani
   if emptyp :skladba [messagebox "Napaka [Nič ni posneto!] stop]
   local "datoteka make "datoteka dialogfilesave "*.midi
   if not emptyp :datoteka [
      make "datoteka first :datoteka
      openwrite :datoteka
      setwrite :datoteka
      print :skladba
      setwrite []
      close :datoteka
   ]
end