diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:37:05 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:37:05 +0000 |
commit | 145364a8af6a1fec06556221e66d4b724a62fc9a (patch) | |
tree | 53bd71a544008c518034f208d64c932dc2883f50 /src/sound/ControlBlock.cpp | |
download | rosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.tar.gz rosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.zip |
Added old abandoned KDE3 version of the RoseGarden MIDI tool
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/rosegarden@1097595 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/sound/ControlBlock.cpp')
-rw-r--r-- | src/sound/ControlBlock.cpp | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/src/sound/ControlBlock.cpp b/src/sound/ControlBlock.cpp new file mode 100644 index 0000000..d0bb6a8 --- /dev/null +++ b/src/sound/ControlBlock.cpp @@ -0,0 +1,181 @@ +// -*- c-basic-offset: 4 -*- + +/* + Rosegarden + A 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 right of the authors to claim authorship of this work + has been asserted. + + 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 <cstring> + +#include "ControlBlock.h" + +namespace Rosegarden +{ + +ControlBlock::ControlBlock(unsigned int maxTrackId) + : m_maxTrackId(maxTrackId), + m_solo(false), + m_routing(true), + m_thruFilter(0), + m_recordFilter(0), + m_selectedTrack(0) +{ + m_metronomeInfo.muted = true; + m_metronomeInfo.instrumentId = 0; + for (unsigned int i = 0; i < CONTROLBLOCK_MAX_NB_TRACKS; ++i) { + m_trackInfo[i].muted = true; + m_trackInfo[i].deleted = true; + m_trackInfo[i].armed = true; + m_trackInfo[i].instrumentId = 0; + } +} + +ControlBlock::ControlBlock() +{ + // DO NOT initialize anything - this ctor is meant to be used by + // the sequencer, through a placement new over an mmapped file. +} + +void ControlBlock::updateTrackData(Track* t) +{ + if (t) { + setInstrumentForTrack(t->getId(), t->getInstrument()); + setTrackArmed(t->getId(), t->isArmed()); + setTrackMuted(t->getId(), t->isMuted()); + setTrackDeleted(t->getId(), false); + setTrackChannelFilter(t->getId(), t->getMidiInputChannel()); + setTrackDeviceFilter(t->getId(), t->getMidiInputDevice()); + if (t->getId() > m_maxTrackId) + m_maxTrackId = t->getId(); + } +} + +void ControlBlock::setInstrumentForTrack(TrackId trackId, InstrumentId instId) +{ + if (trackId < CONTROLBLOCK_MAX_NB_TRACKS) + m_trackInfo[trackId].instrumentId = instId; +} + +InstrumentId ControlBlock::getInstrumentForTrack(TrackId trackId) const +{ + if (trackId < CONTROLBLOCK_MAX_NB_TRACKS) + return m_trackInfo[trackId].instrumentId; + return 0; +} + +void ControlBlock::setTrackMuted(TrackId trackId, bool mute) +{ + if (trackId < CONTROLBLOCK_MAX_NB_TRACKS) + m_trackInfo[trackId].muted = mute; +} + +bool ControlBlock::isTrackMuted(TrackId trackId) const +{ + if (trackId < CONTROLBLOCK_MAX_NB_TRACKS) + return m_trackInfo[trackId].muted; + return true; +} + +void ControlBlock::setTrackArmed(TrackId trackId, bool armed) +{ + if (trackId < CONTROLBLOCK_MAX_NB_TRACKS) + m_trackInfo[trackId].armed = armed; +} + +bool ControlBlock::isTrackArmed(TrackId trackId) const +{ + if (trackId < CONTROLBLOCK_MAX_NB_TRACKS) + return m_trackInfo[trackId].armed; + return false; +} + +void ControlBlock::setTrackDeleted(TrackId trackId, bool deleted) +{ + if (trackId < CONTROLBLOCK_MAX_NB_TRACKS) + m_trackInfo[trackId].deleted = deleted; +} + +bool ControlBlock::isTrackDeleted(TrackId trackId) const +{ + if (trackId < CONTROLBLOCK_MAX_NB_TRACKS) + return m_trackInfo[trackId].deleted; + return true; +} + +void ControlBlock::setTrackChannelFilter(TrackId trackId, char channel) +{ + if (trackId < CONTROLBLOCK_MAX_NB_TRACKS) + m_trackInfo[trackId].channelFilter = channel; +} + +char ControlBlock::getTrackChannelFilter(TrackId trackId) const +{ + if (trackId < CONTROLBLOCK_MAX_NB_TRACKS) + return m_trackInfo[trackId].channelFilter; + return -1; +} + +void ControlBlock::setTrackDeviceFilter(TrackId trackId, DeviceId device) +{ + if (trackId < CONTROLBLOCK_MAX_NB_TRACKS) + m_trackInfo[trackId].deviceFilter = device; +} + +DeviceId ControlBlock::getTrackDeviceFilter(TrackId trackId) const +{ + if (trackId < CONTROLBLOCK_MAX_NB_TRACKS) + return m_trackInfo[trackId].deviceFilter; + return Device::ALL_DEVICES; +} + +bool ControlBlock::isInstrumentMuted(InstrumentId instrumentId) const +{ + for (unsigned int i = 0; i <= m_maxTrackId; ++i) { + if (m_trackInfo[i].instrumentId == instrumentId && + !m_trackInfo[i].deleted && !m_trackInfo[i].muted) + return false; + } + return true; +} + +bool ControlBlock::isInstrumentUnused(InstrumentId instrumentId) const +{ + for (unsigned int i = 0; i <= m_maxTrackId; ++i) { + if (m_trackInfo[i].instrumentId == instrumentId && + !m_trackInfo[i].deleted) + return false; + } + return true; +} + +InstrumentId ControlBlock::getInstrumentForEvent(unsigned int dev, unsigned int chan) +{ + for (unsigned int i = 0; i <= m_maxTrackId; ++i) { + if (!m_trackInfo[i].deleted && m_trackInfo[i].armed) { + if (((m_trackInfo[i].deviceFilter == Device::ALL_DEVICES) || + (m_trackInfo[i].deviceFilter == dev)) && + ((m_trackInfo[i].channelFilter == -1) || + (m_trackInfo[i].channelFilter == chan))) + return m_trackInfo[i].instrumentId; + } + } + // There is not a matching filter, return the selected track instrument + return getInstrumentForTrack(getSelectedTrack()); +} + + +} |