-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
241 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2024 CrSjimo * | ||
* * | ||
* This file is part of TALCS. * | ||
* * | ||
* TALCS is free software: you can redistribute it and/or modify it under the * | ||
* terms of the GNU Lesser General Public License as published by the Free * | ||
* Software Foundation, either version 3 of the License, or (at your option) * | ||
* any later version. * | ||
* * | ||
* TALCS is distributed in the hope that it will be useful, but WITHOUT ANY * | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for * | ||
* more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with TALCS. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
#include "RemoteMidiMessageIntegrator.h" | ||
#include "RemoteMidiMessageIntegrator_p.h" | ||
|
||
namespace talcs { | ||
RemoteMidiMessageIntegrator::RemoteMidiMessageIntegrator() : RemoteMidiMessageIntegrator(*new RemoteMidiMessageIntegratorPrivate) { | ||
|
||
} | ||
|
||
RemoteMidiMessageIntegrator::~RemoteMidiMessageIntegrator() { | ||
|
||
} | ||
|
||
bool RemoteMidiMessageIntegrator::open(qint64 bufferSize, double sampleRate) { | ||
Q_D(RemoteMidiMessageIntegrator); | ||
QMutexLocker locker(&d->mutex); | ||
d->midiMessages.clear(); | ||
return AbstractMidiMessageIntegrator::open(bufferSize, sampleRate); | ||
} | ||
|
||
void RemoteMidiMessageIntegrator::close() { | ||
Q_D(RemoteMidiMessageIntegrator); | ||
QMutexLocker locker(&d->mutex); | ||
d->midiMessages.clear(); | ||
AbstractMidiMessageIntegrator::close(); | ||
} | ||
|
||
QList<IntegratedMidiMessage> RemoteMidiMessageIntegrator::fetch(qint64 length) { | ||
Q_D(RemoteMidiMessageIntegrator); | ||
QMutexLocker locker(&d->mutex); | ||
auto ret = d->midiMessages; | ||
d->midiMessages.clear(); | ||
return ret; | ||
} | ||
|
||
void RemoteMidiMessageIntegrator::onThisBlockProcessInfo(const RemoteProcessInfo &processInfo) { | ||
Q_D(RemoteMidiMessageIntegrator); | ||
QMutexLocker locker(&d->mutex); | ||
d->midiMessages.clear(); | ||
if (processInfo.containsInfo) { | ||
auto midiMessagesRawData = &processInfo.midiMessages; | ||
d->midiMessages.reserve(static_cast<int>(midiMessagesRawData->size)); | ||
auto midiMessagesRawDataPointer = reinterpret_cast<const char *>(midiMessagesRawData->messages); | ||
for (int i = 0; i < midiMessagesRawData->size; i++) { | ||
auto midiMessageRawData = reinterpret_cast<const RemoteMidiMessage *>(midiMessagesRawDataPointer); | ||
d->midiMessages.append({ | ||
midiMessageRawData->position, | ||
MidiMessage(midiMessageRawData->data, static_cast<int>(midiMessageRawData->size), | ||
static_cast<double>(midiMessageRawData->position)) | ||
}); | ||
midiMessagesRawDataPointer+= sizeof(RemoteMidiMessage) + midiMessageRawData->size - 1; | ||
} | ||
} | ||
} | ||
|
||
RemoteMidiMessageIntegrator::RemoteMidiMessageIntegrator(RemoteMidiMessageIntegratorPrivate &d) : AbstractMidiMessageIntegrator(d) { | ||
} | ||
} // talcs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2024 CrSjimo * | ||
* * | ||
* This file is part of TALCS. * | ||
* * | ||
* TALCS is free software: you can redistribute it and/or modify it under the * | ||
* terms of the GNU Lesser General Public License as published by the Free * | ||
* Software Foundation, either version 3 of the License, or (at your option) * | ||
* any later version. * | ||
* * | ||
* TALCS is distributed in the hope that it will be useful, but WITHOUT ANY * | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for * | ||
* more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with TALCS. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
#ifndef TALCS_REMOTEMIDIMESSAGEINTEGRATOR_H | ||
#define TALCS_REMOTEMIDIMESSAGEINTEGRATOR_H | ||
|
||
#include <TalcsMidi/AbstractMidiMessageIntegrator.h> | ||
#include <TalcsRemote/RemoteAudioDevice.h> | ||
|
||
namespace talcs { | ||
|
||
class RemoteMidiMessageIntegratorPrivate; | ||
|
||
class TALCSREMOTE_EXPORT RemoteMidiMessageIntegrator : public AbstractMidiMessageIntegrator, public RemoteProcessInfoCallback { | ||
Q_DECLARE_PRIVATE(RemoteMidiMessageIntegrator) | ||
public: | ||
explicit RemoteMidiMessageIntegrator(); | ||
~RemoteMidiMessageIntegrator() override; | ||
|
||
bool open(qint64 bufferSize, double sampleRate) override; | ||
void close() override; | ||
|
||
protected: | ||
QList<IntegratedMidiMessage> fetch(qint64 length) override; | ||
void onThisBlockProcessInfo(const RemoteProcessInfo &processInfo) override; | ||
|
||
explicit RemoteMidiMessageIntegrator(RemoteMidiMessageIntegratorPrivate &d); | ||
|
||
}; | ||
|
||
} // talcs | ||
|
||
#endif //TALCS_REMOTEMIDIMESSAGEINTEGRATOR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2024 CrSjimo * | ||
* * | ||
* This file is part of TALCS. * | ||
* * | ||
* TALCS is free software: you can redistribute it and/or modify it under the * | ||
* terms of the GNU Lesser General Public License as published by the Free * | ||
* Software Foundation, either version 3 of the License, or (at your option) * | ||
* any later version. * | ||
* * | ||
* TALCS is distributed in the hope that it will be useful, but WITHOUT ANY * | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for * | ||
* more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with TALCS. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
#ifndef TALCS_REMOTEMIDIMESSAGEINTEGRATOR_P_H | ||
#define TALCS_REMOTEMIDIMESSAGEINTEGRATOR_P_H | ||
|
||
#include <TalcsRemote/RemoteMidiMessageIntegrator.h> | ||
|
||
#include <TalcsMidi/private/AbstractMidiMessageIntegrator_p.h> | ||
|
||
namespace talcs { | ||
class RemoteMidiMessageIntegratorPrivate : public AbstractMidiMessageIntegratorPrivate { | ||
Q_DECLARE_PUBLIC(RemoteMidiMessageIntegrator) | ||
public: | ||
QList<IntegratedMidiMessage> midiMessages; | ||
QMutex mutex; | ||
}; | ||
} | ||
|
||
#endif //TALCS_REMOTEMIDIMESSAGEINTEGRATOR_P_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/****************************************************************************** | ||
* Copyright (c) 2024 CrSjimo * | ||
* * | ||
* This file is part of TALCS. * | ||
* * | ||
* TALCS is free software: you can redistribute it and/or modify it under the * | ||
* terms of the GNU Lesser General Public License as published by the Free * | ||
* Software Foundation, either version 3 of the License, or (at your option) * | ||
* any later version. * | ||
* * | ||
* TALCS is distributed in the hope that it will be useful, but WITHOUT ANY * | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for * | ||
* more details. * | ||
* * | ||
* You should have received a copy of the GNU Lesser General Public License * | ||
* along with TALCS. If not, see <https://www.gnu.org/licenses/>. * | ||
******************************************************************************/ | ||
|
||
#ifndef TALCS_REMOTEPROCESSINFO_H | ||
#define TALCS_REMOTEPROCESSINFO_H | ||
|
||
#include <TalcsRemote/TalcsRemoteGlobal.h> | ||
|
||
namespace talcs { | ||
|
||
struct RemoteMidiMessage { | ||
int64_t size; | ||
int64_t position; | ||
char data[1]; | ||
}; | ||
|
||
struct RemoteMidiMessageList { | ||
int64_t size; | ||
RemoteMidiMessage messages[1]; | ||
}; | ||
|
||
struct RemoteProcessInfo { | ||
int containsInfo; | ||
|
||
//== Playback Status Info ==// | ||
enum PlaybackStatus { | ||
NotPlaying, | ||
Playing, | ||
RealtimePlaying, | ||
}; | ||
PlaybackStatus status; | ||
|
||
//== Timeline Info ==// | ||
int timeSignatureNumerator; | ||
int timeSignatureDenominator; | ||
double tempo; | ||
|
||
int64_t position; | ||
|
||
//== MIDI ==// | ||
RemoteMidiMessageList midiMessages; | ||
}; | ||
|
||
class RemoteProcessInfoCallback { | ||
public: | ||
virtual void onThisBlockProcessInfo(const RemoteProcessInfo &processInfo) = 0; | ||
}; | ||
|
||
} | ||
|
||
#endif //TALCS_REMOTEPROCESSINFO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters