📄 rosegardenguiview.cpp
字号:
&aFM, SLOT(slotStopImport())); try { audioFileId = aFM.importURL(kurl, sampleRate); } catch (AudioFileManager::BadAudioPathException e) { CurrentProgressDialog::freeze(); QString errorString = i18n("Can't add dropped file. ") + strtoqstr(e.getMessage()); KMessageBox::sorry(this, errorString); return ; } catch (SoundFile::BadSoundFileException e) { CurrentProgressDialog::freeze(); QString errorString = i18n("Can't add dropped file. ") + strtoqstr(e.getMessage()); KMessageBox::sorry(this, errorString); return ; } disconnect(&progressDlg, SIGNAL(cancelClicked()), &aFM, SLOT(slotStopImport())); connect(&progressDlg, SIGNAL(cancelClicked()), &aFM, SLOT(slotStopPreview())); progressDlg.progressBar()->show(); progressDlg.slotSetOperationName(i18n("Generating audio preview...")); try { aFM.generatePreview(audioFileId); } catch (Exception e) { CurrentProgressDialog::freeze(); QString message = strtoqstr(e.getMessage()) + "\n\n" + i18n("Try copying this file to a directory where you have write permission and re-add it"); KMessageBox::information(this, message); //return false; } disconnect(&progressDlg, SIGNAL(cancelClicked()), &aFM, SLOT(slotStopPreview())); // add the file at the sequencer emit addAudioFile(audioFileId); // Now fetch file details // AudioFile *aF = aFM.getAudioFile(audioFileId); if (aF) { slotAddAudioSegment(audioFileId, trackId, time, RealTime(0, 0), aF->getLength()); RG_DEBUG << "RosegardenGUIView::slotDroppedNewAudio(" << "file = " << url << ", trackid = " << trackId << ", time = " << time << endl; }}voidRosegardenGUIView::slotDroppedAudio(QString audioDesc){ QTextIStream s(&audioDesc); AudioFileId audioFileId; TrackId trackId; timeT position; RealTime startTime, endTime; // read the audio info s >> audioFileId; s >> trackId; s >> position; s >> startTime.sec; s >> startTime.nsec; s >> endTime.sec; s >> endTime.nsec; RG_DEBUG << "RosegardenGUIView::slotDroppedAudio(" //<< audioDesc << ") : audioFileId = " << audioFileId << " - trackId = " << trackId << " - position = " << position << " - startTime.sec = " << startTime.sec << " - startTime.nsec = " << startTime.nsec << " - endTime.sec = " << endTime.sec << " - endTime.nsec = " << endTime.nsec << endl; slotAddAudioSegment(audioFileId, trackId, position, startTime, endTime);}voidRosegardenGUIView::slotSetMuteButton(TrackId track, bool value){ RG_DEBUG << "RosegardenGUIView::slotSetMuteButton - track id = " << track << ", value = " << value << endl; m_trackEditor->getTrackButtons()->setMuteButton(track, value); Track *trackObj = getDocument()-> getComposition().getTrackById(track); /* // to fix 739544 if (m_instrumentParameterBox->getSelectedInstrument() && m_instrumentParameterBox->getSelectedInstrument()->getId() == trackObj->getInstrument()) { m_instrumentParameterBox->setMute(value); } */ // set the value in the composition trackObj->setMuted(value); getDocument()->slotDocumentModified(); // set the modification flag}voidRosegardenGUIView::slotSetMute(InstrumentId id, bool value){ RG_DEBUG << "RosegardenGUIView::slotSetMute - " << "id = " << id << ",value = " << value << endl; Composition &comp = getDocument()->getComposition(); Composition::trackcontainer &tracks = comp.getTracks(); Composition::trackiterator it; for (it = tracks.begin(); it != tracks.end(); ++it) { if ((*it).second->getInstrument() == id) slotSetMuteButton((*it).second->getId(), value); }}voidRosegardenGUIView::slotSetRecord(InstrumentId id, bool value){ RG_DEBUG << "RosegardenGUIView::slotSetRecord - " << "id = " << id << ",value = " << value << endl; /* // IPB // m_instrumentParameterBox->setRecord(value); */ Composition &comp = getDocument()->getComposition(); Composition::trackcontainer &tracks = comp.getTracks(); Composition::trackiterator it;#ifdef NOT_DEFINED for (it = tracks.begin(); it != tracks.end(); ++it) { if (comp.getSelectedTrack() == (*it).second->getId()) { //!!! MTR m_trackEditor->getTrackButtons()-> // setRecordTrack((*it).second->getPosition()); //!!! MTR is this needed? I think probably not slotUpdateInstrumentParameterBox((*it).second->getInstrument()); } }#endif Studio &studio = getDocument()->getStudio(); Instrument *instr = studio.getInstrumentById(id);}voidRosegardenGUIView::slotSetSolo(InstrumentId id, bool value){ RG_DEBUG << "RosegardenGUIView::slotSetSolo - " << "id = " << id << ",value = " << value << endl; emit toggleSolo(value);}voidRosegardenGUIView::slotUpdateRecordingSegment(Segment *segment, timeT ){ // We're only interested in this on the first call per recording segment, // when we possibly create a view for it static Segment *lastRecordingSegment = 0; if (segment == lastRecordingSegment) return ; lastRecordingSegment = segment; KConfig* config = kapp->config(); config->setGroup(GeneralOptionsConfigGroup); int tracking = config->readUnsignedNumEntry("recordtracking", 0); if (tracking != 1) return ; RG_DEBUG << "RosegardenGUIView::slotUpdateRecordingSegment: segment is " << segment << ", lastRecordingSegment is " << lastRecordingSegment << ", opening a new view" << endl; std::vector<Segment *> segments; segments.push_back(segment); NotationView *view = createNotationView(segments); if (!view) return ; /* signal no longer exists QObject::connect (getDocument(), SIGNAL(recordingSegmentUpdated(Segment *, timeT)), view, SLOT(slotUpdateRecordingSegment(Segment *, timeT))); */ view->show();}voidRosegardenGUIView::slotSynchroniseWithComposition(){ // Track buttons // m_trackEditor->getTrackButtons()->slotSynchroniseWithComposition(); // Update all IPBs // Composition &comp = getDocument()->getComposition(); Track *track = comp.getTrackById(comp.getSelectedTrack()); slotUpdateInstrumentParameterBox(track->getInstrument()); m_instrumentParameterBox->slotUpdateAllBoxes();}voidRosegardenGUIView::windowActivationChange(bool){ if (isActiveWindow()) { slotActiveMainWindowChanged(this); }}voidRosegardenGUIView::slotActiveMainWindowChanged(const QWidget *w){ m_lastActiveMainWindow = w;}voidRosegardenGUIView::slotActiveMainWindowChanged(){ const QWidget *w = dynamic_cast<const QWidget *>(sender()); if (w) slotActiveMainWindowChanged(w);}voidRosegardenGUIView::slotControllerDeviceEventReceived(MappedEvent *e){ RG_DEBUG << "Controller device event received - send to " << (void *)m_lastActiveMainWindow << " (I am " << this << ")" << endl; //!!! So, what _should_ we do with these? // -- external controller that sends e.g. volume control for each // of a number of channels -> if mixer present, use control to adjust // tracks on mixer // -- external controller that sends e.g. separate controllers on // the same channel for adjusting various parameters -> if IPB // visible, adjust it. Should we use the channel to select the // track? maybe as an option // do we actually need the last active main window for either of // these? -- yes, to determine whether to send to mixer or to IPB // in the first place. Send to audio mixer if active, midi mixer // if active, plugin dialog if active, otherwise keep it for // ourselves for the IPB. But, we'll do that by having the edit // views pass it back to us. // -- then we need to send back out to device. //!!! special cases: controller 81 received by any window -> // select window 0->main, 1->audio mix, 2->midi mix //!!! controller 82 received by main window -> select track //!!! these obviously should be configurable if (e->getType() == MappedEvent::MidiController) { if (e->getData1() == 81) { // select window int window = e->getData2(); if (window < 10) { // me show(); raise(); setActiveWindow(); } else if (window < 20) { RosegardenGUIApp::self()->slotOpenAudioMixer(); } else if (window < 30) { RosegardenGUIApp::self()->slotOpenMidiMixer(); } } } emit controllerDeviceEventReceived(e, m_lastActiveMainWindow);}voidRosegardenGUIView::slotControllerDeviceEventReceived(MappedEvent *e, const void *preferredCustomer){ if (preferredCustomer != this) return ; RG_DEBUG << "RosegardenGUIView::slotControllerDeviceEventReceived: this one's for me" << endl; raise(); RG_DEBUG << "Event is type: " << int(e->getType()) << ", channel " << int(e->getRecordedChannel()) << ", data1 " << int(e->getData1()) << ", data2 " << int(e->getData2()) << endl; Composition &comp = getDocument()->getComposition(); Studio &studio = getDocument()->getStudio(); TrackId currentTrackId = comp.getSelectedTrack(); Track *track = comp.getTrackById(currentTrackId); // If the event is a control change on channel n, then (if // follow-channel is on) switch to the nth track of the same type // as the current track -- or the first track of the given // channel?, and set the control appropriately. Any controls in // IPB are supported for a MIDI device plus program and bank; only // volume and pan are supported for audio/synth devices. //!!! complete this if (e->getType() != MappedEvent::MidiController) { if (e->getType() == MappedEvent::MidiProgramChange) { int program = e->getData1(); if (!track) return ; InstrumentId ii = track->getInstrument(); Instrument *instrument = studio.getInstrumentById(ii); if (!instrument) return ; instrument->setProgramChange(program); emit instrumentParametersChanged(ii); } return ; } unsigned int channel = e->getRecordedChannel(); MidiByte controller = e->getData1(); MidiByte value = e->getData2(); if (controller == 82) { //!!! magic select-track controller int tracks = comp.getNbTracks(); Track *track = comp.getTrackByPosition(value * tracks / 127); if (track) { slotSelectTrackSegments(track->getId()); } return ; } if (!track) return ; InstrumentId ii = track->getInstrument(); Instrument *instrument = studio.getInstrumentById(ii); if (!instrument) return ; switch (instrument->getType()) { case Instrument::Midi: { MidiDevice *md = dynamic_cast<MidiDevice *> (instrument->getDevice()); if (!md) { std::cerr << "WARNING: MIDI instrument has no MIDI device in slotControllerDeviceEventReceived" << std::endl; return ; } //!!! we need a central clearing house for these changes, // for a proper mvc structure. reqd for automation post-1.2. // in the mean time this duplicates much of // MIDIInstrumentParameterPanel::slotControllerChanged etc switch (controller) { case MIDI_CONTROLLER_VOLUME: RG_DEBUG << "Setting volume for instrument " << instrument->getId() << " to " << va
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -