예제 #1
0
/**
 * MIDI event callback function to display event information to stdout
 * @param data MIDI router instance
 * @param event MIDI event data
 * @return #FLUID_OK on success, #FLUID_FAILED otherwise
 *
 * An implementation of the #handle_midi_event_func_t function type, used for
 * displaying MIDI event information between the MIDI driver and router to
 * stdout.  Useful for adding into a MIDI router chain for debugging MIDI events.
 */
int fluid_midi_dump_postrouter(void* data, fluid_midi_event_t* event)
{
  switch (event->type) {
      case NOTE_ON:
	fprintf(stdout, "event_post_noteon %i %i %i\n",
		event->channel, event->param1, event->param2);
	break;
      case NOTE_OFF:
	fprintf(stdout, "event_post_noteoff %i %i %i\n",
		event->channel, event->param1, event->param2);
	break;
      case CONTROL_CHANGE:
	fprintf(stdout, "event_post_cc %i %i %i\n",
		event->channel, event->param1, event->param2);
	break;
      case PROGRAM_CHANGE:
	fprintf(stdout, "event_post_prog %i %i\n", event->channel, event->param1);
	break;
      case PITCH_BEND:
	fprintf(stdout, "event_post_pitch %i %i\n", event->channel, event->param1);
	break;
      case CHANNEL_PRESSURE:
	fprintf(stdout, "event_post_cpress %i %i\n", event->channel, event->param1);
	break;
      case KEY_PRESSURE:
	fprintf(stdout, "event_post_kpress %i %i %i\n",
		event->channel, event->param1, event->param2);
	break;
      default:
	break;
  }
  return fluid_synth_handle_midi_event((fluid_synth_t*) data, event);
}
예제 #2
0
int midi_event_callback(void* data, fluid_midi_event_t* event)
{

	int track_num = (vgmtrans_fluid_midi_event_get_track((vgmtrans_fluid_midi_event_t*)event))->num;
    int chan = fluid_midi_event_get_channel(event);
    int new_chan = ((track_num / 15) * 16) + chan;
    fluid_midi_event_set_channel(event, new_chan);

	return fluid_synth_handle_midi_event(data, event);
}
/**
 * This MIDI event callback filters out the TEXT and LYRIC events
 * and passes the rest to the default event handler.
 * Here we just print the text of the event, more
 * complex handling can be done
 */
int event_callback(void *data, fluid_midi_event_t *event) {
    fluid_synth_t* synth = (fluid_synth_t*) data;
    int type = fluid_midi_event_get_type(event);
    int chan = fluid_midi_event_get_channel(event);
    if (synth == NULL) printf("Synth is null\n");
    switch(type) {
    case MIDI_TEXT:
	printf("Callback: Playing text event %s (length %d)\n", event->paramptr, event->param1);
	return  FLUID_OK;

    case MIDI_LYRIC:
	printf("Callback: Playing lyric event %d %s\n", event->param1, event->paramptr);
	return  FLUID_OK;
    }
    return fluid_synth_handle_midi_event( data, event);
}
예제 #4
0
/*
 * fluid_track_send_events
 */
int
fluid_track_send_events(fluid_track_t* track,
			fluid_synth_t* synth,
			fluid_player_t* player,
			unsigned int ticks)
{
	int status = FLUID_OK;
	fluid_midi_event_t* event;

	while (1) {

		event = track->cur;
		if (event == NULL) {
			return status;
		}

/* 		printf("track=%02d\tticks=%05u\ttrack=%05u\tdtime=%05u\tnext=%05u\n", */
/* 		       track->num, */
/* 		       ticks, */
/* 		       track->ticks, */
/* 		       event->dtime, */
/* 		       track->ticks + event->dtime); */

		if (track->ticks + event->dtime > ticks) {
			return status;
		}


		track->ticks += event->dtime;

               if (player && player->user_callback)
                       (*player->user_callback)(player->user_data, event);


		if (event->type != MIDI_SET_TEMPO)
			fluid_synth_handle_midi_event (synth, event);
		else if (player) fluid_player_set_midi_tempo (player, event->param1);

		fluid_track_next_event(track);

	}
	return status;
}
/*
 * Class:     org_tritonus_midi_device_fluidsynth_FluidSynthesizer
 * Method:    nReceive
 * Signature: (IIII)V
 */
JNIEXPORT void JNICALL Java_org_tritonus_midi_device_fluidsynth_FluidSynthesizer_nReceive
(JNIEnv *env, jobject obj, jint command, jint channel, jint data1, jint data2)
{
	fluid_midi_event_t* event;
	fluid_synth_t* synth = get_synth(env, obj);

#ifdef VARIADIC_MACROS
	out("nReceive: synth: %p, values: %x %d %d %d\n", synth, (int) command, (int) channel, (int) data1, (int) data2);
#else
	if (debug_flag)
	{
		fprintf(debug_file, "synth: %p, values: %x %d %d %d\n", synth, (int) command, (int) channel, (int) data1, (int) data2);
		fflush(debug_file);
	}
#endif
	if (synth)
	{
		event = new_fluid_midi_event();
		if (!event)
		{
			printf("failed to instantiate fluid_midi_event_t\n");
			return;
		}
		//printf("2"); fflush(stdout);
		fluid_midi_event_set_type(event, command);
		fluid_midi_event_set_channel(event, channel);
		fluid_midi_event_set_key(event, data1);
		fluid_midi_event_set_velocity(event, data2);
		//printf("3"); fflush(stdout);
		/*printf("values2: %d %d %d %d\n",
		fluid_midi_event_get_type(event),
		fluid_midi_event_get_channel(event),
		fluid_midi_event_get_key(event),
		fluid_midi_event_get_velocity(event));
		fflush(stdout);
	*/
		fluid_synth_handle_midi_event(synth, event);
		//printf("4"); fflush(stdout);
		delete_fluid_midi_event(event);
		//printf("5\n"); fflush(stdout);
	}
}