Skip to content

Commit

Permalink
Initial development push
Browse files Browse the repository at this point in the history
Initial development push
  • Loading branch information
tomto66 committed Oct 12, 2020
1 parent bc94e64 commit 455e57b
Show file tree
Hide file tree
Showing 39 changed files with 6,038 additions and 0 deletions.
1 change: 1 addition & 0 deletions Source/Build.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define BUILD_DATE __DATE__ " " __TIME__
288 changes: 288 additions & 0 deletions Source/NoteAssignmentList.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
/////////////////////////////////////////////////////////////////////////////
/*
This file is part of Topiary Riffz, Copyright Tom Tollenaere 2020.
Topiary 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 3 of the License, or
(at your option) any later version.
Topiary is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Topiary. If not, see <https://www.gnu.org/licenses/>.
*/
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include "NoteAssignmentList.h"
#include "TopiaryRiffzModel.h"


NoteAssignmentList::NoteAssignmentList()
{
// initialize the headerlist data
headerListItems = 6;
// headerlist IDs start at 1;
// datalist IDs start at 1;

headerList[0].columnID = 1;
headerList[0].name = "ID";
headerList[0].width = 20;
headerList[0].type = Topiary::HeaderType::Int;
headerList[0].editable = false;
headerList[1].visible = true;

headerList[1].columnID = 2;
headerList[1].name = "NoteNumber";
headerList[1].width = 50;
headerList[1].type = Topiary::HeaderType::Int;
headerList[1].editable = false;
headerList[1].visible = false;

headerList[2].columnID = 3;
headerList[2].name = "Note";
headerList[2].width = 50;
headerList[2].type = Topiary::HeaderType::NoteLabel;
headerList[2].editable = false;
headerList[2].visible = true;

headerList[3].columnID = 4;
headerList[3].name = "Pattern";
headerList[3].width = 110;
headerList[3].type = Topiary::HeaderType::String;
headerList[3].editable = false;
headerList[3].visible = true;

headerList[4].columnID = 5;
headerList[4].name = "PatternId";
headerList[4].width = 40;
headerList[4].type = Topiary::HeaderType::Int;
headerList[4].editable = false;
headerList[4].min = 1;
headerList[4].max = 4;
headerList[4].visible = false;

headerList[5].columnID = 6;
headerList[5].name = "Offset";
headerList[5].width = 40;
headerList[5].type = Topiary::HeaderType::Int;
headerList[5].editable = false;
headerList[5].min = -128;
headerList[5].max = 128;
headerList[5].visible = true;

numItems = 0; // empty list

} // NoteAssignmentList

/////////////////////////////////////////////////////////////////////////////

NoteAssignmentList::~NoteAssignmentList()
{
}

/////////////////////////////////////////////////////////////////////////////

void NoteAssignmentList::setIntByIndex(int row, int i, int newInt)
{
jassert(false); // should never happen, table not editable
UNUSED(row);
UNUSED(i);
UNUSED(newInt);

} // setIntByID

/////////////////////////////////////////////////////////////////////////////

void NoteAssignmentList::setStringByIndex(int row, int i, String newString)
{
jassert(false); // should never happen; table not editable
UNUSED(row);
UNUSED(i);
UNUSED(newString);
}

/////////////////////////////////////////////////////////////////////////////

void NoteAssignmentList::del(int n)
{
jassert(n >= 0);
jassert(n < numItems);
for (int i = n; i < (numItems - 1); i++)
{
swap(i, i + 1);
}

numItems--;
// set the IDs correctly
for (int i = 0; i < numItems; i++)
dataList[i].ID = i + 1;

} // del

/////////////////////////////////////////////////////////////////////////////

void NoteAssignmentList::add()
{
jassert(numItems < (maxItems + 1));

// adds new empty one
dataList[numItems].note = 1;
dataList[numItems].noteLabel = MidiMessage::getMidiNoteName(1, true, true, 5);
dataList[numItems].offset = 0;
dataList[numItems].ID = numItems + 1;
dataList[numItems].patternId = -1;
dataList[numItems].patternName = "UNASSIGNED";
numItems++;

} // add

/////////////////////////////////////////////////////////////////////////////

void NoteAssignmentList::sortByID()
{
// sorts and then renumbers by ID (one might have been deleted)
// IDs to delete are set to Topiary::ToDeleteID

for (int i = 0; i <= numItems; i++)
{
for (int j = i + 1; j < numItems; j++)
{
if (dataList[i].ID > dataList[j].ID)
{
swap(i, j);
}
}
};

renumber();

} // sortByID

/////////////////////////////////////////////////////////////////////////////

void NoteAssignmentList::sortByNote()
{
// sorts and then renumbers by ID (one might have been deleted)
// IDs to delete are set to Topiary::ToDeleteID

for (int i = 0; i <= numItems; i++)
{
for (int j = i + 1; j < numItems; j++)
{
if (dataList[i].note > dataList[j].note)
{
swap(i, j);
}
}
};

renumber();

} // sortByID

/////////////////////////////////////////////////////////////////////////////

void NoteAssignmentList::renumber()
{
for (int i = 0; i < numItems; i++)
dataList[i].ID = i + 1;
} // renumber


/////////////////////////////////////////////////////////////////////////////

void NoteAssignmentList::fillDataList(XmlElement* dList)
{
dList->deleteAllChildElements();
for (int i = 0; i < numItems; i++)
{
XmlElement *child = new XmlElement("NoteAssignment");
child->setAttribute("Note", dataList[i].noteLabel);
child->setAttribute("ID", dataList[i].ID);
child->setAttribute("Offset", dataList[i].offset);
child->setAttribute("NoteNumber", dataList[i].note);
child->setAttribute("Pattern", dataList[i].patternName);
child->setAttribute("PatternId", dataList[i].patternId);
dList->addChildElement(child);
}
} // fillDataList

/////////////////////////////////////////////////////////////////////////////

void NoteAssignmentList::addToModel(XmlElement* model)
{
// adds the noteAssignment data as XmlElement; *model should be <noteAssignments>
// for variation v

jassert(model->getTagName().equalsIgnoreCase("noteAssignments"));

for (int p = 0; p < numItems; p++)
{
XmlElement* child = new XmlElement("noteAssignment");
model->addChildElement(child);
child->setAttribute("ID", dataList[p].ID);
child->setAttribute("note", dataList[p].note);
child->setAttribute("patternId", dataList[p].patternId);
child->setAttribute("offset", dataList[p].offset);

}

} // addToModel

/////////////////////////////////////////////////////////////////////////////

void NoteAssignmentList::getFromModel(XmlElement *model)
{
// adds the pattern data as XmlElement; *model should be <PatternList>
jassert(model->getTagName().equalsIgnoreCase("noteAssignments"));

XmlElement* child = model->getFirstChildElement();
int index = 0;
while (child != nullptr)
{
dataList[index].ID = child->getIntAttribute("ID");
dataList[index].note = child->getIntAttribute("note");
dataList[index].offset = child->getIntAttribute("offset");
dataList[index].patternId = child->getIntAttribute("patternId");

child = child->getNextElement();
index++;
}

numItems = index;

} // getFromModel


/////////////////////////////////////////////////////////////////////////////

void NoteAssignmentList::validateTableEdit(int p, XmlElement* child, String attribute)
{
UNUSED(p);
UNUSED(child);
UNUSED(attribute);

jassert(false); // should not happen, table not editable
} // validateTableEdit

/////////////////////////////////////////////////////////////////////////////

void NoteAssignmentList::setRiffzModel(TopiaryRiffzModel* m)
{
riffzModel = m;
} // setRiffzModel

/////////////////////////////////////////////////////////////////////////////


void NoteAssignmentList::selectedRowsChanged(int lastRowSelected)
{
UNUSED(lastRowSelected)
riffzModel->broadcaster.sendActionMessage(MsgSelectedNoteAssignmentRowsChanged); // may need to disable the variation!
}
80 changes: 80 additions & 0 deletions Source/NoteAssignmentList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
///////////////////////////////////////////////////////////////////////////
/*
This file is part of Topiary Riffz, Copyright Tom Tollenaere 2020.
Topiary 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 3 of the License, or
(at your option) any later version.
Topiary is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Topiary. If not, see <https://www.gnu.org/licenses/>.
*/
/////////////////////////////////////////////////////////////////////////////

#pragma once
#include "../../Topiary/Source/Model/TopiaryListModel.h"

class TopiaryRiffzModel;

class NoteAssignmentList : public TopiaryListModel
{

public:
NoteAssignmentList();
~NoteAssignmentList();

void sortByID() override;
void del(int n) override;
void add() override;
void addToModel(XmlElement *model);
void getFromModel(XmlElement *model);
void validateTableEdit(int p, XmlElement* child, String attribute) override;
void selectedRowsChanged(int lastRowSelected) override;
void setRiffzModel(TopiaryRiffzModel* m);
void sortByNote();

static const int maxItems = 128;

struct data // MUST match what has been defined in the headerlist data!!!
{
int ID;
int note;
String patternName;
int patternId;
int offset;
String noteLabel;

};

data dataList[maxItems];

void fillDataList(XmlElement* dList) override;

void setIntByIndex(int row, int o, int newInt) override;

void setStringByIndex(int row, int i, String newString) override;

void renumber() override;


private:
TopiaryRiffzModel* riffzModel;

void swap(int from, int to)
{
intSwap(dataList[from].ID, dataList[to].ID);
stringSwap(dataList[from].patternName, dataList[to].patternName);
intSwap(dataList[from].offset, dataList[to].offset);
intSwap(dataList[from].note, dataList[to].note);
intSwap(dataList[from].patternId, dataList[to].patternId);
stringSwap(dataList[from].noteLabel, dataList[to].noteLabel);
} // swap

}; // NoteAssignmentList

22 changes: 22 additions & 0 deletions Source/RiffzPluginEditor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/////////////////////////////////////////////////////////////////////////////
/*
This file is part of Topiary Riffz, Copyright Tom Tollenaere 2018-19.
Topiary Riffz 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 3 of the License, or
(at your option) any later version.
Topiary Riffz is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Topiary Riffz. If not, see <https://www.gnu.org/licenses/>.
*/
/////////////////////////////////////////////////////////////////////////////

#pragma once
#include "RiffzPluginEditor.h"
#include "../../Topiary/Source/Plugin/PluginEditor.cpp.h"
Loading

0 comments on commit 455e57b

Please sign in to comment.