summaryrefslogtreecommitdiffstats
path: root/raul
diff options
context:
space:
mode:
Diffstat (limited to 'raul')
-rw-r--r--raul/Makefile.am3
-rw-r--r--raul/Quantizer.h36
-rw-r--r--raul/TimeSlice.h6
3 files changed, 43 insertions, 2 deletions
diff --git a/raul/Makefile.am b/raul/Makefile.am
index 76c9031..70aa03a 100644
--- a/raul/Makefile.am
+++ b/raul/Makefile.am
@@ -27,7 +27,8 @@ raulinclude_HEADERS = \
Stateful.h \
Thread.h \
WeakPtr.h \
- TimeSlice.h
+ TimeSlice.h \
+ Quantizer.h
if WITH_LIBLO
raulinclude_HEADERS += AtomLiblo.h
diff --git a/raul/Quantizer.h b/raul/Quantizer.h
new file mode 100644
index 0000000..c6a9bfb
--- /dev/null
+++ b/raul/Quantizer.h
@@ -0,0 +1,36 @@
+/* This file is part of Raul.
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ *
+ * Raul is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * Raul is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef RAUL_QUANTIZER_H
+#define RAUL_QUANTIZER_H
+
+#include <cmath>
+
+namespace Raul {
+
+
+class Quantizer {
+public:
+ inline static double quantize(double q, double value) {
+ return lrint(value / q) * q;
+ }
+};
+
+
+} // namespace Raul
+
+#endif // RAUL_QUANTIZER_H
diff --git a/raul/TimeSlice.h b/raul/TimeSlice.h
index 289233c..7ffd8a4 100644
--- a/raul/TimeSlice.h
+++ b/raul/TimeSlice.h
@@ -81,6 +81,10 @@ public:
return (time >= start_ticks() && time < start_ticks() + length_ticks());
}
+ double tick_rate() { return _tick_rate; }
+ double beat_rate() { return _beat_rate; }
+ double bpm() { return 60/_beat_rate; }
+
void set_tick_rate(double tick_rate) {
_tick_rate = tick_rate;
update_beat_time();
@@ -88,7 +92,7 @@ public:
void set_bpm(double bpm) {
_beat_rate = 60.0/bpm;
- update_beat_time();
+ //update_beat_time();
}
inline Seconds beats_to_seconds(BeatTime beats) const {