예제 #1
0
/* ------------------------------------------------------------------------- */
static char * DatasToText(MidiEvPtr e , char *buff)
{
	char *ptr= buff;
	int i, max;

	*ptr= 0;
	switch (EvType(e)) {
		case typeTextual:
		case typeCopyright:
		case typeSeqName:
		case typeInstrName:
		case typeLyric:
		case typeMarker:
		case typeCuePoint:
			for( i=0, max= min(MidiCountFields(e), 18); i< max; i++)
				*ptr++= (char)MidiGetField(e, i);
			*ptr= 0;
			break;
		case typeSMPTEOffset:
			for( i=0; i< 6; i++, ptr+=3) 
				sprintf( ptr, "%-2ld ", MidiGetField(e, i));
			break;
		default:
			for( i=0, max= min(MidiCountFields(e), 5); i< max; i++, ptr+=4)
				sprintf( ptr, "%-3ld ", MidiGetField(e, i));
	}
	return buff;
}
예제 #2
0
//_________________________________________________________
static void SendSysEx(SlotPtr slot, MidiEvPtr e)
{
	slot->remaining = (EvType(e) == typeSysEx) ? (MidiCountFields(e)+2) : MidiCountFields(e);
	
	// Write event to be sent
	MidiStreamPutEvent (&slot->outsysex, e);
	SendSysExAux(slot);
}
예제 #3
0
static void LinearizeVarLen (MidiEvPtr e, Ev2UDPStreamPtr f)
{
	MidiSEXPtr	last, first; long len;
	
	len = MidiCountFields(e) + kCommonSize - kLenSize;
	last = e->info.linkSE;
	first = last->link;
	last->link = 0;
	if (first == last) {
		int i = 0, j = first->data[11];
		f->count = kCommonSize + j;
		LinearizeVarLenCommon (f->count, (short)len, e, f);
		while(j>0) f->data[j--] = first->data[i++];
	} else {
		int i = 0, j = 12;
		f->count = kCommonSize + 12;
		LinearizeVarLenCommon (f->count, (short)len, e, f);
		while(j>0) f->data[j--] = first->data[i++];
		f->nextCell = first->link;
		f->cont = VarLenContinuation;
	}
	MidiFreeCell (e);	
	MidiFreeCell ((MidiEvPtr)first);	
}
예제 #4
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);
    }
}