📄 audiomixerwindow.cpp
字号:
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: *//* Rosegarden A MIDI and audio sequencer and musical notation editor. This program is Copyright 2000-2007 Guillaume Laurent <glaurent@telegraph-road.org>, Chris Cannam <cannam@all-day-breakfast.com>, Richard Bown <richard.bown@ferventsoftware.com> The moral rights of Guillaume Laurent, Chris Cannam, and Richard Bown to claim authorship of this work have been asserted. Other copyrights also apply to some parts of this work. Please see the AUTHORS file and individual file headers for details. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING included with this distribution for more information.*/#include "AudioMixerWindow.h"#include <qlayout.h>#include <kapplication.h>#include "AudioPlugin.h"#include "AudioPluginManager.h"#include "MixerWindow.h"#include "StudioControl.h"#include "sound/Midi.h"#include "misc/Debug.h"#include "gui/application/RosegardenDCOP.h"#include "base/AudioLevel.h"#include "base/AudioPluginInstance.h"#include "base/Composition.h"#include "base/Device.h"#include "base/Instrument.h"#include "base/MidiProgram.h"#include "base/Studio.h"#include "document/RosegardenGUIDoc.h"#include "gui/editors/notation/NotePixmapFactory.h"#include "gui/general/GUIPalette.h"#include "gui/seqmanager/SequencerMapper.h"#include "gui/seqmanager/SequenceManager.h"#include "gui/widgets/AudioRouteMenu.h"#include "gui/widgets/AudioVUMeter.h"#include "gui/widgets/Fader.h"#include "gui/widgets/Rotary.h"#include "gui/widgets/VUMeter.h"#include "sound/MappedCommon.h"#include "sound/MappedEvent.h"#include "sound/MappedStudio.h"#include <klocale.h>#include <kstddirs.h>#include <kaction.h>#include <kglobal.h>#include <kmainwindow.h>#include <kstdaction.h>#include <qaccel.h>#include <qcolor.h>#include <qfont.h>#include <qframe.h>#include <qhbox.h>#include <qiconset.h>#include <qlabel.h>#include <qobject.h>#include <qpalette.h>#include <qpixmap.h>#include <qpushbutton.h>#include <qstring.h>#include <qtooltip.h>#include <qvbox.h>#include <qwidget.h>namespace Rosegarden{// We define these such that the default of no-bits-set for the// studio's mixer display options produces the most sensible resultstatic const unsigned int MIXER_OMIT_FADERS = 1 << 0;static const unsigned int MIXER_OMIT_SUBMASTERS = 1 << 1;static const unsigned int MIXER_OMIT_PLUGINS = 1 << 2;static const unsigned int MIXER_SHOW_UNASSIGNED_FADERS = 1 << 3;static const unsigned int MIXER_OMIT_SYNTH_FADERS = 1 << 4;AudioMixerWindow::AudioMixerWindow(QWidget *parent, RosegardenGUIDoc *document): MixerWindow(parent, document), m_mainBox (0){ populate(); KStdAction::close(this, SLOT(slotClose()), actionCollection()); QIconSet icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-play"))); new KAction(i18n("&Play"), icon, Key_Enter, this, SIGNAL(play()), actionCollection(), "play"); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-stop"))); new KAction(i18n("&Stop"), icon, Key_Insert, this, SIGNAL(stop()), actionCollection(), "stop"); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-rewind"))); new KAction(i18n("Re&wind"), icon, Key_End, this, SIGNAL(rewindPlayback()), actionCollection(), "playback_pointer_back_bar"); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-ffwd"))); new KAction(i18n("&Fast Forward"), icon, Key_PageDown, this, SIGNAL(fastForwardPlayback()), actionCollection(), "playback_pointer_forward_bar"); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-rewind-end"))); new KAction(i18n("Rewind to &Beginning"), icon, 0, this, SIGNAL(rewindPlaybackToBeginning()), actionCollection(), "playback_pointer_start"); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-ffwd-end"))); new KAction(i18n("Fast Forward to &End"), icon, 0, this, SIGNAL(fastForwardPlaybackToEnd()), actionCollection(), "playback_pointer_end"); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-record"))); new KAction(i18n("&Record"), icon, 0, this, SIGNAL(record()), actionCollection(), "record"); icon = QIconSet(NotePixmapFactory::toQPixmap(NotePixmapFactory::makeToolbarPixmap ("transport-panic"))); new KAction(i18n("Panic"), icon, Key_P + CTRL + ALT, this, SIGNAL(panic()), actionCollection(), "panic"); unsigned int mixerOptions = m_studio->getMixerDisplayOptions(); (new KToggleAction(i18n("Show Audio &Faders"), 0, this, SLOT(slotToggleFaders()), actionCollection(), "show_audio_faders"))->setChecked (!(mixerOptions & MIXER_OMIT_FADERS)); (new KToggleAction(i18n("Show Synth &Faders"), 0, this, SLOT(slotToggleSynthFaders()), actionCollection(), "show_synth_faders"))->setChecked (!(mixerOptions & MIXER_OMIT_SYNTH_FADERS)); (new KToggleAction(i18n("Show &Submasters"), 0, this, SLOT(slotToggleSubmasters()), actionCollection(), "show_audio_submasters"))->setChecked (!(mixerOptions & MIXER_OMIT_SUBMASTERS)); (new KToggleAction(i18n("Show &Plugin Buttons"), 0, this, SLOT(slotTogglePluginButtons()), actionCollection(), "show_plugin_buttons"))->setChecked (!(mixerOptions & MIXER_OMIT_PLUGINS)); (new KToggleAction(i18n("Show &Unassigned Faders"), 0, this, SLOT(slotToggleUnassignedFaders()), actionCollection(), "show_unassigned_faders"))->setChecked (mixerOptions & MIXER_SHOW_UNASSIGNED_FADERS); KRadioAction *action = 0; for (int i = 1; i <= 16; i *= 2) { action = new KRadioAction(i18n("1 Input", "%n Inputs", i), 0, this, SLOT(slotSetInputCountFromAction()), actionCollection(), QString("inputs_%1").arg(i)); action->setExclusiveGroup("inputs"); if (i == int(m_studio->getRecordIns().size())) action->setChecked(true); } action = new KRadioAction (i18n("No Submasters"), 0, this, SLOT(slotSetSubmasterCountFromAction()), actionCollection(), QString("submasters_0")); action->setExclusiveGroup("submasters"); action->setChecked(true); for (int i = 2; i <= 8; i *= 2) { action = new KRadioAction (i18n("1 Submaster", "%n Submasters", i), 0, this, SLOT(slotSetSubmasterCountFromAction()), actionCollection(), QString("submasters_%1").arg(i)); action->setExclusiveGroup("submasters"); if (i == int(m_studio->getBusses().size()) - 1) action->setChecked(true); } createGUI("mixer.rc");}AudioMixerWindow::~AudioMixerWindow(){ RG_DEBUG << "AudioMixerWindow::~AudioMixerWindow\n"; depopulate();}voidAudioMixerWindow::depopulate(){ if (!m_mainBox) return ; // All the widgets will be deleted when the main box goes, // except that we need to delete the AudioRouteMenus first // because they aren't actually widgets but do contain them for (FaderMap::iterator i = m_faders.begin(); i != m_faders.end(); ++i) { delete i->second.m_input; delete i->second.m_output; } m_faders.clear(); m_submasters.clear(); delete m_mainBox; m_mainBox = 0;}voidAudioMixerWindow::populate(){ if (m_mainBox) { depopulate(); } else { m_surroundBox = new QHBox(this); setCentralWidget(m_surroundBox); } QFont font; font.setPointSize(font.pointSize() * 8 / 10); font.setBold(false); setFont(font); QFont boldFont(font); boldFont.setBold(true); m_mainBox = new QFrame(m_surroundBox); InstrumentList instruments = m_studio->getPresentationInstruments(); BussList busses = m_studio->getBusses(); QString pixmapDir = KGlobal::dirs()->findResource("appdata", "pixmaps/"); m_monoPixmap.load(QString("%1/misc/mono.xpm").arg(pixmapDir)); m_stereoPixmap.load(QString("%1/misc/stereo.xpm").arg(pixmapDir)); // Total cols: is 2 for each fader, submaster or master, plus 1 // for each spacer. QGridLayout *mainLayout = new QGridLayout (m_mainBox, (instruments.size() + busses.size()) * 3, 7); setCaption(i18n("Audio Mixer")); int count = 1; int col = 0; unsigned int mixerOptions = m_studio->getMixerDisplayOptions(); bool showUnassigned = (mixerOptions & MIXER_SHOW_UNASSIGNED_FADERS); for (InstrumentList::iterator i = instruments.begin(); i != instruments.end(); ++i) { if ((*i)->getType() != Instrument::Audio && (*i)->getType() != Instrument::SoftSynth) continue; FaderRec rec; if (!showUnassigned) { // Do any tracks use this instrument? if (!isInstrumentAssigned((*i)->getId())) { continue; } } rec.m_populated = true; if ((*i)->getType() == Instrument::Audio) { rec.m_input = new AudioRouteMenu(m_mainBox, AudioRouteMenu::In, AudioRouteMenu::Compact, m_studio, *i); QToolTip::add (rec.m_input->getWidget(), i18n("Record input source")); rec.m_input->getWidget()->setMaximumWidth(45); } else { rec.m_input = 0; } rec.m_output = new AudioRouteMenu(m_mainBox, AudioRouteMenu::Out, AudioRouteMenu::Compact, m_studio, *i); QToolTip::add (rec.m_output->getWidget(), i18n("Output destination")); rec.m_output->getWidget()->setMaximumWidth(45); rec.m_pan = new Rotary (m_mainBox, -100.0, 100.0, 1.0, 5.0, 0.0, 20, Rotary::NoTicks, false, true); if ((*i)->getType() == Instrument::Audio) { rec.m_pan->setKnobColour(GUIPalette::getColour(GUIPalette::RotaryPastelGreen)); } else { rec.m_pan->setKnobColour(GUIPalette::getColour(GUIPalette::RotaryPastelYellow)); } QToolTip::add (rec.m_pan, i18n("Pan")); rec.m_fader = new Fader (AudioLevel::LongFader, 20, 240, m_mainBox); rec.m_meter = new AudioVUMeter (m_mainBox, VUMeter::AudioPeakHoldIECLong, true, rec.m_input != 0, 20, 240); QToolTip::add (rec.m_fader, i18n("Audio level")); QToolTip::add (rec.m_meter, i18n("Audio level")); rec.m_stereoButton = new QPushButton(m_mainBox); rec.m_stereoButton->setPixmap(m_monoPixmap); rec.m_stereoButton->setFixedSize(20, 20); rec.m_stereoButton->setFlat(true); rec.m_stereoness = false; QToolTip::add (rec.m_stereoButton, i18n("Mono or stereo")); rec.m_muteButton = new QPushButton(m_mainBox); rec.m_muteButton->setText("M"); rec.m_muteButton->setToggleButton(true); rec.m_muteButton->setFixedWidth(rec.m_stereoButton->width()); rec.m_muteButton->setFixedHeight(rec.m_stereoButton->height()); rec.m_muteButton->setFlat(true); QToolTip::add (rec.m_muteButton, i18n("Mute")); rec.m_soloButton = new QPushButton(m_mainBox); rec.m_soloButton->setText("S"); rec.m_soloButton->setToggleButton(true); rec.m_soloButton->setFixedWidth(rec.m_stereoButton->width()); rec.m_soloButton->setFixedHeight(rec.m_stereoButton->height()); rec.m_soloButton->setFlat(true); QToolTip::add (rec.m_soloButton, i18n("Solo")); rec.m_recordButton = new QPushButton(m_mainBox); rec.m_recordButton->setText("R"); rec.m_recordButton->setToggleButton(true); rec.m_recordButton->setFixedWidth(rec.m_stereoButton->width()); rec.m_recordButton->setFixedHeight(rec.m_stereoButton->height()); rec.m_recordButton->setFlat(true); QToolTip::add (rec.m_recordButton, i18n("Arm recording")); rec.m_pluginBox = new QVBox(m_mainBox); for (int p = 0; p < 5; ++p) { QPushButton *plugin = new QPushButton(rec.m_pluginBox, "pluginButton"); plugin->setText(i18n("<none>")); plugin->setMaximumWidth(45); QToolTip::add (plugin, i18n("Audio plugin button")); rec.m_plugins.push_back(plugin); connect(plugin, SIGNAL(clicked()), this, SLOT(slotSelectPlugin())); } QLabel *idLabel; QString idString; if ((*i)->getType() == Instrument::Audio) { idString = i18n("Audio %1").arg((*i)->getId() - AudioInstrumentBase + 1); idLabel = new QLabel(idString, m_mainBox, "audioIdLabel"); } else { idString = i18n("Synth %1").arg((*i)->getId() - SoftSynthInstrumentBase + 1); idLabel = new QLabel(idString, m_mainBox, "synthIdLabel"); } idLabel->setFont(boldFont); if (rec.m_input) { mainLayout->addMultiCellWidget(rec.m_input->getWidget(), 1, 1, col, col + 1); } mainLayout->addMultiCellWidget(rec.m_output->getWidget(), 2, 2, col, col + 1); // mainLayout->addWidget(idLabel, 2, col, Qt::AlignCenter); // mainLayout->addWidget(rec.m_pan, 2, col+1, Qt::AlignLeft); mainLayout->addMultiCellWidget(idLabel, 0, 0, col, col + 1, Qt::AlignCenter); mainLayout->addWidget(rec.m_pan, 5, col, Qt::AlignCenter); mainLayout->addWidget(rec.m_fader, 3, col, Qt::AlignCenter); mainLayout->addWidget(rec.m_meter, 3, col + 1, Qt::AlignCenter); // commented out until implemented // mainLayout->addWidget(rec.m_muteButton, 4, col); // mainLayout->addWidget(rec.m_soloButton, 4, col+1); rec.m_muteButton->hide(); rec.m_soloButton->hide(); // mainLayout->addWidget(rec.m_recordButton, 5, col); // mainLayout->addWidget(rec.m_stereoButton, 5, col+1); rec.m_recordButton->hide(); mainLayout->addWidget(rec.m_stereoButton, 5, col + 1); if (rec.m_pluginBox) { mainLayout->addMultiCellWidget(rec.m_pluginBox, 6, 6, col, col + 1); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -