Music MakerV2.1MarioS

Modification of last week's program.

A0- Variable input (Tempo)

A1- Sync Output

A2- Sync Input

A3- Speaker Bit

;Bits-Musical Standard
;Defines Musical Note lengths and Pitchs
;Options may be added later (Tempo,Tones,Glissando,Init Duet)
;V2.1 w/ equitempered beeps, working duet, variable tempo, new rest function
;Tommy Engdahl

;----Init port A2,3(or more) for digital output (PowerUp) and A2 for duet input, A0 analog----

include ad.lib

to Powerup
        config-analog-lines 1
        clearbit 3 porta-ddr
        clearbit 3 porta
        clearbit 1 porta-ddr
        clearbit 1 porta
        setbit 2 porta-ddr
wait 100
flash
;startup       ;add this for master
loop [if (testbit 2 porta) [startup]]
end

;----Tuning for Musical Notation----            
constants [[g6 9][fs6 10][f6 11][w6 12][ds6 13][d6 14][cs6 15][c6 16]]
constants [[b5 17][as5 19][a5 20][gs5 22][g5 24][fs5 25][f5 27][w5 29][ds5 31][d5 33][cs5 35][c5 38]]
constants [[b4 41][as4 43][a4 46][gs4 49][g4 53][fs4 56][f4 59][w4 64][ds4 68][d4 72][cs4 76][c4 81]]
constants [[b3 86][as3 92][a3 98][gs3 104][g3 110][fs3 117][f3 125][w3 132][ds3 140][d3 148][cs3 158][c3 168]]
constants [[b2 179][as2 189][a2 200][gs2 212][g2 226]]

global [ tone ]
global [ pitch ]
global [ duration ]
global [ time1 ]
global [ tempo ] ;factor on all time variables
;tempo = 20 =125bpm

to tick         ;fundamental sound
clearbit 3 porta
setbit 3 porta
end

;----Duet Algorithm---- 
to duet                ;trigger starts a duet
        
;       setbit 1 porta
end
                        ;listens to start duet
if (testbit 2 porta) [startup]

to sync
clearbit 1 porta
loop [if (not testbit 2 porta)[setbit 1 porta stop]]
end

to rest :duration ;1 beat = rest 24
settempo ((read-ad 0) / 10) + 1
settime1 :duration * tempo
mwait time1
end

;----Note----
to Note :Pitch :Duration   ; :tone might add more but will need new tuning
setduration 1000 / :pitch
repeat :duration 
        [ tick 
                repeat :pitch [no-op]
        ]
end

:-------------Mario Part 1---------------
to startup   ;insert song here
;staccato method :uniform beeps with rests for note duration
;note # #       rest/duration           
setbit 1 porta
intro
sync
;-----------------------------
part1
sync
;-----------------------------
repeat 2[
rest 12
note g4 10      rest 6
note fs4 10     rest 6
note f4 10      rest 6
note ds4 10     rest 12
note w4 10      rest 12
note gs3 5      rest 6
note a3 5       rest 6
note c4 10      rest 12
note a3 5       rest 6
note c4 10      rest 6
note d4 10      rest 18

note g4 10      rest 6
note fs4 10     rest 6
note f4 10      rest 6
note ds4 10     rest 12
note w4 10      rest 12
note c5 20      rest 12
note c5 20      rest 6
note c5 20      rest 36
sync
note g4 10      rest 6
note fs4 10     rest 6
note f4 10      rest 6
note ds4 10     rest 12
note w4 10      rest 12
note gs3 5      rest 6
note a3 5       rest 6
note c4 10      rest 12
note a3 5       rest 6
note c4 10      rest 6
note d4 10      rest 18

note ds4 10     rest 18
note d4 10      rest 18
note c4 10      rest 48
sync
]
;----------------------------
part3
sync
;-----------------------------
part1
sync
;---------------------------
part4
sync
;--------------------------
part3
sync
;--------------------------1/2 part 4
note w4 10      rest 6
note c4 10      rest 12
note g3 5       rest 18
note gs3 5      rest 12
note a3 5       rest 6
note f4 10      rest 12
note f4 10      rest 6
note a3 5       rest 24

note b3 5       rest 9
note a4 10      rest 9
note a4 10      rest 6
note a4 10      rest 9
note g4 10      rest 9
note f4 10      rest 6
note w4 10      rest 6
note c4 10      rest 12
note a3 5       rest 6
note g3 5       rest 24

note w4 10      rest 6
note c4 10      rest 12
note g3 5       rest 18
note gs3 5      rest 12
note a3 5       rest 6
note f4 10      rest 12
note f4 10      rest 6
note a3 5       rest 24

note b3 5       rest 6
note f4 10      rest 12
note f4 10      rest 6
note f4 10      rest 9
note w4 10      rest 9
note d4 10      rest 6
note c4 10      rest 48
sync
;---------------------------

end


to intro
note w4 10      rest 6
note w4 10      rest 12
note w4 10      rest 12
note c4 10      rest 6
note w4 10      rest 12
note g4 10      rest 48
end

to part1
repeat 2[
note c4 10      rest 18
note g3 5       rest 18
note w3 5       rest 18
note a3 5       rest 12
note b3 5       rest 12
note as3 5      rest 6
note a3 5       rest 12

note g3 5       rest 9
note w4 10      rest 9
note g4 10      rest 6
note a4 10      rest 12
note f4 10      rest 6
note g4 10      rest 12
note w4 10      rest 12
note c4 10      rest 6
note d4 10      rest 6
note b3 5       rest 18
sync
]

end

to part2
repeat 2[
rest 12
note g4 10      rest 6
note fs4 10     rest 6
note f4 10      rest 6
note ds4 10     rest 12
note w4 10      rest 12
note gs3 5      rest 6
note a3 5       rest 6
note c4 10      rest 12
note a3 5       rest 6
note c4 10      rest 6
note d4 10      rest 18

note g4 10      rest 6
note fs4 10     rest 6
note f4 10      rest 6
note ds4 10     rest 12
note w4 10      rest 12
note c5 20      rest 12
note c5 20      rest 6
note c5 20      rest 36
sync
note g4 10      rest 6
note fs4 10     rest 6
note f4 10      rest 6
note ds4 10     rest 12
note w4 10      rest 12
note gs3 5      rest 6
note a3 5       rest 6
note c4 10      rest 12
note a3 5       rest 6
note c4 10      rest 6
note d4 10      rest 18

note ds4 10     rest 18
note d4 10      rest 18
note c4 10      rest 48
sync
]
end

to part3
note c4 10      rest 6
note c4 10      rest 12
note c4 10      rest 12
note c4 10      rest 6
note d4 10      rest 12
note w4 10      rest 6
note c4 10      rest 12
note a3 5       rest 6
note g3 5       rest 24

note c4 10      rest 6
note c4 10      rest 12
note c4 10      rest 12
note c4 10      rest 6
note d4 10      rest 6
note w4 10      rest 54
sync
note c4 10      rest 6
note c4 10      rest 12
note c4 10      rest 12
note c4 10      rest 6
note d4 10      rest 12
note w4 10      rest 6
note c4 10      rest 12
note a3 5       rest 6
note g3 5       rest 24

note w4 10      rest 6
note w4 10      rest 12
note w4 10      rest 12
note c4 10      rest 6
note w4 10      rest 12
note g4 10      rest 48
end

to part4
repeat 2[
note w4 10      rest 6
note c4 10      rest 12
note g3 5       rest 18
note gs3 5      rest 12
note a3 5       rest 6
note f4 10      rest 12
note f4 10      rest 6
note a3 5       rest 24

note b3 5       rest 9
note a4 10      rest 9
note a4 10      rest 6
note a4 10      rest 9
note g4 10      rest 9
note f4 10      rest 6
note w4 10      rest 6
note c4 10      rest 12
note a3 5       rest 6
note g3 5       rest 24

note w4 10      rest 6
note c4 10      rest 12
note g3 5       rest 18
note gs3 5      rest 12
note a3 5       rest 6
note f4 10      rest 12
note f4 10      rest 6
note a3 5       rest 24

note b3 5       rest 6
note f4 10      rest 12
note f4 10      rest 6
note f4 10      rest 9
note w4 10      rest 9
note d4 10      rest 6
note c4 10      rest 48
sync
]
end

TASD2007/Thing 4/Programs/ThomasEngdahl/Music MakerV2.1 (last edited 2007-02-18 19:19:43 by ThomasEngdahl)