Cog/Plugins/MIDI/MIDI/AUPlayer.h
Christopher Snowhill aebb0c146f MIDI: Add unstable configuration for AU players
It's regarded as unstable as some plugins randomly decide to overflow
the main thread queue and crash the player on the main thread check, but
only sometimes, and not always.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-03-28 15:25:23 -07:00

69 lines
1.6 KiB
Objective-C

#ifndef __AUPlayer_h__
#define __AUPlayer_h__
#include "MIDIPlayer.h"
//#include <string>
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <CoreAudio/CoreAudioTypes.h>
class AUPluginUI;
class AUPlayer : public MIDIPlayer {
public:
// zero variables
AUPlayer();
// close, unload
virtual ~AUPlayer();
// configuration
void setSoundFont(const char *in);
/*void setFileSoundFont( const char * in );*/
// void showDialog();
typedef void (*callback)(OSType uSubType, OSType uManufacturer, const char *name);
static void enumComponents(callback cbEnum);
void setComponent(OSType uSubType, OSType uManufacturer);
void setPreset(NSDictionary *preset);
protected:
virtual unsigned int send_event_needs_time();
virtual void send_event(uint32_t b);
virtual void send_sysex(const uint8_t *data, size_t size, size_t port);
virtual void render(float *out, unsigned long count);
virtual void shutdown();
virtual bool startup();
virtual void send_event_time(uint32_t b, unsigned int time);
virtual void send_sysex_time(const uint8_t *data, size_t size, size_t port, unsigned int time);
private:
void loadSoundFont(const char *name);
std::string sSoundFontName;
/*std::string sFileSoundFontName;*/
AudioTimeStamp mTimeStamp;
AudioUnit samplerUnit[3];
bool samplerUIinitialized[3];
AUPluginUI *samplerUI[3];
AudioBufferList *bufferList;
float *audioBuffer;
OSType componentSubType, componentManufacturer;
BOOL needsInput;
NSDictionary *preset;
};
#endif