Class MPTKEvent – Generate Note

MPTKEvent class is a central class when you want to:

  • Generate music with MidiStreamPlayer,
  • read midi events from a Midi file with MidiLoad or MidiFilePlayer,
  • receive midi events from keyboard with MidiInReader or MidiKeyboard .

With this MPTKEvent, you can:

  • Play and stop a note,
  • change instrument (preset, patch, …),
  • change some control as modulation or default value of the SoundFont generator,
  • acces to each voice, …

Attributes

See here for the full description.

Methods

MTPK_ModifySynthParameter

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 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: JavaScript (javascript)

Generator List