Exemple #1
0
/*__________________________________________________________________________________*/
static void SetFSmallEv( MidiEvPtr e, unsigned long f, long v)
{
	if( f< 2)
		Data(e)[f]= (Byte)v;
	else if( f== 2)
		Dur(e)=(unsigned short)v;
}
long DurSeq(MidiSeqPtr s) 
{
        long            dur = 0; 
        MidiEvPtr       e = Last(s);
		
		if (e) {
			dur = Date(e);
			if (EvType(e) == typeNote) dur+=Dur(e);
        }
        return dur;
}
/*===========================================================================
		 external functions implementation
  =========================================================================== */
MidiEvPtr MidiStreamPutEvent (Ev2StreamPtr f, MidiEvPtr e)
{
	if (f->count)  return e;
	if (EvType(e) == typeNote) {
		(f->lin[EvType(e)]) (e, f);
		EvType(e) = typeKeyOn;
		Vel(e) = 0;
		Date(e) += Dur(e);
		return e;
	}
	(f->lin[EvType(e)]) (e, f);
	return 0;
}
static pascal void AccProcess(long d, short refNum, long a1, long a2, long a3)
{
  short i;
  for (i = 0; i <= 15; i++) {
    MidiEvPtr e = MidiNewEv(typeNote);
    if (e) {
      Pitch(e) = 60;
      Vel(e) = 80;
      Dur(e) = 16;
      Chan(e) = i;
    }
    MidiSend (refNum, e);
  }
  MidiTask (AccProcess, d + 32, refNum, a1, a2, a3);
}
Exemple #5
0
string MuNote::CsString(void)
{
	string cs_string;
	char buff[10];
	MuParamBlock pBlock;
	float paramVal = 0;
	short numberOfParams = 0;
	MuError err(MuERROR_NONE);
	
	cs_string += "i";
	sprintf(buff,"%d",Instr());
	cs_string += buff;
	cs_string += "\t";
	sprintf(buff,"%.3f",Start());
	cs_string += buff;
	cs_string += "\t";
	sprintf(buff,"%.3f",Dur());
	cs_string += buff;
	cs_string += "\t";
	cs_string +=  PitchString();
	cs_string += "\t\t";
	sprintf(buff,"%.3f",Amp());
	cs_string += buff;
	cs_string += "\t";
	
	pBlock = Params();
	numberOfParams = pBlock.Num();
	if( numberOfParams != 0)
	{
		for(short k = 0; k < numberOfParams; k++)
		{
			err = pBlock.Val(k, &paramVal);
			if(err.Get() != MuERROR_NONE)
				cout << err.Message();
			else
			{
				sprintf(buff,"%.3f",paramVal);
				cs_string += buff;
				cs_string += "\t";
			}
		}
	}
	
	return cs_string;
}
	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;
			}
		}
Exemple #7
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);
  }
}
Exemple #8
0
void Dur6(GtkAction *action, gpointer param) {
  Dur(6);
}
//_____________________________________________________________________________
static MidiEvPtr rcv2Bytes1Short (UDPStreamPtr f, Byte c)
{
	f->shortDst = (short *)&Dur(f->ptrCur);
	f->next = rcvShortHigh;
	return rcv2Bytes (f, c);
}
Exemple #10
0
/*__________________________________________________________________________________*/
static long GetFSmallEv( MidiEvPtr e, unsigned long f)
{
	return (f < 2) ? Data(e)[f] : Dur(e);
}
Exemple #11
0
void Dur1(GtkAction *action, gpointer param) {
  Dur(1);
}
Exemple #12
0
void Dur0(GtkAction *action, gpointer param) {
  Dur(0);
}
Exemple #13
0
void Dur2(GtkAction *action, gpointer param) {
  Dur(2);
}
/*
 * 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);
    }
}
Exemple #15
0
void Dur8(GtkAction *action, gpointer param) {
  Dur(8);
}
Exemple #16
0
void Dur7(GtkAction *action, gpointer param) {
  Dur(7);
}
Exemple #17
0
void Dur3(GtkAction *action, gpointer param) {
  Dur(3);
}
Exemple #18
0
void Dur5(GtkAction *action, gpointer param) {
  Dur(5);
}
Exemple #19
0
void Dur4(GtkAction *action, gpointer param) {
  Dur(4);
}