Guidance
指路人
g.yi.org
Software / Reginald / Examples / rxmidi examples / chngchan.rex

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
/* Changes all events upon MIDI channel 1 to MIDI channel 10.
 */

OPTIONS "C_CALL LABELCHECK NOSOURCE"

/* Add the REXX GUI and RxMidi functions. */
LIBRARY rexxgui, rxmidi

/* Trap errors in RxMidi functions. So, we don't have to check the return values
 * from MIDI REXX functions that set the ERROR condition, such as MIDISetEvent().
 */
midierr = "ERROR"
midiheading = 1

/* Print an introduction. */
IF guisay('This script changes all events upon MIDI channel 1 to MIDI channel 10. Proceed?', 'YES|INFO', 'New MIDI') \= 'YES' THEN SIGNAL out

/* Check if we have a MIDI file name. We get the filename from
 * the command line (ie, the user typed it after disasm.rex), or
 * if not supplied, we bring up the file dialog.
 */
IF ARG() < 1 THEN DO
	ERROR = guifile('FromFilename', 'EXISTING', 'Enter a name for the new MIDI file', 'MIDI files (*.mid, *.rmi) | *.mid;*.rmi | All files (*.*) | *.*')
	IF ERROR \== "" THEN RETURN
END
ELSE fromfilename = ARG(1)

DO
	/* Open a MIDI file */
	MIDIOpenFile(fromfilename)

	/* Move to the start of the next track */
	DO WHILE MIDITrack("") \= 0

		/* For each Voice category event in this track on channel 1 or 10... */
		DO WHILE MIDIGetEvent('On N|Off |(Off|Afte|Cont|Prog|Poly|Pitc', '1|10') == ""

			/* Is it on channel 10? Switch to 1 */
			IF midievent.!channel == 10 THEN midievent.!channel = 1

			/* Switch 1 to 10 */
			ELSE midievent.!channel = 10

			MIDISetEvent('CHAN')

		END /* DO WHILE MIDIGetEvent */

	END /* DO UNTIL MIDITrack */

	/* Save to a MIDI file with an underscore prepended to the name */
	NAME = FILESPEC('N', fromfilename)
	PATH = LEFT(fromfilename, LENGTH(fromfilename) - LENGTH(name))
	MIDISaveFile(PATH || '_' || name)

	CATCH ERROR
		CONDITION('M')
END
RETURN
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Tue 2017-9-26  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:49:22