예제 #1
0
/* ------------------------------------------------------------------------- */
void DisplayTask (short ref)
{
	long n;

	n= MidiCountEvs(ref);
	while (n > 16) {
		MidiFreeEv (MidiGetEv (ref));
		n--;
	}
	while (n--) {
		Display (MidiGetEv (ref));
	}
}
예제 #2
0
//_______________________________________________________________________
static void RcvAlarm (short refNum)
{
	DrvMemPtr mem = GetData ();
	Ev2StreamPtr f = &mem->outFifo;
	MidiEvPtr off, e = MidiGetEv (refNum);
	Byte c;
	
	while (e) {
		off = MidiStreamPutEvent (f, e);
		while (MidiStreamGetByte (f, &c)) {
			write (mem->devId, &c, 1);
		}
		if (off) MidiTask (KeyOffTask, Date(off), refNum, (long)off, (long)mem, 0);
		e = MidiGetEv (refNum);
	}
}
예제 #3
0
static void rcv_alarm (short refnum)
{
	MidiEvPtr e = MidiGetEv (refnum);
	while (e) {
		switch (EvType(e)) {
			case typeStart:	start(TRUE);
				break;
			case typeStop:	stop(TRUE);
				break;
			case typeReset:	reset();
				break;
		}
		MidiFreeEv (e);
		e = MidiGetEv (refnum);
	}
}
예제 #4
0
MSALARMAPI void RecRcv (short ref)
{
        TSequencer * s;
        MidiEvPtr e;
        
        s = (TSequencer *) MidiGetInfo(ref);
        while (e = MidiGetEv(ref)) MidiAddSeq(s->seq, e);
}
예제 #5
0
 void record (short aRefNum)
{
        MidiEvPtr e;
        
        while (e = MidiGetEv(aRefNum)) {
                MidiSendIm(aRefNum, MidiCopyEv(e)); // Remove this line if you don't want to thru events
                MidiAddSeq(ourSequence,e);
        }
}
예제 #6
0
/*____________________________________________________________________*/
static MidiEvPtr GetReceived(void)
{
	long n;
	
	if( (n= MidiCountEvs( refNum)) > 1) {
		print ("\nwarning: %ld evts recus\n", n);
		MidiFlushEvs( refNum);
		return 0;
	}
	return MidiGetEv( refNum);
}
예제 #7
0
//_________________________________________________________
void SendEvents1 (short refNum)
{
	SlotPtr slot = 0;
	MidiEvPtr e;
	
	while ((e = MidiGetEv (refNum))) {
		if (!slot || (Slot(slot->refNum) != Port(e)))
			slot = FindSlot(gOutSlots, Port(e));
		if (slot) {
			if (!MS2MM (refNum, slot, e)) return; 
		}else{
			MidiFreeEv(e);
		}
	}
}
예제 #8
0
 void transposeAndDelay (short aRefNum)
{
        MidiEvPtr e;
        
        while (e = MidiGetEv(aRefNum)) {
                switch (EvType(e)) {
                        case typeNote:
                        case typeKeyOn:
                        case typeKeyOff:
                                MidiSetField(e, 0, 7 + MidiGetField(e,0));      // transpose pitch + 7
                                Date(e) += 1000;                                // delay 1000 ms
                                MidiSend(aRefNum, e);
                                break;
                        default:
                                MidiFreeEv(e);
                }
        }
}
예제 #9
0
//_________________________________________________________
void SendEvents2 (short refNum)
{
	SlotPtr slot = 0;
	MidiEvPtr e;
	
	while ((e = MidiGetEv (refNum))) {
		if (!slot || (Slot(slot->refNum) != Port(e)))
			slot = FindSlot(gOutSlots, Port(e));
		if (slot) {
			if (!MS2MM (refNum, slot, e)) return;  // A SysEx is sent 
		}else{
			MidiFreeEv(e);
		}
	}
	
	MidiSetRcvAlarm(refNum,RcvAlarm);
	MidiSendIm(refNum, MidiNewEv(typeRestart));
}
	void MidiInputDeviceMidiShare::ReceiveEvents(short ref)
	{
		MidiInputDeviceMidiShare* driver = (MidiInputDeviceMidiShare*)MidiGetInfo(ref);
		MidiEvPtr ev;
		
		while ((ev = MidiGetEv(ref)))
		
			switch(EvType(ev)) { 
			
				case typeCtrlChange:
					if (MidiGetField(ev,0) == 0)
						driver->DispatchBankSelectMsb(MidiGetField(ev,0),Chan(ev));
					else if (MidiGetField(ev,0) == 32)
						driver->DispatchBankSelectLsb(MidiGetField(ev,0),Chan(ev));
					else
						driver->DispatchControlChange(MidiGetField(ev,0),MidiGetField(ev,0),Chan(ev));
					MidiFreeEv(ev);
					break;
					
				case typePitchWheel:
					driver->DispatchPitchbend(((MidiGetField(ev,0)+(MidiGetField(ev,1) << 7)) - 8192),Chan(ev));
					MidiFreeEv(ev);
					break;
					
				case typeNote:
					driver->DispatchNoteOn(Pitch(ev),Vel(ev),Chan(ev));
					MidiTask(KeyOffTask,Date(ev)+Dur(ev),ref,(long)ev,0,0);
					break;

				case typeKeyOn:
					if (Vel(ev) > 0)
						driver->DispatchNoteOn(Pitch(ev),Vel(ev),Chan(ev));
					else
						driver->DispatchNoteOff(Pitch(ev),Vel(ev),Chan(ev));
					MidiFreeEv(ev);
					break;
				
				case typeKeyOff:
					driver->DispatchNoteOff(Pitch(ev),Vel(ev),Chan(ev));
					MidiFreeEv(ev);
					break;
			}
		}
예제 #11
0
/* --------------------------------------------------------
Application receive alarm 
-------------------------------------------------------- */
void MSALARMAPI ReceiveEvents ( short r)
{
  MidiEvPtr e;
  unsigned long d;
  
  while (e = MidiGetEv(r)) {
         d = Date(e) + MSParam[kDelay];
         if ( (MSParam[kChan]!=0) && (MSParam[kChan]!=Chan(e)+1) )
                MidiFreeEv(e);
         else if ( EvType(e) == typeNote ) {
                if( !MidiTask(EchoTask,d,r,(long)e,0,0))
                        MidiFreeEv(e);
         }
         else if ( Vel(e) > 0 )  {
	        EvType(e) = typeNote;
                Dur(e) = 100;
                if( !MidiTask(EchoTask,d,r,(long)e,0,0))
                        MidiFreeEv(e);
         }
         else MidiFreeEv(e);
  }
}
예제 #12
0
void thru (short aRefNum)
{
        MidiEvPtr e;
        
        while (e = MidiGetEv(aRefNum)) MidiSend(aRefNum, e);
}
예제 #13
0
/*
 * fluid_midishare_midi_driver_receive
 */
static void fluid_midishare_midi_driver_receive(short ref)
{
    fluid_midishare_midi_driver_t* dev = (fluid_midishare_midi_driver_t*)MidiGetInfo(ref);
    fluid_midi_event_t new_event;
    MidiEvPtr e;
    int count, i;

    while ((e = MidiGetEv (ref)))
    {
        switch (EvType (e))
        {
        case typeNote:
            /* Copy the data to fluid_midi_event_t */
            fluid_midi_event_set_type(&new_event, NOTE_ON);
            fluid_midi_event_set_channel(&new_event, Chan(e));
            fluid_midi_event_set_pitch(&new_event, Pitch(e));
            fluid_midi_event_set_velocity(&new_event, Vel(e));

            /* and send it on its way to the router */
            (*dev->driver.handler)(dev->driver.data, &new_event);

#if defined(MACINTOSH) && defined(MACOS9)
            MidiTask(dev->upp_task_ptr, MidiGetTime()+Dur(e), ref, (long)e, 0, 0);
#else
            MidiTask(fluid_midishare_keyoff_task, MidiGetTime()+Dur(e), ref, (long)e, 0, 0);
#endif

            /* e gets freed in fluid_midishare_keyoff_task */
            continue;

        case typeKeyOn:
            /* Copy the data to fluid_midi_event_t */
            fluid_midi_event_set_type(&new_event, NOTE_ON);
            fluid_midi_event_set_channel(&new_event, Chan(e));
            fluid_midi_event_set_pitch(&new_event, Pitch(e));
            fluid_midi_event_set_velocity(&new_event, Vel(e));
            break;

        case typeKeyOff:
            /* Copy the data to fluid_midi_event_t */
            fluid_midi_event_set_type(&new_event, NOTE_OFF);
            fluid_midi_event_set_channel(&new_event, Chan(e));
            fluid_midi_event_set_pitch(&new_event, Pitch(e));
            fluid_midi_event_set_velocity(&new_event, Vel(e)); /* release vel */
            break;

        case typeCtrlChange:
            /* Copy the data to fluid_midi_event_t */
            fluid_midi_event_set_type(&new_event, CONTROL_CHANGE);
            fluid_midi_event_set_channel(&new_event, Chan(e));
            fluid_midi_event_set_control(&new_event, MidiGetField(e,0));
            fluid_midi_event_set_value(&new_event, MidiGetField(e,1));
            break;

        case typeProgChange:
            /* Copy the data to fluid_midi_event_t */
            fluid_midi_event_set_type(&new_event, PROGRAM_CHANGE);
            fluid_midi_event_set_channel(&new_event, Chan(e));
            fluid_midi_event_set_program(&new_event, MidiGetField(e,0));
            break;

        case typePitchWheel:
            /* Copy the data to fluid_midi_event_t */
            fluid_midi_event_set_type(&new_event, PITCH_BEND);
            fluid_midi_event_set_channel(&new_event, Chan(e));
            fluid_midi_event_set_value(&new_event, ((MidiGetField(e,0)
                                                    + (MidiGetField(e,1) << 7))
                                                    - 8192));
            break;

        case typeSysEx:
            count = MidiCountFields (e);

            /* Discard empty or too large SYSEX messages */
            if (count == 0 || count > FLUID_MIDI_PARSER_MAX_DATA_SIZE)
            {
                MidiFreeEv (e);
                continue;
            }

            /* Copy SYSEX data, one byte at a time */
            for (i = 0; i < count; i++)
                dev->sysexbuf[i] = MidiGetField (e, i);

            fluid_midi_event_set_sysex (&new_event, dev->sysexbuf, count, FALSE);
            break;

        default:
            MidiFreeEv (e);
            continue;
        }

        MidiFreeEv (e);

        /* Send the MIDI event */
        (*dev->driver.handler)(dev->driver.data, &new_event);
    }
}
예제 #14
0
MSALARMAPI void NullRcv (short ref)
{
        MidiEvPtr e;
        while (e = MidiGetEv(ref)) MidiFreeEv(e);
}