Skip to content

Commit

Permalink
archive old edit model components
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed May 15, 2024
1 parent c12c8b3 commit d8bb18b
Show file tree
Hide file tree
Showing 18 changed files with 4,155 additions and 4,155 deletions.
264 changes: 132 additions & 132 deletions Source/MappingLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,135 +181,135 @@ int IncrMidiNotesMappingLogic::terpstraKeyToIndex(LumatoneKey keyData) const
//==============================================================================
// KBM files

KBMFilesMappingLogic::KBMFilesMappingLogic(ScaleStructure& scaleStructureIn, Array<Colour>& colourTableIn)
: MappingLogicBase(scaleStructureIn, colourTableIn)
{
}

//==============================================================
// Set parameters

void KBMFilesMappingLogic::setMapping(int subDlgIndex, int midiChannel, KBMMappingDataStructure kbmMappingStructure)
{
jassert(subDlgIndex >= 0 && subDlgIndex < noOfChannels);

KBMMappingWithChannel channelMapping;
channelMapping.channelNumber = midiChannel;
channelMapping.mapping = kbmMappingStructure;

channelMappingData[subDlgIndex] = channelMapping;

createMappingTable();
}

void KBMFilesMappingLogic::createMappingTable()
{
mappingTable.clear();

for ( int subTableIndex = 0; subTableIndex < noOfChannels; subTableIndex++)
{
if (channelMappingData[subTableIndex].channelNumber > 0)
{
KBMMappingDataStructure::NoteAndFrequencyTable noteAndFrequencyTable =
channelMappingData[subTableIndex].mapping.createNoteFrequencyTable();

for ( int k = 0; k < noteAndFrequencyTable.size(); k++)
{
KBMMappingTableEntry tableEntry;
tableEntry.channelNumber = channelMappingData[subTableIndex].channelNumber;
tableEntry.noteNumber = noteAndFrequencyTable[k].noteNumber;
tableEntry.frequency = noteAndFrequencyTable[k].frequency;

mappingTable.add(tableEntry); // This adds entry only if there is no other entry woth the same frequency.
}
}
}

// Notify listeners
this->listeners.call(&Listener::mappingLogicChanged, this);
}

int KBMFilesMappingLogic::getStartOfMap() const
{
// Start of map is supposed to be the same for all KBM files
// ToDo display error/warning message if not so
int subTableIndex;
for (subTableIndex = 0; subTableIndex < noOfChannels; subTableIndex++)
{
if (channelMappingData[subTableIndex].channelNumber > 0)
break;
}

if (subTableIndex == noOfChannels)
{
jassert(false);
return 0;
}

LumatoneKey keyData;
keyData.setChannelNumber(channelMappingData[subTableIndex].channelNumber);
keyData.setNoteOrCC(channelMappingData[subTableIndex].mapping.noteNrWhereMappingStarts);

return terpstraKeyToIndex(keyData);
}

/*
int KBMFilesMappingLogic::getPeriodSize() const
{
// Period size is supposed to be the same for all KBM files
// ToDo display error/warning message if not so
int subTableIndex;
for (subTableIndex = 0; subTableIndex < noOfChannels; subTableIndex++)
{
if (channelMappingData[subTableIndex].channelNumber > 0)
break;
}
if (subTableIndex == noOfChannels)
{
jassert(false);
return 0;
}
else
return channelMappingData[subTableIndex].mapping.scaleSize;
}
*/

//=================================================================
// Access mapping data (overrides)

int KBMFilesMappingLogic::globalMappingSize() const
{
return mappingTable.size();
}

int KBMFilesMappingLogic::indexToMIDIChannel(int inx) const
{
if (inx < 0 || inx >= globalMappingSize())
return 0;
else
return mappingTable[inx].channelNumber;
}

int KBMFilesMappingLogic::indexToMIDINote(int inx) const
{
if (inx < 0 || inx >= globalMappingSize())
return 0;
else
return mappingTable[inx].noteNumber;
}

int KBMFilesMappingLogic::terpstraKeyToIndex(LumatoneKey keyData) const
{
if (keyData.isEmpty() || globalMappingSize() == 0)
return -1;

int inx;
for ( inx = 0; inx < globalMappingSize(); inx++)
{
if (keyData.hasMidiChannel(mappingTable[inx].channelNumber) && keyData.hasMidiNumber(mappingTable[inx].noteNumber))
break;
}

return inx < globalMappingSize() ? inx : -1;
}
// KBMFilesMappingLogic::KBMFilesMappingLogic(ScaleStructure& scaleStructureIn, Array<Colour>& colourTableIn)
// : MappingLogicBase(scaleStructureIn, colourTableIn)
// {
// }

// //==============================================================
// // Set parameters

// void KBMFilesMappingLogic::setMapping(int subDlgIndex, int midiChannel, KBMMappingDataStructure kbmMappingStructure)
// {
// jassert(subDlgIndex >= 0 && subDlgIndex < noOfChannels);

// KBMMappingWithChannel channelMapping;
// channelMapping.channelNumber = midiChannel;
// channelMapping.mapping = kbmMappingStructure;

// channelMappingData[subDlgIndex] = channelMapping;

// createMappingTable();
// }

// void KBMFilesMappingLogic::createMappingTable()
// {
// mappingTable.clear();

// for ( int subTableIndex = 0; subTableIndex < noOfChannels; subTableIndex++)
// {
// if (channelMappingData[subTableIndex].channelNumber > 0)
// {
// KBMMappingDataStructure::NoteAndFrequencyTable noteAndFrequencyTable =
// channelMappingData[subTableIndex].mapping.createNoteFrequencyTable();

// for ( int k = 0; k < noteAndFrequencyTable.size(); k++)
// {
// KBMMappingTableEntry tableEntry;
// tableEntry.channelNumber = channelMappingData[subTableIndex].channelNumber;
// tableEntry.noteNumber = noteAndFrequencyTable[k].noteNumber;
// tableEntry.frequency = noteAndFrequencyTable[k].frequency;

// mappingTable.add(tableEntry); // This adds entry only if there is no other entry woth the same frequency.
// }
// }
// }

// // Notify listeners
// this->listeners.call(&Listener::mappingLogicChanged, this);
// }

// int KBMFilesMappingLogic::getStartOfMap() const
// {
// // Start of map is supposed to be the same for all KBM files
// // ToDo display error/warning message if not so
// int subTableIndex;
// for (subTableIndex = 0; subTableIndex < noOfChannels; subTableIndex++)
// {
// if (channelMappingData[subTableIndex].channelNumber > 0)
// break;
// }

// if (subTableIndex == noOfChannels)
// {
// jassert(false);
// return 0;
// }

// LumatoneKey keyData;
// keyData.setChannelNumber(channelMappingData[subTableIndex].channelNumber);
// keyData.setNoteOrCC(channelMappingData[subTableIndex].mapping.noteNrWhereMappingStarts);

// return terpstraKeyToIndex(keyData);
// }

// /*
// int KBMFilesMappingLogic::getPeriodSize() const
// {
// // Period size is supposed to be the same for all KBM files
// // ToDo display error/warning message if not so
// int subTableIndex;
// for (subTableIndex = 0; subTableIndex < noOfChannels; subTableIndex++)
// {
// if (channelMappingData[subTableIndex].channelNumber > 0)
// break;
// }

// if (subTableIndex == noOfChannels)
// {
// jassert(false);
// return 0;
// }
// else
// return channelMappingData[subTableIndex].mapping.scaleSize;
// }
// */

// //=================================================================
// // Access mapping data (overrides)

// int KBMFilesMappingLogic::globalMappingSize() const
// {
// return mappingTable.size();
// }

// int KBMFilesMappingLogic::indexToMIDIChannel(int inx) const
// {
// if (inx < 0 || inx >= globalMappingSize())
// return 0;
// else
// return mappingTable[inx].channelNumber;
// }

// int KBMFilesMappingLogic::indexToMIDINote(int inx) const
// {
// if (inx < 0 || inx >= globalMappingSize())
// return 0;
// else
// return mappingTable[inx].noteNumber;
// }

// int KBMFilesMappingLogic::terpstraKeyToIndex(LumatoneKey keyData) const
// {
// if (keyData.isEmpty() || globalMappingSize() == 0)
// return -1;

// int inx;
// for ( inx = 0; inx < globalMappingSize(); inx++)
// {
// if (keyData.hasMidiChannel(mappingTable[inx].channelNumber) && keyData.hasMidiNumber(mappingTable[inx].noteNumber))
// break;
// }

// return inx < globalMappingSize() ? inx : -1;
// }
Loading

0 comments on commit d8bb18b

Please sign in to comment.