diff --git a/src/detail/auv2/auv2_base_classes.h b/src/detail/auv2/auv2_base_classes.h index a15d7d6c..7e35ca0e 100644 --- a/src/detail/auv2/auv2_base_classes.h +++ b/src/detail/auv2/auv2_base_classes.h @@ -26,6 +26,8 @@ #include "detail/os/osutil.h" #include "detail/clap/automation.h" +#define NDUAL_SCHEDULING_ENABLED 1 + enum class AUV2_Type : uint32_t { aufx_effect = 1, @@ -169,18 +171,19 @@ class WrapAsAUV2 : public ausdk::AUBase, // Notes OSStatus StartNote(MusicDeviceInstrumentID /*inInstrument*/, MusicDeviceGroupID /*inGroupID*/, - NoteInstanceID* /*outNoteInstanceID*/, UInt32 /*inOffsetSampleFrame*/, - const MusicDeviceNoteParams& /*inParams*/) override + NoteInstanceID* outNoteInstanceID, UInt32 inOffsetSampleFrame, + const MusicDeviceNoteParams& inParams) override { // _processAdapter - // _processAdapter->addMIDIEvent(, <#UInt32 inData1#>, <#UInt32 inData2#>, <#UInt32 inOffsetSampleFrame#>) - return kAudio_UnimplementedError; + // _processAdapter->addMIDIEvent(, <#UInt32 inData1#>, <#UInt32 inData2#>, <#UInt32 inOffsetSampleFrame#>); + *outNoteInstanceID = inParams.mPitch; + return MIDIEvent(0x90, inParams.mPitch, inParams.mVelocity, inOffsetSampleFrame); } - OSStatus StopNote(MusicDeviceGroupID /*inGroupID*/, NoteInstanceID /*inNoteInstanceID*/, - UInt32 /*inOffsetSampleFrame*/) override + OSStatus StopNote(MusicDeviceGroupID /*inGroupID*/, NoteInstanceID inNoteInstanceID, + UInt32 inOffsetSampleFrame) override { - return kAudio_UnimplementedError; + return MIDIEvent(0x80, inNoteInstanceID, 0, inOffsetSampleFrame); } // unfortunately hidden in the base c++ file @@ -311,6 +314,9 @@ class WrapAsAUV2 : public ausdk::AUBase, uint32_t _midi_preferred_dialect = 0; bool _midi_wants_midi_input = false; // takes any input bool _midi_understands_midi2 = false; +#ifdef DUAL_SCHEDULING_ENABLED + bool _midi_dualscheduling_mode = false; +#endif std::map> _parametertree; CFStringRef _current_program_name = 0; diff --git a/src/wrapasauv2.cpp b/src/wrapasauv2.cpp index b158ada8..b252421a 100644 --- a/src/wrapasauv2.cpp +++ b/src/wrapasauv2.cpp @@ -565,16 +565,19 @@ OSStatus WrapAsAUV2::GetPropertyInfo(AudioUnitPropertyID inID, AudioUnitScope in outWritable = true; outDataSize = sizeof(UInt32); return noErr; +#ifdef DUAL_SCHEDULING_ENABLED case kMusicDeviceProperty_DualSchedulingMode: outWritable = true; outDataSize = sizeof(UInt32); return noErr; break; +#endif case kMusicDeviceProperty_SupportsStartStopNote: outWritable = true; outDataSize = sizeof(UInt32); return noErr; break; + case kAudioUnitProperty_CocoaUI: outWritable = false; outDataSize = sizeof(struct AudioUnitCocoaViewInfo); @@ -640,6 +643,7 @@ OSStatus WrapAsAUV2::GetProperty(AudioUnitPropertyID inID, AudioUnitScope inScop if (_autype == AUV2_Type::aumu_musicdevice) return noErr; return kAudioUnitErr_InvalidProperty; // return GetInstrumentCount(*static_cast(outData)); + case kAudioUnitProperty_BypassEffect: *static_cast(outData) = (IsBypassEffect() ? 1 : 0); // NOLINT return noErr; @@ -651,6 +655,7 @@ OSStatus WrapAsAUV2::GetProperty(AudioUnitPropertyID inID, AudioUnitScope inScop _uiconn._window = nullptr; *static_cast(outData) = _uiconn; return noErr; + case kAudioUnitProperty_CocoaUI: LOGINFO("query Property: kAudioUnitProperty_CocoaUI {}", (_plugin) ? "plugin" : "no plugin"); if (_plugin && @@ -670,15 +675,16 @@ OSStatus WrapAsAUV2::GetProperty(AudioUnitPropertyID inID, AudioUnitScope inScop } return kAudioUnitErr_InvalidProperty; break; +#ifdef DUAL_SCHEDULING_ENABLED case kMusicDeviceProperty_DualSchedulingMode: // yes we do - *static_cast(outData) = 1; + // *static_cast(outData) = 1; return noErr; break; +#endif case kMusicDeviceProperty_SupportsStartStopNote: // TODO: change this when figured out how the NoteParamsControlValue actually do work. - - *static_cast(outData) = 0; + *static_cast(outData) = 1; return noErr; break; default: @@ -717,18 +723,21 @@ OSStatus WrapAsAUV2::SetProperty(AudioUnitPropertyID inID, AudioUnitScope inScop // mProcessesInPlace = *static_cast(inData) != 0; // return noErr; break; - case kMusicDeviceProperty_SupportsStartStopNote: +#ifdef DUAL_SCHEDULING_ENABLED + + case kMusicDeviceProperty_DualSchedulingMode: { - // TODO: we probably want to use start/stop note auto x = *static_cast(inData); - (void)x; + if (x > 0) LOGINFO("Host supports DualSchedulung Mode"); + _midi_dualscheduling_mode = (x != 0); return noErr; } break; - case kMusicDeviceProperty_DualSchedulingMode: +#endif + case kMusicDeviceProperty_SupportsStartStopNote: { + // TODO: we probably want to use start/stop note auto x = *static_cast(inData); - if (x > 0) LOGINFO("Host supports DualSchedulung Mode"); (void)x; return noErr; }