I am trying to append a (musical) note of type Note to a sequence, which is a Vector of type Note. When i is 1, the result is:
sequence: Note[Note(0x00000002, 0x5d, 0x38, 0x0000000d, 0x40)]
which is correct. When i = 2, makeRndNote produces a new note but the result:
sequence: Note[Note(0x00000005, 0x2b, 0x54, 0x0000000b, 0x40), Note(0x00000005, 0x2b, 0x54, 0x0000000b, 0x40)]
is 2 instances of only the second set of values, i.e.: [second note, second note], not [first note, second note]
I’d sure appreciate a solution!
Don
===============================================================================
include(“/home/das/Development/julia/include/MIDIcodes.jl”)
include(“/home/das/Development/julia/include/stddef.jl”)
mutable struct Note
delta::UInt32 # time until event occurs
pitch::UInt8 # middle C = 60
velocity::UInt8 # mf = 60
duration::UInt32
panposition::UInt8
end
function makeRndNote(note::Note, delta)
note.delta = delta
note.pitch = rand(1:(MAXNOTE - MINNOTE)) + MINNOTE
note.velocity = rand(1:(MAXVELOCITY - MINVELOCITY)) + MINVELOCITY
note.duration = rand(1:(MAXDELTA - MINDELTA)) + MINDELTA
note.panposition = CENTERPAN
end
function main()
note = Note(MINDELTA, MIDDLEC, MINVELOCITY, QUARTERNOTE, CENTERPAN)
sequence = Note[]
for i in 1:2
delta = rand(1:(MAXDELTA - MINDELTA))
makeRndNote(note, delta)
push!(sequence, note)
println("\nsequence: ", sequence)
end
end
main()