Recorder support for session cut
This commit is contained in:
parent
d5c754b580
commit
376ce88f76
2 changed files with 68 additions and 25 deletions
|
@ -322,13 +322,12 @@ void CJamRecorder::Init( const CServer* server,
|
||||||
this, SLOT( OnDisconnected ( int ) ),
|
this, SLOT( OnDisconnected ( int ) ),
|
||||||
Qt::ConnectionType::QueuedConnection );
|
Qt::ConnectionType::QueuedConnection );
|
||||||
|
|
||||||
qRegisterMetaType<CVector<int16_t>>();
|
qRegisterMetaType<CVector<int16_t>> ( "CVector<int16_t>" );
|
||||||
QObject::connect( (const QObject *)server, SIGNAL ( AudioFrame( const int, const QString, const CHostAddress, const int, const CVector<int16_t> ) ),
|
QObject::connect( (const QObject *)server, SIGNAL ( AudioFrame( const int, const QString, const CHostAddress, const int, const CVector<int16_t> ) ),
|
||||||
this, SLOT( OnFrame (const int, const QString, const CHostAddress, const int, const CVector<int16_t> ) ),
|
this, SLOT( OnFrame (const int, const QString, const CHostAddress, const int, const CVector<int16_t> ) ),
|
||||||
Qt::ConnectionType::QueuedConnection );
|
Qt::ConnectionType::QueuedConnection );
|
||||||
|
|
||||||
QObject::connect( QCoreApplication::instance(),
|
QObject::connect( QCoreApplication::instance(), SIGNAL ( aboutToQuit() ),
|
||||||
SIGNAL ( aboutToQuit() ),
|
|
||||||
this, SLOT( OnAboutToQuit() ) );
|
this, SLOT( OnAboutToQuit() ) );
|
||||||
|
|
||||||
iServerFrameSizeSamples = _iServerFrameSizeSamples;
|
iServerFrameSizeSamples = _iServerFrameSizeSamples;
|
||||||
|
@ -338,11 +337,10 @@ void CJamRecorder::Init( const CServer* server,
|
||||||
thisThread->start();
|
thisThread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CJamRecorder::OnStart Start up tasks when the first client connects
|
* @brief CJamRecorder::Start Start up tasks for a new session
|
||||||
*/
|
*/
|
||||||
void CJamRecorder::OnStart() {
|
void CJamRecorder::Start() {
|
||||||
// Ensure any previous cleaning up has been done.
|
// Ensure any previous cleaning up has been done.
|
||||||
OnEnd();
|
OnEnd();
|
||||||
|
|
||||||
|
@ -350,11 +348,17 @@ void CJamRecorder::OnStart() {
|
||||||
isRecording = true;
|
isRecording = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CJamRecorder::OnEnd Finalise the recording and emit the Reaper RPP file
|
* @brief CJamRecorder::OnEnd Finalise the recording and emit the Reaper RPP file
|
||||||
|
*
|
||||||
|
* Emits RecordingSessionEnded with the Reaper project file name,
|
||||||
|
* or null if was not recording or a problem occurs
|
||||||
*/
|
*/
|
||||||
void CJamRecorder::OnEnd()
|
void CJamRecorder::OnEnd()
|
||||||
{
|
{
|
||||||
|
QString reaperProjectFileName = QString::Null();
|
||||||
|
|
||||||
if ( isRecording )
|
if ( isRecording )
|
||||||
{
|
{
|
||||||
isRecording = false;
|
isRecording = false;
|
||||||
|
@ -366,21 +370,46 @@ void CJamRecorder::OnEnd()
|
||||||
if (fi.exists())
|
if (fi.exists())
|
||||||
{
|
{
|
||||||
qWarning() << "CJamRecorder::OnEnd():" << fi.absolutePath() << "exists and will not be overwritten.";
|
qWarning() << "CJamRecorder::OnEnd():" << fi.absolutePath() << "exists and will not be overwritten.";
|
||||||
|
reaperProjectFileName = QString::Null();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QFile outf (reaperProjectFileName);
|
QFile outf (reaperProjectFileName);
|
||||||
outf.open(QFile::WriteOnly);
|
if ( outf.open(QFile::WriteOnly) )
|
||||||
QTextStream out(&outf);
|
{
|
||||||
out << CReaperProject( currentSession->Tracks(), iServerFrameSizeSamples ).toString() << endl;
|
QTextStream out(&outf);
|
||||||
qDebug() << "Session RPP:" << reaperProjectFileName;
|
out << CReaperProject( currentSession->Tracks(), iServerFrameSizeSamples ).toString() << endl;
|
||||||
|
qDebug() << "Session RPP:" << reaperProjectFileName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << "CJamRecorder::OnEnd():" << fi.absolutePath() << "could not be created, no RPP written.";
|
||||||
|
reaperProjectFileName = QString::Null();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete currentSession;
|
delete currentSession;
|
||||||
currentSession = nullptr;
|
currentSession = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit RecordingSessionEnded ( reaperProjectFileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief CJamRecorder::OnTriggerSession End one session and start a new one
|
||||||
|
*/
|
||||||
|
void CJamRecorder::OnTriggerSession()
|
||||||
|
{
|
||||||
|
// This should magically get everything right...
|
||||||
|
if ( isRecording )
|
||||||
|
{
|
||||||
|
Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief CJamRecorder::OnAboutToQuit End any recording and exit thread
|
||||||
|
*/
|
||||||
void CJamRecorder::OnAboutToQuit()
|
void CJamRecorder::OnAboutToQuit()
|
||||||
{
|
{
|
||||||
OnEnd();
|
OnEnd();
|
||||||
|
@ -452,7 +481,7 @@ void CJamRecorder::OnFrame(const int iChID, const QString name, const CHostAddre
|
||||||
// Make sure we are ready
|
// Make sure we are ready
|
||||||
if ( !isRecording )
|
if ( !isRecording )
|
||||||
{
|
{
|
||||||
OnStart();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSession->Frame( iChID, name, address, numAudioChannels, data, iServerFrameSizeSamples );
|
currentSession->Frame( iChID, name, address, numAudioChannels, data, iServerFrameSizeSamples );
|
||||||
|
|
|
@ -143,21 +143,44 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create recording directory, if necessary, and connect signal handlers
|
||||||
|
* @param server Server object emiting signals
|
||||||
|
*/
|
||||||
void Init( const CServer* server, const int _iServerFrameSizeSamples );
|
void Init( const CServer* server, const int _iServerFrameSizeSamples );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SessionDirToReaper Method that allows an RPP file to be recreated
|
||||||
|
* @param strSessionDirName Where the session wave files are
|
||||||
|
* @param serverFrameSizeSamples What the server frame size was for the session
|
||||||
|
*/
|
||||||
static void SessionDirToReaper( QString& strSessionDirName, int serverFrameSizeSamples );
|
static void SessionDirToReaper( QString& strSessionDirName, int serverFrameSizeSamples );
|
||||||
|
|
||||||
public slots:
|
private:
|
||||||
/**
|
void Start();
|
||||||
* @brief Raised when first client joins the server, triggering a new recording.
|
|
||||||
*/
|
|
||||||
void OnStart();
|
|
||||||
|
|
||||||
|
QDir recordBaseDir;
|
||||||
|
|
||||||
|
bool isRecording;
|
||||||
|
CJamSession* currentSession;
|
||||||
|
int iServerFrameSizeSamples;
|
||||||
|
|
||||||
|
QThread* thisThread;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void RecordingSessionEnded ( QString sessionDir );
|
||||||
|
|
||||||
|
private slots:
|
||||||
/**
|
/**
|
||||||
* @brief Raised when last client leaves the server, ending the recording.
|
* @brief Raised when last client leaves the server, ending the recording.
|
||||||
*/
|
*/
|
||||||
void OnEnd();
|
void OnEnd();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Raised to end one session and start a new one.
|
||||||
|
*/
|
||||||
|
void OnTriggerSession();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Raised when application is stopping
|
* @brief Raised when application is stopping
|
||||||
*/
|
*/
|
||||||
|
@ -173,15 +196,6 @@ public slots:
|
||||||
* @brief Raised when a frame of data is available to process
|
* @brief Raised when a frame of data is available to process
|
||||||
*/
|
*/
|
||||||
void OnFrame ( const int iChID, const QString name, const CHostAddress address, const int numAudioChannels, const CVector<int16_t> data );
|
void OnFrame ( const int iChID, const QString name, const CHostAddress address, const int numAudioChannels, const CVector<int16_t> data );
|
||||||
|
|
||||||
private:
|
|
||||||
QDir recordBaseDir;
|
|
||||||
|
|
||||||
bool isRecording;
|
|
||||||
CJamSession* currentSession;
|
|
||||||
int iServerFrameSizeSamples;
|
|
||||||
|
|
||||||
QThread* thisThread;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue