diff options
Diffstat (limited to 'src/commands/studio')
18 files changed, 1666 insertions, 0 deletions
diff --git a/src/commands/studio/AddControlParameterCommand.cpp b/src/commands/studio/AddControlParameterCommand.cpp new file mode 100644 index 0000000..35ac62a --- /dev/null +++ b/src/commands/studio/AddControlParameterCommand.cpp @@ -0,0 +1,75 @@ +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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 "AddControlParameterCommand.h" + +#include "base/ControlParameter.h" +#include "base/Device.h" +#include "base/MidiDevice.h" +#include "base/Studio.h" +#include <qstring.h> +#include <iostream> + + +namespace Rosegarden +{ + +AddControlParameterCommand::~AddControlParameterCommand() +{} + +void +AddControlParameterCommand::execute() +{ + MidiDevice *md = dynamic_cast<MidiDevice *> + (m_studio->getDevice(m_device)); + if (!md) { + std::cerr << "WARNING: AddControlParameterCommand::execute: device " + << m_device << " is not a MidiDevice in current studio" + << std::endl; + return ; + } + + md->addControlParameter(m_control); + + // store id of the new control + m_id = md->getControlParameters().size() - 1; +} + +void +AddControlParameterCommand::unexecute() +{ + MidiDevice *md = dynamic_cast<MidiDevice *> + (m_studio->getDevice(m_device)); + if (!md) { + std::cerr << "WARNING: AddControlParameterCommand::unexecute: device " + << m_device << " is not a MidiDevice in current studio" + << std::endl; + return ; + } + + md->removeControlParameter(m_id); +} + +} diff --git a/src/commands/studio/AddControlParameterCommand.h b/src/commands/studio/AddControlParameterCommand.h new file mode 100644 index 0000000..fa614ac --- /dev/null +++ b/src/commands/studio/AddControlParameterCommand.h @@ -0,0 +1,75 @@ + +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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. +*/ + +#ifndef _RG_ADDCONTROLPARAMETERCOMMAND_H_ +#define _RG_ADDCONTROLPARAMETERCOMMAND_H_ + +#include "base/ControlParameter.h" +#include "base/Device.h" +#include <kcommand.h> +#include <qstring.h> +#include <klocale.h> + + + + +namespace Rosegarden +{ + +class Studio; + + +class AddControlParameterCommand : public KNamedCommand +{ +public: + AddControlParameterCommand(Studio *studio, + DeviceId device, + ControlParameter control): + KNamedCommand(getGlobalName()), + m_studio(studio), + m_device(device), + m_control(control), + m_id(0) { } + + ~AddControlParameterCommand(); + + virtual void execute(); + virtual void unexecute(); + + static QString getGlobalName() { return i18n("&Add Control Parameter"); } + +protected: + Studio *m_studio; + DeviceId m_device; + ControlParameter m_control; + int m_id; + +}; + + + +} + +#endif diff --git a/src/commands/studio/CreateOrDeleteDeviceCommand.cpp b/src/commands/studio/CreateOrDeleteDeviceCommand.cpp new file mode 100644 index 0000000..48dc6c1 --- /dev/null +++ b/src/commands/studio/CreateOrDeleteDeviceCommand.cpp @@ -0,0 +1,161 @@ +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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 "CreateOrDeleteDeviceCommand.h" + +#include "misc/Debug.h" +#include "misc/Strings.h" +#include "base/Device.h" +#include "base/MidiDevice.h" +#include "base/Studio.h" +#include <qcstring.h> +#include <qdatastream.h> +#include <qstring.h> +#include "gui/application/RosegardenApplication.h" + + +namespace Rosegarden +{ + +CreateOrDeleteDeviceCommand::CreateOrDeleteDeviceCommand(Studio *studio, + DeviceId id) : + KNamedCommand(getGlobalName(true)), + m_studio(studio), + m_deviceId(id), + m_deviceCreated(true) +{ + Device *device = m_studio->getDevice(m_deviceId); + + if (device) { + m_name = device->getName(); + m_type = device->getType(); + m_direction = MidiDevice::Play; + MidiDevice *md = + dynamic_cast<MidiDevice *>(device); + if (md) + m_direction = md->getDirection(); + m_connection = device->getConnection(); + } else { + RG_DEBUG << "CreateOrDeleteDeviceCommand: No such device as " + << m_deviceId << endl; + } +} + +void +CreateOrDeleteDeviceCommand::execute() +{ + if (!m_deviceCreated) { + + // Create + + // don't want to do this again on undo even if it fails -- only on redo + m_deviceCreated = true; + + + QByteArray data; + QByteArray replyData; + QCString replyType; + QDataStream arg(data, IO_WriteOnly); + + arg << (int)m_type; + arg << (unsigned int)m_direction; + + if (!rgapp->sequencerCall("addDevice(int, unsigned int)", + replyType, replyData, data)) { + SEQMAN_DEBUG << "CreateDeviceCommand::execute - " + << "failure in sequencer addDevice" << endl; + return ; + } + + QDataStream reply(replyData, IO_ReadOnly); + reply >> m_deviceId; + + if (m_deviceId == Device::NO_DEVICE) { + SEQMAN_DEBUG << "CreateDeviceCommand::execute - " + << "sequencer addDevice failed" << endl; + return ; + } + + SEQMAN_DEBUG << "CreateDeviceCommand::execute - " + << " added device " << m_deviceId << endl; + + arg.device()->reset(); + arg << (unsigned int)m_deviceId; + arg << strtoqstr(m_connection); + + if (!rgapp->sequencerCall("setConnection(unsigned int, QString)", + replyType, replyData, data)) { + SEQMAN_DEBUG << "CreateDeviceCommand::execute - " + << "failure in sequencer setConnection" << endl; + return ; + } + + SEQMAN_DEBUG << "CreateDeviceCommand::execute - " + << " reconnected device " << m_deviceId + << " to " << m_connection << endl; + + // Add the device to the Studio now, so that we can name it -- + // otherwise the name will be lost + m_studio->addDevice(m_name, m_deviceId, m_type); + Device *device = m_studio->getDevice(m_deviceId); + if (device) { + MidiDevice *md = dynamic_cast<MidiDevice *> + (device); + if (md) + md->setDirection(m_direction); + } + + } else { + + // Delete + + QByteArray data; + QByteArray replyData; + QCString replyType; + QDataStream arg(data, IO_WriteOnly); + + if (m_deviceId == Device::NO_DEVICE) + return ; + + arg << (int)m_deviceId; + + if (!rgapp->sequencerCall("removeDevice(unsigned int)", + replyType, replyData, data)) { + SEQMAN_DEBUG << "CreateDeviceCommand::execute - " + << "failure in sequencer addDevice" << endl; + return ; + } + + SEQMAN_DEBUG << "CreateDeviceCommand::unexecute - " + << " removed device " << m_deviceId << endl; + + m_studio->removeDevice(m_deviceId); + + m_deviceId = Device::NO_DEVICE; + m_deviceCreated = false; + } +} + +} diff --git a/src/commands/studio/CreateOrDeleteDeviceCommand.h b/src/commands/studio/CreateOrDeleteDeviceCommand.h new file mode 100644 index 0000000..2fe69a3 --- /dev/null +++ b/src/commands/studio/CreateOrDeleteDeviceCommand.h @@ -0,0 +1,88 @@ + +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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. +*/ + +#ifndef _RG_CREATEORDELETEDEVICECOMMAND_H_ +#define _RG_CREATEORDELETEDEVICECOMMAND_H_ + +#include "base/Device.h" +#include "base/MidiDevice.h" +#include <string> +#include <kcommand.h> +#include <qstring.h> +#include <klocale.h> + + + + +namespace Rosegarden +{ + +class Studio; + + +class CreateOrDeleteDeviceCommand : public KNamedCommand +{ +public: + // Creation constructor + CreateOrDeleteDeviceCommand(Studio *studio, + std::string name, + Device::DeviceType type, + MidiDevice::DeviceDirection direction, + std::string connection) : + KNamedCommand(getGlobalName(false)), + m_studio(studio), + m_name(name), + m_type(type), + m_direction(direction), + m_connection(connection), + m_deviceId(Device::NO_DEVICE), + m_deviceCreated(false) { } + + // Deletion constructor + CreateOrDeleteDeviceCommand(Studio *studio, + DeviceId deviceId); + + static QString getGlobalName(bool deletion) { + return (deletion ? i18n("Delete Device") : i18n("Create Device")); + } + + virtual void execute(); + virtual void unexecute() { execute(); } + +protected: + Studio *m_studio; + std::string m_name; + Device::DeviceType m_type; + MidiDevice::DeviceDirection m_direction; + std::string m_connection; + DeviceId m_deviceId; + bool m_deviceCreated; +}; + + + +} + +#endif diff --git a/src/commands/studio/ModifyControlParameterCommand.cpp b/src/commands/studio/ModifyControlParameterCommand.cpp new file mode 100644 index 0000000..5c8c1a2 --- /dev/null +++ b/src/commands/studio/ModifyControlParameterCommand.cpp @@ -0,0 +1,75 @@ +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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 "ModifyControlParameterCommand.h" + +#include "base/ControlParameter.h" +#include "base/Device.h" +#include "base/MidiDevice.h" +#include "base/Studio.h" +#include <qstring.h> +#include <iostream> + + +namespace Rosegarden +{ + +ModifyControlParameterCommand::~ModifyControlParameterCommand() +{} + +void +ModifyControlParameterCommand::execute() +{ + MidiDevice *md = dynamic_cast<MidiDevice *> + (m_studio->getDevice(m_device)); + if (!md) { + std::cerr << "WARNING: ModifyControlParameterCommand::execute: device " + << m_device << " is not a MidiDevice in current studio" + << std::endl; + return ; + } + + ControlParameter *param = md->getControlParameter(m_id); + if (param) + m_originalControl = *param; + md->modifyControlParameter(m_control, m_id); +} + +void +ModifyControlParameterCommand::unexecute() +{ + MidiDevice *md = dynamic_cast<MidiDevice *> + (m_studio->getDevice(m_device)); + if (!md) { + std::cerr << "WARNING: ModifyControlParameterCommand::execute: device " + << m_device << " is not a MidiDevice in current studio" + << std::endl; + return ; + } + + md->modifyControlParameter(m_originalControl, m_id); +} + +} diff --git a/src/commands/studio/ModifyControlParameterCommand.h b/src/commands/studio/ModifyControlParameterCommand.h new file mode 100644 index 0000000..cd705d6 --- /dev/null +++ b/src/commands/studio/ModifyControlParameterCommand.h @@ -0,0 +1,74 @@ + +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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. +*/ + +#ifndef _RG_MODIFYCONTROLPARAMETERCOMMAND_H_ +#define _RG_MODIFYCONTROLPARAMETERCOMMAND_H_ + +#include "base/ControlParameter.h" +#include "base/Device.h" +#include <kcommand.h> +#include <qstring.h> +#include <klocale.h> + + + + +namespace Rosegarden +{ + +class Studio; + + +class ModifyControlParameterCommand : public KNamedCommand +{ +public: + ModifyControlParameterCommand(Studio *studio, + DeviceId device, + ControlParameter control, + int id): + KNamedCommand(getGlobalName()), + m_studio(studio), + m_device(device), + m_control(control), + m_id(id) { } + ~ModifyControlParameterCommand(); + + virtual void execute(); + virtual void unexecute(); + + static QString getGlobalName() { return i18n("&Modify Control Parameter"); } + +protected: + Studio *m_studio; + DeviceId m_device; + ControlParameter m_control; + int m_id; + ControlParameter m_originalControl; + +}; + +} + +#endif diff --git a/src/commands/studio/ModifyDeviceCommand.cpp b/src/commands/studio/ModifyDeviceCommand.cpp new file mode 100644 index 0000000..d3323ac --- /dev/null +++ b/src/commands/studio/ModifyDeviceCommand.cpp @@ -0,0 +1,198 @@ +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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 "ModifyDeviceCommand.h" + +#include "base/Device.h" +#include "base/MidiDevice.h" +#include "base/Studio.h" +#include <qstring.h> +#include <iostream> + + +namespace Rosegarden +{ + +ModifyDeviceCommand::ModifyDeviceCommand( + Studio *studio, + DeviceId device, + const std::string &name, + const std::string &librarianName, + const std::string &librarianEmail): + KNamedCommand(getGlobalName()), + m_studio(studio), + m_device(device), + m_name(name), + m_librarianName(librarianName), + m_librarianEmail(librarianEmail), + m_overwrite(true), + m_rename(true), + m_changeVariation(false), + m_changeBanks(false), + m_changePrograms(false), + m_changeControls(false), + m_changeKeyMappings(false), + m_clearBankAndProgramList(false) +{} + +void ModifyDeviceCommand::setVariation(MidiDevice::VariationType variationType) +{ + m_variationType = variationType; + m_changeVariation = true; +} + +void ModifyDeviceCommand::setBankList(const BankList &bankList) +{ + m_bankList = bankList; + m_changeBanks = true; +} + +void ModifyDeviceCommand::setProgramList(const ProgramList &programList) +{ + m_programList = programList; + m_changePrograms = true; +} + +void ModifyDeviceCommand::setControlList(const ControlList &controlList) +{ + m_controlList = controlList; + m_changeControls = true; +} + +void ModifyDeviceCommand::setKeyMappingList(const KeyMappingList &keyMappingList) +{ + m_keyMappingList = keyMappingList; + m_changeKeyMappings = true; +} + +void +ModifyDeviceCommand::execute() +{ + Device *device = m_studio->getDevice(m_device); + MidiDevice *midiDevice = + dynamic_cast<MidiDevice *>(device); + + if (device) { + if (!midiDevice) { + std::cerr << "ERROR: ModifyDeviceCommand::execute: device " + << m_device << " is not a MIDI device" << std::endl; + return ; + } + } else { + std::cerr + << "ERROR: ModifyDeviceCommand::execute: no such device as " + << m_device << std::endl; + return ; + } + + m_oldName = midiDevice->getName(); + m_oldBankList = midiDevice->getBanks(); + m_oldProgramList = midiDevice->getPrograms(); + m_oldControlList = midiDevice->getControlParameters(); + m_oldKeyMappingList = midiDevice->getKeyMappings(); + m_oldLibrarianName = midiDevice->getLibrarianName(); + m_oldLibrarianEmail = midiDevice->getLibrarianEmail(); + m_oldVariationType = midiDevice->getVariationType(); + + if (m_changeVariation) + midiDevice->setVariationType(m_variationType); + + if (m_overwrite) { + if (m_clearBankAndProgramList) { + midiDevice->clearBankList(); + midiDevice->clearProgramList(); + } else { + if (m_changeBanks) + midiDevice->replaceBankList(m_bankList); + if (m_changePrograms) + midiDevice->replaceProgramList(m_programList); + } + + if (m_changeKeyMappings) { + midiDevice->replaceKeyMappingList(m_keyMappingList); + } + + if (m_rename) + midiDevice->setName(m_name); + midiDevice->setLibrarian(m_librarianName, m_librarianEmail); + } else { + if (m_clearBankAndProgramList) { + midiDevice->clearBankList(); + midiDevice->clearProgramList(); + } else { + if (m_changeBanks) + midiDevice->mergeBankList(m_bankList); + if (m_changePrograms) + midiDevice->mergeProgramList(m_programList); + } + + if (m_changeKeyMappings) { + midiDevice->mergeKeyMappingList(m_keyMappingList); + } + + if (m_rename) { + std::string mergeName = midiDevice->getName() + + std::string("/") + m_name; + midiDevice->setName(mergeName); + } + } + + //!!! merge option? + if (m_changeControls) + midiDevice->replaceControlParameters(m_controlList); +} + +void +ModifyDeviceCommand::unexecute() +{ + Device *device = m_studio->getDevice(m_device); + MidiDevice *midiDevice = + dynamic_cast<MidiDevice *>(device); + + if (device) { + if (!midiDevice) { + std::cerr << "ERROR: ModifyDeviceCommand::unexecute: device " + << m_device << " is not a MIDI device" << std::endl; + return ; + } + } else { + std::cerr + << "ERROR: ModifyDeviceCommand::unexecute: no such device as " + << m_device << std::endl; + return ; + } + + if (m_rename) + midiDevice->setName(m_oldName); + midiDevice->replaceBankList(m_oldBankList); + midiDevice->replaceProgramList(m_oldProgramList); + midiDevice->replaceControlParameters(m_oldControlList); + midiDevice->replaceKeyMappingList(m_oldKeyMappingList); + midiDevice->setLibrarian(m_oldLibrarianName, m_oldLibrarianEmail); + if (m_changeVariation) + midiDevice->setVariationType(m_oldVariationType); +} + +} diff --git a/src/commands/studio/ModifyDeviceCommand.h b/src/commands/studio/ModifyDeviceCommand.h new file mode 100644 index 0000000..f8f820e --- /dev/null +++ b/src/commands/studio/ModifyDeviceCommand.h @@ -0,0 +1,109 @@ + +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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. +*/ + +#ifndef _RG_MODIFYDEVICECOMMAND_H_ +#define _RG_MODIFYDEVICECOMMAND_H_ + +#include "base/Device.h" +#include "base/MidiDevice.h" +#include <string> +#include <kcommand.h> +#include <qstring.h> +#include <klocale.h> + + +class Modify; + + +namespace Rosegarden +{ + +class Studio; + + +class ModifyDeviceCommand : public KNamedCommand +{ +public: + // Any of the arguments passed by pointer may be null (except for + // the Studio) -- in which case they will not be changed in the device. + ModifyDeviceCommand(Studio *studio, + DeviceId device, + const std::string &name, + const std::string &librarianName, + const std::string &librarianEmail); + + void setVariation (MidiDevice::VariationType variationType); + void setBankList (const BankList &bankList); + void setProgramList(const ProgramList &programList); + void setControlList(const ControlList &controlList); + void setKeyMappingList(const KeyMappingList &keyMappingList); + void setOverwrite (bool overwrite) { m_overwrite = overwrite; } + void setRename (bool rename) { m_rename = rename; } + + /// supersedes setBankList() and setProgramList() + void clearBankAndProgramList() { m_clearBankAndProgramList = true; } + + static QString getGlobalName() { return i18n("Modify &MIDI Bank"); } + + virtual void execute(); + virtual void unexecute(); + +protected: + + Studio *m_studio; + int m_device; + std::string m_name; + std::string m_librarianName; + std::string m_librarianEmail; + MidiDevice::VariationType m_variationType; + BankList m_bankList; + ProgramList m_programList; + ControlList m_controlList; + KeyMappingList m_keyMappingList; + + std::string m_oldName; + std::string m_oldLibrarianName; + std::string m_oldLibrarianEmail; + MidiDevice::VariationType m_oldVariationType; + BankList m_oldBankList; + ProgramList m_oldProgramList; + ControlList m_oldControlList; + KeyMappingList m_oldKeyMappingList; + + bool m_overwrite; + bool m_rename; + bool m_changeVariation; + bool m_changeBanks; + bool m_changePrograms; + bool m_changeControls; + bool m_changeKeyMappings; + bool m_clearBankAndProgramList; + +}; + + +} + +#endif diff --git a/src/commands/studio/ModifyDeviceMappingCommand.cpp b/src/commands/studio/ModifyDeviceMappingCommand.cpp new file mode 100644 index 0000000..6f02d8d --- /dev/null +++ b/src/commands/studio/ModifyDeviceMappingCommand.cpp @@ -0,0 +1,147 @@ +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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 "ModifyDeviceMappingCommand.h" + +#include "misc/Debug.h" +#include "base/Composition.h" +#include "base/Device.h" +#include "base/Instrument.h" +#include "base/MidiProgram.h" +#include "base/Studio.h" +#include "base/Track.h" +#include "document/RosegardenGUIDoc.h" +#include <qstring.h> + + +namespace Rosegarden +{ + +ModifyDeviceMappingCommand::ModifyDeviceMappingCommand( + RosegardenGUIDoc *doc, + DeviceId fromDevice, + DeviceId toDevice): + KNamedCommand(getGlobalName()), + m_composition(&doc->getComposition()), + m_studio(&doc->getStudio()), + m_fromDevice(fromDevice), + m_toDevice(toDevice) +{} + +void +ModifyDeviceMappingCommand::execute() +{ + Composition::trackcontainer &tracks = + m_composition->getTracks(); + Composition::trackcontainer::iterator it = tracks.begin(); + Instrument *instr = 0; + int index = 0; + + for (; it != tracks.end(); it++) { + instr = m_studio->getInstrumentById(it->second->getInstrument()); + if (!instr || !instr->getDevice()) + continue; + + if (instr->getDevice()->getId() == m_fromDevice) { + // if source and target are MIDI + if (m_studio->getDevice(m_fromDevice)->getType() == + Device::Midi && + m_studio->getDevice(m_toDevice)->getType() == + Device::Midi) { + // Try to match channels on the target device + // + MidiByte channel = instr->getMidiChannel(); + + InstrumentList destList = m_studio-> + getDevice(m_toDevice)->getPresentationInstruments(); + + InstrumentList::iterator dIt = destList.begin(); + + for (; dIt != destList.end(); dIt++) { + if ((*dIt)->getMidiChannel() == channel) { + break; + } + } + + // Failure to match anything and there's no Instruments + // at all in the destination. Skip to next source Instrument. + // + if (dIt == destList.end() || destList.size() == 0) + continue; + + + RG_DEBUG << " Track " << it->first + << ", setting Instrument to " + << (*dIt)->getId() << endl; + + // store "to" and "from" values + // + m_mapping.push_back( + std::pair < TrackId, + InstrumentId > + (it->first, + instr->getId())); + + it->second->setInstrument((*dIt)->getId()); + } else // audio is involved in the mapping - use indexes + { + // assign by index numbers + InstrumentList destList = m_studio-> + getDevice(m_toDevice)->getPresentationInstruments(); + + // skip if we can't match + // + if (index > (int)(destList.size() - 1)) + continue; + + m_mapping.push_back( + std::pair < TrackId, + InstrumentId > + (it->first, + instr->getId())); + + it->second->setInstrument(destList[index]->getId()); + } + + index++; + } + } + +} + +void +ModifyDeviceMappingCommand::unexecute() +{ + std::vector<std::pair<TrackId, InstrumentId> > + ::iterator it = m_mapping.begin(); + Track *track = 0; + + for (; it != m_mapping.end(); it++) { + track = m_composition->getTrackById(it->first); + track->setInstrument(it->second); + } +} + +} diff --git a/src/commands/studio/ModifyDeviceMappingCommand.h b/src/commands/studio/ModifyDeviceMappingCommand.h new file mode 100644 index 0000000..150275d --- /dev/null +++ b/src/commands/studio/ModifyDeviceMappingCommand.h @@ -0,0 +1,71 @@ + +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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. +*/ + +#ifndef _RG_MODIFYDEVICEMAPPINGCOMMAND_H_ +#define _RG_MODIFYDEVICEMAPPINGCOMMAND_H_ + +#include "base/Device.h" +#include "base/Track.h" +#include <kcommand.h> +#include <qstring.h> +#include <vector> +#include <klocale.h> + + +class Modify; + + +namespace Rosegarden +{ + +class Studio; +class RosegardenGUIDoc; +class Composition; + + +class ModifyDeviceMappingCommand : public KNamedCommand +{ +public: + ModifyDeviceMappingCommand(RosegardenGUIDoc *doc, + DeviceId fromDevice, + DeviceId toDevice); + + static QString getGlobalName() { return i18n("Modify &Device Mapping"); } + + virtual void execute(); + virtual void unexecute(); +protected: + Composition *m_composition; + Studio *m_studio; + DeviceId m_fromDevice; + DeviceId m_toDevice; + + std::vector<std::pair<TrackId, InstrumentId> > m_mapping; +}; + + +} + +#endif diff --git a/src/commands/studio/ModifyInstrumentMappingCommand.cpp b/src/commands/studio/ModifyInstrumentMappingCommand.cpp new file mode 100644 index 0000000..e6369b6 --- /dev/null +++ b/src/commands/studio/ModifyInstrumentMappingCommand.cpp @@ -0,0 +1,78 @@ +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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 "ModifyInstrumentMappingCommand.h" + +#include "base/Composition.h" +#include "base/MidiProgram.h" +#include "base/Studio.h" +#include "base/Track.h" +#include "document/RosegardenGUIDoc.h" +#include <qstring.h> + + +namespace Rosegarden +{ + +ModifyInstrumentMappingCommand::ModifyInstrumentMappingCommand( + RosegardenGUIDoc *doc, + InstrumentId fromInstrument, + InstrumentId toInstrument): + KNamedCommand(getGlobalName()), + m_composition(&doc->getComposition()), + m_studio(&doc->getStudio()), + m_fromInstrument(fromInstrument), + m_toInstrument(toInstrument) +{} + +void +ModifyInstrumentMappingCommand::execute() +{ + Composition::trackcontainer &tracks = + m_composition->getTracks(); + Composition::trackcontainer::iterator it = tracks.begin(); + + for (; it != tracks.end(); it++) { + if (it->second->getInstrument() == m_fromInstrument) { + m_mapping.push_back(it->first); + it->second->setInstrument(m_toInstrument); + } + } + +} + +void +ModifyInstrumentMappingCommand::unexecute() +{ + std::vector<TrackId>::iterator it = m_mapping.begin(); + Track *track = 0; + + for (; it != m_mapping.end(); it++) { + track = m_composition->getTrackById(*it); + track->setInstrument(m_fromInstrument); + } +} + +} diff --git a/src/commands/studio/ModifyInstrumentMappingCommand.h b/src/commands/studio/ModifyInstrumentMappingCommand.h new file mode 100644 index 0000000..224459b --- /dev/null +++ b/src/commands/studio/ModifyInstrumentMappingCommand.h @@ -0,0 +1,76 @@ + +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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. +*/ + +#ifndef _RG_MODIFYINSTRUMENTMAPPINGCOMMAND_H_ +#define _RG_MODIFYINSTRUMENTMAPPINGCOMMAND_H_ + +#include "base/MidiProgram.h" +#include "base/Track.h" +#include <kcommand.h> +#include <qstring.h> +#include <vector> +#include <klocale.h> + + +class Modify; + + +namespace Rosegarden +{ + +class Studio; +class RosegardenGUIDoc; +class Composition; + + +class ModifyInstrumentMappingCommand : public KNamedCommand +{ +public: + ModifyInstrumentMappingCommand(RosegardenGUIDoc *doc, + InstrumentId fromInstrument, + InstrumentId toInstrument); + + static QString getGlobalName() { return i18n("Modify &Instrument Mapping"); } + + virtual void execute(); + virtual void unexecute(); + +protected: + Composition *m_composition; + Studio *m_studio; + InstrumentId m_fromInstrument; + InstrumentId m_toInstrument; + + std::vector<TrackId> m_mapping; + +}; + + +// because ModifyDeviceCommand is overkill for this + + +} + +#endif diff --git a/src/commands/studio/ReconnectDeviceCommand.cpp b/src/commands/studio/ReconnectDeviceCommand.cpp new file mode 100644 index 0000000..6d40ede --- /dev/null +++ b/src/commands/studio/ReconnectDeviceCommand.cpp @@ -0,0 +1,98 @@ +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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 "ReconnectDeviceCommand.h" + +#include "misc/Strings.h" +#include "misc/Debug.h" +#include "base/Device.h" +#include "base/Studio.h" +#include <qcstring.h> +#include <qdatastream.h> +#include <qstring.h> +#include "gui/application/RosegardenApplication.h" + + +namespace Rosegarden +{ + +void +ReconnectDeviceCommand::execute() +{ + Device *device = m_studio->getDevice(m_deviceId); + + if (device) { + m_oldConnection = device->getConnection(); + + QByteArray data; + QByteArray replyData; + QCString replyType; + QDataStream arg(data, IO_WriteOnly); + + arg << (unsigned int)m_deviceId; + arg << strtoqstr(m_newConnection); + + if (!rgapp->sequencerCall("setConnection(unsigned int, QString)", + replyType, replyData, data)) { + SEQMAN_DEBUG << "ReconnectDeviceCommand::execute - " + << "failure in sequencer setConnection" << endl; + return ; + } + + SEQMAN_DEBUG << "ReconnectDeviceCommand::execute - " + << " reconnected device " << m_deviceId + << " to " << m_newConnection << endl; + } +} + +void +ReconnectDeviceCommand::unexecute() +{ + Device *device = m_studio->getDevice(m_deviceId); + + if (device) { + + QByteArray data; + QByteArray replyData; + QCString replyType; + QDataStream arg(data, IO_WriteOnly); + + arg << (unsigned int)m_deviceId; + arg << strtoqstr(m_oldConnection); + + if (!rgapp->sequencerCall("setConnection(unsigned int, QString)", + replyType, replyData, data)) { + SEQMAN_DEBUG << "ReconnectDeviceCommand::unexecute - " + << "failure in sequencer setConnection" << endl; + return ; + } + + SEQMAN_DEBUG << "ReconnectDeviceCommand::unexecute - " + << " reconnected device " << m_deviceId + << " to " << m_oldConnection << endl; + } +} + +} diff --git a/src/commands/studio/ReconnectDeviceCommand.h b/src/commands/studio/ReconnectDeviceCommand.h new file mode 100644 index 0000000..910bdbf --- /dev/null +++ b/src/commands/studio/ReconnectDeviceCommand.h @@ -0,0 +1,70 @@ + +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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. +*/ + +#ifndef _RG_RECONNECTDEVICECOMMAND_H_ +#define _RG_RECONNECTDEVICECOMMAND_H_ + +#include "base/Device.h" +#include <string> +#include <kcommand.h> +#include <qstring.h> +#include <klocale.h> + + + + +namespace Rosegarden +{ + +class Studio; + + +class ReconnectDeviceCommand : public KNamedCommand +{ +public: + ReconnectDeviceCommand(Studio *studio, + DeviceId deviceId, + std::string newConnection) : + KNamedCommand(getGlobalName()), + m_studio(studio), + m_deviceId(deviceId), + m_newConnection(newConnection) { } + + static QString getGlobalName() { return i18n("Reconnect Device"); } + + virtual void execute(); + virtual void unexecute(); + +protected: + Studio *m_studio; + DeviceId m_deviceId; + std::string m_newConnection; + std::string m_oldConnection; +}; + + +} + +#endif diff --git a/src/commands/studio/RemoveControlParameterCommand.cpp b/src/commands/studio/RemoveControlParameterCommand.cpp new file mode 100644 index 0000000..5f596b5 --- /dev/null +++ b/src/commands/studio/RemoveControlParameterCommand.cpp @@ -0,0 +1,75 @@ +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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 "RemoveControlParameterCommand.h" + +#include "base/ControlParameter.h" +#include "base/Device.h" +#include "base/MidiDevice.h" +#include "base/Studio.h" +#include <qstring.h> +#include <iostream> + + +namespace Rosegarden +{ + +RemoveControlParameterCommand::~RemoveControlParameterCommand() +{} + +void +RemoveControlParameterCommand::execute() +{ + MidiDevice *md = dynamic_cast<MidiDevice *> + (m_studio->getDevice(m_device)); + if (!md) { + std::cerr << "WARNING: RemoveControlParameterCommand::execute: device " + << m_device << " is not a MidiDevice in current studio" + << std::endl; + return ; + } + + ControlParameter *param = md->getControlParameter(m_id); + if (param) + m_oldControl = *param; + md->removeControlParameter(m_id); +} + +void +RemoveControlParameterCommand::unexecute() +{ + MidiDevice *md = dynamic_cast<MidiDevice *> + (m_studio->getDevice(m_device)); + if (!md) { + std::cerr << "WARNING: RemoveControlParameterCommand::execute: device " + << m_device << " is not a MidiDevice in current studio" + << std::endl; + return ; + } + + md->addControlParameter(m_oldControl, m_id); +} + +} diff --git a/src/commands/studio/RemoveControlParameterCommand.h b/src/commands/studio/RemoveControlParameterCommand.h new file mode 100644 index 0000000..3143739 --- /dev/null +++ b/src/commands/studio/RemoveControlParameterCommand.h @@ -0,0 +1,73 @@ + +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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. +*/ + +#ifndef _RG_REMOVECONTROLPARAMETERCOMMAND_H_ +#define _RG_REMOVECONTROLPARAMETERCOMMAND_H_ + +#include "base/ControlParameter.h" +#include "base/Device.h" +#include <kcommand.h> +#include <qstring.h> +#include <klocale.h> + + + + +namespace Rosegarden +{ + +class Studio; + + +class RemoveControlParameterCommand : public KNamedCommand +{ +public: + RemoveControlParameterCommand(Studio *studio, + DeviceId device, + int id): + KNamedCommand(getGlobalName()), + m_studio(studio), + m_device(device), + m_id(id) { } + + ~RemoveControlParameterCommand(); + + virtual void execute(); + virtual void unexecute(); + + static QString getGlobalName() { return i18n("&Remove Control Parameter"); } + +protected: + Studio *m_studio; + DeviceId m_device; + int m_id; + ControlParameter m_oldControl; + +}; + + +} + +#endif diff --git a/src/commands/studio/RenameDeviceCommand.cpp b/src/commands/studio/RenameDeviceCommand.cpp new file mode 100644 index 0000000..1d6c382 --- /dev/null +++ b/src/commands/studio/RenameDeviceCommand.cpp @@ -0,0 +1,52 @@ +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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 "RenameDeviceCommand.h" + +#include "base/Device.h" +#include "base/Studio.h" +#include <qstring.h> + + +namespace Rosegarden +{ + +void +RenameDeviceCommand::execute() +{ + Device *device = m_studio->getDevice(m_deviceId); + if (m_oldName == "") + m_oldName = device->getName(); + device->setName(m_name); +} + +void +RenameDeviceCommand::unexecute() +{ + Device *device = m_studio->getDevice(m_deviceId); + device->setName(m_oldName); +} + +} diff --git a/src/commands/studio/RenameDeviceCommand.h b/src/commands/studio/RenameDeviceCommand.h new file mode 100644 index 0000000..d767bca --- /dev/null +++ b/src/commands/studio/RenameDeviceCommand.h @@ -0,0 +1,71 @@ + +/* -*- 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-2008 + Guillaume Laurent <[email protected]>, + Chris Cannam <[email protected]>, + Richard Bown <[email protected]> + + 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. +*/ + +#ifndef _RG_RENAMEDEVICECOMMAND_H_ +#define _RG_RENAMEDEVICECOMMAND_H_ + +#include "base/Device.h" +#include <string> +#include <kcommand.h> +#include <qstring.h> +#include <klocale.h> + + + + +namespace Rosegarden +{ + +class Studio; + + +class RenameDeviceCommand : public KNamedCommand +{ +public: + RenameDeviceCommand(Studio *studio, + DeviceId deviceId, + std::string name) : + KNamedCommand(getGlobalName()), + m_studio(studio), + m_deviceId(deviceId), + m_name(name) { } + + static QString getGlobalName() { return i18n("Rename Device"); } + + virtual void execute(); + virtual void unexecute(); + +protected: + Studio *m_studio; + DeviceId m_deviceId; + std::string m_name; + std::string m_oldName; +}; + + + +} + +#endif |