AppModel

interface AppModel

Host side of uapmd_app::AppModel (tools/uapmd-app-model) — the façade uapmd-app itself renders against, wrapped by c-api/uapmd-c-app.h.

It is a process-wide singleton: call instantiateAppModel once, before any UI exists, then reach it with getAppModel. It owns its RealtimeSequencer, so the instance returned by sequencer must not be closed.

A host must install an event loop (see uapmd_set_event_loop, which the JVM/Android bindings do via initJvmEventLoop() / initAndroidEventLoop()) before instantiating: AppModel marshals plugin deactivation and history completions through remidy::EventLoop, and without one they never run.

Inheritors

AndroidAppModel
JsAppModel
JvmAppModel
NativeAppModel
WasmJsAppModel

Properties

Link copied to clipboard
Link copied to clipboard

AppModel's own blocklist — the list the Plugin Selector shows. A standalone ScanTool keeps a separate one. BlocklistEntry.timestamp in uapmd has no counterpart in uapmd_blocklist_entry_t, so it is not carried across.

Link copied to clipboard
abstract val historyState: UndoState

Also reports busy while an asynchronous plug-in mutation is still capturing state, so shortcuts cannot race the capture.

Link copied to clipboard

Turning this off is not a plain stopAudio(): the model stops the transport, mutes the output, lets release/reverb tails drain inaudibly, then deactivates plugins on the main thread and resets processing state, so a restart cannot resume stale voices.

Link copied to clipboard
abstract val isScanning: Boolean
Link copied to clipboard

The last scanning error, or null.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract val sampleRate: Int
Link copied to clipboard

Owned by the model; do not close.

Link copied to clipboard

Progress of the slow scan. isScanning alone cannot tell a long scan from a stuck one, which is why uapmd-app's selector shows these.

Link copied to clipboard
abstract val timelineTrackCount: UInt
Link copied to clipboard
abstract val trackCount: UInt
Link copied to clipboard

Functions

Link copied to clipboard
abstract fun addTrack(callback: (trackIndex: Int, error: String?) -> Unit)

Asynchronous since uapmd 0.5.6: track mutations are undo engine operations.

Link copied to clipboard
abstract fun addUmpEventToClip(trackIndex: Int, clipId: Int, tick: Long, words: UIntArray): Boolean
Link copied to clipboard
abstract fun cancelPluginScanning()
Link copied to clipboard
abstract fun clearPluginBlocklist()
Link copied to clipboard
abstract fun connectTrackGraph(trackIndex: Int, connection: GraphConnection): OpResult
Link copied to clipboard
abstract fun createEmptyMidiClip(trackIndex: Int, positionSamples: Long, tickResolution: UInt, bpm: Double = 120.0): ClipAddResult

Creates an empty MIDI 2.0 clip; tickResolution is ticks per quarter.

Link copied to clipboard
abstract fun createPluginInstance(format: String, pluginId: String, trackIndex: Int, config: PluginInstanceConfig = PluginInstanceConfig(), callback: (PluginInstanceResult) -> Unit)

Instantiates pluginId and attaches it to trackIndex; a negative index creates a new track. The callback runs once, on the thread that finishes instantiation.

Link copied to clipboard
abstract fun disableUmpDevice(instanceId: Int)
Link copied to clipboard
abstract fun disconnectTrackGraphConnection(trackIndex: Int, connectionId: Long): OpResult
Link copied to clipboard
abstract fun enableUmpDevice(instanceId: Int, deviceName: String)

Registers the instance as a virtual MIDI 2.0 device where the platform supports it.

Link copied to clipboard
abstract fun ensureTrackUsesEditorGraph(trackIndex: Int): Boolean

Switches the track from the simple linear chain to the editable graph.

Link copied to clipboard
abstract fun generateScanReport(): String
Link copied to clipboard
abstract fun getClipAudioEvents(trackIndex: Int, clipId: Int): ClipAudioEventsResult

Reading counterpart to ProjectCommands.setClipMarkers/setClipAudioWarps.

Link copied to clipboard
abstract fun getInstanceGroup(instanceId: Int): UByte
Link copied to clipboard
abstract fun getMidiClipUmpEvents(trackIndex: Int, clipId: Int): UmpEventsResult
Link copied to clipboard
Link copied to clipboard
abstract fun getTimelineTrack(index: UInt): TimelineTrack
Link copied to clipboard
Link copied to clipboard
abstract fun getTrackGraphNodes(trackIndex: Int): GraphNodesResult
Link copied to clipboard
abstract fun hidePluginUi(instanceId: Int)
Link copied to clipboard
abstract fun importMidiTracksFromFile(filepath: String, callback: (Boolean, String?, Int) -> Unit)

Imports a possibly multi-track SMF, one new track per SMF track. callback receives success, an error when it failed, and how many tracks were created.

Link copied to clipboard
abstract fun loadProject(filePath: String): AppProjectResult
Link copied to clipboard

Android's document-picker path: resolves a content:// handle token.

Link copied to clipboard
Link copied to clipboard
abstract fun notifyUiReady()

Startup lifecycle; uapmd-app calls both once the UI exists.

Link copied to clipboard
abstract fun performPluginScanning(forceRescan: Boolean = false, mode: ScanMode = ScanMode.InProcess, remoteTimeoutSeconds: Double = 20.0, requireFastScanning: Boolean = false)

Runs asynchronously; watch isScanning. ScanMode.Remote launches a separate scanner process on desktop and is unavailable on WebAssembly.

Link copied to clipboard
abstract fun redo(callback: (error: String?) -> Unit? = null)
Link copied to clipboard

Master-track tempo map. getTimelineState().tempo is a single value and cannot describe a project whose tempo changes; a beats view needs these. Rebuild once with refreshMasterTempoMap, then read the lists — they stay valid until the next refresh.

Link copied to clipboard
abstract fun removeAllTracks(callback: (error: String?) -> Unit)
Link copied to clipboard
abstract fun removeClipFromTrack(trackIndex: Int, clipId: Int): Boolean
Link copied to clipboard
abstract fun removePluginInstance(instanceId: Int)
Link copied to clipboard
abstract fun removeTrack(trackIndex: Int, callback: (trackIndex: Int, error: String?) -> Unit)
Link copied to clipboard
abstract fun removeUmpEventFromClip(trackIndex: Int, clipId: Int, eventIndex: Int): Boolean
Link copied to clipboard
abstract fun requestShowInstanceDetails(instanceId: Int)
Link copied to clipboard
abstract fun requestShowPluginUi(instanceId: Int)
Link copied to clipboard
abstract fun revertTrackToSimpleGraph(trackIndex: Int): Boolean
Link copied to clipboard
abstract fun saveProject(filePath: String, callback: (AppProjectResult) -> Unit)
Link copied to clipboard
abstract fun saveProjectSync(filePath: String): AppProjectResult
Link copied to clipboard
abstract fun setAudioEngineEnabled(enabled: Boolean)
Link copied to clipboard
abstract fun setClipAudioEvents(trackIndex: Int, clipId: Int, markers: List<ClipMarkerData>, warps: List<AudioWarpPointData>): OpResult
Link copied to clipboard
abstract fun setInstanceGroup(instanceId: Int, group: UByte): Boolean
Link copied to clipboard
abstract fun toggleAudioEngine()
Link copied to clipboard
abstract fun unblockPlugin(entryId: String): Boolean
Link copied to clipboard
abstract fun undo(callback: (error: String?) -> Unit? = null)
Link copied to clipboard
abstract fun updateAudioDeviceSettings(sampleRate: Int, bufferSize: UInt)