Skip to content

Commit

Permalink
Added 2x CC mode and adjusted gate time heuristic
Browse files Browse the repository at this point in the history
  • Loading branch information
sauraen committed Dec 17, 2023
1 parent bd3a696 commit 30211cc
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 35 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE)
set(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "" FORCE)

project(SEQ64 VERSION 2.2.1)
project(SEQ64 VERSION 2.3.0)

if(NOT EXISTS "${CMAKE_SOURCE_DIR}/juce/CMakeLists.txt")
message(FATAL_ERROR "You forgot to get the Git submodules, please run git submodule update --init")
Expand Down
59 changes: 41 additions & 18 deletions Source/SeqABIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Projucer version: 6.0.1
Created with Projucer version: 6.0.7
------------------------------------------------------------------------------
Expand Down Expand Up @@ -62,7 +62,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
TRANS("Audioseq / Nintendo 64 Music Macro Language\n"
"ABI definition file: /foo/bar.xml")));
addAndMakeVisible (lblTitle.get());
lblTitle->setFont (juce::Font (15.00f, juce::Font::plain));
lblTitle->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblTitle->setJustificationType (juce::Justification::centredLeft);
lblTitle->setEditable (false, false, false);
lblTitle->setColour (juce::TextEditor::textColourId, juce::Colours::black);
Expand Down Expand Up @@ -111,7 +111,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
lblCmdNameCmm.reset (new juce::Label ("lblCmdNameCmm",
TRANS("Community:")));
addAndMakeVisible (lblCmdNameCmm.get());
lblCmdNameCmm->setFont (juce::Font (15.00f, juce::Font::plain));
lblCmdNameCmm->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblCmdNameCmm->setJustificationType (juce::Justification::centredLeft);
lblCmdNameCmm->setEditable (false, false, false);
lblCmdNameCmm->setColour (juce::TextEditor::textColourId, juce::Colours::black);
Expand All @@ -128,7 +128,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
lblCmdNameCanon.reset (new juce::Label ("lblCmdNameCanon",
TRANS("Canon:")));
addAndMakeVisible (lblCmdNameCanon.get());
lblCmdNameCanon->setFont (juce::Font (15.00f, juce::Font::plain));
lblCmdNameCanon->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblCmdNameCanon->setJustificationType (juce::Justification::centredLeft);
lblCmdNameCanon->setEditable (false, false, false);
lblCmdNameCanon->setColour (juce::TextEditor::textColourId, juce::Colours::black);
Expand All @@ -139,7 +139,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
lblCmdNameOld.reset (new juce::Label ("lblCmdNameOld",
TRANS("Canon (Old):")));
addAndMakeVisible (lblCmdNameOld.get());
lblCmdNameOld->setFont (juce::Font (15.00f, juce::Font::plain));
lblCmdNameOld->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblCmdNameOld->setJustificationType (juce::Justification::centredLeft);
lblCmdNameOld->setEditable (false, false, false);
lblCmdNameOld->setColour (juce::TextEditor::textColourId, juce::Colours::black);
Expand Down Expand Up @@ -186,7 +186,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
lblCmd.reset (new juce::Label ("lblCmd",
TRANS("Cmd:")));
addAndMakeVisible (lblCmd.get());
lblCmd->setFont (juce::Font (15.00f, juce::Font::plain));
lblCmd->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblCmd->setJustificationType (juce::Justification::centredLeft);
lblCmd->setEditable (false, false, false);
lblCmd->setColour (juce::TextEditor::textColourId, juce::Colours::black);
Expand All @@ -209,7 +209,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
lblTo.reset (new juce::Label ("lblTo",
TRANS("to")));
addAndMakeVisible (lblTo.get());
lblTo->setFont (juce::Font (15.00f, juce::Font::plain));
lblTo->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblTo->setJustificationType (juce::Justification::centredLeft);
lblTo->setEditable (false, false, false);
lblTo->setColour (juce::TextEditor::textColourId, juce::Colours::black);
Expand Down Expand Up @@ -300,7 +300,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
lblAction.reset (new juce::Label ("lblAction",
TRANS("Action:")));
addAndMakeVisible (lblAction.get());
lblAction->setFont (juce::Font (15.00f, juce::Font::plain));
lblAction->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblAction->setJustificationType (juce::Justification::centredLeft);
lblAction->setEditable (false, false, false);
lblAction->setColour (juce::TextEditor::textColourId, juce::Colours::black);
Expand All @@ -323,7 +323,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
lblComments.reset (new juce::Label ("lblComments",
TRANS("Comments:")));
addAndMakeVisible (lblComments.get());
lblComments->setFont (juce::Font (15.00f, juce::Font::plain));
lblComments->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblComments->setJustificationType (juce::Justification::centredLeft);
lblComments->setEditable (false, false, false);
lblComments->setColour (juce::TextEditor::textColourId, juce::Colours::black);
Expand All @@ -334,7 +334,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
lblParams.reset (new juce::Label ("lblParams",
TRANS("Params:")));
addAndMakeVisible (lblParams.get());
lblParams->setFont (juce::Font (15.00f, juce::Font::plain));
lblParams->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblParams->setJustificationType (juce::Justification::centredLeft);
lblParams->setEditable (false, false, false);
lblParams->setColour (juce::TextEditor::textColourId, juce::Colours::black);
Expand All @@ -351,7 +351,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
lblParamName.reset (new juce::Label ("lblParamName",
TRANS("Name:")));
addAndMakeVisible (lblParamName.get());
lblParamName->setFont (juce::Font (15.00f, juce::Font::plain));
lblParamName->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblParamName->setJustificationType (juce::Justification::centredLeft);
lblParamName->setEditable (false, false, false);
lblParamName->setColour (juce::TextEditor::textColourId, juce::Colours::black);
Expand All @@ -362,7 +362,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
lblParamMeaning.reset (new juce::Label ("lblParamMeaning",
TRANS("Meaning:")));
addAndMakeVisible (lblParamMeaning.get());
lblParamMeaning->setFont (juce::Font (15.00f, juce::Font::plain));
lblParamMeaning->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblParamMeaning->setJustificationType (juce::Justification::centredLeft);
lblParamMeaning->setEditable (false, false, false);
lblParamMeaning->setColour (juce::TextEditor::textColourId, juce::Colours::black);
Expand Down Expand Up @@ -459,13 +459,13 @@ SeqABIEditor::SeqABIEditor (String abi_name)
lblDataLen.reset (new juce::Label ("lblDataLen",
TRANS("(none)")));
addAndMakeVisible (lblDataLen.get());
lblDataLen->setFont (juce::Font (15.00f, juce::Font::plain));
lblDataLen->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblDataLen->setJustificationType (juce::Justification::centredLeft);
lblDataLen->setEditable (false, false, false);
lblDataLen->setColour (juce::TextEditor::textColourId, juce::Colours::black);
lblDataLen->setColour (juce::TextEditor::backgroundColourId, juce::Colour (0x00000000));

lblDataLen->setBounds (360, 588, 64, 24);
lblDataLen->setBounds (360, 576, 64, 24);

txtDataLen.reset (new juce::TextEditor ("txtDataLen"));
addAndMakeVisible (txtDataLen.get());
Expand All @@ -477,7 +477,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
txtDataLen->setPopupMenuEnabled (true);
txtDataLen->setText (juce::String());

txtDataLen->setBounds (424, 588, 32, 24);
txtDataLen->setBounds (424, 576, 32, 24);

btnSave.reset (new juce::TextButton ("btnSave"));
addAndMakeVisible (btnSave.get());
Expand All @@ -501,7 +501,7 @@ SeqABIEditor::SeqABIEditor (String abi_name)
lblCC.reset (new juce::Label ("lblCC",
TRANS("CC:")));
addAndMakeVisible (lblCC.get());
lblCC->setFont (juce::Font (15.00f, juce::Font::plain));
lblCC->setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
lblCC->setJustificationType (juce::Justification::centredLeft);
lblCC->setEditable (false, false, false);
lblCC->setColour (juce::TextEditor::textColourId, juce::Colours::black);
Expand All @@ -517,6 +517,14 @@ SeqABIEditor::SeqABIEditor (String abi_name)

btnCCHelp->setBounds (448, 552, 22, 24);

chkx2.reset (new juce::ToggleButton ("chkx2"));
addAndMakeVisible (chkx2.get());
chkx2->setTooltip (TRANS("CC value is multiplied by 2 to get MML value, because MIDI is 0-127 whereas MML is 0-255."));
chkx2->setButtonText (TRANS("x2"));
chkx2->addListener (this);

chkx2->setBounds (400, 600, 72, 24);


//[UserPreSize]

Expand Down Expand Up @@ -631,6 +639,7 @@ SeqABIEditor::~SeqABIEditor()
txtCC = nullptr;
lblCC = nullptr;
btnCCHelp = nullptr;
chkx2 = nullptr;


//[Destructor]. You can add your own custom destruction code here..
Expand Down Expand Up @@ -932,6 +941,14 @@ void SeqABIEditor::buttonClicked (juce::Button* buttonThatWasClicked)
);
//[/UserButtonCode_btnCCHelp]
}
else if (buttonThatWasClicked == chkx2.get())
{
//[UserButtonCode_chkx2] -- add your button handler code here..
if(!selparam.isValid()) return;
selparam.setProperty("x2", chkx2->getToggleState(), nullptr);
needssaving = true;
//[/UserButtonCode_chkx2]
}

//[UserbuttonClicked_Post]
//[/UserbuttonClicked_Post]
Expand Down Expand Up @@ -1131,6 +1148,7 @@ void SeqABIEditor::fillParamInfo(){
lblDataLen->setText("(none)", dontSendNotification);
txtDataLen->setText("", false);
txtCC->setText("", false);
chkx2->setToggleState(false, dontSendNotification);
return;
}
txtParamName->setText(selparam.getProperty("name", ""), false);
Expand All @@ -1150,6 +1168,7 @@ void SeqABIEditor::fillParamInfo(){
txtDataLen->setText(datasrc == "offset" || datasrc == "variable" ? ""
: selparam.getProperty("datalen", "").toString(), false);
txtDataLen->setEnabled(datasrc == "fixed" || datasrc == "constant");
chkx2->setToggleState((bool)selparam.getProperty("x2", false), dontSendNotification);
}

void SeqABIEditor::fillMeaningsBox(String action){
Expand Down Expand Up @@ -1390,12 +1409,12 @@ BEGIN_JUCER_METADATA
virtualName="" explicitFocusOrder="0" pos="96 608 48 24" buttonText="Dn"
connectedEdges="5" needsCallback="1" radioGroupId="0"/>
<LABEL name="lblDataLen" id="1e1a075250c48074" memberName="lblDataLen"
virtualName="" explicitFocusOrder="0" pos="360 588 64 24" edTextCol="ff000000"
virtualName="" explicitFocusOrder="0" pos="360 576 64 24" edTextCol="ff000000"
edBkgCol="0" labelText="(none)" editableSingleClick="0" editableDoubleClick="0"
focusDiscardsChanges="0" fontname="Default font" fontsize="15.0"
kerning="0.0" bold="0" italic="0" justification="33"/>
<TEXTEDITOR name="txtDataLen" id="7975a2934104f024" memberName="txtDataLen"
virtualName="" explicitFocusOrder="0" pos="424 588 32 24" initialText=""
virtualName="" explicitFocusOrder="0" pos="424 576 32 24" initialText=""
multiline="0" retKeyStartsLine="0" readonly="0" scrollbars="1"
caret="1" popupmenu="1"/>
<TEXTBUTTON name="btnSave" id="f1826d8815459bef" memberName="btnSave" virtualName=""
Expand All @@ -1412,6 +1431,10 @@ BEGIN_JUCER_METADATA
<TEXTBUTTON name="btnCCHelp" id="d5818054c15cd3a3" memberName="btnCCHelp"
virtualName="" explicitFocusOrder="0" pos="448 552 22 24" buttonText="?"
connectedEdges="1" needsCallback="1" radioGroupId="0"/>
<TOGGLEBUTTON name="chkx2" id="a5451667905d26f3" memberName="chkx2" virtualName=""
explicitFocusOrder="0" pos="400 600 72 24" tooltip="CC value is multiplied by 2 to get MML value, because MIDI is 0-127 whereas MML is 0-255."
buttonText="x2" connectedEdges="0" needsCallback="1" radioGroupId="0"
state="0"/>
</JUCER_COMPONENT>

END_JUCER_METADATA
Expand Down
4 changes: 3 additions & 1 deletion Source/SeqABIEditor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Projucer version: 6.0.1
Created with Projucer version: 6.0.7
------------------------------------------------------------------------------
Expand Down Expand Up @@ -145,6 +145,7 @@ class SeqABIEditor : public Component,
std::unique_ptr<juce::TextEditor> txtCC;
std::unique_ptr<juce::Label> lblCC;
std::unique_ptr<juce::TextButton> btnCCHelp;
std::unique_ptr<juce::ToggleButton> chkx2;


//==============================================================================
Expand All @@ -153,3 +154,4 @@ class SeqABIEditor : public Component,

//[EndFile] You can add extra defines here...
//[/EndFile]

23 changes: 15 additions & 8 deletions Source/SeqFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Identifier SeqFile::idSType("stype");
Identifier SeqFile::idValidInSeq("validinseq");
Identifier SeqFile::idValidInChn("validinchn");
Identifier SeqFile::idValidInTrk("validintrk");
Identifier SeqFile::idx2("x2");
Identifier SeqFile::idChannel("channel");
Identifier SeqFile::idLayer("layer");
Identifier SeqFile::idShortMode("shortmode");
Expand Down Expand Up @@ -174,6 +175,7 @@ ValueTree SeqFile::loadABI(String name){
std::cout << "Error parsing XML of " + abifile.getFullPathName() + "!\n";
return ValueTree();
}
std::cout << "Loading ABI " + abifile.getFullPathName() + "\n";
return ValueTree::fromXml(*xml);
}
bool SeqFile::saveABI(String name, ValueTree abi_){
Expand Down Expand Up @@ -398,11 +400,10 @@ ValueTree SeqFile::createCommand(ValueTree want, bool warnIfImpossible){
for(int j=0; j<test.getNumChildren(); j++){
param2 = test.getChild(j);
param = want.getChildWithProperty(idMeaning, param2.getProperty(idMeaning));
if(param.isValid()){
param2.setProperty(idValue, param.getProperty(idValue), nullptr);
}else{
param2.setProperty(idValue, 0, nullptr);
}
int value = 0;
if(param.isValid()) value = (int)param.getProperty(idValue);
if((bool)param2.getProperty(idx2, false)) value *= 2;
param2.setProperty(idValue, value, nullptr);
}
//Hash
test.setProperty(idHash, Random::getSystemRandom().nextInt(), nullptr);
Expand Down Expand Up @@ -1436,6 +1437,7 @@ int SeqFile::importMIDI(File midifile, ValueTree midiopts){
ccstates[paramcc]->lastvalue = value2;
ccstates[paramcc]->lasttime = timestamp;
ccstates[paramcc]->lastcmd = cccmd;
if((bool)tmpparam.getProperty(idx2, false)) value2 *= 2;
tmpparam.setProperty(idValue, value2, nullptr);
trk->deleteEvent(i, false);
if(i == m) --m;
Expand Down Expand Up @@ -1589,19 +1591,23 @@ int SeqFile::importMIDI(File midifile, ValueTree midiopts){
transpose += 12 * (((note - 0x40) / 12) + 1);
}
note = msg.getNoteNumber() - transpose - midi_basenote;
int transpose_unsigned = transpose < 0 ? (0x100 + transpose) : transpose;
if(transposecmd.isValid()){
transposecmd.getChildWithProperty(idMeaning, "Value").setProperty(idValue, transpose, nullptr);
transposecmd.getChildWithProperty(idMeaning, "Value").setProperty(idValue, transpose_unsigned, nullptr);
}else{
want2 = wantAction("Layer Transpose", 2);
wantProperty(want2, "Value", transpose);
wantProperty(want2, "Value", transpose_unsigned);
section.addChild(createCommand(want2), cmd, nullptr);
cmd++;
}
}
wantProperty(want, "Note", note);
//Delay
delay = timestamp3 - timestamp;
if(delay >= 48*2 && ((timestamp2 - timestamp) * 0x100 / delay) < 0x08){
//Want to make sure there is sufficient resolution to encode the note off
//time of any note using gate time.
const int minDelayResolution = 8; //Sixteenth note triplet; 48 ppqn
if(delay >= minDelayResolution * 0x100){ //10 2/3 measures at 4/4
//Full note and then timestamp
wantProperty(want, "Delay", timestamp2 - timestamp);
wantProperty(want, "Gate Time", 0);
Expand Down Expand Up @@ -2528,6 +2534,7 @@ int SeqFile::exportMIDI(File midifile, ValueTree midiopts){
continue;
}
int value = param.getProperty(idValue);
if((bool)param.getProperty(idx2, false)) value /= 2;
if(cc != 128 && (value < 0 || value > 0x7F)){
dbgmsg("CC " + String(cc) + " event with invalid value = " + String(value) + "!");
importresult |= 1;
Expand Down
1 change: 1 addition & 0 deletions Source/SeqFile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class SeqFile{
static Identifier idValidInSeq;
static Identifier idValidInChn;
static Identifier idValidInTrk;
static Identifier idx2;
static Identifier idChannel;
static Identifier idLayer;
static Identifier idShortMode;
Expand Down
3 changes: 2 additions & 1 deletion abi/1 - SM64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@
</command>
<command cmd="217" name="release" action="CC or CC Group" validinchn="1"
comments="Set envelope release rate." oname="release">
<parameter name="Release" meaning="CC" datasrc="fixed" datalen="1" cc="72"/>
<parameter name="Release" meaning="CC" datasrc="fixed" datalen="1" cc="72"
x2="1"/>
</command>
<command cmd="218" name="cenvelope" action="Ptr Envelope" validinchn="1"
comments="Load channel envelope from sequence data." oname="envelope">
Expand Down
3 changes: 2 additions & 1 deletion abi/2 - SM64 EU.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@
</command>
<command cmd="217" name="release" action="CC or CC Group" validinchn="1"
comments="Set envelope release rate." oname="release">
<parameter name="Release" meaning="CC" datasrc="fixed" datalen="1" cc="72"/>
<parameter name="Release" meaning="CC" datasrc="fixed" datalen="1" cc="72"
x2="1"/>
</command>
<command cmd="218" name="cenvelope" action="Ptr Envelope" validinchn="1"
comments="Load channel envelope from sequence data." oname="envelope">
Expand Down
3 changes: 2 additions & 1 deletion abi/3 - SF64.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@
</command>
<command cmd="217" name="release" action="CC or CC Group" validinchn="1"
comments="Set envelope release rate." oname="release">
<parameter name="Release" meaning="CC" datasrc="fixed" datalen="1" cc="72"/>
<parameter name="Release" meaning="CC" datasrc="fixed" datalen="1" cc="72"
x2="1"/>
</command>
<command cmd="218" name="cenvelope" action="Ptr Envelope" validinchn="1"
comments="Load channel envelope from sequence data." oname="envelope">
Expand Down
Loading

0 comments on commit 30211cc

Please sign in to comment.