OMIDIV
MidiManager Class Reference

Stores information about the currently loaded midi and its playback status. More...

Inheritance diagram for MidiManager:
OmidivComponent

Static Public Member Functions

static decimal TicksPerSecond (uint tempoMicros)
 The current number of midi ticks per second, dependent on tempo.
 
static decimal TimePerTick (uint tempoMicros)
 The duration of one midi tick.
 
static decimal MicrosToTicks (decimal start, decimal micros)
 Converts a number of microseconds into a number of ticks.
This is dependent on tempo and tempo changes, so the start time is needed.
 

Protected Member Functions

override void OnEnable ()
 
override void OnDisable ()
 
override void Restart ()
 
override void LoadMidi ()
 Currently just reads the midi from the file into Midi
 
override void DrawGUI ()
 Override this. Use ImGui to draw most UI elements here.
 
void DrawMainMenuItems (string menuName)
 
- Protected Member Functions inherited from OmidivComponent
virtual void Awake ()
 
virtual void OnDestroy ()
 
virtual void ReadConfig ()
 Override this. Read from Config here.
Don't forget to include ConfigTag in your config keys.
 
virtual void WriteConfig ()
 Override this. Write to Config here.
Don't forget to include ConfigTag in your config keys.
 
virtual void OnPlayStart ()
 Override this. Called when the visualization starts playing. May be starting from the beginning or resuming.
 
virtual void OnPlayStop ()
 Override this. Called when the visualization stops playing.
 
virtual void Reset_ ()
 Override this. Called when SceneController.OnReset is fired. LoadAudio and LoadMidi will also be called afterwards, so don't do any of that here, but do reload any other resources your component needs.
 
virtual void LoadVisuals ()
 Override this. Called when the visuals need to be recreated (like when something in the MIDI Controls window is changed).
 
virtual void LoadAudio ()
 Override this. Called when the audio needs to be loaded from the file.
 

Properties

static FileInfo MidiPath [get]
 The path to the currently loaded midi file.
 
static RawMidi rawMidi [get]
 The raw midi data of the currently loaded midi.
 
static CookedMidi Midi = new CookedMidi() [get]
 The currently loaded midi.
 
static int MidiDelay [get, set]
 
static decimal CurrentTick [get, set]
 The current midi tick the visualization is on. May be negative with a midi delay.
 
static decimal CurrentTime [get, set]
 The current midi time in microseconds. May be negative with a midi delay.
 
static uint CurrentTempoMicros = 500000 [get, set]
 The current tempo in microseconds per quarter note (as per the midi file format).
 
static double CurrentTempoBPM [get, set]
 The current tempo in Beats Per Minute.
 
static decimal TicksPerFrame [get]
 The frame delta time converted to ticks, accounting for tempo changes. Will be 0 if not playing.
 
- Properties inherited from OmidivComponent
static bool IsPlaying [get]
 Is the visualization currently playing.
 
static double FrameDeltaTime [get]
 Time.deltaTime when not recording, 1/recording framerate when recording. In most cases, use this instead of Time.deltaTime so that recordings work properly.
 

Events

static Action< long, decimal > OnMidiDelayChanged
 < long diffMicros, decimal tickDelta >
Called before CurrentTime and CurrentTick have been updated.
 

Additional Inherited Members

- Public Attributes inherited from OmidivComponent
string ConfigTag = "def"
 Use this to give different instances in difference scenes different saved config.

 

Detailed Description

Stores information about the currently loaded midi and its playback status.

Member Function Documentation

◆ DrawGUI()

override void MidiManager.DrawGUI ( )
protectedvirtual

Override this. Use ImGui to draw most UI elements here.

Subscribe to ImGuiManager.DrawMainMenuItems to add to main menu bar menus instead of here.

Reimplemented from OmidivComponent.

◆ DrawMainMenuItems()

void MidiManager.DrawMainMenuItems ( string menuName)
protected

Please call base.DrawMainMenuItems() if overriding this.

◆ LoadMidi()

override void MidiManager.LoadMidi ( )
protectedvirtual

Currently just reads the midi from the file into Midi

Please call base.LoadMidi() if overriding this.

Reimplemented from OmidivComponent.

◆ MicrosToTicks()

static decimal MidiManager.MicrosToTicks ( decimal start,
decimal micros )
static

Converts a number of microseconds into a number of ticks.
This is dependent on tempo and tempo changes, so the start time is needed.

Parameters
startThe microsecond of playback to start at. May be negative.
microsThe number of microseconds to convert

Known very small issue: If there is a tempo change at, say 1000 microseconds, start is 1000.xxx, and micros is negative, 0.xxx micros will be converted at the previous tempo. Keep in mind this is nanoseconds of error.

◆ OnDisable()

override void MidiManager.OnDisable ( )
protectedvirtual

Please call base.OnDisable() if overriding this, unless you really know what you're doing.

Reimplemented from OmidivComponent.

◆ OnEnable()

override void MidiManager.OnEnable ( )
protectedvirtual

Please call base.OnEnable() if overriding this, unless you really know what you're doing.

Reimplemented from OmidivComponent.

◆ Restart()

override void MidiManager.Restart ( )
protectedvirtual

Please call base.LoadMidi() if overriding this.

Reimplemented from OmidivComponent.


The documentation for this class was generated from the following file: