Skip to content

Commit

Permalink
Index editing support; names cleanup; SM64DD and WR64 support; better…
Browse files Browse the repository at this point in the history
… instruments-to-drums support; bugfixes
  • Loading branch information
sauraen committed Nov 24, 2018
1 parent 600214c commit d7f7989
Show file tree
Hide file tree
Showing 32 changed files with 5,712 additions and 3,256 deletions.
28 changes: 15 additions & 13 deletions Source/AudiobankPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ AudiobankPane::AudiobankPane (SEQ64& seq64_)
lblStructSemicolon->setColour (TextEditor::backgroundColourId, Colour (0x00000000));

addAndMakeVisible (label = new Label ("new label",
TRANS("Instrument sets:")));
TRANS("Banks:")));
label->setFont (Font (15.00f, Font::plain));
label->setJustificationType (Justification::centredLeft);
label->setEditable (false, false, false);
Expand Down Expand Up @@ -513,7 +513,7 @@ AudiobankPane::AudiobankPane (SEQ64& seq64_)
btnLoadXML->addListener (this);

addAndMakeVisible (chkLibFixAddr = new ToggleButton ("new toggle button"));
chkLibFixAddr->setButtonText (TRANS("Convert Sample Addr for Sample Set"));
chkLibFixAddr->setButtonText (TRANS("Convert Sample Addr for Table"));
chkLibFixAddr->addListener (this);
chkLibFixAddr->setToggleState (true, dontSendNotification);

Expand Down Expand Up @@ -571,7 +571,7 @@ AudiobankPane::AudiobankPane (SEQ64& seq64_)

//[/UserPreSize]

setSize (600, 400);
setSize (1078, 713);


//[Constructor] You can add your own custom stuff here..
Expand Down Expand Up @@ -1127,7 +1127,7 @@ void AudiobankPane::buttonClicked (Button* buttonThatWasClicked)
"node labels (e.g. instrument names, etc.)--but not including\n"
"the actual audio sample data of course. Loading it again\n"
"will restore the state, but it will only be compatible with\n"
"ROMs that have the same sample sets (generally, different\n"
"ROMs that have the same sample tables (generally, different\n"
"hacks/edits of the same ROM are fine but different released\n"
"ROM versions may not be). Of course it is also dependent on\n"
"the Audiobank format (as defined in the RomDesc) being the\n"
Expand Down Expand Up @@ -1157,7 +1157,7 @@ void AudiobankPane::buttonClicked (Button* buttonThatWasClicked)
"including header/metadata and node labels (e.g. instrument\n"
"names, etc.)--but not including the actual audio sample data\n"
"of course. Loading it will restore the state, but it will only\n"
"be compatible with ROMs that have the same sample sets\n"
"be compatible with ROMs that have the same sample tables\n"
"(generally, different hacks/edits of the same ROM are fine but\n"
"different released ROM versions may not be). Of course it is\n"
"also dependent on the Audiobank format (as defined in the\n"
Expand Down Expand Up @@ -1441,12 +1441,12 @@ void AudiobankPane::fillMeaningsBox(){
if(editstruct == "ABIndexEntry"){
cbxMeaning->addItem("Ptr Bank (in Audiobank)", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("Bank Length", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("Sample Set Index number", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("Sample Table number", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("NUM_INST", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("NUM_DRUM", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("NUM_SFX", cbxMeaning->getNumItems()+1);
}else if(editstruct == "ABHeader"){
cbxMeaning->addItem("Sample Set Index number", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("Sample Table number", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("NUM_INST", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("NUM_DRUM", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("NUM_SFX", cbxMeaning->getNumItems()+1);
Expand All @@ -1460,6 +1460,8 @@ void AudiobankPane::fillMeaningsBox(){
}else if(editstruct == "ABSFXList"){
cbxMeaning->addItem("List of Sounds", cbxMeaning->getNumItems()+1);
}else if(editstruct == "ABInstrument"){
cbxMeaning->addItem("Split Point 1", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("Split Point 2", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("Ptr Envelope", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("List of 3 Sounds for Splits", cbxMeaning->getNumItems()+1);
}else if(editstruct == "ABDrum"){
Expand All @@ -1470,7 +1472,7 @@ void AudiobankPane::fillMeaningsBox(){
}else if(editstruct == "ABSound"){
cbxMeaning->addItem("Ptr Sample", cbxMeaning->getNumItems()+1);
}else if(editstruct == "ABSample"){
cbxMeaning->addItem("Sample Address (in Sample Set)", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("Sample Address (in Sample Table)", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("Sample Length", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("Ptr ALADPCMLoop", cbxMeaning->getNumItems()+1);
cbxMeaning->addItem("Ptr ALADPCMBook", cbxMeaning->getNumItems()+1);
Expand Down Expand Up @@ -1777,7 +1779,7 @@ BEGIN_JUCER_METADATA
parentClasses="public Component, public TextEditor::Listener, public TextListModel::Listener"
constructorParams="SEQ64& seq64_" variableInitialisers="seq64(seq64_)"
snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
fixedSize="0" initialWidth="600" initialHeight="400">
fixedSize="1" initialWidth="1078" initialHeight="713">
<METHODS>
<METHOD name="visibilityChanged()"/>
<METHOD name="broughtToFront()"/>
Expand Down Expand Up @@ -1897,9 +1899,9 @@ BEGIN_JUCER_METADATA
fontsize="15" bold="0" italic="0" justification="33"/>
<LABEL name="new label" id="bf0f024772c31c54" memberName="label" virtualName=""
explicitFocusOrder="0" pos="8 360 240 24" edTextCol="ff000000"
edBkgCol="0" labelText="Instrument sets:" editableSingleClick="0"
editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
fontsize="15" bold="0" italic="0" justification="33"/>
edBkgCol="0" labelText="Banks:" editableSingleClick="0" editableDoubleClick="0"
focusDiscardsChanges="0" fontname="Default font" fontsize="15"
bold="0" italic="0" justification="33"/>
<COMBOBOX name="new combo box" id="dc4b63bcb4d73721" memberName="cbxLibList"
virtualName="" explicitFocusOrder="0" pos="256 360 240 24" editable="0"
layout="33" items="Instruments&#10;Drums&#10;Sound Effects" textWhenNonSelected=""
Expand Down Expand Up @@ -2022,7 +2024,7 @@ BEGIN_JUCER_METADATA
virtualName="" explicitFocusOrder="0" pos="912 176 104 24" buttonText="Load XML"
connectedEdges="1" needsCallback="1" radioGroupId="0"/>
<TOGGLEBUTTON name="new toggle button" id="23b75b22565a0123" memberName="chkLibFixAddr"
virtualName="" explicitFocusOrder="0" pos="512 480 232 24" buttonText="Convert Sample Addr for Sample Set"
virtualName="" explicitFocusOrder="0" pos="512 480 232 24" buttonText="Convert Sample Addr for Table"
connectedEdges="0" needsCallback="1" radioGroupId="0" state="1"/>
</JUCER_COMPONENT>

Expand Down
4 changes: 2 additions & 2 deletions Source/AudioseqPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ AudioseqPane::AudioseqPane (SEQ64& seq64_)

//[/UserPreSize]

setSize (1000, 632);
setSize (1078, 713);


//[Constructor] You can add your own custom stuff here..
Expand Down Expand Up @@ -1489,7 +1489,7 @@ BEGIN_JUCER_METADATA
parentClasses="public Component, public TextEditor::Listener, public TextListModel::Listener"
constructorParams="SEQ64&amp; seq64_" variableInitialisers="seq64(seq64_)"
snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
fixedSize="0" initialWidth="1000" initialHeight="632">
fixedSize="1" initialWidth="1078" initialHeight="713">
<METHODS>
<METHOD name="focusGained (FocusChangeType cause)"/>
<METHOD name="visibilityChanged()"/>
Expand Down
82 changes: 39 additions & 43 deletions Source/BankFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ============================================================================
*
* BankFile.cpp
* Class to hold/import/export a single instrument set (Audiobank format)
* Class to hold/import/export a single bank (Audiobank format)
*
* From seq64 - Sequenced music editor for first-party N64 games
* Copyright (C) 2014-2018 Sauraen
Expand All @@ -23,7 +23,8 @@
*/

#include "BankFile.h"

#include "ROM.h"
#include "seq64.h"

#define ALIGN(a, b) MACRO_WITH_FORCED_SEMICOLON(a += (b-1); a /= b; a *= b;)

Expand Down Expand Up @@ -65,7 +66,7 @@ void BankFile::reset(){
d.setProperty("NUM_INST", -1, nullptr);
d.setProperty("NUM_DRUM", -1, nullptr);
d.setProperty("NUM_SFX", -1, nullptr);
d.setProperty("SSIindex", -1, nullptr);
d.setProperty("ATnum", -1, nullptr);
}

void BankFile::loadRDNamesNode(int banknum){
Expand Down Expand Up @@ -363,9 +364,9 @@ bool BankFile::load(ROM& rom, int banknum){
if(!bankprops.valid) return false;
d.getChildWithName("abindexentry").addChild(bankprops.abiestru, -1, nullptr);
//
temp = bankprops.abiestru.getChildWithProperty("meaning", "Sample Set Index number");
temp = bankprops.abiestru.getChildWithProperty("meaning", "Sample Table number");
if(temp.isValid()){
d.setProperty("SSIindex", temp.getProperty("value", 0), nullptr);
d.setProperty("ATnum", temp.getProperty("value", 0), nullptr);
}
//
temp = bankprops.abiestru.getChildWithProperty("meaning", "NUM_INST");
Expand Down Expand Up @@ -393,12 +394,13 @@ bool BankFile::load(ROM& rom, int banknum){
a += strsize;
baseaddr = a;
//Read relevant data from header
temp = stru.getChildWithProperty("meaning", "Sample Set Index number");
temp = stru.getChildWithProperty("meaning", "Sample Table number");
if(temp.isValid()){
d.setProperty("SSIindex", temp.getProperty("value", 0), nullptr);
d.setProperty("ATnum", temp.getProperty("value", 0), nullptr);
}
if((int)d.getProperty("SSIindex") < 0){
SEQ64::say("Sample Set Index number not defined in either ABIndexEntry or ABHeader (not critical)");
if((int)d.getProperty("ATnum") < 0){
SEQ64::say("Sample Table number not defined in either ABIndexEntry or ABHeader!");
return false;
}
temp = stru.getChildWithProperty("meaning", "NUM_INST");
if(temp.isValid()){
Expand Down Expand Up @@ -471,12 +473,6 @@ bool BankFile::load(ROM& rom, int banknum){
return ret == 1;
}

/*
int save(ROM& rom, int banknum);
bool saveRaw(File rawfile);
int save_internal(ROM& rom, uint32 abieaddr, uint32 abbaseaddr);
*/
int BankFile::save(ROM& rom, int banknum){
//========================================================================
//Put in all info determined at import
Expand Down Expand Up @@ -1642,52 +1638,52 @@ ValueTree BankFile::importNodeRecurse(ROM& rom, BankFile& sourcebank, bool merge
}
//Check for sample address to fix
while(fixsampleaddr && destnode.getProperty("meaning", "None").toString()
== "Sample Address (in Sample Set)"){
== "Sample Address (in Sample Table)"){
uint32 origaddr = (uint32)(int)destnode.getProperty("value", 0);
int src_ssiindex = (int)sourcebank.d.getProperty("SSIindex", -1);
int dest_ssiindex = (int)d.getProperty("SSIindex", -1);
SEQ64::say("Trying to fix sample address: src_ssiindex=" + String(src_ssiindex)
+ ", dest_ssiindex=" + String(dest_ssiindex));
if(src_ssiindex < 0 || dest_ssiindex < 0){
SEQ64::say("--Source or dest bank don't have SSI index!");
int src_ATnum = (int)sourcebank.d.getProperty("ATnum", -1);
int dest_ATnum = (int)d.getProperty("ATnum", -1);
SEQ64::say("Trying to fix sample address: src_ATnum=" + String(src_ATnum)
+ ", dest_ATnum=" + String(dest_ATnum));
if(src_ATnum < 0 || dest_ATnum < 0){
SEQ64::say("--Source or dest bank don't have Sample Table number!");
break;
}
//Read sample set index
ValueTree ssinode = romdesc.getOrCreateChildWithName("knownfilelist", nullptr)
.getChildWithProperty("type", "Sample Set Index");
uint32 ssiaddr = 0x7FFFFFFF;
if(ssinode.isValid()){
ssiaddr = (uint32)(int)ssinode.getProperty("address", 0x7FFFFFFF);
//Read table number
ValueTree atinode = romdesc.getOrCreateChildWithName("knownfilelist", nullptr)
.getChildWithProperty("type", "Audiotable Index");
uint32 atiaddr = 0x7FFFFFFF;
if(atinode.isValid()){
atiaddr = (uint32)(int)atinode.getProperty("address", 0x7FFFFFFF);
}
if(ssiaddr >= rom.getSize()){
SEQ64::say("--Nonexistent or invalid Sample Set Index in romdesc!");
if(atiaddr >= rom.getSize()){
SEQ64::say("--Nonexistent or invalid Audiotable Index in romdesc!");
break;
}
uint16 count;
if((int)romdesc.getProperty("indextype", 1) == 2){
count = rom.readHalfWord(ssiaddr);
count = rom.readHalfWord(atiaddr);
}else{
count = rom.readHalfWord(ssiaddr+2);
count = rom.readHalfWord(atiaddr+2);
}
if(count > 1000 || count <= 0){
SEQ64::say("--" + String(count) + " entries in SSI, probably wrong!");
SEQ64::say("--" + String(count) + " entries in Audiotable Index, probably wrong!");
break;
}
if(src_ssiindex >= (int)count || dest_ssiindex >= (int)count){
SEQ64::say("--Source or dest bank have SSI index larger than SSI count!");
if(src_ATnum >= (int)count || dest_ATnum >= (int)count){
SEQ64::say("--Source or dest bank have Sample Table number larger than Audiotable Index count!");
break;
}
uint32 src_ssaddr, dest_ssaddr;
uint32 src_tbladdr, dest_tbladdr;
if((int)romdesc.getProperty("indextype", 1) == 2){
src_ssaddr = rom.readWord(ssiaddr + (16*src_ssiindex) + 16);
dest_ssaddr = rom.readWord(ssiaddr + (16*dest_ssiindex) + 16);
src_tbladdr = rom.readWord(atiaddr + (16*src_ATnum) + 16);
dest_tbladdr = rom.readWord(atiaddr + (16*dest_ATnum) + 16);
}else{
src_ssaddr = rom.readWord(ssiaddr + (8*src_ssiindex) + 4);
dest_ssaddr = rom.readWord(ssiaddr + (8*dest_ssiindex) + 4);
src_tbladdr = rom.readWord(atiaddr + (8*src_ATnum) + 4);
dest_tbladdr = rom.readWord(atiaddr + (8*dest_ATnum) + 4);
}
SEQ64::say("--src_ssaddr=0x" + ROM::hex(src_ssaddr)
+ ", dest_ssaddr=0x" + ROM::hex(dest_ssaddr));
uint32 newaddr = origaddr + src_ssaddr - dest_ssaddr;
SEQ64::say("--src_tbladdr=0x" + ROM::hex(src_tbladdr)
+ ", dest_tbladdr=0x" + ROM::hex(dest_tbladdr));
uint32 newaddr = origaddr + src_tbladdr - dest_tbladdr;
SEQ64::say("--Moving sample addr from 0x" + ROM::hex(origaddr) + " to 0x" + ROM::hex(newaddr));
destnode.setProperty("value", (int)newaddr, nullptr);
break;
Expand Down
5 changes: 2 additions & 3 deletions Source/BankFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* ============================================================================
*
* BankFile.h
* Class to hold/import/export a single instrument set (Audiobank format)
* Class to hold/import/export a single bank (Audiobank format)
*
* From seq64 - Sequenced music editor for first-party N64 games
* Copyright (C) 2014-2018 Sauraen
Expand All @@ -26,9 +26,8 @@
#define BANKFILE_H_INCLUDED

#include "JuceHeader.h"
#include "seq64.h"
#include "ROM.h"

class ROM;

class BankFile {
public:
Expand Down
Loading

0 comments on commit d7f7989

Please sign in to comment.