From a78ac717983bebfcb29f9693720ad6408b6c09d8 Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Fri, 10 Apr 2020 18:32:01 +0100 Subject: [PATCH] Pass frame size to frame handlers --- src/recorder/jamrecorder.cpp | 18 +++++++++--------- src/recorder/jamrecorder.h | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/recorder/jamrecorder.cpp b/src/recorder/jamrecorder.cpp index bfe6c005..1055efdc 100755 --- a/src/recorder/jamrecorder.cpp +++ b/src/recorder/jamrecorder.cpp @@ -70,11 +70,11 @@ CJamClient::CJamClient(const qint64 frame, const int _numChannels, const QString * @param _name The client's current name * @param pcm The PCM data */ -void CJamClient::Frame(const QString _name, const CVector& pcm) +void CJamClient::Frame(const QString _name, const CVector& pcm, int iServerFrameSizeSamples) { name = _name; - for(int i = 0; i < numChannels * SYSTEM_FRAME_SIZE_SAMPLES; i++) + for(int i = 0; i < numChannels * iServerFrameSizeSamples; i++) { *out << pcm[i]; } @@ -165,7 +165,7 @@ void CJamSession::DisconnectClient(int iChID) * * Also manages the overall current frame counter for the session. */ -void CJamSession::Frame(const int iChID, const QString name, const CHostAddress address, const int numAudioChannels, const CVector data) +void CJamSession::Frame(const int iChID, const QString name, const CHostAddress address, const int numAudioChannels, const CVector data, int iServerFrameSizeSamples) { if (vecptrJamClients[iChID] == nullptr) { @@ -193,7 +193,7 @@ void CJamSession::Frame(const int iChID, const QString name, const CHostAddress return; } - vecptrJamClients[iChID]->Frame(name, data); + vecptrJamClients[iChID]->Frame(name, data, iServerFrameSizeSamples); // If _any_ connected client frame steps past currentFrame, increase currentFrame if (vecptrJamClients[iChID]->StartFrame() + vecptrJamClients[iChID]->FrameCount() > currentFrame) @@ -250,7 +250,7 @@ QMap> CJamSession::Tracks() * @param sessionDirName the directory name to scan * @return a map of (latest) client name to connection items */ -QMap> CJamSession::TracksFromSessionDir(const QString& sessionDirName) +QMap> CJamSession::TracksFromSessionDir(const QString& sessionDirName, int iServerFrameSizeSamples) { QMap> tracks; @@ -272,7 +272,7 @@ QMap> CJamSession::TracksFromSessionDir(const QString } QFileInfo fiEntry(sessionDir.absoluteFilePath(entry)); - qint64 length = fiEntry.size() / numChannels.toInt() / SYSTEM_FRAME_SIZE_SAMPLES; + qint64 length = fiEntry.size() / numChannels.toInt() / iServerFrameSizeSamples; STrackItem track ( numChannels.toInt(), @@ -363,7 +363,7 @@ void CJamRecorder::OnEnd() QFile outf (reaperProjectFileName); outf.open(QFile::WriteOnly); QTextStream out(&outf); - out << CReaperProject(currentSession->Tracks(), iServerFrameSizeSamples).toString() << endl; + out << CReaperProject( currentSession->Tracks(), iServerFrameSizeSamples ).toString() << endl; qDebug() << "Session RPP:" << reaperProjectFileName; } @@ -398,7 +398,7 @@ void CJamRecorder::SessionDirToReaper(QString& strSessionDirName, int serverFram } QTextStream out(&outf); - out << CReaperProject( CJamSession::TracksFromSessionDir(fiSessionDir.absoluteFilePath()), serverFrameSizeSamples ).toString() << endl; + out << CReaperProject( CJamSession::TracksFromSessionDir( fiSessionDir.absoluteFilePath(), serverFrameSizeSamples ), serverFrameSizeSamples ).toString() << endl; qDebug() << "Session RPP:" << reaperProjectFileName; } @@ -439,5 +439,5 @@ void CJamRecorder::OnFrame(const int iChID, const QString name, const CHostAddre OnStart(); } - currentSession->Frame(iChID, name, address, numAudioChannels, data); + currentSession->Frame( iChID, name, address, numAudioChannels, data, iServerFrameSizeSamples ); } diff --git a/src/recorder/jamrecorder.h b/src/recorder/jamrecorder.h index 86e535cd..cc49705d 100755 --- a/src/recorder/jamrecorder.h +++ b/src/recorder/jamrecorder.h @@ -70,7 +70,7 @@ class CJamClient : public QObject public: CJamClient(const qint64 frame, const int numChannels, const QString name, const CHostAddress address, const QDir recordBaseDir); - void Frame(const QString name, const CVector& pcm); + void Frame(const QString name, const CVector& pcm, int iServerFrameSizeSamples); void Disconnect(); @@ -106,7 +106,7 @@ public: CJamSession(QDir recordBaseDir); - void Frame(const int iChID, const QString name, const CHostAddress address, const int numAudioChannels, const CVector data); + void Frame(const int iChID, const QString name, const CHostAddress address, const int numAudioChannels, const CVector data, int iServerFrameSizeSamples); void End(); @@ -120,7 +120,7 @@ public: void DisconnectClient(int iChID); - static QMap> TracksFromSessionDir(const QString& name); + static QMap> TracksFromSessionDir(const QString& name, int iServerFrameSizeSamples); private: CJamSession();