Mercurial > hg > svcore
changeset 1051:cafd65fc411b cxx11
Comments etc
author | Chris Cannam |
---|---|
date | Wed, 11 Mar 2015 09:29:44 +0000 |
parents | 5ad98be7f635 |
children | e603b44510c3 |
files | base/BaseTypes.h |
diffstat | 1 files changed, 30 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/base/BaseTypes.h Tue Mar 10 20:03:08 2015 +0000 +++ b/base/BaseTypes.h Wed Mar 11 09:29:44 2015 +0000 @@ -1,12 +1,34 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + Centre for Digital Music, Queen Mary, University of London. + + This program 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. See the file + COPYING included with this distribution for more information. +*/ #ifndef BASE_TYPES_H #define BASE_TYPES_H #include <cstdint> +/** Frame index, the unit of our time axis. This is signed because the + axis conceptually extends below zero: zero represents the start of + the main loaded audio model, not the start of time; a windowed + transform could legitimately produce results before then. We also + use this for frame counts, simply to avoid error-prone arithmetic + between signed and unsigned types. +*/ typedef int64_t sv_frame_t; -typedef double sv_samplerate_t; +/** Check whether an integer index is in range for a container, + avoiding overflows and signed/unsigned comparison warnings. +*/ template<typename T, typename C> bool in_range_for(const C &container, T i) { @@ -18,4 +40,11 @@ } } +/** Sample rate. We have to deal with sample rates provided as float + or (unsigned) int types, so we might as well have a type that can + represent both. Storage size isn't an issue anyway. +*/ +typedef double sv_samplerate_t; + #endif +