TimeMicros struct
This commit is contained in:
parent
e579ba8ee8
commit
b218bdea7a
9 changed files with 188 additions and 25 deletions
|
|
@ -2171,7 +2171,7 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
|
|||
playPosLock.unlock();
|
||||
|
||||
// also set the playback position and sync file player if necessary
|
||||
DivSongTimestamps::Timestamp rowTS=curSubSong->ts.getTimes(curOrder,curRow);
|
||||
TimeMicros rowTS=curSubSong->ts.getTimes(curOrder,curRow);
|
||||
totalSeconds=rowTS.seconds;
|
||||
totalTicks=rowTS.micros;
|
||||
if (curFilePlayer && filePlayerSync) {
|
||||
|
|
@ -3109,7 +3109,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
// if file player is synchronized then set its position to that of the loop row
|
||||
if (curFilePlayer && filePlayerSync) {
|
||||
if (curFilePlayer->isPlaying()) {
|
||||
DivSongTimestamps::Timestamp rowTS=curSubSong->ts.loopStartTime;
|
||||
TimeMicros rowTS=curSubSong->ts.loopStartTime;
|
||||
int finalSeconds=rowTS.seconds+filePlayerCueSeconds;
|
||||
int finalMicros=rowTS.micros+filePlayerCueMicros;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@
|
|||
#include "../ta-log.h"
|
||||
#include <chrono>
|
||||
|
||||
DivSongTimestamps::Timestamp DivSongTimestamps::getTimes(int order, int row) {
|
||||
if (order<0 || order>=DIV_MAX_PATTERNS) return Timestamp(-1,0);
|
||||
if (row<0 || row>=DIV_MAX_ROWS) return Timestamp(-1,0);
|
||||
Timestamp* t=orders[order];
|
||||
if (t==NULL) return Timestamp(-1,0);
|
||||
TimeMicros DivSongTimestamps::getTimes(int order, int row) {
|
||||
if (order<0 || order>=DIV_MAX_PATTERNS) return TimeMicros(-1,0);
|
||||
if (row<0 || row>=DIV_MAX_ROWS) return TimeMicros(-1,0);
|
||||
TimeMicros* t=orders[order];
|
||||
if (t==NULL) return TimeMicros(-1,0);
|
||||
return t[row];
|
||||
}
|
||||
|
||||
|
|
@ -391,12 +391,12 @@ void DivSubSong::calcTimestamps(int chans, std::vector<DivGroovePattern>& groove
|
|||
// log row time here
|
||||
if (rowChanged && !endOfSong) {
|
||||
if (ts.orders[prevOrder]==NULL) {
|
||||
ts.orders[prevOrder]=new DivSongTimestamps::Timestamp[DIV_MAX_ROWS];
|
||||
ts.orders[prevOrder]=new TimeMicros[DIV_MAX_ROWS];
|
||||
for (int i=0; i<DIV_MAX_ROWS; i++) {
|
||||
ts.orders[prevOrder][i].seconds=-1;
|
||||
}
|
||||
}
|
||||
ts.orders[prevOrder][prevRow]=DivSongTimestamps::Timestamp(ts.totalSeconds,ts.totalMicros);
|
||||
ts.orders[prevOrder][prevRow]=TimeMicros(ts.totalSeconds,ts.totalMicros);
|
||||
rowChanged=false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "../pch.h"
|
||||
|
||||
#include "defines.h"
|
||||
#include "../timeutils.h"
|
||||
#include "../ta-utils.h"
|
||||
#include "config.h"
|
||||
#include "orders.h"
|
||||
|
|
@ -187,22 +188,15 @@ struct DivSongTimestamps {
|
|||
|
||||
// timestamp of a row
|
||||
// DO NOT ACCESS DIRECTLY! use the functions instead.
|
||||
struct Timestamp {
|
||||
// if seconds is -1, it means this row is not touched at all.
|
||||
int seconds, micros;
|
||||
Timestamp(int s, int u):
|
||||
seconds(s), micros(u) {}
|
||||
Timestamp():
|
||||
seconds(0), micros(0) {}
|
||||
};
|
||||
Timestamp* orders[DIV_MAX_PATTERNS];
|
||||
Timestamp loopStartTime;
|
||||
// if seconds is -1, it means this row is not touched at all.
|
||||
TimeMicros* orders[DIV_MAX_PATTERNS];
|
||||
TimeMicros loopStartTime;
|
||||
|
||||
// the furthest row that the playhead goes through in an order.
|
||||
unsigned char maxRow[DIV_MAX_PATTERNS];
|
||||
|
||||
// call this function to get the timestamp of a row.
|
||||
Timestamp getTimes(int order, int row);
|
||||
TimeMicros getTimes(int order, int row);
|
||||
|
||||
DivSongTimestamps();
|
||||
~DivSongTimestamps();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue