Mercurial > hg > svapp
comparison audio/AudioGenerator.h @ 615:755fc02a1565
Associate a note-on time with each pending note-off as well, so we can check whether a rewind action (or looping) has caused us to jump to before the note began. Also improve implementation of note-off structure comparator
author | Chris Cannam |
---|---|
date | Mon, 13 Aug 2018 14:13:38 +0100 |
parents | 0aee6ff48018 |
children | 7d3a6357ce64 |
comparison
equal
deleted
inserted
replaced
614:0aee6ff48018 | 615:755fc02a1565 |
---|---|
110 bool m_soloing; | 110 bool m_soloing; |
111 std::set<Model *> m_soloModelSet; | 111 std::set<Model *> m_soloModelSet; |
112 | 112 |
113 struct NoteOff { | 113 struct NoteOff { |
114 | 114 |
115 NoteOff(float _freq, sv_frame_t _frame) : | 115 NoteOff(float _freq, sv_frame_t _offFrame, sv_frame_t _onFrame) : |
116 frequency(_freq), frame(_frame) { } | 116 frequency(_freq), offFrame(_offFrame), onFrame(_onFrame) { } |
117 | 117 |
118 float frequency; | 118 float frequency; |
119 sv_frame_t frame; | 119 sv_frame_t offFrame; |
120 | |
121 // This is the frame at which the note whose note-off appears | |
122 // here began. It is used to determine when we should silence | |
123 // a note because the playhead has jumped back in time - if | |
124 // the current frame for rendering is earlier than this one, | |
125 // then we should end and discard the note | |
126 // | |
127 sv_frame_t onFrame; | |
120 | 128 |
121 struct Comparator { | 129 struct Comparator { |
122 bool operator()(const NoteOff &n1, const NoteOff &n2) const { | 130 bool operator()(const NoteOff &n1, const NoteOff &n2) const { |
123 return n1.frame < n2.frame; | 131 if (n1.offFrame != n2.offFrame) { |
132 return n1.offFrame < n2.offFrame; | |
133 } else if (n1.onFrame != n2.onFrame) { | |
134 return n1.onFrame < n2.onFrame; | |
135 } else { | |
136 return n1.frequency < n2.frequency; | |
137 } | |
124 } | 138 } |
125 }; | 139 }; |
126 }; | 140 }; |
127 | 141 |
128 | 142 |