Skip to content

Commit

Permalink
use the correct id when an adapter childs message is received
Browse files Browse the repository at this point in the history
  • Loading branch information
aolsenjazz committed Oct 29, 2024
1 parent cb80c7b commit e3cc924
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/shared/hardware-config/adapter-device-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { MessageProcessorMeta } from '../message-processor';
import { MessageTransport } from '../message-transport';
import { BaseDevicePlugin } from '../../plugins/core/base-device-plugin';
import { BasePlugin } from '../../plugins/core/base-plugin';
import { getQualifiedInputId } from '../util';
import { idForMsg } from '../midi-util';

export class AdapterDeviceConfig extends DeviceConfig {
child?: SupportedDeviceConfig;
Expand Down Expand Up @@ -34,8 +36,24 @@ export class AdapterDeviceConfig extends DeviceConfig {
this.child = config;
}

/**
* Interestingly, at this point, we're not event calling the child for anything here.
* Makes one wonder what the relationship between adapters and children is, and
* whether or not DeviceConfigs need to be aware of their own inputs at runtime.
*/
public process(msg: NumberArrayWithStatus, meta: MessageProcessorMeta) {
return this.child?.process(msg, meta);
if (this.child) {
const message = super.process(msg, meta)!;
const messageIdentifier = idForMsg(msg, false);

const input = meta.inputProvider.get(
getQualifiedInputId(this.id, messageIdentifier),
);

return input ? input.process(message, meta) : message;
}

return msg;
}

public init(loopbackTransport: MessageTransport) {
Expand Down
1 change: 1 addition & 0 deletions src/shared/hardware-config/supported-device-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class SupportedDeviceConfig extends DeviceConfig<SupportedDeviceConfigDTO
public process(msg: NumberArrayWithStatus, meta: MessageProcessorMeta) {
const message = super.process(msg, meta)!;
const messageIdentifier = idForMsg(msg, false);

const input = meta.inputProvider.get(
getQualifiedInputId(this.id, messageIdentifier),
);
Expand Down

0 comments on commit e3cc924

Please sign in to comment.