MusIT

Class MPTKEvent – Generate MIDI Events as NoteOn and apply Real Time Effect

MPTKEvent class is a central class for all these activities:

  • Real time Processing of Midi events from MidiFilePlayer.
  • Build music from scratch with MidiStreamPlayer.
  • Read midi events from a Midi file with MidiLoad.
  • Receive midi events from keyboard with MidiInReader or MidiKeyboard.

With this MPTKEvent, you can:

  • Play and stop a note.
  • Modify in real time default internal synthesizer generators values.
  • Change instrument (preset, patch, …).
  • Change controllers values.
  • Change default value of the SoundFont generator.
  • Access to the parameters of each voice.

Attributes

See here for the full description.

Methods

MTPK_ModifySynthParameter(
   fluid_gen_type genType, 
   float value, 
   MPTKModeGeneratorChange mode)

Apply modification on default SoundFont generator value. Can be applied independently for each notes, can be applied in real time when the note is played.

  • genType Type of generator to modify. Not all generators are authorized to real time modification.
  • value for the generator between 0 (min value for the generator) and 1 (max value for the generator)
  • mode
    • Override: the SoundFont value is overridden,
    • Reinforce: the value is added to the default value.

See here to get a sheet

This sheet contains with detailed explanations of parameters as volume envelope (ADSR) and tuning.
// Create a midi event for a C5 note (60) mptkEvent = new MPTKEvent() { Value = 60 }; // Fine tuning (pitch) mptkEvent.MPTK_ModifySynthGenerator(fluid_gen_type.GEN_FINETUNE, 0.52f, MPTKModeGeneratorChange.Override); // Change low pass filter frequency mptkEvent.MPTK_ModifySynthGenerator(fluid_gen_type.GEN_FILTERFC, 0.6f, MPTKModeGeneratorChange.Override); midiStream.MPTK_PlayDirectEvent(mptkEvent);
Code language: C# (cs)

Generator List

The range of the internal values of the SoundFont synthesizer depends on the type of generator. In the hope that will help using this method, the value in MTPK_ModifySynthParameter is normalize : with 0 the minimum value of the parameter is used, with 1 the maximum.

For example, the range of value for “Modulation LFO To Pitch” is -12000 to 12000. Also, a value of 0 in MTPK_ModifySynthParameter will set a value of -12000 for this generator and a value of 1 will set a value of 12000. Look here for the bravest 🙂

Get MPTK from the Unity store

If you like Midi Player Tool Kit, please leave a review on the Asset Store. It’s very appreciated!!!

Contact

If you have any questions, please don’t hesitate to reach out to us with the dedicated Unity forum or on our Discord  channel

We always enjoy discussing your projects!

Add MIDI Music With 3 Clicks for Free

Sound Spatialisation, MPTK is ready for Virtual Reality [Pro]

Sound Spatialisation, MPTK is ready for Virtual Reality [free]

Midi Synth : Real Time Voice Effect Change

Euclidean Rhythm demo

New on Asset Store

Asset Store Partners