~quadrispro/qtractor/trunk

« back to all changes in this revision

Viewing changes to src/qtractorTrack.cpp

  • Committer: rncbc
  • Date: 2014-11-02 22:13:10 UTC
  • Revision ID: svn-v4:e0d40dc8-ea4a-44c7-bef6-bdaa6cc6c87d:trunk:4144
- Loop-recording/takes mode + punch-in/out fixed (BETA).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1114
1114
 
1115
1115
unsigned long qtractorTrack::clipRecordEnd ( unsigned long iFrameTime ) const
1116
1116
{
1117
 
        // HACK: Care of punch-out...
 
1117
        // HACK: Care of loop-recording + punch-in/out...
1118
1118
        if (m_pSession && m_pSession->isPunching()) {
1119
1119
                const unsigned long iLoopStart = m_pSession->loopStart();
1120
1120
                const unsigned long iLoopEnd = m_pSession->loopEnd();
 
1121
                unsigned long iPunchIn = m_pSession->punchIn();
1121
1122
                unsigned long iPunchOut = m_pSession->punchOut();
1122
 
        #if 1//TEST_PUNCH_LOOP_RECORDING_1
1123
1123
                if (iLoopStart < iLoopEnd &&
1124
 
                        iLoopStart < iFrameTime &&
 
1124
                        iLoopEnd < iFrameTime &&
1125
1125
                        m_pSession->loopRecordingMode() > 0) {
 
1126
                        if (iPunchIn < iLoopStart)
 
1127
                                iPunchIn = iLoopStart;
 
1128
                        if (iPunchOut > iLoopEnd)
 
1129
                                iPunchOut = iLoopEnd;
1126
1130
                        const unsigned long iLoopLength
1127
1131
                                = iLoopEnd - iLoopStart;
1128
 
                        const unsigned long iLoopCount
1129
 
                                = (iFrameTime - iLoopStart) / iLoopLength;
 
1132
                        const unsigned int iLoopCount
 
1133
                                = (iFrameTime - iPunchIn) / iLoopLength;
1130
1134
                        iPunchOut += iLoopCount * iLoopLength;
1131
1135
                }
1132
 
        #else
1133
 
                if (iLoopStart < iLoopEnd && iPunchOut >= iLoopEnd)
1134
 
                        iPunchOut = iLoopEnd;
1135
 
        #endif
1136
1136
                // Make sure it's really about to punch-out...
1137
 
                if (iFrameTime >= iPunchOut)
 
1137
                if (iFrameTime > iPunchOut)
1138
1138
                        return iPunchOut;
1139
1139
        }
1140
1140
 
1244
1244
                // Punch-in/out recording...
1245
1245
                if (m_pSession->isPunching()
1246
1246
                        && m_pSession->frameTimeEx() < iFrameEnd) {
1247
 
                #if 1//TEST_PUNCH_LOOP_RECORDING_1
1248
1247
                        const unsigned long iPunchIn = m_pSession->punchIn();
1249
1248
                        // Punch-in (likely...)
1250
1249
                        if (iPunchIn < iFrameEnd) {
1251
 
                                unsigned int offs = 0;
 
1250
                                unsigned int offset = 0;
1252
1251
                                if (iPunchIn >= iFrameStart) {
1253
 
                                        offs += (iPunchIn - iFrameStart);
 
1252
                                        offset += (iPunchIn - iFrameStart);
1254
1253
                                        nframes = (iFrameEnd - iPunchIn);
1255
1254
                                }
1256
1255
                                // Punch-in recording...
1257
1256
                                pAudioClip->write(
1258
 
                                        pInputBus->in(), nframes, pInputBus->channels(), offs);
1259
 
                        }
1260
 
                #else
1261
 
                        const unsigned long iPunchIn  = m_pSession->punchIn();
1262
 
                        const unsigned long iPunchOut = m_pSession->punchOut();
1263
 
                        if (iPunchIn < iFrameEnd && iPunchOut > iFrameStart) {
1264
 
                                unsigned int offs = 0;
1265
 
                                // Punch-out (unlikely...)
1266
 
                                if (iPunchIn >= iFrameStart) {
1267
 
                                        offs += (iPunchIn - iFrameStart);
1268
 
                                        if (iPunchOut < iFrameEnd)
1269
 
                                                nframes = (iPunchOut - iPunchIn);
1270
 
                                        else
1271
 
                                                nframes = (iFrameEnd - iPunchIn);
1272
 
                                }
1273
 
                                else
1274
 
                                // Punch-out (likely...)
1275
 
                                if (iPunchOut < iFrameEnd)
1276
 
                                        nframes = (iPunchOut - iFrameStart);
1277
 
                                // Punch-in/out recording...
1278
 
                                pAudioClip->write(
1279
 
                                        pInputBus->in(), nframes, pInputBus->channels(), offs);
1280
 
                        }
1281
 
                #endif
 
1257
                                        pInputBus->in(), nframes, pInputBus->channels(), offset);
 
1258
                        }
1282
1259
                } else {
1283
1260
                        // Regular full-length recording...
1284
1261
                        pAudioClip->write(