Rex's plugins for Construct2
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About

rex_JSMidiParser

Plugin, ACE table, Discussion thread
Dependence:
rex_timeline plugin (optional)


Introduction
Convert a midi binary data to JSON to get note events.
To play note events, it needs
rex_timeline plugin.

Usage
 

Load & convert midi to JSON
Call
"Action:Load & Convert midi" to load midi from URL and convert it to JSON. "Condition:On convert completed" will be triggered while converting completed, otherwise "Condition:On convert error" will be triggered.
JSON string of converting result could be got by "Expression:Midi2JSON".
Retrieve all notes
Sample capx
Uses "Condition:For each note" to retrieve all notes sorted by note start time. Get properties of triggered note by these expressions -
  • Expression:CurTime, Expression:CurTick : playing time of this triggered note
  • Expression:CurPitch, Expression:CurPitchKey = (Expression:CurPitchKeyName + Expression:CurPitchKeyOctave) : pitch of triggered note
  • Expression:CurVelocity : velocity of triggered note
  • Expression:CurDuration, Expression:CurDurationTick : duration of triggered note, i.e. end time - start time of this triggered note.
Play notes
Sample capx
Use official audio's "action: Schedule next play" to play a note sound under "Condition:For each note".

Play note events
Sample capx , Sample capx 2

Prepare
Add rex_timeline plugin into project if designer want to trigger note events in run-time.
Playing
Call "
Action:Start" to start to play note events - "Condition:On note on" or "Condition:On note off" will be triggered at respondent time.

Action: Start -> Condition: On note on/ On note off -> Expression: CurPitchKey
Get properties of triggered note by these expressions -
  • Expression:CurTime, Expression:CurTick : playing time of this triggered note
  • Expression:CurPitch, Expression:CurPitchKey = (Expression:CurPitchKeyName + Expression:CurPitchKeyOctave) : pitch of triggered note
  • Expression:CurVelocity : velocity of triggered note
  • Expression:CurDuration, Expression:CurDurationTick : duration of triggered note, i.e. end time - start time of this triggered note.
The "Beat period" could be set at properties table.
"Condition:On ended" will be triggered when all notes playing finished.

Stop playing
Call "
Action:Stop" to stop playing notes.
Pause or resume
Sample capx
Call "Action:Pause" to pause current playing, or call "Action:Resume" to continue playing.

Pitch keys mapping
The pitch keys mapping lists below -
图片
The "octave" is start from -2. User could add "Octave offset" which set in property table to move up or down this mapping table.

Properties of midi
There are some properties of midi could be retrieved -
  • Expression:EndTime : total length of this midi

Official save & load feature
This plugin support official save load feature.

Create a free web site with Weebly
  • Home
  • Map
  • Tutorial/Templates
  • News
  • About