On Monday 19 Dec 2005 20:25, Chris Cannam wrote: > Next things: > > -- The MIDI record segment doesn't appear until the first event > arrives (but updates smoothly after that). Fix.
Not fixed. Attached is a patch I previously mentioned, that does some of this (i.e. it does actually make the MIDI record segment appear as soon as you start recording). But it causes some pretty insidious crashes. See about half way through my email of 22:46 this evening for more about this one. I'm including the patch anyway because it might be a good starting point (or hint of what not to do). > -- Need one audio preview updater per segment in the composition > view, so that preview generation gets cancelled properly when the > zoom size etc changes. Done. > -- Audio preview generation doesn't start happening until the audio > segments are exposed -- we've argued about this before, I maintain my > view, we should revert to the former behaviour. Done. > -- Audio previews don't take tempo changes into account (bug > #whatever, filed in 1643). Haven't attempted this yet. Chris
Index: rosegardenguidoc.cpp =================================================================== RCS file: /cvsroot/rosegarden/gui/rosegardenguidoc.cpp,v retrieving revision 1.444 diff -c -r1.444 rosegardenguidoc.cpp *** rosegardenguidoc.cpp 11 Dec 2005 10:34:22 -0000 1.444 --- rosegardenguidoc.cpp 19 Dec 2005 23:45:30 -0000 *************** *** 1443,1475 **** if (!midiRecordTrack) return; if (m_recordMIDISegment == 0) { ! ! m_recordMIDISegment = new Segment(); ! m_recordMIDISegment->setTrack(midiRecordTrack->getId()); ! m_recordMIDISegment->setStartTime(m_recordStartTime); ! ! // Set an appropriate segment label ! // ! std::string label = ""; ! ! if (midiRecordTrack) { ! if (midiRecordTrack->getLabel() == "") { ! Rosegarden::Instrument *instr = ! m_studio.getInstrumentById(midiRecordTrack->getInstrument()); ! ! if (instr) { ! label = m_studio.getSegmentName(instr->getId()); ! } ! } else { ! label = midiRecordTrack->getLabel(); ! } ! ! label = qstrtostr(i18n("%1 (recorded)").arg(strtoqstr(label))); ! } ! ! m_recordMIDISegment->setLabel(label); ! ! emit newMIDIRecordingSegment(m_recordMIDISegment); } if (mC.size() > 0 && m_recordMIDISegment) --- 1443,1449 ---- if (!midiRecordTrack) return; if (m_recordMIDISegment == 0) { ! addRecordMIDISegment(midiRecordTrack->getId()); } if (mC.size() > 0 && m_recordMIDISegment) *************** *** 1644,1657 **** // rEvent->set<Int>(RECORDED_PORT, device); ! // Set the start index and then insert into the Composition ! // (if we haven't before) // ! if (m_recordMIDISegment->size() == 0 && !m_composition.contains(m_recordMIDISegment)) { m_recordMIDISegment->setStartTime (m_composition.getBarStartForTime(absTime)); m_recordMIDISegment->fillWithRests(absTime); - m_composition.addSegment(m_recordMIDISegment); } // Now insert the new event --- 1618,1629 ---- // rEvent->set<Int>(RECORDED_PORT, device); ! // Set the proper start index (if we haven't before) // ! if (m_recordMIDISegment->size() == 0) { m_recordMIDISegment->setStartTime (m_composition.getBarStartForTime(absTime)); m_recordMIDISegment->fillWithRests(absTime); } // Now insert the new event *************** *** 1738,1743 **** --- 1710,1725 ---- if (m_recordMIDISegment == 0) return; + if (m_recordMIDISegment->size() == 0) { + if (m_recordMIDISegment->getComposition()) { + m_recordMIDISegment->getComposition()->deleteSegment(m_recordMIDISegment); + } else { + delete m_recordMIDISegment; + } + m_recordMIDISegment = 0; + return; + } + RG_DEBUG << "RosegardenGUIDoc::stopRecordingMidi: have record MIDI segment" << endl; // otherwise do something with it *************** *** 2117,2122 **** --- 2099,2142 ---- } void + RosegardenGUIDoc::addRecordMIDISegment(Rosegarden::TrackId tid) + { + RG_DEBUG << "RosegardenGUIDoc::addRecordMIDISegment(" << tid << ")" << endl; + + delete m_recordMIDISegment; + + m_recordMIDISegment = new Segment(); + m_recordMIDISegment->setTrack(tid); + m_recordMIDISegment->setStartTime(m_recordStartTime); + + // Set an appropriate segment label + // + std::string label = ""; + + Rosegarden::Track *track = m_composition.getTrackById(tid); + if (track) { + if (track->getLabel() == "") { + Rosegarden::Instrument *instr = + m_studio.getInstrumentById(track->getInstrument()); + + if (instr) { + label = m_studio.getSegmentName(instr->getId()); + } + } else { + label = track->getLabel(); + } + + label = qstrtostr(i18n("%1 (recorded)").arg(strtoqstr(label))); + } + + m_recordMIDISegment->setLabel(label); + + m_composition.addSegment(m_recordMIDISegment); + + emit newMIDIRecordingSegment(m_recordMIDISegment); + } + + void RosegardenGUIDoc::addRecordAudioSegment(Rosegarden::InstrumentId iid, Rosegarden::AudioFileId auid) { Index: rosegardenguidoc.h =================================================================== RCS file: /cvsroot/rosegarden/gui/rosegardenguidoc.h,v retrieving revision 1.146 diff -c -r1.146 rosegardenguidoc.h *** rosegardenguidoc.h 11 Dec 2005 10:34:22 -0000 1.146 --- rosegardenguidoc.h 19 Dec 2005 23:45:31 -0000 *************** *** 342,347 **** --- 342,348 ---- */ void getMappedDevice(Rosegarden::DeviceId id); + void addRecordMIDISegment(Rosegarden::TrackId); void addRecordAudioSegment(Rosegarden::InstrumentId, Rosegarden::AudioFileId); // Audio play and record latencies direct from the sequencer Index: sequencemanager.cpp =================================================================== RCS file: /cvsroot/rosegarden/gui/sequencemanager.cpp,v retrieving revision 1.332 diff -c -r1.332 sequencemanager.cpp *** sequencemanager.cpp 14 Dec 2005 15:16:30 -0000 1.332 --- sequencemanager.cpp 19 Dec 2005 23:45:31 -0000 *************** *** 657,662 **** --- 657,664 ---- bool haveInstrument = false; bool haveAudioInstrument = false; + bool haveMIDIInstrument = false; + Rosegarden::TrackId recordMIDITrack = 0; for (Rosegarden::Composition::recordtrackcontainer::const_iterator i = comp.getRecordTracks().begin(); *************** *** 671,676 **** --- 673,681 ---- if (inst->getType() == Instrument::Audio) { haveAudioInstrument = true; break; + } else { // soft synths count as MIDI for our purposes here + haveMIDIInstrument = true; + recordMIDITrack = *i; } } } *************** *** 714,719 **** --- 719,735 ---- m_doc->updateAudioRecordLatency(); } + if (haveMIDIInstrument) { + // Create the record MIDI segment now, so that the + // composition view has a real segment to display. It + // won't actually be added to the composition until the + // first recorded event arrives. We don't have to do this + // from here for audio, because for audio the sequencer + // calls back on createRecordAudioFiles so as to find out + // what files it needs to write to. + m_doc->addRecordMIDISegment(recordMIDITrack); + } + // set the buttons m_transport->RecordButton()->setOn(true); m_transport->PlayButton()->setOn(true);