Skip to content

Commit

Permalink
disabling dual_scheduling mode for now (#196)
Browse files Browse the repository at this point in the history
WIP: Auv2 wrapper
  • Loading branch information
defiantnerd authored Nov 11, 2023
1 parent c50a7de commit 752b9c2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
20 changes: 13 additions & 7 deletions src/detail/auv2/auv2_base_classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<uint32_t, std::unique_ptr<Clap::AUv2::Parameter>> _parametertree;

CFStringRef _current_program_name = 0;
Expand Down
25 changes: 17 additions & 8 deletions src/wrapasauv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<UInt32*>(outData));

case kAudioUnitProperty_BypassEffect:
*static_cast<UInt32*>(outData) = (IsBypassEffect() ? 1 : 0); // NOLINT
return noErr;
Expand All @@ -651,6 +655,7 @@ OSStatus WrapAsAUV2::GetProperty(AudioUnitPropertyID inID, AudioUnitScope inScop
_uiconn._window = nullptr;
*static_cast<ui_connection*>(outData) = _uiconn;
return noErr;

case kAudioUnitProperty_CocoaUI:
LOGINFO("query Property: kAudioUnitProperty_CocoaUI {}", (_plugin) ? "plugin" : "no plugin");
if (_plugin &&
Expand All @@ -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<UInt32*>(outData) = 1;
// *static_cast<UInt32*>(outData) = 1;
return noErr;
break;
#endif
case kMusicDeviceProperty_SupportsStartStopNote:
// TODO: change this when figured out how the NoteParamsControlValue actually do work.

*static_cast<UInt32*>(outData) = 0;
*static_cast<UInt32*>(outData) = 1;
return noErr;
break;
default:
Expand Down Expand Up @@ -717,18 +723,21 @@ OSStatus WrapAsAUV2::SetProperty(AudioUnitPropertyID inID, AudioUnitScope inScop
// mProcessesInPlace = *static_cast<const UInt32*>(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<const UInt32*>(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<const UInt32*>(inData);
if (x > 0) LOGINFO("Host supports DualSchedulung Mode");
(void)x;
return noErr;
}
Expand Down

0 comments on commit 752b9c2

Please sign in to comment.