1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 3 /* 4 Rosegarden 5 A MIDI and audio sequencer and musical notation editor. 6 Copyright 2000-2021 the Rosegarden development team. 7 8 Other copyrights also apply to some parts of this work. Please 9 see the AUTHORS file and individual file headers for details. 10 11 This program is free software; you can redistribute it and/or 12 modify it under the terms of the GNU General Public License as 13 published by the Free Software Foundation; either version 2 of the 14 License, or (at your option) any later version. See the file 15 COPYING included with this distribution for more information. 16 */ 17 18 19 #include "TimeSigSegmentMapper.h" 20 21 #include "base/RealTime.h" 22 #include "document/RosegardenDocument.h" 23 #include "gui/seqmanager/SpecialSegmentMapper.h" 24 #include "sound/MappedEvent.h" 25 26 27 namespace Rosegarden 28 { 29 30 void 31 TimeSigSegmentMapper::fillBuffer() 32 { 33 RealTime eventTime; 34 35 Composition& comp = m_doc->getComposition(); 36 37 int index = 0; 38 39 for (int i = 0; i < comp.getTimeSignatureCount(); ++i) { 40 41 std::pair<timeT, TimeSignature> timeSigChange = comp.getTimeSignatureChange(i); 42 43 eventTime = comp.getElapsedRealTime(timeSigChange.first); 44 45 MappedEvent e; 46 e.setType(MappedEvent::TimeSignature); 47 e.setEventTime(eventTime); 48 e.setData1(timeSigChange.second.getNumerator()); 49 e.setData2(timeSigChange.second.getDenominator()); 50 51 getBuffer()[index] = e; 52 ++index; 53 } 54 55 resize(index); 56 } 57 58 int 59 TimeSigSegmentMapper::calculateSize() 60 { 61 return m_doc->getComposition().getTimeSignatureCount(); 62 } 63 64 // Time signatures always "play", even not-yet-played signatures 65 // before the beginning of a slice. 66 bool 67 TimeSigSegmentMapper:: 68 shouldPlay(MappedEvent */*evt*/, RealTime /*startTime*/) 69 { return true; } 70 71 } 72