LMMS
Loading...
Searching...
No Matches
Time.h
Go to the documentation of this file.
1/*
2 ZynAddSubFX - a software synthesizer
3
4 Time.h - Frame Tracker
5 Copyright (C) 2016 Mark McCurry
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
11*/
12#pragma once
13#include <stdint.h>
14#include "../globals.h"
15
16namespace zyncarla {
17
19{
20 public:
22 :frames(0),
23 s(synth){};
24 void operator++(){++frames;};
25 void operator++(int){frames++;};
26 int64_t time() const {return frames;};
27 float dt() const { return s.dt(); }
28 float framesPerSec() const { return 1/s.dt();}
29 int samplesPerFrame() const {return s.buffersize;}
30 private:
31 int64_t frames;
32 const SYNTH_T &s;
33};
34
35//Marker for an event relative to some position of the absolute timer
37{
38 public:
39 RelTime(const AbsTime &t_, float sec)
40 :t(t_)
41 {
42 //Calculate time of event
43 double deltaFrames = sec*t.framesPerSec();
44 int64_t tmp = (int64_t)deltaFrames;
45 frame = t.time() + tmp;
46 sample = t.samplesPerFrame()*(deltaFrames-tmp);
47 }
48 bool inThisFrame() {return t.time() == frame;};
49 bool inPast() {return t.time() > frame;}
50 bool inFuture() {return t.time() < frame;}
51 private:
52 int64_t frame;
54 const AbsTime &t;
55};
56
57}
Definition Time.h:19
void operator++()
Definition Time.h:24
float dt() const
Definition Time.h:27
int64_t time() const
Definition Time.h:26
float framesPerSec() const
Definition Time.h:28
void operator++(int)
Definition Time.h:25
const SYNTH_T & s
Definition Time.h:32
int samplesPerFrame() const
Definition Time.h:29
AbsTime(const SYNTH_T &synth)
Definition Time.h:21
int64_t frames
Definition Time.h:31
bool inFuture()
Definition Time.h:50
const AbsTime & t
Definition Time.h:54
int64_t frame
Definition Time.h:52
int32_t sample
Definition Time.h:53
RelTime(const AbsTime &t_, float sec)
Definition Time.h:39
bool inThisFrame()
Definition Time.h:48
bool inPast()
Definition Time.h:49
int int32_t
Definition mid.cpp:97
Definition zynaddsubfx-src.cpp:569
const SYNTH_T & synth
Definition PADnoteParameters.h:210
Definition globals.h:294