Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Trouble with MidiSetEvent

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. 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

/* Read in numbers first */
 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

        /* TIME is 1:1:0 */


 /*if beatt = 0 or beatt//4 = 0  then do */
 
 /* Event type set type first onNote OffNote*/
   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   /* 384 clocks per beat for a 96 PPQN */
	midievent.!channel = 1
	midievent.!data1 = whatrate1        /* Note Number */
	midievent.!data2 = 64        /* Velocity */


	/* Insert it */
	errse = MIDISetEvent(TIME, midievent.!measure )
	IF errse = "" THEN SAY "ERROR: " errse

	/* An error? MIDISetEvent IF err = "" THEN SAY err */
	
	meas = meas + 1
	

END

err = MIDISaveFile("TestMIDI".txt)
IF err = "" THEN SAY "ERROR saving TestMIDI" err

SAY total
RETURN
Message2. Re: Trouble with MidiSetEvent(),
#2001
Posted by: Jeff Glatt 2003-11-02 04:09:38
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 • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥860.00 ·
 
 
¥900.00 ·
 
 
¥810.00 ·
 
 
¥317.00 ·
 
 
¥1,370.00 ·
 
 
¥660.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0