# HG changeset patch # User Chris Cannam # Date 1413198022 -3600 # Node ID 9b94545a7fdc9e77e5e676998686073ee39d3808 # Parent a4bee1a374b48db8936d35e5755505d316e70fbb More of MIDIFeatureWriter diff -r a4bee1a374b4 -r 9b94545a7fdc runner/MIDIFeatureWriter.cpp --- a/runner/MIDIFeatureWriter.cpp Mon Oct 13 11:43:24 2014 +0100 +++ b/runner/MIDIFeatureWriter.cpp Mon Oct 13 12:00:22 2014 +0100 @@ -60,12 +60,42 @@ const Plugin::FeatureList& features, std::string summaryType) { - QString filename = getOutputFilename(trackId, transform.getIdentifier()); + QString transformId = transform.getIdentifier(); + + QString filename = getOutputFilename(trackId, transformId); if (filename == "") { - throw FailedToOpenOutputStream(trackId, transform.getIdentifier()); + throw FailedToOpenOutputStream(trackId, transformId); } - //!!! implement! + if (m_rates.find(filename) == m_rates.end()) { + // If the output is FixedSampleRate, we draw the sample rate + // from the output descriptor; otherwise from the transform + float sampleRate; + if (output.sampleType == Plugin::OutputDescriptor::FixedSampleRate) { + sampleRate = output.sampleRate; + } else { + sampleRate = transform.getSampleRate(); + } + m_rates[filename] = sampleRate; + } + + if (m_fileTransforms[filename].find(transformId) == + m_fileTransforms[filename].end()) { + + // This transform is new to the file, give it a channel number + + int channel = m_nextChannels[filename]; + m_nextChannels[filename] = channel + 1; + + m_fileTransforms[filename].insert(transformId); + m_channels[transformId] = channel; + } + + NoteList notes = m_notes[filename]; + + + + m_notes[filename] = notes; } void diff -r a4bee1a374b4 -r 9b94545a7fdc runner/MIDIFeatureWriter.h --- a/runner/MIDIFeatureWriter.h Mon Oct 13 11:43:24 2014 +0100 +++ b/runner/MIDIFeatureWriter.h Mon Oct 13 12:00:22 2014 +0100 @@ -50,7 +50,7 @@ virtual NoteList getNotes() const { return m_notes; } - virtual NoteList getNotesWithin(int startFrame, int endFrame) const { + virtual NoteList getNotesWithin(int, int) const { // Not required by MIDIFileWriter, not supported return NoteList(); } @@ -60,6 +60,9 @@ typedef map NoteMap; // output filename -> notes NoteMap m_notes; + + typedef map > FileTransformMap; + FileTransformMap m_fileTransforms; typedef map SampleRateMap; // NoteData uses sample timing SampleRateMap m_rates; @@ -67,8 +70,8 @@ typedef map ChannelMap; ChannelMap m_channels; - typedef map LastChannelMap; - LastChannelMap m_lastChannels; + typedef map NextChannelMap; + NextChannelMap m_nextChannels; }; #endif