Rename Beat/Bassline to Pattern (#6284)
- BB* -> Pattern* - BBTrackContainer -> PatternStore - BBTrackContainerView -> PatternEditor - BBEditor -> PatternEditorWindow Does not touch save files
This commit is contained in:
@@ -14,9 +14,9 @@
|
||||
#include "InstrumentTrack.h"
|
||||
#include "Note.h"
|
||||
#include "MidiClip.h"
|
||||
#include "PatternStore.h"
|
||||
#include "PatternTrack.h"
|
||||
#include "Track.h"
|
||||
#include "BBTrack.h"
|
||||
#include "BBTrackContainer.h"
|
||||
#include "Instrument.h"
|
||||
|
||||
#include "plugin_export.h"
|
||||
@@ -223,7 +223,9 @@ bool HydrogenImport::readSong()
|
||||
|
||||
if ( nLayer == 0 )
|
||||
{
|
||||
drum_track[sId] = ( InstrumentTrack * ) Track::create( Track::InstrumentTrack,Engine::getBBTrackContainer() );
|
||||
drum_track[sId] = static_cast<InstrumentTrack*>(
|
||||
Track::create(Track::InstrumentTrack, Engine::patternStore())
|
||||
);
|
||||
drum_track[sId]->volumeModel()->setValue( fVolume * 100 );
|
||||
drum_track[sId]->panningModel()->setValue( ( fPan_R - fPan_L ) * 100 );
|
||||
ins = drum_track[sId]->loadInstrument( "audiofileprocessor" );
|
||||
@@ -247,7 +249,7 @@ bool HydrogenImport::readSong()
|
||||
}
|
||||
QDomNode patterns = songNode.firstChildElement( "patternList" );
|
||||
int pattern_count = 0;
|
||||
int nbb = Engine::getBBTrackContainer()->numOfBBs();
|
||||
int existing_patterns = Engine::patternStore()->numOfPatterns();
|
||||
QDomNode patternNode = patterns.firstChildElement( "pattern" );
|
||||
int pn = 1;
|
||||
while ( !patternNode.isNull() )
|
||||
@@ -255,7 +257,7 @@ bool HydrogenImport::readSong()
|
||||
if ( pn > 0 )
|
||||
{
|
||||
pattern_count++;
|
||||
s->addBBTrack();
|
||||
s->addPatternTrack();
|
||||
pn = 0;
|
||||
}
|
||||
QString sName; // name
|
||||
@@ -278,7 +280,7 @@ bool HydrogenImport::readSong()
|
||||
QString nNoteOff = LocalFileMng::readXmlString( noteNode, "note_off", "false", false, false );
|
||||
|
||||
QString instrId = LocalFileMng::readXmlString( noteNode, "instrument", 0,false, false );
|
||||
int i = pattern_count - 1 + nbb;
|
||||
int i = pattern_count - 1 + existing_patterns;
|
||||
pattern_id[sName] = pattern_count - 1;
|
||||
MidiClip*p = dynamic_cast<MidiClip*>( drum_track[instrId]->getClip( i ) );
|
||||
Note n;
|
||||
@@ -315,7 +317,7 @@ bool HydrogenImport::readSong()
|
||||
patternId = ( QDomNode ) patternId.nextSiblingElement( "patternID" );
|
||||
|
||||
int i = pattern_id[patId]+song_num_tracks;
|
||||
Track *t = ( BBTrack * ) s->tracks().at( i );
|
||||
Track* t = s->tracks().at(i);
|
||||
t->createClip(pos);
|
||||
|
||||
if ( pattern_length[patId] > best_length )
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
|
||||
#include "lmms_math.h"
|
||||
#include "TrackContainer.h"
|
||||
#include "BBTrack.h"
|
||||
#include "DataFile.h"
|
||||
#include "InstrumentTrack.h"
|
||||
#include "LocaleHelper.h"
|
||||
#include "PatternTrack.h"
|
||||
|
||||
#include "plugin_export.h"
|
||||
|
||||
@@ -76,7 +76,7 @@ MidiExport::~MidiExport()
|
||||
|
||||
|
||||
bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
const TrackContainer::TrackList &tracks_BB,
|
||||
const TrackContainer::TrackList &patternStoreTracks,
|
||||
int tempo, int masterPitch, const QString &filename)
|
||||
{
|
||||
QFile f(filename);
|
||||
@@ -84,7 +84,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
QDataStream midiout(&f);
|
||||
|
||||
InstrumentTrack* instTrack;
|
||||
BBTrack* bbTrack;
|
||||
PatternTrack* patternTrack;
|
||||
QDomElement element;
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
uint32_t size;
|
||||
|
||||
for (const Track* track : tracks) if (track->type() == Track::InstrumentTrack) nTracks++;
|
||||
for (const Track* track : tracks_BB) if (track->type() == Track::InstrumentTrack) nTracks++;
|
||||
for (const Track* track : patternStoreTracks) if (track->type() == Track::InstrumentTrack) nTracks++;
|
||||
|
||||
// midi header
|
||||
MidiFile::MIDIHeader header(nTracks);
|
||||
@@ -145,22 +145,22 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
}
|
||||
|
||||
}
|
||||
ProcessBBNotes(midiClip, INT_MAX);
|
||||
processPatternNotes(midiClip, INT_MAX);
|
||||
writeMidiClipToTrack(mtrack, midiClip);
|
||||
size = mtrack.writeToBuffer(buffer);
|
||||
midiout.writeRawData((char *)buffer, size);
|
||||
}
|
||||
|
||||
if (track->type() == Track::BBTrack)
|
||||
if (track->type() == Track::PatternTrack)
|
||||
{
|
||||
bbTrack = dynamic_cast<BBTrack *>(track);
|
||||
element = bbTrack->saveState(dataFile, dataFile.content());
|
||||
patternTrack = dynamic_cast<PatternTrack*>(track);
|
||||
element = patternTrack->saveState(dataFile, dataFile.content());
|
||||
|
||||
std::vector<std::pair<int,int>> plist;
|
||||
for (QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling())
|
||||
{
|
||||
|
||||
if (n.nodeName() == "bbclip")
|
||||
if (n.nodeName() == "bbclip") // TODO rename to patternclip
|
||||
{
|
||||
QDomElement it = n.toElement();
|
||||
int pos = it.attribute("pos", "0").toInt();
|
||||
@@ -174,13 +174,15 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
}
|
||||
} // for each track
|
||||
|
||||
// midi tracks in BB tracks
|
||||
for (Track* track : tracks_BB)
|
||||
// for each instrument in the pattern editor
|
||||
for (Track* track : patternStoreTracks)
|
||||
{
|
||||
DataFile dataFile(DataFile::SongProject);
|
||||
MTrack mtrack;
|
||||
|
||||
// begin at the first pattern track (first pattern)
|
||||
auto itr = plists.begin();
|
||||
|
||||
std::vector<std::pair<int,int>> st;
|
||||
|
||||
if (track->type() != Track::InstrumentTrack) continue;
|
||||
@@ -195,6 +197,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
int base_pitch = 0;
|
||||
double base_volume = 1.0;
|
||||
|
||||
// for each pattern in the pattern editor
|
||||
for (QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling())
|
||||
{
|
||||
if (n.nodeName() == "instrumenttrack")
|
||||
@@ -215,21 +218,24 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
MidiNoteVector nv, midiClip;
|
||||
writeMidiClip(midiClip, n, base_pitch, base_volume, 0);
|
||||
|
||||
// workaround for nested BBClips
|
||||
|
||||
// FIXME better variable names and comments
|
||||
int pos = 0;
|
||||
int len = n.toElement().attribute("steps", "1").toInt() * 12;
|
||||
|
||||
// for each pattern clip of the current pattern track (in song editor)
|
||||
for (auto it = plist.begin(); it != plist.end(); ++it)
|
||||
{
|
||||
while (!st.empty() && st.back().second <= it->first)
|
||||
{
|
||||
writeBBClip(midiClip, nv, len, st.back().first, pos, st.back().second);
|
||||
writePatternClip(midiClip, nv, len, st.back().first, pos, st.back().second);
|
||||
pos = st.back().second;
|
||||
st.pop_back();
|
||||
}
|
||||
|
||||
if (!st.empty() && st.back().second <= it->second)
|
||||
{
|
||||
writeBBClip(midiClip, nv, len, st.back().first, pos, it->first);
|
||||
writePatternClip(midiClip, nv, len, st.back().first, pos, it->first);
|
||||
pos = it->first;
|
||||
while (!st.empty() && st.back().second <= it->second)
|
||||
{
|
||||
@@ -243,13 +249,15 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks,
|
||||
|
||||
while (!st.empty())
|
||||
{
|
||||
writeBBClip(midiClip, nv, len, st.back().first, pos, st.back().second);
|
||||
writePatternClip(midiClip, nv, len, st.back().first, pos, st.back().second);
|
||||
pos = st.back().second;
|
||||
st.pop_back();
|
||||
}
|
||||
|
||||
ProcessBBNotes(nv, pos);
|
||||
processPatternNotes(nv, pos);
|
||||
writeMidiClipToTrack(mtrack, nv);
|
||||
|
||||
// next pattern track
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
@@ -294,7 +302,7 @@ void MidiExport::writeMidiClipToTrack(MTrack &mtrack, MidiNoteVector &nv)
|
||||
|
||||
|
||||
|
||||
void MidiExport::writeBBClip(MidiNoteVector &src, MidiNoteVector &dst,
|
||||
void MidiExport::writePatternClip(MidiNoteVector& src, MidiNoteVector& dst,
|
||||
int len, int base, int start, int end)
|
||||
{
|
||||
if (start >= end) { return; }
|
||||
@@ -318,7 +326,7 @@ void MidiExport::writeBBClip(MidiNoteVector &src, MidiNoteVector &dst,
|
||||
|
||||
|
||||
|
||||
void MidiExport::ProcessBBNotes(MidiNoteVector &nv, int cutPos)
|
||||
void MidiExport::processPatternNotes(MidiNoteVector& nv, int cutPos)
|
||||
{
|
||||
std::sort(nv.begin(), nv.end());
|
||||
int cur = INT_MAX, next = INT_MAX;
|
||||
|
||||
@@ -66,16 +66,16 @@ public:
|
||||
}
|
||||
|
||||
virtual bool tryExport(const TrackContainer::TrackList &tracks,
|
||||
const TrackContainer::TrackList &tracks_BB,
|
||||
const TrackContainer::TrackList &patternTracks,
|
||||
int tempo, int masterPitch, const QString &filename);
|
||||
|
||||
private:
|
||||
void writeMidiClip(MidiNoteVector &midiClip, QDomNode n,
|
||||
int base_pitch, double base_volume, int base_time);
|
||||
void writeMidiClipToTrack(MTrack &mtrack, MidiNoteVector &nv);
|
||||
void writeBBClip(MidiNoteVector &src, MidiNoteVector &dst,
|
||||
void writePatternClip(MidiNoteVector &src, MidiNoteVector &dst,
|
||||
int len, int base, int start, int end);
|
||||
void ProcessBBNotes(MidiNoteVector &nv, int cutPos);
|
||||
void processPatternNotes(MidiNoteVector &nv, int cutPos);
|
||||
|
||||
void error();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user