Skip to content

Commit

Permalink
[plugin-manager] in MidiSourceNode, set remote instance and get prese…
Browse files Browse the repository at this point in the history
…ts URID.

Surprisingly(?), remote instance was always null.
  • Loading branch information
atsushieno committed Apr 27, 2024
1 parent 0641691 commit a4cd454
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ size_t aap::AAPMidiEventTranslator::runThroughMidi2UmpForMidiMapping(uint8_t* by
conversion_helper_buffer_size,
0,
instance->aapxsRequestIdSerial(),
0, // FIXME: provide valid URID
preset_urid,
AAP_PRESETS_EXTENSION_URI,
OPCODE_SET_PRESET_INDEX,
(const uint8_t *) aapxsInstance->serialization->data,
Expand Down Expand Up @@ -160,3 +160,10 @@ size_t aap::AAPMidiEventTranslator::translateMidiBufferIfNeeded(uint8_t* bytes,
}
return 0;
}

void aap::AAPMidiEventTranslator::setPlugin(aap::RemotePluginInstance *pluginInstance) {
auto reg = instance ? instance->getAAPXSRegistry() : nullptr;
auto map = reg ? reg->items()->getUridMapping() : nullptr;
preset_urid = map ? map->getUrid(AAP_PRESETS_EXTENSION_URI) : aap::xs::UridMapping::UNMAPPED_URID;
instance = pluginInstance;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace aap {

class AAPMidiEventTranslator {
RemotePluginInstance* instance;
uint8_t preset_urid{aap::xs::UridMapping::UNMAPPED_URID};
// used when we need MIDI1<->UMP translation.
uint8_t* translation_buffer{nullptr};
int32_t midi_buffer_size;
Expand All @@ -28,6 +29,8 @@ namespace aap {
AAPMidiEventTranslator(RemotePluginInstance* instance, int32_t midiBufferSize = AAP_MANAGER_MIDI_BUFFER_SIZE, int32_t initialMidiProtocol = CMIDI2_PROTOCOL_TYPE_MIDI2);
~AAPMidiEventTranslator();

void setPlugin(RemotePluginInstance* pluginInstance);

int32_t translateMidiEvent(uint8_t *data, int32_t length);

// If needed, translate MIDI1 bytestream to MIDI2 UMP.
Expand Down
1 change: 1 addition & 0 deletions androidaudioplugin-manager/src/main/cpp/AudioGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void aap::SimpleLinearAudioGraph::processAudio(AudioBuffer *audioData, int32_t n
}

void aap::SimpleLinearAudioGraph::setPlugin(aap::RemotePluginInstance *instance) {
midi_input.setPlugin(instance);
plugin.setPlugin(instance);
}

Expand Down
2 changes: 2 additions & 0 deletions androidaudioplugin-manager/src/main/cpp/AudioGraphNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ namespace aap {

virtual ~MidiSourceNode();

void setPlugin(RemotePluginInstance* instance) { translator.setPlugin(instance); }

void addMidiEvent(uint8_t *data, int32_t length, int64_t timestampInNanoseconds);

void start() override;
Expand Down

0 comments on commit a4cd454

Please sign in to comment.