Mercurial > hg > svcore
annotate data/model/NoteModel.cpp @ 249:d3ac9f953ebf
* Fix #1672407 confused by plugin-named files in cwd (or home?)
* Fix #1491848 crash when loading new file while transform plugin runs
* Fix #1502287 Background remains black after spectrogram layer deleted
* Fix #1604477 Replacing the main audio file silences secondary audio file
* Fix failure to initialise property box layout to last preference on startup
* Fix resample/wrong-rate display in Pane, ensure that right rate is chosen
if all current models have an acceptable rate even if previous main model
had a different one
* Fix "global zoom" broken in previous commit
* Some fixes to spectrogram cache area updating (makes spectrogram appear
more quickly, previously it had a tendency to refresh with empty space)
* Fixes to colour 3d plot normalization
author | Chris Cannam |
---|---|
date | Thu, 08 Mar 2007 16:53:08 +0000 |
parents | 3a13b0d4934e |
children | dc46851837d6 |
rev | line source |
---|---|
Chris@147 | 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
Chris@147 | 2 |
Chris@147 | 3 /* |
Chris@147 | 4 Sonic Visualiser |
Chris@147 | 5 An audio file viewer and annotation editor. |
Chris@147 | 6 Centre for Digital Music, Queen Mary, University of London. |
Chris@147 | 7 This file copyright 2006 Chris Cannam. |
Chris@147 | 8 |
Chris@147 | 9 This program is free software; you can redistribute it and/or |
Chris@147 | 10 modify it under the terms of the GNU General Public License as |
Chris@147 | 11 published by the Free Software Foundation; either version 2 of the |
Chris@147 | 12 License, or (at your option) any later version. See the file |
Chris@147 | 13 COPYING included with this distribution for more information. |
Chris@147 | 14 */ |
Chris@147 | 15 |
Chris@147 | 16 #include "NoteModel.h" |
Chris@147 | 17 |
Chris@147 | 18 NoteModel::PointList |
Chris@147 | 19 NoteModel::getPoints(long start, long end) const |
Chris@147 | 20 { |
Chris@147 | 21 if (start > end) return PointList(); |
Chris@147 | 22 QMutexLocker locker(&m_mutex); |
Chris@147 | 23 |
Chris@147 | 24 Note endPoint(end); |
Chris@147 | 25 |
Chris@147 | 26 PointListIterator endItr = m_points.upper_bound(endPoint); |
Chris@147 | 27 |
Chris@147 | 28 if (endItr != m_points.end()) ++endItr; |
Chris@147 | 29 if (endItr != m_points.end()) ++endItr; |
Chris@147 | 30 |
Chris@147 | 31 PointList rv; |
Chris@147 | 32 |
Chris@147 | 33 for (PointListIterator i = endItr; i != m_points.begin(); ) { |
Chris@147 | 34 --i; |
Chris@147 | 35 if (i->frame < start) { |
Chris@147 | 36 if (i->frame + i->duration >= start) { |
Chris@147 | 37 rv.insert(*i); |
Chris@147 | 38 } |
Chris@147 | 39 } else if (i->frame <= end) { |
Chris@147 | 40 rv.insert(*i); |
Chris@147 | 41 } |
Chris@147 | 42 } |
Chris@147 | 43 |
Chris@147 | 44 return rv; |
Chris@147 | 45 } |
Chris@147 | 46 |
Chris@147 | 47 NoteModel::PointList |
Chris@147 | 48 NoteModel::getPoints(long frame) const |
Chris@147 | 49 { |
Chris@147 | 50 QMutexLocker locker(&m_mutex); |
Chris@147 | 51 |
Chris@147 | 52 if (m_resolution == 0) return PointList(); |
Chris@147 | 53 |
Chris@147 | 54 long start = (frame / m_resolution) * m_resolution; |
Chris@147 | 55 long end = start + m_resolution; |
Chris@147 | 56 |
Chris@147 | 57 Note endPoint(end); |
Chris@147 | 58 |
Chris@147 | 59 PointListIterator endItr = m_points.upper_bound(endPoint); |
Chris@147 | 60 |
Chris@147 | 61 PointList rv; |
Chris@147 | 62 |
Chris@147 | 63 for (PointListIterator i = endItr; i != m_points.begin(); ) { |
Chris@147 | 64 --i; |
Chris@147 | 65 if (i->frame < start) { |
Chris@147 | 66 if (i->frame + i->duration >= start) { |
Chris@147 | 67 rv.insert(*i); |
Chris@147 | 68 } |
Chris@147 | 69 } else if (i->frame <= end) { |
Chris@147 | 70 rv.insert(*i); |
Chris@147 | 71 } |
Chris@147 | 72 } |
Chris@147 | 73 |
Chris@147 | 74 return rv; |
Chris@147 | 75 } |