From 3831e835353070f73a4b5cf941e217b6a6ec7cc4 Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Fri, 10 Apr 2020 17:37:19 +0100 Subject: [PATCH 1/5] Migrate off ConsoleWriterFactory --- src/recorder/jamrecorder.cpp | 10 +++++----- src/recorder/jamrecorder.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/recorder/jamrecorder.cpp b/src/recorder/jamrecorder.cpp index c9623b0a..0d5d20d5 100755 --- a/src/recorder/jamrecorder.cpp +++ b/src/recorder/jamrecorder.cpp @@ -353,7 +353,7 @@ void CJamRecorder::OnEnd() if (fi.exists()) { - tsConsole << "CJamRecorder::OnEnd() - " << fi.absolutePath() << " exists and will not be overwritten." << endl; + qWarning() << "CJamRecorder::OnEnd():" << fi.absolutePath() << "exists and will not be overwritten."; } else { @@ -361,7 +361,7 @@ void CJamRecorder::OnEnd() outf.open(QFile::WriteOnly); QTextStream out(&outf); out << CReaperProject(currentSession->Tracks()).toString() << endl; - tsConsole << "Session RPP: " << reaperProjectFileName << endl; + qDebug() << "Session RPP:" << reaperProjectFileName; } delete currentSession; @@ -397,7 +397,7 @@ void CJamRecorder::SessionDirToReaper(QString& strSessionDirName) out << CReaperProject(CJamSession::TracksFromSessionDir(fiSessionDir.absoluteFilePath())).toString() << endl; - (*(new ConsoleWriterFactory())->get()) << "Session RPP: " << reaperProjectFileName << endl; + qDebug() << "Session RPP:" << reaperProjectFileName; } /** @@ -408,11 +408,11 @@ void CJamRecorder::OnDisconnected(int iChID) { if (!isRecording) { - tsConsole << "CJamRecorder::OnDisconnected: channel " << iChID << " disconnected but not recording" << endl; + qWarning() << "CJamRecorder::OnDisconnected: channel" << iChID << "disconnected but not recording"; } if (currentSession == nullptr) { - tsConsole << "CJamRecorder::OnDisconnected: channel " << iChID << " disconnected but no currentSession" << endl; + qWarning() << "CJamRecorder::OnDisconnected: channel" << iChID << "disconnected but no currentSession"; return; } currentSession->DisconnectClient(iChID); diff --git a/src/recorder/jamrecorder.h b/src/recorder/jamrecorder.h index 600faab6..3dd24e15 100755 --- a/src/recorder/jamrecorder.h +++ b/src/recorder/jamrecorder.h @@ -170,7 +170,6 @@ private: bool isRecording; CJamSession* currentSession; - QTextStream& tsConsole = *((new ConsoleWriterFactory())->get()); }; } From a80b4378583456ccc76ae3f885c09aa247929284 Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Fri, 10 Apr 2020 17:51:37 +0100 Subject: [PATCH 2/5] Pass frame size to recorder --- src/recorder/jamrecorder.cpp | 5 ++++- src/recorder/jamrecorder.h | 4 +++- src/server.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/recorder/jamrecorder.cpp b/src/recorder/jamrecorder.cpp index 0d5d20d5..c1a4f0d1 100755 --- a/src/recorder/jamrecorder.cpp +++ b/src/recorder/jamrecorder.cpp @@ -295,7 +295,8 @@ QMap> CJamSession::TracksFromSessionDir(const QString * @brief CJamRecorder::Init Create recording directory, if necessary, and connect signal handlers * @param server Server object emiting signals */ -void CJamRecorder::Init(const CServer* server) +void CJamRecorder::Init( const CServer* server, + const int _iServerFrameSizeSamples ) { QFileInfo fi(recordBaseDir.absolutePath()); fi.setCaching(false); @@ -325,6 +326,8 @@ void CJamRecorder::Init(const CServer* server) QObject::connect((const QObject *)server, SIGNAL ( AudioFrame(const int, const QString, const CHostAddress, const int, const CVector) ), this, SLOT( OnFrame(const int, const QString, const CHostAddress, const int, const CVector) ), Qt::ConnectionType::QueuedConnection); + + iServerFrameSizeSamples = _iServerFrameSizeSamples; } /** diff --git a/src/recorder/jamrecorder.h b/src/recorder/jamrecorder.h index 3dd24e15..6adac471 100755 --- a/src/recorder/jamrecorder.h +++ b/src/recorder/jamrecorder.h @@ -139,7 +139,8 @@ class CJamRecorder : public QThread public: CJamRecorder(const QString recordingDirName) : recordBaseDir (recordingDirName), isRecording (false) {} - void Init(const CServer* server); + + void Init( const CServer* server, const int _iServerFrameSizeSamples ); static void SessionDirToReaper(QString& strSessionDirName); @@ -170,6 +171,7 @@ private: bool isRecording; CJamSession* currentSession; + int iServerFrameSizeSamples; }; } diff --git a/src/server.cpp b/src/server.cpp index 93ea88ce..16acb80a 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -397,7 +397,7 @@ CServer::CServer ( const int iNewMaxNumChan, // Enable jam recording (if requested) if ( bEnableRecording ) { - JamRecorder.Init ( this ); + JamRecorder.Init ( this, iServerFrameSizeSamples ); JamRecorder.start(); } From e4ac2f472d4317cd7696f0470e7e4c764baeea63 Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Fri, 10 Apr 2020 17:52:17 +0100 Subject: [PATCH 3/5] Use variable frame size in Reaper project --- src/recorder/creaperproject.cpp | 14 +++++++------- src/recorder/creaperproject.h | 12 ++++++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/recorder/creaperproject.cpp b/src/recorder/creaperproject.cpp index 412f61e1..69b179ce 100755 --- a/src/recorder/creaperproject.cpp +++ b/src/recorder/creaperproject.cpp @@ -55,7 +55,7 @@ using namespace recorder; * @param trackItem the details of where the item is in the track, along with the RIFF WAVE filename * @param iid the sequential item id */ -CReaperItem::CReaperItem(const QString& name, const STrackItem& trackItem, const qint32& iid) +CReaperItem::CReaperItem(const QString& name, const STrackItem& trackItem, const qint32& iid, int frameSize) { QString wavName = trackItem.fileName; // assume RPP in same location... @@ -64,8 +64,8 @@ CReaperItem::CReaperItem(const QString& name, const STrackItem& trackItem, const sOut << " items) +CReaperTrack::CReaperTrack(QString name, qint32& iid, QList items, int frameSize) { QTextStream sOut(&out); @@ -96,7 +96,7 @@ CReaperTrack::CReaperTrack(QString name, qint32& iid, QList items) int ino = 1; foreach (auto item, items) { - sOut << CReaperItem(name + " (" + QString::number(ino) + ")", item, iid).toString() << endl; + sOut << CReaperItem(name + " (" + QString::number(ino) + ")", item, iid, frameSize).toString() << endl; ino++; iid++; } @@ -109,7 +109,7 @@ CReaperTrack::CReaperTrack(QString name, qint32& iid, QList items) * @brief CReaperProject::CReaperProject Construct a Reaper RPP "" for a given list of tracks * @param tracks the list of tracks */ -CReaperProject::CReaperProject(QMap> tracks) +CReaperProject::CReaperProject(QMap> tracks, int frameSize) { QTextStream sOut(&out); @@ -121,7 +121,7 @@ CReaperProject::CReaperProject(QMap> tracks) qint32 iid = 0; foreach(auto trackName, tracks.keys()) { - sOut << CReaperTrack(trackName, iid, tracks[trackName]).toString() << endl; + sOut << CReaperTrack(trackName, iid, tracks[trackName], frameSize).toString() << endl; } sOut << ">"; diff --git a/src/recorder/creaperproject.h b/src/recorder/creaperproject.h index 5e2f49df..be6f190a 100755 --- a/src/recorder/creaperproject.h +++ b/src/recorder/creaperproject.h @@ -52,7 +52,7 @@ class CReaperItem : public QObject Q_OBJECT public: - CReaperItem(const QString& name, const STrackItem& trackItem, const qint32& iid); + CReaperItem( const QString& name, const STrackItem& trackItem, const qint32& iid, int frameSize ); QString toString() { return out; } private: @@ -60,7 +60,11 @@ private: const QUuid guid = QUuid::createUuid(); QString out; - inline QString secondsAt48K(const qint64 frames) { return QString::number(static_cast(frames * SYSTEM_FRAME_SIZE_SAMPLES) / 48000, 'f', 14); } + inline QString secondsAt48K( const qint64 frames, + const int frameSize ) + { + return QString::number( static_cast( frames * frameSize ) / 48000, 'f', 14 ); + } }; class CReaperTrack : public QObject @@ -68,7 +72,7 @@ class CReaperTrack : public QObject Q_OBJECT public: - CReaperTrack(QString name, qint32 &iid, QList items); + CReaperTrack( QString name, qint32 &iid, QList items, int frameSize ); QString toString() { return out; } private: @@ -81,7 +85,7 @@ class CReaperProject : public QObject Q_OBJECT public: - CReaperProject(QMap > tracks); + CReaperProject( QMap > tracks, int frameSize ); QString toString() { return out; } private: From ec2673eaa1f7bdf4f4c9a8999cd55cd1bdd35eb1 Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Fri, 10 Apr 2020 17:56:04 +0100 Subject: [PATCH 4/5] Pass frame size to Reaper project from recorder --- src/recorder/jamrecorder.cpp | 6 +++--- src/recorder/jamrecorder.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/recorder/jamrecorder.cpp b/src/recorder/jamrecorder.cpp index c1a4f0d1..bfe6c005 100755 --- a/src/recorder/jamrecorder.cpp +++ b/src/recorder/jamrecorder.cpp @@ -363,7 +363,7 @@ void CJamRecorder::OnEnd() QFile outf (reaperProjectFileName); outf.open(QFile::WriteOnly); QTextStream out(&outf); - out << CReaperProject(currentSession->Tracks()).toString() << endl; + out << CReaperProject(currentSession->Tracks(), iServerFrameSizeSamples).toString() << endl; qDebug() << "Session RPP:" << reaperProjectFileName; } @@ -376,7 +376,7 @@ void CJamRecorder::OnEnd() * @brief CJamRecorder::SessionDirToReaper Replica of CJamRecorder::OnEnd() but using the directory contents to construct the CReaperProject object * @param strSessionDirName */ -void CJamRecorder::SessionDirToReaper(QString& strSessionDirName) +void CJamRecorder::SessionDirToReaper(QString& strSessionDirName, int serverFrameSizeSamples) { const QFileInfo fiSessionDir(QDir::cleanPath(strSessionDirName)); if (!fiSessionDir.exists() || !fiSessionDir.isDir()) @@ -398,7 +398,7 @@ void CJamRecorder::SessionDirToReaper(QString& strSessionDirName) } QTextStream out(&outf); - out << CReaperProject(CJamSession::TracksFromSessionDir(fiSessionDir.absoluteFilePath())).toString() << endl; + out << CReaperProject( CJamSession::TracksFromSessionDir(fiSessionDir.absoluteFilePath()), serverFrameSizeSamples ).toString() << endl; qDebug() << "Session RPP:" << reaperProjectFileName; } diff --git a/src/recorder/jamrecorder.h b/src/recorder/jamrecorder.h index 6adac471..86e535cd 100755 --- a/src/recorder/jamrecorder.h +++ b/src/recorder/jamrecorder.h @@ -142,7 +142,7 @@ public: void Init( const CServer* server, const int _iServerFrameSizeSamples ); - static void SessionDirToReaper(QString& strSessionDirName); + static void SessionDirToReaper( QString& strSessionDirName, int serverFrameSizeSamples ); public slots: /** From a78ac717983bebfcb29f9693720ad6408b6c09d8 Mon Sep 17 00:00:00 2001 From: Peter L Jones Date: Fri, 10 Apr 2020 18:32:01 +0100 Subject: [PATCH 5/5] 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();