Improved MIDI timing interface

This commit is contained in:
Jack Andersen 2016-06-07 18:37:21 -10:00
parent 521b490d0f
commit 52c0cca593
5 changed files with 16 additions and 2 deletions

View File

@ -64,6 +64,9 @@ struct IAudioVoiceEngine
/** Open named MIDI in/out port, name format depends on OS */ /** Open named MIDI in/out port, name format depends on OS */
virtual std::unique_ptr<IMIDIInOut> newRealMIDIInOut(const char* name, ReceiveFunctor&& receiver)=0; virtual std::unique_ptr<IMIDIInOut> newRealMIDIInOut(const char* name, ReceiveFunctor&& receiver)=0;
/** If this returns true, MIDI callbacks are assumed to be *not* thread-safe; need protection via mutex */
virtual bool useMIDILock() const=0;
}; };
/** Construct host platform's voice engine */ /** Construct host platform's voice engine */

View File

@ -9,7 +9,7 @@
namespace boo namespace boo
{ {
using ReceiveFunctor = std::function<void(std::vector<uint8_t>&&)>; using ReceiveFunctor = std::function<void(std::vector<uint8_t>&&, double time)>;
class IMIDIPort class IMIDIPort
{ {

View File

@ -231,7 +231,8 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
for (int i=0 ; i<pktlist->numPackets ; ++i) for (int i=0 ; i<pktlist->numPackets ; ++i)
{ {
std::vector<uint8_t> bytes(std::cbegin(packet->data), std::cbegin(packet->data) + packet->length); std::vector<uint8_t> bytes(std::cbegin(packet->data), std::cbegin(packet->data) + packet->length);
readProcRefCon->m_receiver(std::move(bytes)); ;
readProcRefCon->m_receiver(std::move(bytes), AudioConvertHostTimeToNanos(packet->timeStamp) / 1.0e9);
packet = MIDIPacketNext(packet); packet = MIDIPacketNext(packet);
} }
} }
@ -534,6 +535,8 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
return ret; return ret;
} }
bool useMIDILock() const {return true;}
AQSAudioVoiceEngine() AQSAudioVoiceEngine()
{ {
m_mixInfo.m_channels = _getAvailableSet(); m_mixInfo.m_channels = _getAvailableSet();

View File

@ -6,6 +6,8 @@
#include <list> #include <list>
#include <vector> #include <vector>
struct AudioUnitVoiceEngine;
namespace boo namespace boo
{ {
class BaseAudioVoiceEngine; class BaseAudioVoiceEngine;
@ -15,6 +17,7 @@ class AudioSubmix : public IAudioSubmix, public IAudioMix
{ {
friend class BaseAudioVoiceEngine; friend class BaseAudioVoiceEngine;
friend struct WASAPIAudioVoiceEngine; friend struct WASAPIAudioVoiceEngine;
friend struct ::AudioUnitVoiceEngine;
/* Mixer-engine relationships */ /* Mixer-engine relationships */
BaseAudioVoiceEngine& m_root; BaseAudioVoiceEngine& m_root;

View File

@ -6,6 +6,8 @@
#include "boo/audiodev/IAudioVoice.hpp" #include "boo/audiodev/IAudioVoice.hpp"
#include "AudioMatrix.hpp" #include "AudioMatrix.hpp"
struct AudioUnitVoiceEngine;
namespace boo namespace boo
{ {
class BaseAudioVoiceEngine; class BaseAudioVoiceEngine;
@ -17,6 +19,7 @@ class AudioVoice : public IAudioVoice
friend class BaseAudioVoiceEngine; friend class BaseAudioVoiceEngine;
friend class AudioSubmix; friend class AudioSubmix;
friend struct WASAPIAudioVoiceEngine; friend struct WASAPIAudioVoiceEngine;
friend struct ::AudioUnitVoiceEngine;
protected: protected:
/* Mixer-engine relationships */ /* Mixer-engine relationships */
@ -68,6 +71,8 @@ public:
void start(); void start();
void stop(); void stop();
void unbindVoice(); void unbindVoice();
double getSampleRateIn() const {return m_sampleRateIn;}
double getSampleRateOut() const {return m_sampleRateOut;}
}; };
class AudioVoiceMono : public AudioVoice class AudioVoiceMono : public AudioVoice