| Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 | 1. Trouble with MidiSetEvent #2000 Posted by: 2003-10-31 07:22:19 | Hi I'm new to MidiRexx but would like to learn, what I'm doing is taking numbers from a text file reading them in with CharIn() that works fine, but what I'm having trouble with is the syntax of MidiSetEvent(), do I have to go through and set one event at a time like "On Note" and then Time and then Channel, can't one set them all at the same time. I also realize maybe I have to set Time Signature first but anyways if anybody could help me get started it would be great.
Well here's the whole script:LIBRARY rxmidi
errof = MIDIOpenFile()
IF errof = "" THEN SAY "ERROR creating new MIDI file:" err
meas = 0
beatt = 0
clck = 0
total = CHARS("GR.txt")
DO total
whatrate1 = CHARIN("GR.txt")
IF whatrate1 = 1 THEN whatrate1 = "c"
IF whatrate1 = 3 THEN whatrate1 = "d"
IF whatrate1 = 5 THEN whatrate1 = "e"
IF whatrate1 = 6 THEN whatrate1 = "f"
IF whatrate1 = 8 THEN whatrate1 = "g"
IF whatrate1 = 10 THEN whatrate1 = "a"
IF whatrate1 = 9 THEN whatrate1 = "b"
IF whatrate1 = 2 THEN whatrate1 = "d"
IF whatrate1 = 4 THEN whatrate1 = "e"
IF whatrate1 = 7 THEN whatrate1 = "g"
midievent.!type = 'On Note'
IF meas//4 = 0 THEN
midievent.!measure = meas + 1
ELSE IF meas//4 = 0 THEN midievent.!measure = meas
IF beatt < 4 THEN beatt = beatt + 1 ELSE beatt = 1
IF clck > 1 & clck < 384 THEN clck = clck + 96 ELSE clck = 0
midievent.!beat = beatt
midievent.!clock = clck
midievent.!channel = 1
midievent.!data1 = whatrate1
midievent.!data2 = 64
errse = MIDISetEvent(TIME, midievent.!measure )
IF errse = "" THEN SAY "ERROR: " errse
meas = meas + 1
END
err = MIDISaveFile("TestMIDI".txt)
IF err = "" THEN SAY "ERROR saving TestMIDI" err
SAY total
RETURN | 2. Re: Trouble with MidiSetEvent(), #2001 | You do have to set one event at a time, but you can set all of the properties for it with one call (ie, Time, MIDI channel, and the MIDI data, which for a note-on event would be the note number and velocity). The first arg to MidiSetEvent() is the options, and that's where you tell which property(s) you wish to set. For example, to set the TIME, channel, and MIDI data simultaneously with one call, you need to specify 'TIME|CHAN|DATA' (and if you're inserting a new event, add 'INS' to that too). So MidiSetEvent allows set only whichever properties you want.
I think you want your call to be (and note the quotes, just for safety):
errSE = MIDISetEvent('TIME|CHAN|DATA|INS') | Forum List • Thread List • Refresh • New Topic • Search • Previous • Next 1 |
|
|