comparison layer/NoteLayer.cpp @ 507:efe0f232685f

* Make it possible to record live MIDI to a note layer. Now we're a proper MIDI sequencer. Ha, ha.
author Chris Cannam
date Wed, 25 Feb 2009 12:02:53 +0000
parents 0990b95140e3
children 1dd2cddc32eb
comparison
equal deleted inserted replaced
506:33572f3ad62b 507:efe0f232685f
1153 1153
1154 finish(command); 1154 finish(command);
1155 return true; 1155 return true;
1156 } 1156 }
1157 1157
1158 void
1159 NoteLayer::addNoteOn(long frame, int pitch, int velocity)
1160 {
1161 m_pendingNoteOns.insert(Note(frame, pitch, 0, float(velocity) / 127.0, ""));
1162 }
1163
1164 void
1165 NoteLayer::addNoteOff(long frame, int pitch)
1166 {
1167 for (NoteSet::iterator i = m_pendingNoteOns.begin();
1168 i != m_pendingNoteOns.end(); ++i) {
1169 if (lrintf((*i).value) == pitch) {
1170 Note note(*i);
1171 m_pendingNoteOns.erase(i);
1172 note.duration = frame - note.frame;
1173 if (m_model) {
1174 NoteModel::AddPointCommand *c = new NoteModel::AddPointCommand
1175 (m_model, note, tr("Record Note"));
1176 // execute and bundle:
1177 CommandHistory::getInstance()->addCommand(c, true, true);
1178 }
1179 break;
1180 }
1181 }
1182 }
1183
1184 void
1185 NoteLayer::abandonNoteOns()
1186 {
1187 m_pendingNoteOns.clear();
1188 }
1189
1158 int 1190 int
1159 NoteLayer::getDefaultColourHint(bool darkbg, bool &impose) 1191 NoteLayer::getDefaultColourHint(bool darkbg, bool &impose)
1160 { 1192 {
1161 impose = false; 1193 impose = false;
1162 return ColourDatabase::getInstance()->getColourIndex 1194 return ColourDatabase::getInstance()->getColourIndex